‎2008 Feb 12 10:54 AM
Hi
I have two straucture lets say struc1 and struc 2
i want to pass the value of struc2-field1 to struct1-field2 ( *fields name are not same here)
both structure are already filled.
struct1 are filled in this way
struct-name1 = abc
struct-name2 = pqr
struct2 are filled in this way
struct-name1 = aaa
struct-name2 = pqr
My problem is i am doing
struct-name1 = struct-name2. ( * Fields have different name)
Logically struct-name2 value has to pass in struct-name1.
but its not working it coudn't able to assigned it.
please give me solution for it.
Thanks
Subham
‎2008 Feb 12 11:07 AM
HI,
Please refer to the code below :
data : begin of itab1,
name(4) type c,
add(4) type c,
end of itab1.
data : begin of itab2,
name(4) type c,
add(4) type c,
end of itab2.
itab1-name = 'ABC'.
itab1-add = 'PQR'.
itab2-name = 'AAA'.
itab2-add = 'PQR'.
itab1-name = itab2-add.
Thanks,
Sriram POnna.
‎2008 Feb 12 11:09 AM
‎2008 Feb 12 11:23 AM
Hi,
Try to use below code
DATA : BEGIN OF struct1,
name1(4) TYPE C,
name2(4) TYPE C,
END OF struct1.
DATA : BEGIN OF STRUCT2,
name1(4) TYPE C,
name2(4) TYPE C,
END OF struct2.
struct1-name1 = 'ABC'.
struct1-name2 = 'PQR'.
struct2-name1 = 'AAA'.
struct2-name2 = 'PQR'.
*MOVE-CORRESPONDING struct1 TO struct2. " To Copy all the corresponding fields from struct1 to struct2.
or
struct1-name1 = struct2-name2.
WRITE : / struct1-name1,
struct1-name2,
struct2-name1,
struct2-name2.
Move corresponding statement moves value from one structure to another structure
If you want to pass the data from one internal table to another internal table, then if the structure of both the table will be same then you can assign directly like that
it_tab1 = it_tab2.
or
it_tab1[] = it_tab2.