Skip to Content
author's profile photo
Former Member

Move-corresponding is not working

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

8 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:30 AM

    The field names must be same

    S_AMT <> SALE_AMT

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10: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 😉

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10: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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10: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.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 28, 2007 at 10: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>

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10: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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10: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..

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10: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.

    Add comment
    10|10000 characters needed characters exceeded