Application Development and Automation 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: 
Read only

Syntax of move corresponding

Former Member
0 Likes
3,736

hi

Can anyone give me the syntax of move corresponding.

I even want to know wat does this exactly do.

Can I have some sample sof move corresponding.

Its urgent.U'll get points.

Thanking you

Chandrika.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,809

data: beging of itab occurs 0,

fld1 type matnr,

fld2 type werks,

fld3 type lgort,

end of itab.

data: beging of jtab occurs 0,

fld3 type matnr,

fld2 type werks,

fld1 type lgort,

end of jtab.

move-corresponding itab to jtab.

This will move the field values of itab to jtab. Even though the fields in jtab are not in order as itab, move corresponding will look for filed name and moves the itab content into jtab. So the jtab field values are similar to that of itab.

jtab-fld1 = itab-fld1.

jtab-fld2= itab-fld2.

jtabfld = itabfld3.

If helpful award points.

Regards.

10 REPLIES 10
Read only

Former Member
0 Likes
1,809

move-correspoding xtab to itab.

assume that xtab and itab are two work areas(structure).

xtab has field1 field2 field4 as the fields inside.

itab has field1 field2 field3 field4.

then after executing this statement, itab will have the values for field1 field2 and field4 copied from xtab structure.

Regards,

ravi

Message was edited by:

Ravi Kanth Talagana

Read only

0 Likes
1,809
MOVE-CORRESPONDING looks for the corresponding field names in the target structure and move those values only..

DATA: BEGIN OF source,
matnr type matnr,
end of source.

DATA: BEGIN OF target,
vbeln type vbeln,
matnr type matnr,
end of target.

source-matnr = 'asdfasf'.

MOVE-CORRESPONDING source to target.

write: / 'vbeln- ', target-vbeln.
write: / 'matnr- ', target-matnr.

clear: target.

skip 1.

MOVE source to target.
write: / 'vbeln- ', target-vbeln.
write: / 'matnr- ', target-matnr.

* If you see the second output the value in matnr is moved to
* vbeln in target.
Read only

Former Member
0 Likes
1,809

HI,

MOVE-CORRESPONDING source_struct TO destination_struct.

Here source_struct & destination_struct are two structures (work area/header lines) which have at least 1 field in common ( same field name & type).

null

Read only

Former Member
0 Likes
1,809

Hi Sarath!

Here move corresponding is used to move indetical fields from a transparent table to an internal table.

Name of transparent table: bkpf

Name of internal table : itob

TYPES: BEGIN OF T_BTOP,

CPUDT LIKE BKPF-CPUDT,

BUKRS LIKE BKPF-BUKRS,

GJAHR LIKE BKPF-GJAHR,

BLART LIKE BKPF-BLART,

END OF T_ITAB.

data: itop type t_itop occurs 0 with header line.

SELECT * FROM BKPF

WHERE CPUDT = PCPUDT.

MOVE-CORRESPONDING BKPF TO ITOP.

ENDSELECT.

Read only

sourabhshah
Product and Topic Expert
Product and Topic Expert
0 Likes
1,809

hi,

MOVE-CORRESPONDING

Basic form

MOVE-CORRESPONDING struc1 TO struc2.

Effect

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

MOVE struc1-ni TO struc2-ni.

The other fields remain unchanged.

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

Example

DATA: BEGIN OF INT_TABLE OCCURS 10,

WORD(10),

NUMBER TYPE I,

INDEX LIKE SY-INDEX,

END OF INT_TABLE,

BEGIN OF RECORD,

NAME(10) VALUE 'not WORD',

NUMBER TYPE I,

INDEX(20),

END OF RECORD.

...

MOVE-CORRESPONDING INT_TABLE TO RECORD.

This MOVE-CORRESPONDING statement is equivalent to both the following statements:

MOVE INT_TABLE-NUMBER TO RECORD-NUMBER.

MOVE INT_TABLE-INDEX TO RECORD-INDEX.

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.

Note

The same runtime errors may occur as with MOVE.

Note

This statement assigns values based on pairs of fields with identical names. To avoid unwanted assignments, you should consider all fields of the source and target structures. If either is defined with reference to an ABAP Dictionary type (for example, a database table), remember that any subsequent extension to the type could cause coincidental pairs of identically-named fields, which could lead to incorrect program logic.

Regards,

Sourabh

Read only

Former Member
0 Likes
1,809

hi

MOVE-CORRESPONDING struc1 TO struc2.

Structures must be specified for struc1 and struc2. All components with the same name are searched for in struc1 und struc2 and the content of components in struc1 is assigned to the components with the same name in struc2. All other components are not affected.

with regards

Balasubramanian .S

Read only

Former Member
0 Likes
1,809

syntax is

move-corresponding <itab1> to <itab2>.

it will only move those fields values which are common between itab1 and itab2.

other fields of itab2 be as they are in previous state (i.e. before using the command)

regards

shiba dutta

Read only

Former Member
0 Likes
1,809
data : begin of itab1 occurs 0,
            matnr like mara-matnr,
            vbeln like vbap-vbeln,
         end of itab1.

data : begin of itab2 occurs 0,
            matnr like mara-matnr,
            posnr like vbap-posnr,,
         end of itab1.

loop at itab1.
  move-corresponding itab1 to itab2.
  append itab2.
endloop.


move-corresponding  will move the fields whose names are same in both the tables

In the above statement only MATNR will be moved to ITAB2 as both the fieldnames are same in itab1 and itab2
Read only

Former Member
0 Likes
1,810

data: beging of itab occurs 0,

fld1 type matnr,

fld2 type werks,

fld3 type lgort,

end of itab.

data: beging of jtab occurs 0,

fld3 type matnr,

fld2 type werks,

fld1 type lgort,

end of jtab.

move-corresponding itab to jtab.

This will move the field values of itab to jtab. Even though the fields in jtab are not in order as itab, move corresponding will look for filed name and moves the itab content into jtab. So the jtab field values are similar to that of itab.

jtab-fld1 = itab-fld1.

jtab-fld2= itab-fld2.

jtabfld = itabfld3.

If helpful award points.

Regards.

Read only

Former Member
0 Likes
1,809

This message was moderated.