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

Delcare deep structures

Former Member
0 Likes
4,957

How to declare an itab from a structure

This structure has substructure in it...i.e., deep structure

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,459

Hi,

Deep Structures are declared in the normal way as we declare strucures.

the same way mentioned here you can go ahead..


REPORT zstructure.

TYPES: BEGIN OF name,
title(5) TYPE c,
first_name(10) TYPE c,
last_name(10) TYPE c,
END OF name.

TYPES: BEGIN OF mylist,
client TYPE name,
number TYPE i,
END OF mylist.

DATA list TYPE mylist.

list-client-title = 'Lord'.
list-client-first_name = 'Howard'.
list-client-last_name = 'Mac Duff'.
list-number = 1.

WRITE list-client-title.
WRITE list-client-first_name.
WRITE list-client-last_name.
WRITE / 'Number'.
WRITE list-number.

Regds

Chandru

5 REPLIES 5
Read only

Former Member
0 Likes
1,459

Hi Dude,

The same you declare from an ordinary structure.

Regards,

Lakshmanan

Read only

Former Member
0 Likes
1,459

Hi

you can just declare the internal table normally as you wil do with a single structure...

Just see the code you may get some insight.

REPORT ZSTRUCT.

TYPES: BEGIN OF student,

first_name(10) TYPE c,

last_name(10) TYPE c,

age type i,

END OF student.

TYPES: BEGIN OF mystudent,

customer TYPE student,

amount TYPE f,

END OF mystudent.

DATA assign TYPE mystudent.

DATA itab type table of mystudent.

DATA wa LIKE LINE OF ITAB.

assign-customer-first_name = 'Lord'.

assign-customer-last_name = 'Howard'.

assign-customer-age = '10'.

assign-amount = '3'.

APPEND assign TO itab.

LOOP AT itab into wa.

WRITE wa-customer-first_name.

WRITE wa-customer-last_name.

WRITE wa-amount.

ENDLOOP.

Reward if helpful.

Read only

Former Member
0 Likes
1,460

Hi,

Deep Structures are declared in the normal way as we declare strucures.

the same way mentioned here you can go ahead..


REPORT zstructure.

TYPES: BEGIN OF name,
title(5) TYPE c,
first_name(10) TYPE c,
last_name(10) TYPE c,
END OF name.

TYPES: BEGIN OF mylist,
client TYPE name,
number TYPE i,
END OF mylist.

DATA list TYPE mylist.

list-client-title = 'Lord'.
list-client-first_name = 'Howard'.
list-client-last_name = 'Mac Duff'.
list-number = 1.

WRITE list-client-title.
WRITE list-client-first_name.
WRITE list-client-last_name.
WRITE / 'Number'.
WRITE list-number.

Regds

Chandru

Read only

Former Member
0 Likes
1,459

Hi Sunil,

Make a table type using the structure of which you want to make internal table.

And then make internal table of type as that Table Type.

And to access the substructure, treat substructure as one of the fields of main structure.

Hope it helps you.

Reward points if helpful.

Regards,

Preeti

Read only

Former Member
0 Likes
1,459

hi

hope it will help you.

Reward if help,.

structures containing internal tables as components or

Internal table containing Structure as components are called Deep Internal table.

Please check this link for reading a deep structure.

Example:

TYPES: BEGIN OF TYPE_DEEP,

MATNR TYPE MATNR,

T_MARC TYPE MARC OCCURS 0,

END OF TYPE_DEEP.

DATA: T_DEEP TYPE STANDARD TABLE OF TYPE_DEEP.

DATA: WA_DEEP TYPE TYPE_DEEP.

DATA: T_MARC TYPE TABLE OF MARC.

DATA: S_MARC TYPE MARC.

  • Populating data.

WA_DEEP-MATNR = 'TEST'.

S_MARC-MATNR = 'TEST'.

S_MARC-WERKS = '9090'.

APPEND S_MARC TO T_MARC.

  • Append second level internal table.

WA_DEEP-T_MARC[] = T_MARC[].

  • Append.

APPEND WA_DEEP TO T_DEEP.

  • Process the internal table.

LOOP AT T_DEEP INTO WA_DEEP.

WRITE: / WA_DEEP-MATNR.

  • PROCESS the second level internal table.

LOOP AT WA_DEEP-T_MARC INTO S_MARC.

WRITE: S_MARC-WERKS.

ENDLOOP.

ENDLOOP.