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

what is nested internal tables concept

Former Member
0 Likes
804

hi all

what is nested internal tables concept

thanks

Devi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
776
It is looping an internal table inside a loop.

loop at itab1.
  loop at itab2 where...
  endloop.
endloop.

hi all

what is nested internal tables concept

thanks

Devi

5 REPLIES 5
Read only

Former Member
0 Likes
777
It is looping an internal table inside a loop.

loop at itab1.
  loop at itab2 where...
  endloop.
endloop.
Read only

Former Member
Read only

Former Member
0 Likes
776

hi,

dividing the processing of data into more than one internal table i.e

looping an internal table in another may effect the run-time.

for better ref go thru this thread.

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

however u can increase the performance ..refernce

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40729734-3668-2910-deba-fa0e95e2...

all the bset,

regards,

sampath

*award points if helpful

Read only

Former Member
0 Likes
776

hi devi,

generally it is used when we want to populate or read data from more than two internal tables

reg

praveen

Read only

Former Member
0 Likes
776

When storing data in internal tables, you often use one internal table for each database you read.

Each one contains some or all columns of the relevant database table. It is up to you whether

you create an internal table with a flat structure for each database table or if you create, for

example, internal tables with nested structures. If you have several tables, each one with a flat

structure, you have to work with redundant key fields to link the tables. If, on the other hand, you

use nested internal tables, you can store the data from the database tables hierarchically.

Saving and processing very large amounts of data in internal tables has disadvantages. If you

divide up the data into different internal tables, processing it can be very runtime-intensive, since

the tables have to be processed individually. Furthermore, it requires a lot of storage space,

since internal tables are not stored in compressed form. The system may even need to store the

dataset outside of its working memory. This means that processing it takes even longer.

<u>An example of nested internal table:</u>

Assume the following program is linked to the logical database [Page 1163] 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.

Regards