Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Move-corresponding is not working

Former Member
0 Kudos

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??

1 ACCEPTED SOLUTION

Former Member
0 Kudos

The field names must be same

S_AMT <> SALE_AMT

8 REPLIES 8

Former Member
0 Kudos

The field names must be same

S_AMT <> SALE_AMT

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

varma_narayana
Active Contributor
0 Kudos

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>

former_member404244
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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..

Former Member
0 Kudos

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.