‎2008 Nov 27 8:52 AM
Hi all,
I have 2 internal tables and i want to append it another table. data of both are like below.
1.internal table : itab.
in this field BANFN. values are like :
81000
81001
81002
81003
81004
2. internal table : itab1.
same field BANFN. values are like :
81000
81001
81002
81003
I want third internal table having combination of both and values are like:
81000
81001
81002
81003
81004
Plz help me..
‎2008 Nov 27 9:50 AM
Hi,
Try this..
LOOP AT ITAB.
READ TABLE ITAB1 WITH KEY BANFN = ITAB-BANFN.
IF SY-SUBRC = 0.
APPEND ITAB1 TO ITAB2.
ELSE.
APPEND ITAB TO ITAB2.
ENDIF.
ENDLOOP.
‎2008 Nov 27 8:55 AM
hi
1>take one more table of same type as of itab.
2> loop through 1 table and readt the second table
3> if entries found then pass it to the third table
eg
loop at itab
read table itab1 ....
if sy-subrc eq 0.
move to itab2
endif.
endloop.
‎2008 Nov 27 8:55 AM
APPEND LINES OF itab1 TO itab3.
APPEND LINES OF itab2 TO itab3.
SORT itab3.
DELETE ADJACENT DUPLICATES FROM itab3.
‎2008 Nov 27 8:57 AM
‎2008 Nov 27 8:58 AM
HI Ankitha,
Do you have any other fields apart from these.
anyhow.
loop at itab1.
move itab1 to final.
append final.
endloop.
loop at itab2.
read table final with key banfn = itab2-banfn,
if sy-subrc is not initial.
move itab2 to final
append final.
endif.
endloop.
try this out.
Eric's approch is better one
Regards
Ramchander Rao.K
Edited by: ramchander krishnamraju on Nov 27, 2008 9:58 AM
‎2008 Nov 27 9:06 AM
Hi Ramchandar..
your logic may be right but it does not work for such internal table
output of ur logic is like .
81000
81001
81001
81003
81000
81001
81002
81003
81004
I want same column.
output like:
81000
81001
81002
81003
81004
‎2008 Nov 27 9:17 AM
Hi Ankitha,
You need to write the output after the final append into the final table from both the 2 internal tables.
even eric's method is better one , try that.
Regards
Ramchander Rao.K
‎2008 Nov 27 9:30 AM
Hi,
Erics Method is feasible. try for tht.
Take one more internal table of same type.
Append itab1 to that internal table.
Append another itab2 to same internal table.
Now delete the adjacent duplicate entries from new table .
Thanks.
‎2008 Nov 27 9:02 AM
use select queyr with APPENDING CORRESPONDING FIELDS OF TABLE <internal table>
‎2008 Nov 27 9:02 AM
loop at table itab into wa1.
append to fina_tab.
read table itab1 into wa2.
if ay-subrc NE 0.
append to final_tab.
endif.
endif.
endloop.
‎2008 Nov 27 9:24 AM
seee this example
DATA : BEGIN OF ITAB OCCURS 0,
NAME(3),
VALUE TYPE I,
END OF ITAB.
DATA : BEGIN OF ITAB1 OCCURS 0,
NAME(3),
VALUE TYPE I,
END OF ITAB1.
DATA : BEGIN OF ITAB3 OCCURS 0,
NAME(3),
VALUE TYPE I,
END OF ITAB3.
ITAB-NAME = 'abc'.
ITAB-VALUE = 100.
APPEND ITAB.
ITAB-NAME = 'abd'.
ITAB-VALUE = 100.
APPEND ITAB.
ITAB-NAME = 'abc'.
ITAB-VALUE = 100.
APPEND ITAB.
ITAB-NAME = 'abd'.
ITAB-VALUE = 300.
APPEND ITAB.
ITAB1-NAME = 'abc'.
ITAB1-VALUE = 100.
APPEND ITAB1.
ITAB1-NAME = 'abd'.
ITAB1-VALUE = 100.
APPEND ITAB1.
ITAB1-NAME = 'abc'.
ITAB1-VALUE = 100.
APPEND ITAB1.
break developer.
loop at itab.
move itab to itab3.
append itab3.
endloop.
loop at itab1.
read table itab3 with key name = itab1-name.
if sy-subrc <> 0.
move itab1 to itab3.
append itab3.
endif.
endloop.
‎2008 Nov 27 9:38 AM
loop at itab into wa_itab
append itab_final from wa_itab.
loop at itab1 into wa_itab1
append itab_final from wa_itab1.
then use delete adjacent command and sort command to get desired result.
‎2008 Nov 27 9:50 AM
Hi,
Try this..
LOOP AT ITAB.
READ TABLE ITAB1 WITH KEY BANFN = ITAB-BANFN.
IF SY-SUBRC = 0.
APPEND ITAB1 TO ITAB2.
ELSE.
APPEND ITAB TO ITAB2.
ENDIF.
ENDLOOP.