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

Create internal table in inside another internal table.....

Former Member
0 Likes
8,056

Hi All,

I want to create Internal table in inside another internal table in my program. so is it possible??

I have craete like below but its giving error to me....

DATA: BEGIN OF wt_tab1 occurs 0,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp,

BEGIN OF wt_tab2 occurs 0,

eadet like ekpo-eadet,

END OF wt_tab2,

END OF wt_tab1.

If anyone have idea so please let me know.....

Thanks

Jigar Bhatt

14 REPLIES 14
Read only

Former Member
0 Likes
3,731

HI Jigar,

Initially create a structure, and later include this structure while creating your table. This will work. Refer some standard program, where nested tables are used a lot. Eg: If i rember correctly, ALV using OOPs uses nested table for making cells editable.

Read only

0 Likes
3,731

Hi Saravanan,

Thanks for reply...

Could you give me some standard program name? so its useful for me....

Thanks

Jigar

Read only

former_member386202
Active Contributor
0 Likes
3,731

Hi,

Refer following code

types: BEGIN OF ty_s_clear_doc,

bukrs TYPE bukrs, "Company Code

header TYPE bapiache09, "Header data

account TYPE bapiacgl09_tab, "Account Data

curramount TYPE bapiaccr09_tab, "Currency Amount

END OF ty_s_clear_doc,

data : it_clear_doc type standard table of ty_s_clear_doc.

Regards,

Prashant

Read only

Former Member
0 Likes
3,731

Hi,

Try below code:

Types: BEGIN OF wt_tab2,

eadat like ekpo-aedat,

END OF wt_tab2.

DATA: BEGIN OF wt_tab1 occurs 0,

ebeln like ekpo-ebeln,

ebelp like ekpo-ebelp.

data: it_tab2 type table of wt_tab2,

END OF wt_tab1.

Cheers,

Surinder

Read only

former_member206377
Active Contributor
3,731

Hi Jigar,

Try this :



DATA: BEGIN OF struct1,
       field1 TYPE c,
       field2 TYPE c,
      END OF struct1.
 
DATA: BEGIN OF struct2,
       field3 TYPE c,
       field4 TYPE c.
        INCLUDE STRUCTURE struct1.     " The structure is included here
DATA  END OF struct2.

Read only

0 Likes
3,731

Hi Vasuki,

Can you please elaborate how your code would create a internal table inside an internal table as per what i know it wud create a structure inside the table.

Cheers,

Surinder

Read only

3,731

Hi Jigar,

Yes you are right. To have nested internal tabel try this :


TYPES: BEGIN OF struct3,
       field1 TYPE c,
       field2 TYPE c,
      END OF struct3.
 DATA it_itab1 TYPE table of struct3.
TYPES: BEGIN OF struct4,
       field3 TYPE c,
       field4 TYPE c,
       it_tab1 like it_itab1, 
      END OF struct4.
DATA : it_tab2 TYPE table of struct4.         "This is the nested Internal table

Read only

0 Likes
3,731

Hi Vasuki,

this one is not working.....

i want internal table inside internal table.... not a structure....

Thanks

Jigar

Read only

0 Likes
3,731

Hi Jigar,

It is a nested internal table.

In this case it_tab2 is an internal table which holds another internal table it_tab1 .Please try debugging and see. You can notice that in debugging.

Read only

Former Member
0 Likes
3,731

Hi,

I hope your talking about the deep structure con..

use the below link ..

http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb2fcc358411d1829f0000e829fbfe/content.htm.

~linganna

Read only

former_member217544
Active Contributor
0 Likes
3,731

Hi Jigar,

Check this link. This gives you an example of using deep structures.

Regards,

Swarna Munukoti

Read only

Former Member
0 Likes
3,731

Refer this link for an example on nested internal table :

http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9eaa35c111d1829f0000e829fbfe/content.htm

You'll find the example code under the section "Formatting Data Using Nested Internal Tables"

Read only

Former Member
0 Likes
3,731

Please check the below declaration.

Types : Begin of g_makt,

spras type spras,

maktx type maktx,

End of g_makt.

Types : g_makt_t Type standard table of g_makt.

Data : Begin of g_matnr,

matnr type matnr,

ersda type ersda,

lt_makt type g_makt_t,

End of g_matnr.

Data : gt_mtnr Like table of g_matnr Initial Size 0.

Here gt_mtnr is an internal table with another internal table lt_makt inside it.

Thanks,

Nitin Sethi

Read only

Former Member
0 Likes
3,731

Thanks vasuki...