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

deep structure issue...

Former Member
0 Likes
1,295

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?

7 REPLIES 7
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,149

Not clear

Read only

Former Member
0 Likes
1,149

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?

Read only

0 Likes
1,149

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.

Read only

Former Member
0 Likes
1,149

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?

Read only

0 Likes
1,149

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

Read only

0 Likes
1,149

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.

Read only

Former Member
0 Likes
1,149

Resolved...