05-27-2008 12:05 PM
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.
05-27-2008 12:15 PM
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!
05-27-2008 12:08 PM
05-27-2008 12:10 PM
u mean nested means looping or reading a internal table with in a loop of an internal table?
05-27-2008 12:47 PM
05-27-2008 12:50 PM
05-28-2008 5:21 AM
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.
05-27-2008 12:15 PM
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!
05-27-2008 12:23 PM
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
05-27-2008 12:48 PM
Hi,
It should have headerline or work area, otherwise you cannot use where condition in the inner loop.
Thanks,
Sriram Ponna,.
05-27-2008 12:56 PM
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.
05-27-2008 12:59 PM