Vous êtes sur la page 1sur 9

code for populating the field

1 of 9

https://archive.sap.com/discussions/thread/174259

11/1/2016 8:52 AM

code for populating the field

2 of 9

https://archive.sap.com/discussions/thread/174259

This question is answered

Hi,
can any one help me out for populating the appended field to data source.
<u><b>My requirement:</b></u> I have enhanced the data source 2lis_11_vahdr by appending the field
zzmatnr in to its extract structure, Now i want to populate this field from the field available in the MARC
table. so can any one help me out the whole code for this?
apart from this i have one another question that is if i append this field to the communication structure( like
mcvbak, mcvbap... etc) then how we will populate this field.
and what is the exact difference between appending the field to the extract structure and appending the
field to the communication structure.
Thanks

anu gupta
July 06, 2006 at 10:19 AM
0 Likes

Correct Answer

Krishnamoorthy Gopalakrishnan

replied
July 06, 2006 at 11:34 AM

1)Just a sample code to add old material code(zzoldmatno) to the data source
'2LIS_02_S012'.
The function module is EXIT_SAPLRSAP_001.

11/1/2016 8:52 AM

code for populating the field

3 of 9

https://archive.sap.com/discussions/thread/174259

The function module is EXIT_SAPLRSAP_001.


You have write the code in the include zxrsau01.
when '2LIS_02_S012' .
data : it_s012biws like s012biws .
tables : mara .
loop at c_t_data into it_s012biws .
l_tabix = sy-tabix.
select single bismt from mara into mara-bismt where matnr =
it_s012biws-matnr.
if sy-subrc = 0.
it_s012biws-zzoldmatno = mara-bismt .
endif.
clear mara-bismt .
modify c_t_data from it_s012biws index l_tabix.
endloop.
2) Replicate the datasource.
3) Now with the above code datasource R/3 part is finished.To receive the new
column at the BW end you have to add a column to your ODS or infocube as
well to the communication structure(say ZOLDMAT in my case) and map the
new field(ZZOLDMATNO) to the field (ZOLDMAT).
4) Activate the Transfer Rule.
Hope this helps.
Regs
Gopi.
0

View this answer in context

Correct Answer

11/1/2016 8:52 AM

code for populating the field

4 of 9

https://archive.sap.com/discussions/thread/174259

Correct Answer

Krishnamoorthy Gopalakrishnan
replied
July 06, 2006 at 11:34 AM

1)Just a sample code to add old material


code(zzoldmatno) to the data source
'2LIS_02_S012'.
The function module is EXIT_SAPLRSAP_001.
You have write the code in the include zxrsau01.
when '2LIS_02_S012' .
data : it_s012biws like s012biws .
tables : mara .
loop at c_t_data into it_s012biws .
l_tabix = sy-tabix.
select single bismt from mara into mara-bismt where matnr
=
it_s012biws-matnr.
if sy-subrc = 0.
it_s012biws-zzoldmatno = mara-bismt .
endif.
clear mara-bismt .
modify c_t_data from it_s012biws index l_tabix.
endloop.
2) Replicate the datasource.
3) Now with the above code datasource R/3 part is
finished.To receive the new column at the BW end you
have to add a column to your ODS or infocube as well to
the communication structure(say ZOLDMAT in my case)
and map the new field(ZZOLDMATNO) to the field
(ZOLDMAT).
4) Activate the Transfer Rule.

11/1/2016 8:52 AM

code for populating the field

5 of 9

https://archive.sap.com/discussions/thread/174259

4) Activate the Transfer Rule.


Hope this helps.
Regs
Gopi.
0

anu gupta

July 06, 2006 at 12:33 PM

replied

hi gopi
thanks it is help ful for me but can u not send me exact user exit code
meeting my requirement.
anu
0

anu gupta

replied July 06, 2006 at 13:59 PM

hi
i have written one code to populate the zzmatnr from matnr from
mara.
case i_datasource.
when 's_11_vahdr'.
data:it_MC11VA0HDR like MC11VA0HDR,
wa_matnr like mara-matnr.
tables mara.
loop at c_t_data into it_MC11VA0HDR.
l_tabix = sy-tabix.
select single matnr from mara into wa_matnr where matnr =
it_MC11VA0HDR-matnr.
if sy-subrc = 0.

11/1/2016 8:52 AM

code for populating the field

6 of 9

https://archive.sap.com/discussions/thread/174259

if sy-subrc = 0.
it_MC11VA0HDR-zzmatnr = wa_matnr.
endif.
clear wa_matnr.
modify c_t_data from it_MC11VA0HDR index l_tabix.
but it is giving the error like......The data object "IT_MC11VA0HDR"
has no component called "MATNR", but there is a component called
"ZZMATNR".
can any one please correct it.
0

Srinivas Neelam

replied
July 06, 2006 at 14:09 PM

Hi Anu,
select single <b>matnr</b> from mara
into wa_matnr where <b>matnr</b> =
it_MC11VA0HDR-matnr.
Anu, according to this code you are
passing MATNR and fetching MATNR
only, why so...!! If you have MATNR in
your datasource, why you want to
enhace,,,??
Check extract structure(MC11VA0HDR)
having newly added field(ZZMATNR) or
not...?? and remove the Hide button.
Hope it Helps
Srini
0

anu gupta

replied
July 06, 2006 at 14:36 PM

11/1/2016 8:52 AM

code for populating the field

7 of 9

https://archive.sap.com/discussions/thread/174259
anu gupta

replied
July 06, 2006 at 14:36 PM

hi srini
thanks for help.
actually i am using
2lis_11_vahdr, this data source
is not having the matnr, but
irequire this field bw side, so i
appended this datasource by
zzmatnr.
No i want to simply populate this
field by matnr that is in the mara
table.
so please send me whole code if
u can, it will be help ful for me.
thanks
0

Srinivas Neelam

replied
July 06, 2006 at 15:17 PM

Anu,
Pre-requisites to enhance a data
source.
1. All primary keys of the
table(here table MARA & primary
key MATNR) should be available
in datasource.
2. Based on this field you can
enhance the datasource and can
fetch some other fields by
passing this(MATNR).
So, in this case, You can not
fetch data from MARA.
3. Here you are having two
options, Find out the table which
can provide MATNR(not MARA).
OR

11/1/2016 8:52 AM

code for populating the field

8 of 9

https://archive.sap.com/discussions/thread/174259

options, Find out the table which


can provide MATNR(not MARA).
OR
Try to pull 2LIS_11_VAITM Sales Document Item Data. It
contains MATNR.
Hope it Helps
Srini
Message was edited by: Srini
0

anu gupta

replied
July 06, 2006 at 15:06 PM

ok srini,
thanks
0

Krishnamoorthy Gopalakrishnan
replied
July 06, 2006 at 15:00 PM

case i_datasource.
when 's_11_vahdr'.
data:it_MC11VA0HDR like
MC11VA0HDR,
wa_matnr like mara-matnr.
tables mara.
loop at c_t_data into it_MC11VA0HDR.
l_tabix = sy-tabix.
select single matnr from VBAP into
wa_matnr where VBELN =
it_MC11VA0HDR-VBELN.
if sy-subrc = 0.

11/1/2016 8:52 AM

code for populating the field

9 of 9

https://archive.sap.com/discussions/thread/174259

it_MC11VA0HDR-VBELN.
if sy-subrc = 0.
it_MC11VA0HDR-zzmatnr = wa_matnr.
endif.
clear wa_matnr.
modify c_t_data from it_MC11VA0HDR
index l_tabix.
Please check the code
Regs
Gopi.
0

Krishnamoorthy Gopalakrishnan
replied
July 06, 2006 at 14:05 PM

I am still searching to connect MARC and MC11VA0HDR


because MARC Material-plant where MC11VA0HDR does
not have Material number so we can not link it. To link a
table we must have common fields between MARC and
MC11VAOHDR.
Is your requirement is correct ? Is the data source is
2lis_11_vahdr or 2list_11_VADITM?
Regs
Gopi.
0

anu gupta

replied

July 06, 2006 at 14:39 PM

Hi gopi
sorry that is not marc table , it is mara table, now if u have some time
please send me the whole code keeping in the view of my requirement.

11/1/2016 8:52 AM

Vous aimerez peut-être aussi