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

internal table

Former Member
0 Likes
954

hi all,

An internal table that is nested within another internal table should not contain a header line.

is it true or false?pls explain.

thank u

sunny.

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
921

If you have an internal table which has a component which is itself an internal table - a nested table - it is not possible to for the inner table to have a header-line. The syntax of defining tables does n't allow for it

...EDIT... It never used to be possible!

TYPES: BEGIN OF line_ty,
         field1 TYPE field1,
         field2 TYPE field2,
         nested_table TYPE STANDARD TABLE OF sometype WITH NON-UNIQUE KEY TABLE_LINE,
       END OF line_ty.

DATA: my_itab TYPE line_ty OCCURS 0.

...EDIT... the below is still true, however.

( It is not, in any case, advisable to use tables with header lines, as then you have ambiguity between whether my_itab refers to the table or the header line - and in programming, ambiguity is BAD ).

matt

Edited by: Matthew Billingham on May 27, 2008 1:58 PM

Got bits wrong!

10 REPLIES 10
Read only

Former Member
0 Likes
921

false... u can have both as with header line...

Read only

Former Member
0 Likes
921

u mean nested means looping or reading a internal table with in a loop of an internal table?

Read only

0 Likes
921

yes

Read only

0 Likes
921

yes chandrika..

Read only

0 Likes
921

u can use header line then.

for ex: loop at itab1 into wa_itab1.

read table itab2 into wa_itab2 where condition.

Reward if helpful.

Read only

matt
Active Contributor
0 Likes
922

If you have an internal table which has a component which is itself an internal table - a nested table - it is not possible to for the inner table to have a header-line. The syntax of defining tables does n't allow for it

...EDIT... It never used to be possible!

TYPES: BEGIN OF line_ty,
         field1 TYPE field1,
         field2 TYPE field2,
         nested_table TYPE STANDARD TABLE OF sometype WITH NON-UNIQUE KEY TABLE_LINE,
       END OF line_ty.

DATA: my_itab TYPE line_ty OCCURS 0.

...EDIT... the below is still true, however.

( It is not, in any case, advisable to use tables with header lines, as then you have ambiguity between whether my_itab refers to the table or the header line - and in programming, ambiguity is BAD ).

matt

Edited by: Matthew Billingham on May 27, 2008 1:58 PM

Got bits wrong!

Read only

Former Member
0 Likes
921

Hi,

Check this example..

DATA: BEGIN OF WA,

WERKS TYPE WERKS_D,

END OF WA.

DATA: BEGIN OF ITAB1 OCCURS 0,

MATNR TYPE MATNR,

ITAB_NESTED LIKE WA OCCURS 0,

END OF ITAB1.

DATA: ITAB2 LIKE WA OCCURS 0 WITH HEADER LINE.

ITAB1-MATNR = 'TEST'.

ITAB2-WERKS = 'ASDF'.APPEND ITAB2.

ITAB2-WERKS = 'ADDD'.APPEND ITAB2.

ITAB1-ITAB_NESTED] = ITAB2[.

APPEND ITAB1.

LOOP AT ITAB1.

LOOP AT ITAB1-ITAB_NESTED INTO WA.

WRITE: / WA-WERKS.

ENDLOOP.

ENDLOOP.

Reward points if useful

Read only

Former Member
0 Likes
921

Hi,

It should have headerline or work area, otherwise you cannot use where condition in the inner loop.

Thanks,

Sriram Ponna,.

Read only

Former Member
0 Likes
921

Hi Sunny!!

No doubt u can use internal tables wid header line even widin a loop..bt its obsolete n performance wise nt better to use header line.

Instead use TYPES,thn declare data and work area and thn use ur inter table wid header line.

for ex:

loop at itab into wa_itab.

write wa_itab

endloop.

reward if useful.

Read only

Former Member
0 Likes
921

u can have headerline declared for the inner internal table