2011 Apr 06 3:41 PM
Hi All,
I have a slight problem, I have two internal tables that I wish to merge into one.
The first i_GFSB contains matnr,werk,verpr,peinh from mbew
The second i_GFSBData has matnr, < i_GFSB-werk>, < i_GFSB-verpr>, < i_GFSB-peinh> ,bwky,verpr,peinh also from mbew
The <> are the fields from i_GFSB that I need to 'insert' into i_GFSBData
Ok,
i_GFSB contains data from a single plant (and the records are distinct)
i_GFSBData contains data for multiple plants (again distinct records)
What I am trying to do is insert the i_GFSB data when the matnr is the same in both tables.
Sounds simple, probably is but this is my first real ABAP program and I am a little confused.
Is there any variable like a python dictionary? If so I could do this in a flash
Cheers all
Ian
2011 Apr 06 3:58 PM
Hi Ian,
Please try this code:
data: wa_gfsb like line of i_gfsb,
wa_gfsbdata like line of i_gfsbdata,
lv_tabix type sy-tabix.
* Sort Table by Plant.
sort i_gfsbdata by matnr.
loop at i_gfsb into wa_gfsb.
read table i_gfsbdata into wa_gfsbdata
with key matnr = wa_gfsb-matnr binary search.
if sy-subrc is initial.
lv_tabix = sy-tabix.
loop at i_gfsbdata into wa_gfsbdata
from lv_tabix.
if wa_gfsbdata-matnr ne wa_gfsb-matnr.
exit.
else.
wa_gfsbdata-werks = wa_gfsb-werks.
wa_gfsbdata-verpr = wa_gfsb-verpr.
wa_gfsbdata-peinh = wa_gfsb-peinh.
modify i_gfsbdata from wa_gfsbdata.
endif.
clear wa_gfsbdata.
endloop.
endif.
endloop.
Hope this helps.
Ernesto
Edited by: Ernesto Caballero on Apr 6, 2011 4:59 PM
Hi All,
I have a slight problem, I have two internal tables that I wish to merge into one.
The first i_GFSB contains matnr,werk,verpr,peinh from mbew
The second i_GFSBData has matnr, < i_GFSB-werk>, < i_GFSB-verpr>, < i_GFSB-peinh> ,bwky,verpr,peinh also from mbew
The <> are the fields from i_GFSB that I need to 'insert' into i_GFSBData
Ok,
i_GFSB contains data from a single plant (and the records are distinct)
i_GFSBData contains data for multiple plants (again distinct records)
What I am trying to do is insert the i_GFSB data when the matnr is the same in both tables.
Sounds simple, probably is but this is my first real ABAP program and I am a little confused.
Is there any variable like a python dictionary? If so I could do this in a flash
Cheers all
Ian
2011 Apr 06 3:58 PM
Hi Ian,
Please try this code:
data: wa_gfsb like line of i_gfsb,
wa_gfsbdata like line of i_gfsbdata,
lv_tabix type sy-tabix.
* Sort Table by Plant.
sort i_gfsbdata by matnr.
loop at i_gfsb into wa_gfsb.
read table i_gfsbdata into wa_gfsbdata
with key matnr = wa_gfsb-matnr binary search.
if sy-subrc is initial.
lv_tabix = sy-tabix.
loop at i_gfsbdata into wa_gfsbdata
from lv_tabix.
if wa_gfsbdata-matnr ne wa_gfsb-matnr.
exit.
else.
wa_gfsbdata-werks = wa_gfsb-werks.
wa_gfsbdata-verpr = wa_gfsb-verpr.
wa_gfsbdata-peinh = wa_gfsb-peinh.
modify i_gfsbdata from wa_gfsbdata.
endif.
clear wa_gfsbdata.
endloop.
endif.
endloop.
Hope this helps.
Ernesto
Edited by: Ernesto Caballero on Apr 6, 2011 4:59 PM
2011 Apr 07 7:49 AM
Hi Ernesto
Yeah thats the ticket, all working fine now.
Thank you very much.
Ian
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |