‎2008 Feb 20 9:39 AM
How to declare an itab from a structure
This structure has substructure in it...i.e., deep structure
‎2008 Feb 20 9:52 AM
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
‎2008 Feb 20 9:41 AM
Hi Dude,
The same you declare from an ordinary structure.
Regards,
Lakshmanan
‎2008 Feb 20 9:47 AM
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.
‎2008 Feb 20 9:52 AM
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
‎2008 Feb 20 9:52 AM
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
‎2008 Feb 20 9:56 AM
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.