Skip to Content
author's profile photo Former Member
Former Member

Corresponding

Hi all,

What is the exact use of corresponding?

Identical structure in the sense same fields or same structure?

What will happen if not same name and also not same fields while using corresponding???

Message was edited by:

arunshori ganesan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

11 Answers

  • Best Answer
    Posted on Sep 19, 2007 at 09:04 AM

    that you don't have to declare all the fields individually.

    so when you say into corresponding fields of table alle fields with the same name from the source are transported to fields with the same fieldname in the target area.

    kind regards

    arthur

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 19, 2007 at 09:04 AM

    We have

    SUBTRACT-CORRESPONDING

    ADD-CORRESPONDING

    MULTIPLY-CORRESPONDING

    DIVIDE-CORRESPONDING

    MOVE-CORRESPONDING

    Ex:

    MOVE-CORRESPONDING struc1 TO struc2.

    Effect

    <b>Interprets struc1 and struc2 as structures. If, for example, struc1 and struc2 are tables, it executes the statement for their header lines.

    Searches for the sub-fields which occur both in struc1 and struc2 and then generates, for all relevant field pairs which correspond to the sub-fields ni, statements of the form</b>

    MOVE struc1-ni TO struc2-ni.

    The other fields remain unchanged.

    With complex structures, the full names of the corresponding <b>field pairs must be identical</b>.

    Example

    TYPES: BEGIN OF ROW1_3,

    CO1 TYPE I,

    CO2 TYPE I,

    CO3 TYPE I,

    END OF ROW1_3.

    TYPES: BEGIN OF ROW2_4,

    CO2 TYPE I,

    CO3 TYPE I,

    CO4 TYPE I,

    END OF ROW2_4.

    TYPES: BEGIN OF MATRIX1,

    R1 TYPE ROW1_3,

    R2 TYPE ROW1_3,

    R3 TYPE ROW1_3,

    END OF MATRIX1.

    TYPES: BEGIN OF MATRIX2,

    R2 TYPE ROW2_4,

    R3 TYPE ROW2_4,

    R4 TYPE ROW2_4,

    END OF MATRIX2.

    DATA: ROW TYPE ROW1_3,

    M1 TYPE MATRIX1,

    M2 TYPE MATRIX2.

    ROW-CO1 = 1. ROW-CO2 = 2. ROW-CO3 = 3.

    MOVE: ROW TO M1-R1, ROW TO M1-R2, ROW TO M1-R3.

    MOVE-CORRESPONDING M1 TO M2.

    The last MOVE-CORRESPONDING statement is equivalent to the statements:

    MOVE: M1-R2-CO2 TO M2-R2-CO2,

    M1-R2-CO3 TO M2-R2-CO3,

    M1-R3-CO2 TO M2-R3-CO2,

    M1-R3-CO3 TO M2-R3-CO3.

    Regards,

    SaiRam

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:05 AM

    if you two internal tables of not identical structure ie some fields in common.

    move-corresponding itab1 to itab2.

    this will copy the fields that have identical names in itab1 to itab2, other fields which does not match will be left blank

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:08 AM

    Hi

    **********************

    INTO CORRESPONDING FIELDS OF TABLE is transferring the value from select clause to itab where the field names are same.

    suppose you have

    data : begin of itab occurs 0,

    matnr like mara-matnr,

    menge like mseg-menge,

    lgort like mard-lgort,

    end of itab.

    select matnr lgort into table from mard where....

    it may give an error because you are not filling menge here or it may fetch the value in matnr and menge field.

    but if you use INTO CORRESPONDING FIELDS OF TABLE then it will fetch the data to matnr and lgort field only.

    INTO CORRESPONDING FIELDS OF TABLE is only matching by name not by datatype be careful.

    ***********************

    ADD-CORRESPONDING rec1 TO rec2.

    Effect

    Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines.

    Searches for all sub-fields which occur both in rec1 and rec2 and then, for all relevant field pairs corresponding to the sub-fields ni , generates statements of the form

    ADD rec1-ni TO rec2-ni.

    The other fields remain unchanged.

    With complex structures, the complete names of the corresponding field

    pairs must be textually identical.

    ************************

    MOVE-CORRESPONDING rec1 TO rec2.

    Effect

    Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines.

    Searches for the sub-fields which occur both in rec1 and rec2 and then generates, for all relevant field pairs which correspond to the sub-fields ni , statements of the form

    MOVE rec1-ni TO rec2-ni.

    The other fields remain unchanged.

    With complex structures, the full names of the corresponding field pairs must be identical.

    ***********************************

    SUBTRACT-CORRESPONDING rec1 FROM rec2.

    Effect

    Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines.

    Searches for all sub-fields which occur both in rec1 and rec2 and then generates, for all relevant field pairs corresponding to the component fields ni , statements of the form

    SUBTRACT rec1-ni FROM rec2-ni.

    The other fields remain unchanged.

    With complex structures, the full names of the field pairs must be identical.

    ****************************************

    MULTIPLY-CORRESPONDING rec1 BY rec2.

    Effect

    Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines.

    Searches for all sub-fields which occur both in rec1 and rec2 and then generates, for all field pairs corresponding to the sub-fields ni , statements of the form

    MULTIPLY rec1-ni BY rec2-ni.

    The other fields remain unchanged.

    With complex structures, the full names of the corresponding field pairs must be identical.

    ****************************************

    DIVIDE-CORRESPONDING rec1 BY rec2.

    Effect

    Interprets rec1 and rec2 as field strings, i.e. if rec1 and rec2 are tables with header lines, the statement is executed for their header lines.

    Searches for all sub-fields that occur both in rec1 and rec2 and then generates, for all field pairs corresponding to the sub-fields ni , statements similar in the following form:

    DIVIDE rec1-ni BY rec2-ni.

    The other fields remain unchanged.

    With more complex structures, the complete names of the field pairs must be identical.

    ******************************************

    Please go through this link.

    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/add_corr.htm

    Regards

    Vasu

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 19, 2007 at 09:09 AM

    Hi

    CORRESPONDING option is used to Copy the fields based on their name (matching fields) instead of their Position.

    So only when the Field names are same it will copy the data.

    It is used in 2 cases:

    1)

    MOVE-CORRESPONDING WA1 TO WA2.

    "To copy identical fields from one wa to anothter

    2) SELECT <FIELDS> FROM <DBTABLE> INTO CORRESPONDING FIELDS OF TABLE <ITAB>

    reward if Helpful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:13 AM

    Hello,

    We use CORRESPONDING with following options

    SUBTRACT-CORRESPONDING

    ADD-CORRESPONDING

    MULTIPLY-CORRESPONDING

    DIVIDE-CORRESPONDING

    MOVE-CORRESPONDING

    Generally we use <b>CORRESPONDING</b>, if we have two different internal tables/structures with some common fields(and order of the common fields in those internal tables/structures also different) in them.

    Ex: MOVE-CORRESPONDING source to destination.

    In this case values of common fields with the same name will be moved from source to destination.

    <b>Reward Points If Useful</b>

    Regards, Srikanth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:14 AM

    hi,

    please see below declaration..

    data: begin of itab occurs 0,

    matnr type mara-matnr,

    ersda type mara-ersda,

    ernam type mara-ernam,

    end of itab.

    select matnr

    ernam

    from mara

    into table itab.

    if u see aboveinternal table declaration ernam is the third place. if u write the select qurey (please see below) ernam will sit in second plzce of internal table some times type mismatch may occur in that case program give dump.

    if u use into corresponding fields of table itab selected field will sit in writght place of internal table.

    thsi is the difference between corresponding and normal select query...

    thanks,

    maheedhar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:14 AM

    Hi Ganesh,

    report zsubfield.

    data : f1 type i value 1,

    • field string

    begin of s1,

    c1 type i value 10,

    c2 type i value 20,

    c3 type i value 30,

    end of s1.

    data : f2 type i value 5,

    • field string

    begin of s2,

    c1 type i value 40,

    c2 type i value 50,

    c3 type i value 60,

    end of s2.

    write : / f1.

    add-corresponding s1 to s2.

    write : / s2-c1,

    s2-c2,

    s2-c3.

    subtract-corresponding s1 from s2.

    write : / s2-c1,

    s2-c2,

    s2-c3.

    multiply-corresponding s2 by s1.

    write : / s2-c1,

    s2-c2,

    s2-c3.

    Try to understand this program. You will come to know the usage of Corresponding..

    Regards,

    Sai

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:23 AM

    hi,

    Corresponding keyword is used in two cases.

    1. INTO CORRESPONDING

    2. MOVE-CORRESPONDING

    corresponding generally used when we don't know the order of fields that are declared in internal tables and to move data into that table with out bothering for order we go for it.

    generally the order in which we declare in internal tables should be used in populating data otherwise it displays a error for us.

    in order to skip this procedure we go for corresponding and if we use corresponding then the field names are taken into consideration rather than index and data is placed into corresponding fields by comparing manes of fields.

    if helpful reward some points.

    with regards,

    Suresh Aluri.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:29 AM

    move corresponding in select query that means its moves the feild data to the declared itab from header to the body correspondingly , if we r not using it inthe select statement, it generals moves the data directly into the body.

    but it always better to use move corresponding in the select stament

    regards

    prasanth kumar

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.