2006 Sep 28 1:37 PM
HI,
I am getting data from three data base tables to the three different internal tables. Now i have to integrate all the data from the three internal tables based on condition and have to put in single table for display.
SELECT AEDAT EKGRP EBELN
BEDAT LIFNR WAERS
ERNAM FROM EKKO INTO TABLE GT_EKKO WHERE
EBELN IN SO_EBELN AND
BUKRS IN SO_BUKRS AND
EKGRP IN SO_EKGRP.
CHECK SY-SUBRC EQ 0.
SELECT EDOKN DIFWR ERDAT
RSCOD REVNO ERNAM
FROM EREV INTO TABLE GT_EREV FOR ALL ENTRIES
IN GT_EKKO WHERE ERNAM IN SO_ERNAM AND
ERDAT IN SO_ERDAT AND
EDOKN EQ GT_EKKO-EBELN.
CHECK SY-SUBRC EQ 0.
SELECT LIFNR NAME1 WERKS
FROM LFA1 INTO TABLE GT_LFA1 FOR ALL ENTRIES
IN GT_EKKO WHERE WERKS IN SO_WERKS AND
LIFNR EQ GT_EKKO-LIFNR.
finally i have to put in table for display.
How?
Regards
Reddy
2006 Sep 28 1:42 PM
loop at itab1.
read table itab2 with key fld1 = itab1-fl1.
read table itab3 with key fld1 = itab1-fld1.
move-corresponding itab1 to it_final.
move-corresponding itab2 to it_final.
move-corresponding itab3 to it_final.
append it_final.
clear it_final.
endloop.
HI,
I am getting data from three data base tables to the three different internal tables. Now i have to integrate all the data from the three internal tables based on condition and have to put in single table for display.
SELECT AEDAT EKGRP EBELN
BEDAT LIFNR WAERS
ERNAM FROM EKKO INTO TABLE GT_EKKO WHERE
EBELN IN SO_EBELN AND
BUKRS IN SO_BUKRS AND
EKGRP IN SO_EKGRP.
CHECK SY-SUBRC EQ 0.
SELECT EDOKN DIFWR ERDAT
RSCOD REVNO ERNAM
FROM EREV INTO TABLE GT_EREV FOR ALL ENTRIES
IN GT_EKKO WHERE ERNAM IN SO_ERNAM AND
ERDAT IN SO_ERDAT AND
EDOKN EQ GT_EKKO-EBELN.
CHECK SY-SUBRC EQ 0.
SELECT LIFNR NAME1 WERKS
FROM LFA1 INTO TABLE GT_LFA1 FOR ALL ENTRIES
IN GT_EKKO WHERE WERKS IN SO_WERKS AND
LIFNR EQ GT_EKKO-LIFNR.
finally i have to put in table for display.
How?
Regards
Reddy
2006 Sep 28 1:42 PM
loop at GT_EKKO.
*populate the final table
read table GT_EREV with key EDOKN = GT_EKKO-EBELN.
if sy-subrc = 0.
populate the final table
endif.
read table GT_LFA1 with key LIFNR = GT_EKKO-LIFNR.
if sy-subrc = 0.
populate the final table
endif.
endloop.
Here one check as to done whether only data will stored in GT_EREV for a Purchasing Document Number or mutilple data will be stored.
If multiple datas are there use loop instead of read statement.
Prakash.
2006 Sep 28 1:42 PM
loop at itab1.
read table itab2 with key fld1 = itab1-fl1.
read table itab3 with key fld1 = itab1-fld1.
move-corresponding itab1 to it_final.
move-corresponding itab2 to it_final.
move-corresponding itab3 to it_final.
append it_final.
clear it_final.
endloop.
2006 Sep 28 1:49 PM
Hi chandu.
u got data from 3 database tables into 3 interanl tables
now u want to join those internaltables into final internal table
consider this example.
itab1 with a1 a2 a3 contains 100 records
itab2 with b1 b2 b3 contains 30 reocrds
itab3 with c1 c2 c3 contains 30 records
and a1 = b1 and b2 = c2
u want to fill itab4 with a1 a2 a3 b2 b3 c1 c3
now follow this
loop at itab1.
itab4-a1 = itab1-a1.
itab4-a2 = itab1-a2.
itab4-a3 = itab1-a3.
now read table itab2 by comparing a1 and b1 on these tables and append to itab4.
read table itab2 with key b1 = itab1-a1.
itab4-b2 = itab2-b2.
itab4-b3 = itab2-b3.
now read table itab3 by comparing b2 from retrieved itab2 and with c2 in itab3, on these tables and append to itab4.
read table itab3 with key c2 = itab2-b2.
itab4-c1 = itab3-c1.
itab4-c3 = itab3-c3.
append itab4.
endloop.
now in final internal table itab4 u will have all data from all internal tables.
<b>NOTE: while joining two internal table.</b>
use loop statement for one internal table. and use read statement for one intenaltable.
<b>NOTE: while using read and loop.</b>
Use LOOP for a table that has large no of records
Use READ for a table that has small no of records
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |