Application Development and Automation 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: 
Read only

doubt for internal table

Former Member
0 Likes
978

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
951

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

12 REPLIES 12
Read only

Former Member
0 Likes
951

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

Read only

0 Likes
951

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

Read only

Former Member
0 Likes
951

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.

Read only

andreas_mann3
Active Contributor
0 Likes
951

Hi,

try:

loop at itab1.

  read table itab2 with key f1 = itab1-f1
                            f2 = itab2-f2

...

A.

Read only

Former Member
0 Likes
951

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

Read only

Former Member
0 Likes
951

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

Read only

Former Member
0 Likes
951

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

Read only

0 Likes
951

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

Read only

Former Member
0 Likes
951

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

Read only

Former Member
0 Likes
951

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

Read only

Former Member
0 Likes
951

thanks ABAP gurus

solved my problems

thanks and regards,

bala

Read only

Former Member
0 Likes
952

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