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 Concept

Former Member
0 Kudos

Helo Experts,

Plz tell what is the problem in my code.Data is not coming in internal talbe it_error, even on the correct condition

loop at record.

if record-BUKRS_001 = 'XYZ' and record-EKORG_002 ne '2000' .

if sy-subrc eq 0.

MOVE-CORRESPONDING record TO it_error.

APPEND record TO it_error.

endif.

endif.

endloop.

Ravi

9 REPLIES 9

Former Member
0 Kudos

only identical fields in the structure get moved by move-corresponding..by identical i mean same name, same data type..

And why are you again checking

if sy-subrc eq 0

after if condition?

G@urav.

Former Member
0 Kudos

Hi ,

write this way:

loop at record when BUKRS_001 = 'XYZ'

and EKORG_002 ne '2000' .

MOVE-CORRESPONDING record TO it_error.

APPEND it_error.

clear it_error.

endloop.

Thanks,

Krishna...

Former Member
0 Kudos

Hello Ravi ,

Unfortunately i did not understand the logic of the below piece of code

MOVE-CORRESPONDING record TO it_error.

APPEND record TO it_error.

i feel the correct statement would be

append it_error.

Regards

Arun

Former Member
0 Kudos

Hi ravi,

first of all I think, Sy-subrc check is redundant here, however that doesn't affect the result.

you better check wheather you have BUKRS_001 and EKORG_002 fields in it_error, as MOVE-CORRESPONDING moves records between two fields having same name not based on data type.

Regards,

Anirban

Former Member
0 Kudos

what is record wheather is an work area or an internal table if its an work area you cnt use loop if at all it is an internal tabel we cnt use append internal table to another internal table

so please be specific what is record? just give total code

bpawanchand
Active Contributor
0 Kudos

Hi

when you are using MOVE-CORRESPONDING both should be the work areas.

Regards

Pavan

Former Member
0 Kudos

Hi Ravi Jain,

1. Both structure should be same.

2. Use APPEND IT_ERROR instead of APPEND record TO it_error.

Rajneesh Gupta

nisha_vinod
Advisor
Advisor
0 Kudos

Hello,

MOVE-CORRESPONDING, as the name suggests is used to move data between equivalent fields of two different structures. A crude eg: could be:

Struct 1 -> has fields

Name type char30

DOB type dats

Struct 2-> has fields

Name type char30

Address type string

When you say 'MOVE-CORRESPONDING struct2 to struct 1'. the contents of the 'Name' field would be moved.

In your case, it_error appears to be an internal table and you are trying to move contents of a structure to the internal table? As far as I can see, this should not be the case.

Regards

Nisha

Former Member
0 Kudos

Hi,

if u r using move corresponding then both the internaal tables sould ahve same stucture...

here is small eg just go through the code ...

data: begin of itab occurs 0,

name(20) type c,

comp(20) type c,

city(20) type c,

END OF ITAB.

data: begin of itab1 occurs 0,

name(20) type c,

city(20) type c,

END OF ITAB1.

itab1-name = 'Rajat11'.

itab1-city = 'Delhi2222'.

append itab1.

itab1-name = 'Rajat22'.

itab1-city = 'Delhi1'.

append itab1.

itab1-name = 'Rajat33'.

itab1-city = 'Delhi2'.

append itab1.

loop at itab1 .

move-corresponding itab1 to itab.

append itab.

endloop.

loop at itab.

write:/ itab-name.

write:/ itab-city.

write:/ itab-comp.

endloop.

i hope u will get solution..

Thanks & Regards

Ashu Singh