2006 May 02 11:58 AM
i have 1 itab
matnr lbkum min
1111 2 X
and another itab (2)
matnr lgort bwart
1111 10 601
i want to merge between them and have 1 itab that have all the data in 1 line
i have 1 itab
matnr lbkum min
1111 2 X
and another itab (2)
matnr lgort bwart
1111 10 601
i want to merge between them and have 1 itab that have all the data in 1 line
2006 May 02 12:03 PM
data: begin of itab_final occurs 0.
matnr type matnr
lbkum type lbkum
min type min
lgort type lgort
bwart type bwart
end of itab.
itab_final[] = itab1[]
loop at itab_final.
read table itab2 with key matnr = itab_final-matnr.
itab_final-lgort = itab2-lgort.
itab_final-bwart = itab2-bwart.
modify itab_final.
endloop.
2006 May 02 12:04 PM
Hi Liat,
If MATNR is the key field then take and internal table with all the fields, say it_outtab. Now loop at on table and read the other table's records with key MATNR. Then pass all these values to the it_outtab work area and append the same to it_outtab. Hope this may help you...
Thanks and Regards,
Bharat Kumar Reddy.V
2006 May 02 12:06 PM
HI,
Create a table with the fields of both the tables.
loop at itab1.
read table itab2 with key matnr = itab1-matnr.
if sy-subrc = 0.
move-correspond itab1 to itab3.
move-correspond itab1 to itab3.
append itab3.
endif.
endloop.
Regards,
Ravi
Note : Please mark the helpful answers
2006 May 02 12:10 PM
2006 May 02 12:12 PM
2006 May 02 12:15 PM
Hi,
One move statement for each table will be required.
Take a look at my other posts where I have answered a similar one.
Points - Don't worry about it, do it when you can.
Regards,
Ravi
2006 May 02 12:08 PM
Hello Liat,
As the two internal tables are having different structure, u will have to create a 3rd internal table with all the fields from both the internal tables. Now loop through the first internal table, clearing the work area first and then moving the fields to the work area and appending.after u have doen with all the records perfrom the same for secod table. U can then sort the table on matnr.
2006 May 02 12:11 PM
Hi lia tal,
i hope ur prob will solved if u declare another table (itab3) as below..
data:begin of itab3 occurs 0.
include structure itab1.
include structure itab2.
data:end of itab3.
Regards,
Kiran
2006 May 02 12:12 PM
data : begin of itab occurs 0 ,
matnr like ztab-matnr,
lbkum like ...
min like ..
lgort like ...
bwart like ..
end of itab.
loop at itab1.
Loop at itab2 where matnr = itab1-matnr.
if sy-subrc eq 0.
itab-matnr = itab1-matnr.
itab-lbknum = itab1-lbknum.
itab-min = itab1-min.
itab-lgort = itab2-lgort.
itab-bwart = itab2-bwart.
Append itab.
clear itab.
endif.
endloop.
endloop.where itab1 is ur first table and itab2 is ur second table
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |