‎2006 Sep 13 3:02 PM
hi abap gurus,
Consider u have 2 internal tables (one for Header Data, other one
for Line Item)
How to transfer the Header & its corresponding Item data
to third Internal table
thanks and regards,
bala
‎2006 Sep 13 3:32 PM
hi balaji,
try this way.
loop at itab1.
read table itab2 with key---.
itab3-field1 = itab1-field1
itab3-field2 = itab1-field2
itab3-field3 = itab2-field3
itab3-field4 = itab2-field4
append itab3.
clear itab3.
endloop.
if u want all the data from header and its item table
loop at itab1.
loop at itab2.
itab3-field1 = itab1-field1
itab3-field2 = itab1-field2
itab3-field3 = itab2-field3
itab3-field4 = itab2-field4
append itab3.
clear itab3.
endloop.
endloop.
Regards,
sudha
‎2006 Sep 13 3:06 PM
Hi Bala,
Loop through the item internal table. Within the loop read the header internal table and move the data to the third internal table.
Regards
Arun
‎2006 Sep 13 3:08 PM
hi,
loop at itab_item.
read table int_header with key fied1 = itab_item-field.
if sy-subrc = 0.
append int_table_third from itab_item.
endif.
endloop.
rgds
anver
if hlped rwd points
‎2006 Sep 13 3:06 PM
hi Balaji,
do this way ..
loop at it_header.
read table it_item where <conditions>
it_final = it_header-field1.
it_final = it_header-field2.
it_final = it_header-field3.
it_final = it_header-field4.
endloop.
‎2006 Sep 13 3:07 PM
Hi,
try:
loop at itab1.
read table itab2 with key f1 = itab1-f1
f2 = itab2-f2...
A.
‎2006 Sep 13 3:09 PM
SORT IT_HEADER BY EBELN.
SORT IT_ITEMS BY EBELN EBELP.
LOOP AT IT_HEADER.
<b>AT NEW EBELN.</b>
*--For each Header record we have to loop all of its ITEMS records.
LOOP AT IT_ITEMS WHERE EBELN = IT_HEADER-EBELN.
*--move header data to it_final
MOVE CORRESPONDING IT_HEADER TO IT_FINAL.
*--move item data to it_final.
MOVE CORRESPONDING IT_ITEMS TO IT_FINAL.
APPEND IT_FINAL.
ENDLOOP.
<b> ENDAT.</b>
ENDLOOP.HERE i have taken EKKO-EBELN. po no header and items data
Regards
Srikanth
Message was edited by: Srikanth Kidambi
Message was edited by: Srikanth Kidambi
‎2006 Sep 13 3:09 PM
Hello Bala,
Try like this.
Loop at IT_ITEM.
READ TABLE IT_HEADER <Condition>.
if sy-subrc = 0.
Move-corresponding it_header to itab3.
Move-corresponding it_item to itab3.
apeend itab3.
Endif.
ENDLOOP.
If useful reward.
vasanth
‎2006 Sep 13 3:09 PM
Hi ,
Try this.
loop at it_vbak.
loop at it_vbap where vbeln = it_vbak-vbeln.
it_sales-vbeln= it_vbak-vbeln.
it_sales-posnr = it_vbap-posnr.
it_sales-vkorg = it_vbak-vkorg.
it_sales-matnr = it_vbap-matnr.
append it_sales .
endloop.
endloop.
Regards,
Raghav
‎2006 Sep 13 3:13 PM
Hi,
U cud try this out.
LOOP AT THE HEADERTAB.
IF SY-SUBRC = 0.
FINALTAB-DATA = HEADERTAB-DATA.
APPEND FINALTAB.
LOOP AT ITEMTAB WHERE FIELD1 = HEADER-FIELD1.
IF SY-SUBRC = 0.
FINALTAB-DATA = ITEMTAB-DATA.
APPEND FINALTAB.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
But this may cause performance issues coz there's a loop inside another loop.
Regards,
Johnson
‎2006 Sep 13 3:16 PM
Hi,
sort header by vbeln.
sort item by vbeln posnr.
loop at header.
read table item with key vbeln = header-vbeln
binary search.
loop at item from sy-tabix.
if item-vbeln <> header-vbeln.
exit.
endif.
move header to final.
move item to final.
append final.
endloop.
endloop.
performance wise above code will work fine.
Regards,
amole
‎2006 Sep 13 3:22 PM
Hi Bala,
DATA : BEGIN OF IT_LIKP OCCURS 0, "1st internal table
FIELD1,
FIELD2,
FIELD3, ETC....
END OF IT_LIKP.
DATA : BEGIN OF IT_VBPA OCCURS 0, "2nd internal table
FIELD1,
FIELD2,
FIELD3, ETC....
END OF IT_VBPA.
DATA : BEGIN OF IT_FINAL OCCURS 0, "3rd internal table
FIELD1,
FIELD2,
FIELD3, ETC....
END OF IT_FINAL.
SELECT STATEMENTS ON FIRST 2 INTERANL TABLES AND THEN PASS THE DATA IN THE FINAL INTERNAL TABLE IE IT_FINAL.
THEN WITH IT_FINAL TABLE DISPLAY THE DATA.
LOOP AT IT_LIKP.
IT_FINAL-VBELN = IT_LIKP-VBELN.
IT_FINAL-WADAT_IST = IT_LIKP-WADAT_IST.
IT_FINAL-KUNNR = IT_LIKP-KUNNR.
IT_FINAL-NAME1 = IT_LIKP-NAME1.
IT_FINAL-VBELN_S = IT_LIKP-VBELV.
IT_FINAL-ERDAT = IT_LIKP-ERDAT.
READ TABLE IT_VBPA WITH KEY VBELN = IT_LIKP-VBELV BINARY
SEARCH.
IF SY-SUBRC = 0.
IT_FINAL-KUNN2 = IT_VBPA-KUNNR.
IT_FINAL-NAME2 = IT_VBPA-NAME1.
ENDIF.
APPEND IT_FINAL.
CLEAR IT_FINAL.
ENDLOOP.
Thanks
Vikranth Khimavath
‎2006 Sep 13 3:23 PM
‎2006 Sep 13 3:32 PM
hi balaji,
try this way.
loop at itab1.
read table itab2 with key---.
itab3-field1 = itab1-field1
itab3-field2 = itab1-field2
itab3-field3 = itab2-field3
itab3-field4 = itab2-field4
append itab3.
clear itab3.
endloop.
if u want all the data from header and its item table
loop at itab1.
loop at itab2.
itab3-field1 = itab1-field1
itab3-field2 = itab1-field2
itab3-field3 = itab2-field3
itab3-field4 = itab2-field4
append itab3.
clear itab3.
endloop.
endloop.
Regards,
sudha