‎2009 Oct 02 11:26 AM
hello,
I have 2 internal tables which i am supposed to merge as 1. the problem here is that the the relation is 1: N
table A table B
key 1 desc Key 1 Value1
Key 1 Value 2
key 1 Value 3
And my final output should be
key 1 desc value1 value2 value3. One thing I know is there wont be more than 9 values in table b for every one in table a. Any quick ideas?
‎2009 Oct 02 11:29 AM
quick idea.. use loop at B and read from A
now a simple code
data: gt_final type table of string,
gs_final like line of gt_final.
sort table_b by key.
loop at table_b into wa_b.
at new key.
clear : gs_final, wa_a.
read table table_a into wa_a with key KEY = wa_b-KEY.
if sy-subrc = 0.
concatenate wa_a-key wa_a-desc into gs_final separated by space.
endif.
endat.
concatenate gs_final wa_b-value into gs_final separated by space.
at end of key.
append gs_final to gt_final.
clear gs_final.
endat.
endloop.one more option is to use field symbols. search to see how it is used.
Edited by: Soumyaprakash Mishra on Oct 2, 2009 3:59 PM
‎2009 Oct 02 11:29 AM
quick idea.. use loop at B and read from A
now a simple code
data: gt_final type table of string,
gs_final like line of gt_final.
sort table_b by key.
loop at table_b into wa_b.
at new key.
clear : gs_final, wa_a.
read table table_a into wa_a with key KEY = wa_b-KEY.
if sy-subrc = 0.
concatenate wa_a-key wa_a-desc into gs_final separated by space.
endif.
endat.
concatenate gs_final wa_b-value into gs_final separated by space.
at end of key.
append gs_final to gt_final.
clear gs_final.
endat.
endloop.one more option is to use field symbols. search to see how it is used.
Edited by: Soumyaprakash Mishra on Oct 2, 2009 3:59 PM