‎2010 Mar 01 7:16 PM
Hi,
Iam creating a table type(vbak) in which another table type(vbap) is specified.Now I want to populate data into internal table of vbak which is of vbak tabletype.How can I acheive this?
‎2010 Mar 01 7:25 PM
‎2010 Mar 01 7:32 PM
Iam creating a tabletype lets suppose zvbak having header fields and another table type zvbap in the same tabletype vbak.
Now zvbap contain the item fields.Now I want to populate data from vbak and vbap into an internal table of type zvbak.So how can I acheive the same?
‎2010 Mar 01 7:43 PM
Hi Srilatha,
first of all its not possible to create a table type in another table type.
What i understand from your question is that
to the line type of ZVBAK you are adding new fileds of VBAP
you can declare a internal table of table type ZVBAK but the relationship between header and item is one to many.
You can use join statement and select into the internal table or
you have to declare two internal tables for VBAP and VBAK.
first select the reuired data to header, and based on header data select the item data to another itab.
Then loop through both and format it to internal tables.
‎2010 Mar 01 8:15 PM
Hi,
table type :zvbak -> linetype:zltvbak -> vbeln,erdat,zvbap(table type).
table type:zvbap -> linetype:vbeln,posnr,matnr.
data: itab1 type zvbak,
itab2 type zvbap,
itab3 type zvbak.
data: wa_itab1 line type of zvbak,
wa_itab2 line type of zvbap.
SELECT vbeln erdat
FROM vbak INTO corresponding fields of TABLE itab1
WHERE vbeln = s_vbeln.
if sy-subrc = 0.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE itab2
FOR ALL ENTRIES in itab1
WHERE vbeln = itab1-vbeln.
endif.
loop at itab2 into wa_itab2.
read table itab1 into wa_itab1 with key vbeln = wa_itab2-vbeln.
if sy-subrc = 0.
-
append wa_itab2 to itab3.
endif.
endloop.
here hw can I populate the data from itab2 to itab3?
‎2010 Mar 01 8:21 PM
hi,
loop at itab2 into wa_itab2.
read table itab1 into wa_itab1 with key vbeln = wa_itab2-vbeln.
if sy-subrc = 0.
move wa_itab2 into itab3--zvbap.
append itab3.
endif.
endloop.
Edited by: subas Bose on Mar 1, 2010 9:21 PM
‎2010 Mar 01 8:37 PM
itab3 - declare it with all four fields,
data:wk_tabix type i.
SELECT vbeln erdat
FROM vbak INTO corresponding fields of TABLE itab1
WHERE vbeln in s_vbeln.
if itab1[] is not initial.
SELECT vbeln posnr matnr
FROM vbap
INTO TABLE itab2
FOR ALL ENTRIES in itab1
WHERE vbeln = itab1-vbeln.
sort itab1 by vbeln.
sort itab2 by vbeln.
loop at itab1 into wa_itab1.
loop at itab2 into wa_itab2 from wk_tabix.
if wa_itab2-vbeln ne wa_itab1-vbeln.
wk_tabix = sy-tabix.
exit.
endif.
wa_itab3-vbeln = wa_itab1-vbeln.
wa_itab3-posnr = wa_itab2-posnr.
wa_itab3-erdat = wa_itab1-erdat.
wa_itab3-matnr = wa_itab2-matnr.
append wa_itab3 to itab3.
endloop.
endloop.
endif.
‎2010 Mar 01 8:58 PM