Application Development 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: 

JOINING ITABS

Former Member
0 Kudos

HI ,

I have 2 internal tables, itab and itab1.

how do I combine the two to get the output.

thanks

ajju

5 REPLIES 5

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Use your main itab in loop. Inside that based on the fields you have loop the other internal table or read records from that.Place the record in another internal table (say output).

Loop at itab.

output-field1 = itab-field1.

output-field2 = itab-field2.

read table itab1 with key field2 = itab-field2.

if sy-subrc eq 0.

output-field3 = itab1-field3.

....

append output.

endif.

endloop.

Former Member
0 Kudos

Hi,

If both tables have similar structure, you could use <b>APPEND LINES OF itab1 TO itab</b>. Otherwise, if the structure is not the same, then you might have to loop at itab1 and append corresponding columns to itab. Please get back if I haven't understood the question correctly.

Regards

Message was edited by: Shehryar Khan

Former Member
0 Kudos

Hi,

Try this out

LOOP AT i_output INTO w_output.

READ TABLE i_connect INTO w_connect

WITH KEY object_id = w_output-awkey.

IF sy-subrc = 0.

MOVE-CORRESPONDING w_connect TO w_output.

APPEND w_output TO i_output.

ENDIF. " SY_SUBRC

CLEAR: w_connect,

w_output.

ENDLOOP.

Can also do MODIFY i_output FROM w_output when u need to modify any fields further in the program.

Thanks & Regards,

Judith.

Former Member
0 Kudos

DATA itab_scarr TYPE STANDARD TABLE OF scarr.

DATA wa_scarr TYPE scarr.

DATA itab_scarr2 TYPE STANDARD TABLE OF scarr.

SELECT * FROM scarr

INTO TABLE itab_scarr.

wa_scarr-carrid = 'AA'.

wa_scarr-carrname = 'Aeroplane'.

wa_scarr-currcode = 'PKR'.

wa_scarr-url = 'www.pia.com.pk'.

APPEND wa_scarr TO itab_scarr2.

wa_scarr-carrid = 'AB'.

wa_scarr-carrname = 'AeroAsia'.

wa_scarr-currcode = 'PKR'.

wa_scarr-url = 'www.aeroasia.com.pk'.

APPEND wa_scarr TO itab_scarr2.

LOOP AT itab_scarr2 INTO wa_scarr.

APPEND wa_scarr TO itab_scarr.

ENDLOOP.

LOOP AT itab_scarr INTO wa_scarr.

WRITE: / wa_scarr.

ENDLOOP.

former_member183804
Active Contributor
0 Kudos

If you have the optin to define the table structure you may should ceck the ABAP docu regarding the PROVIDE statement.

Best Regards

Klaus