Skip to Content
author's profile photo Former Member
Former Member

JOINING ITABS

HI ,

I have 2 internal tables, itab and itab1.

how do I combine the two to get the output.

thanks

ajju

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on May 06, 2005 at 05:29 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 06, 2005 at 05:30 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 06, 2005 at 05:53 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 06, 2005 at 07:27 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 06, 2005 at 06:58 PM

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

    Best Regards

    Klaus

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.