‎2008 Aug 27 3:46 AM
Hi Friends,
Can any body tel how can i add two internal tables.
itab1-ebeln = '110000023'. itab2-ebeln = '110000023'.
itab1-ebelp = '01'. itab2-ebelp = '01'.
itab1-belnr = '333333333'. itab2-belnr1 = '333333344'.
itab1-f = 'a'. itab2-f = 'b'.
append itab1. append itab2.
itab1-ebeln = '110000023'. itab2-ebeln = '110000023'.
itab1-ebelp = '02'. itab2-ebelp = '02'.
itab1-belnr = '333333334'. itab2-belnr1 = '333333355'.
itab1-f = 'a'. itab2-f = 'b'.
append itab1. append itab2.
itab1-ebeln = '110000023'. itab2-ebeln = '110000023'.
itab1-ebelp = '02'. itab2-ebelp = '03'.
itab1-belnr = '333333335'. itab2-belnr1 = '333333364'.
itab1-f = 'a'. itab2-f = 'b'.
append itab1. append itab2.
itab1-ebeln = '110000023'.
itab1-ebelp = '03'.
itab1-belnr = '333333336'.
itab1-f = 'a'.
append itab1.
i need like this
ebeln ebelp belnr belnr1
110000023 01 333333333 333333344
110000023 02 333333334 333333355
110000023 02 333333335 333333355
110000023 03 333333336 333333364
some time may be itab1 records lessthan itab2.
that case how can we handle this scenario.
‎2008 Aug 27 4:03 AM
Hi Kumar,
Here is the below logic to fulfill your requirement.
Loop at itab1.
Read table itab2 with key ebeln = itab1-ebeln.
if sy-subrc = 0.
<Populate all data into the it_final table>
append it_final.
endif.
Endloop.
‎2008 Aug 27 4:06 AM
Hi Kumar,
Try the following:
loop at itab1.
read table itab2 with key ebeln = itab1-ebeln.
if sy-subrc eq 0.
itab3-ebeln =itab1-ebeln.
itab3-ebelp = itab1-ebelp.
itab3-belnr = itab1-belnr.
itab3-belnr1 = itab2-belnr1.
append itab3.
endif.
endloop.
loop at itab3.
write:/ itab3-ebeln,
itab3-ebelp,
itab3-belnr,
itab3-belnr1
endloop.Regards,
Chandra Sekhar
‎2008 Aug 27 4:26 AM
Hi I am getting like this.
110000023 00001 333333333 333333344
110000023 00002 333333334 333333344
110000023 00002 333333335 333333344
110000023 00003 333333336 333333344
this is wrong na.. Please advice.
‎2008 Aug 27 4:29 AM
Hi Kumar,
Check this code now :
loop at itab1.
read table itab2 with key ebeln = itab1-ebeln ebelp = itab1-ebelp.
if sy-subrc eq 0.
itab3-ebeln =itab1-ebeln.
itab3-ebelp = itab1-ebelp.
itab3-belnr = itab1-belnr.
itab3-belnr1 = itab2-belnr1.
append itab3.
clear itab3.
endif.
endloop.
loop at itab3.
write:/ itab3-ebeln,
itab3-ebelp,
itab3-belnr,
itab3-belnr1
endloop.Regards,
Chandra Sekhar
‎2008 Aug 27 4:29 AM
hi kumar use this.
loop at itab1.
read table itab2 with key ebeln = itab1-ebeln ebelp = itab1-ebelp.
if sy-subrc eq 0.
itab3-ebeln =itab1-ebeln.
itab3-ebelp = itab1-ebelp.
itab3-belnr = itab1-belnr.
itab3-belnr1 = itab2-belnr1.
append itab3.
endif.
endloop.
loop at itab3.
write:/ itab3-ebeln,
itab3-ebelp,
itab3-belnr,
itab3-belnr1
endloop.
‎2008 Aug 27 4:47 AM
Hi Chandrashekar,
Again the result same.
I have another doubt also. If my itab1 no records and itab2 have records can i get that records also into ITAB3.
Thanks,
Kumar.
‎2008 Aug 27 5:05 AM
Hi Kumar,
see below.
loop at itab1.
read table itab2 into wa_itab2 with key ebeln = itab1-ebeln ebelp = itab1-ebelp.
if sy-subrc eq 0.
itab3-ebeln =itab1-ebeln.
itab3-ebelp = itab1-ebelp.
itab3-belnr = itab1-belnr.
itab3-belnr1 = wa_itab2-belnr1.
append itab3.
clear itab3.
delete itab2 where ebeln = wa_itab2-ebeln and ebelp = wa_itab2-ebelp and belnr1 = wa_itab2-belnr1.
else.
clear itab.
itab3-ebeln = itab1-ebeln.
itab3-ebelp = itab1-ebelp.
itab3-belnr = itab1-belnr.
append itab3.
endif.
endloop.
if itab2[] is not initial.
clear itab3.
loop at itab2.
itab3-ebeln = itab2-ebeln.
itab3-ebelp = itab2-ebelp.
itab3-belnr1 = itab2-belnr1.
append itab3.
endloop.
endif.
sort itab3 by ebelp.
loop at itab3.
write:/ itab3-ebeln,
itab3-ebelp,
itab3-belnr,
itab3-belnr1
endloop.
thanks,
Naresh