09-28-2007 11:28 AM
Hi All,
I have 2 structures like this.
DATA: BEGIN OF ITAB1 OCCURS 0,
zuonr(18) TYPE c,
group(10) TYPE c,
s_amt type invfo-WRBTR,
END OF ITAB1.
DATA : BEGIN OF TABC OCCURS 0,
ZUONR LIKE ITAB1-ZUONR,
GROUP LIKE ITAB1-GROUP,
SALE_AMT LIKE ITAB1-S_AMT,
END OF TABC.
LOOP AT ITAB1.
move-corresponding ITAB1 TO TABC.
APPEND TABC.
CLEAR TABC.
ENDLOOP.
I am getting zuonr and group values into TABC. But I am not getting values into Sale_Amt field.
What is wrong in the above code??
09-28-2007 11:30 AM
09-28-2007 11:30 AM
09-28-2007 11:31 AM
Hi,
you have to set same name for S_AMT field, like this:
DATA: BEGIN OF ITAB1 OCCURS 0,
zuonr(18) TYPE c,
group(10) TYPE c,
s_amt type invfo-WRBTR,
END OF ITAB1.
DATA : BEGIN OF TABC OCCURS 0,
ZUONR LIKE ITAB1-ZUONR,
GROUP LIKE ITAB1-GROUP,
<b>S_AMT</b> LIKE ITAB1-S_AMT,
END OF TABC.
reward
09-28-2007 11:31 AM
The fields need to have the same name, but here one is call s_amt and one sale_amt. If your tables have the same structure (as they appear to have here) you don't need to use MOVE-CORRESPONDING, just MOVE.
Regards,
Nick
09-28-2007 11:32 AM
DATA: BEGIN OF ITAB1 OCCURS 0,
zuonr(18) TYPE c,
group(10) TYPE c,
s_amt type invfo-WRBTR,
END OF ITAB1.
DATA : BEGIN OF TABC OCCURS 0,
ZUONR LIKE ITAB1-ZUONR,
GROUP LIKE ITAB1-GROUP,
<b>SALE_AMT</b> LIKE ITAB1-S_AMT, <u>"Change SALE_AMT to s_amt - Fields should be matchable.</u>END OF TABC.
LOOP AT ITAB1.
move-corresponding ITAB1 TO TABC.
APPEND TABC.
CLEAR TABC.
ENDLOOP.
09-28-2007 11:32 AM
Hi ..
MOVE-Corresponding <WA1> to <wa2>.
This statement will assign the fields from WA1 to WA2 based on the Field names matching.
So it is only copying where the Field names are same.
Then you can change the code like this.
DATA: BEGIN OF ITAB1 OCCURS 0,
zuonr(18) TYPE c,
group(10) TYPE c,
s_amt type invfo-WRBTR,
END OF ITAB1.
DATA : BEGIN OF TABC OCCURS 0,
ZUONR LIKE ITAB1-ZUONR,
GROUP LIKE ITAB1-GROUP,
SALE_AMT LIKE ITAB1-S_AMT,
END OF TABC.
LOOP AT ITAB1.
<b>move ITAB1 TO TABC.</b>
APPEND TABC.
CLEAR TABC.
ENDLOOP.
<b>Reward if Helpful.</b>
09-28-2007 11:32 AM
Hi,
do like this
DATA: BEGIN OF ITAB1 OCCURS 0,
zuonr(18) TYPE c,
group(10) TYPE c,
s_amt type invfo-WRBTR,
END OF ITAB1.
DATA : BEGIN OF TABC OCCURS 0,
ZUONR LIKE ITAB1-ZUONR,
GROUP LIKE ITAB1-GROUP,
s_amt type invfo-WRBTR,
END OF TABC.
Regards,
Nagaraj
09-28-2007 11:41 AM
Two approaches,,,
1> change the 3rd component name of either WA to match the other one.. and the code will work,,,
2> instead of move corrosponding use. simply move.. it will move data byte by byte irrespective of file name and size.. (note atlease the secquence , datatype , length should be same). in this approach the file name match is nt required and is quite faster then the move corrosonding
happy coding..
09-28-2007 11:51 AM
Hi Priya,
DATA: BEGIN OF ITAB1 OCCURS 0,
zuonr(18) TYPE c,
group(10) TYPE c,
s_amt type invfo-WRBTR,
END OF ITAB1.
DATA : BEGIN OF TABC OCCURS 0,
ZUONR LIKE ITAB1-ZUONR,
GROUP LIKE ITAB1-GROUP,
SALE_AMT LIKE ITAB1-S_AMT,
END OF TABC.
LOOP AT ITAB1.
move-corresponding ITAB1 TO TABC.
<b>TABC-SALE_AMT = ITAB1-s_amt.</b>
APPEND TABC.
CLEAR TABC.
ENDLOOP.