Application Development and Automation 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: 
Read only

Two different internal table, how to move in third internal table.

Former Member
0 Likes
862

i want to move two different internal table (fields and data) in to third internal table( output table).

itab 1 : l_t_vbrk.

itab 2 : l_t_vbak.

itab 3 : l_t_output_header_data.

i want to move two different internal table (fields and data) in to third internal table( output table).

itab 1 : l_t_vbrk.

itab 2 : l_t_vbak.

itab 3 : l_t_output_header_data.

6 REPLIES 6
Read only

Former Member
0 Likes
749

Hi

Assume that internal table l_t_vbrk contains data of items and relationship to sales document.

  sort l_t_vbak by vbeln posnr.
  loop at l_t_vbrk.
       move-corrsponding l_t_vbrk to l_t_output_header_data.
       read table l_t_vbak with key vbeln = l_t_vbrk-vgbel
                                    posnr = l_t_vbrk-vgpos.
       if sy-subrc eq 0.
          move-corresponding l_t_vbak to l_t_output_header_data.
       endif.
  endloop.

Note that, VBGEL and VGPOS can be extracted from VBRP.

Kind Regards

Eswar

Read only

Former Member
0 Likes
749

Hi,

Are the table structures are the same ?

If yes :


* here you move the first Table in the final table
l_t_output_header_data[] =  l_t_vbrk[]

* Here you append the second table to the final table
loop at  l_t_vbak.
move-corresponding l_t_vbak to l_t_output_header_data.
append l_t_output_header_data.
endloop.

Hope this helps,

Erwan

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
749

Hi,

Hope atleast one field will be common(Key field) in two tables.

loop at itab1 into wa1.

move-corresponding wa1 to wa3.

loop at itab2 into wa2 where f1 = wa2-f1.

move-corresponding wa2 to wa3.

append wa3 to itab3.

endloop.

endloop.

Read only

Former Member
0 Likes
749

sort l_t_vbrk by vbeln posnr.

sort i_t_vbak by vbeln posnr.

loop at l_t_vbrk into wa_vbrk.

read table l_t_vbak into wa_vbak with key vbeln = wa_vbrk-vbeln and posnr = wa_vbrk-posnr binary seach.

if sy-subrc = 0.

wa_output_header-vbeln = wa_vbak-vbeln.

wa_output_header-posnr = wa_vbak-posnr.

*in this way move data to output work area else if the structure is same u can also use move corresponding.

append wa_output_header to l_t_output_header_data.

endif.

endloop.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

Former Member
0 Likes
749

Hi Santosh,

both tables have only 1 primary keys so..

loop at t_vbrk.

move reqired fields into t_output from t_vbrk.

read table t_vbak with key vbeln = t_vbrk.

if sy-subrc = 0.

move required fields into t_outpt from t_vbak.

endif.

append t_output.

endloop.

-Anu.

Read only

Former Member
0 Likes
749

Hi,

sort i_vbrk by aubel.

loop at i_vbrk.

read table i_vbak with key vbeln = i_vbrk-aubel

binary search.

if sy-subrc eq 0.

data lv_index type sy-tabix.

clear lv_index.

lv_index = sy-tabix.

loop at i_vbak from lv_index.

if i_vbak-vbeln <> i_vbrk-aubel.

clear i_vbak.

exit.

endif.

endloop.

endif.

move-corresponding i_vbak to i_final.

move-corresponding i_vbrk to i_final.

append it_final.

endif.

endloop.

Regards,

Amole