Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8746

Re: How to Join Table Types?

$
0
0

Hi Betram,

 

What you are asking for is to combine the results in ITAB1 and LT_TAB. This does not mean joining two table types.

 

To achieve what you are looking for, you will need to declare one more Table Type and a corresponding internal table, say LT_JOIN, which contains all the UNIQUE columns from ITAB1 and LT_TAB.

 

Also, to be noted is that you would need a common key connecting both ITAB1 and LT_TAB, as in a common column, based on which you can join them.

 

Once the pre-requisites are set, you need to loop at the parent table and read the second table with the common key, then populate the new table.

 

e.g.: Assuming ITAB1 is the parent.

 

LOOP AT itab1 INTO wa_itab1.

     READ TABLE lt_tab INTO ls_tab WITH KEY column = wa_itab1-column.

     IF sy-subrc EQ 0.

          ls_join-column1 = wa_itab1-column1.

          ls_join-column2 = wa_itab1-column2.

          ls_join-column3 = wa_itab1-column2.

          ls_join-column4 = wa_itab1-column3.

          ls_join-column5 = ls_tab-column1.

          ls_join-column6 = ls_tab-column2.

          ls_join-column7 = ls_tab-column3.

          ls_join-column8 = ls_tab-column4.

          APPEND ls_join INTO lt_join.

     ENDIF.

     CLEAR:   ls_join,

                    wa_itab1,

                    ls_tab.

ENDLOOP.

 

Hope this helps.


Viewing all articles
Browse latest Browse all 8746

Trending Articles