‎2007 Apr 01 7:46 AM
can any one pls tell what is nested internal tables,syntax and ther adv
‎2007 Apr 01 7:55 AM
Hi,
Formatting Data Using Nested Internal Tables
Assume the following program is linked to the logical database F1S.
REPORT DEMO.
DATA: SUM TYPE I, CNT TYPE I.
NODES: SPFLI, SFLIGHT, SBOOK.
DATA: BEGIN OF WA_SBOOK,
BOOKID TYPE SBOOK-BOOKID,
SMOKER TYPE SBOOK-SMOKER,
CLASS TYPE SBOOK-CLASS,
LUGGWEIGHT TYPE SBOOK-LUGGWEIGHT,
WUNIT TYPE SBOOK-WUNIT,
END OF WA_SBOOK.
DATA: BEGIN OF WA_SFLIGHT,
FLDATE TYPE SFLIGHT-FLDATE,
SBOOK LIKE TABLE OF WA_SBOOK ,
END OF WA_SFLIGHT.
DATA: BEGIN OF WA_SPFLI,
CARRID TYPE SPFLI-CARRID,
CONNID TYPE SPFLI-CONNID,
CITYFROM TYPE SPFLI-CITYFROM,
CITYTO TYPE SPFLI-CITYTO,
SFLIGHT LIKE TABLE OF WA_SFLIGHT ,
END OF WA_SPFLI.
DATA TAB_SPFLI LIKE TABLE OF WA_SPFLI .
START-OF-SELECTION.
GET SPFLI.
REFRESH WA_SPFLI-SFLIGHT.
GET SFLIGHT.
REFRESH WA_SFLIGHT-SBOOK.
GET SBOOK.
MOVE-CORRESPONDING SBOOK TO WA_SBOOK.
APPEND WA_SBOOK TO WA_SFLIGHT-SBOOK.
GET SFLIGHT LATE.
MOVE-CORRESPONDING SFLIGHT TO WA_SFLIGHT.
APPEND WA_SFLIGHT TO WA_SPFLI-SFLIGHT.
GET SPFLI LATE.
MOVE-CORRESPONDING SPFLI TO WA_SPFLI.
APPEND WA_SPFLI TO TAB_SPFLI.
END-OF-SELECTION.
SORT TAB_SPFLI BY CITYFROM CITYTO CONNID.
LOOP AT TAB_SPFLI INTO WA_SPFLI.
SKIP.
WRITE: / WA_SPFLI-CARRID,
WA_SPFLI-CONNID,
'from', (15) WA_SPFLI-CITYFROM,
'to', (15) WA_SPFLI-CITYTO.
ULINE.
SORT WA_SPFLI-SFLIGHT BY FLDATE.
LOOP AT WA_SPFLI-SFLIGHT INTO WA_SFLIGHT.
SKIP.
WRITE: / 'Date:', WA_SFLIGHT-FLDATE.
WRITE: 20 'Book-ID', 40 'Smoker', 50 'Class'.
ULINE.
SORT WA_SFLIGHT-SBOOK BY CLASS SMOKER BOOKID.
SUM = 0.
CNT = 0.
LOOP AT WA_SFLIGHT-SBOOK INTO WA_SBOOK.
WRITE: / WA_SBOOK-BOOKID UNDER 'Book-ID',
WA_SBOOK-SMOKER UNDER 'Smoker',
WA_SBOOK-CLASS UNDER 'Class'.
SUM = SUM + WA_SBOOK-LUGGWEIGHT.
CNT = CNT + 1.
ENDLOOP.
ULINE.
WRITE: 'Number of bookings: ', (3) CNT,
/ 'Total luggage weight:',
(3) SUM, WA_SBOOK-WUNIT.
ENDLOOP.
ENDLOOP.
This program creates the same list as in the Example of Formatted Data.
During the GET events, the system reads the data into the three-level internal table SORT_SPFLI which contains the substructure SFLIGHT and its substructure SBOOK. The sorting process takes place on the individual nesting levels.
This way of programming does not require key relations between the internal tables (no WHERE conditions), but it is more complex than using flat internal tables. And the increased internal administration effort has a negative effect on the storage space required as well as on the runtime.
Thanks,
Sankar M
‎2007 Apr 01 8:02 AM
pandu,
internal table within an internal table is called as nested internal table.
It is used when in the declaration of the internal table it should be without header line.
it is same as structure within structure which v use in other programming lang like c.
Regards....
Arun.
Reward points if useful.
‎2007 Apr 01 8:41 AM
hi,
nested internal table means declare internal table with in the internal table
this is possible only with 'without header line'.
types : begin of stab1,
f1 type dt,
f2 type dt,
types : begin of stab2,
f3 type dt,
f4 type dt,
end of stab2,
end of stab1.
data: itab1 type standard table of stab1,
wa_tab1 type stab1.
is it clear?
hope this is useful to you
bye