1

How to change the old BW3.x code (tables with header) to BW7.x (tables without header)

OLD code:

LOOP AT p_package.
  gv_tabix = sy-tabix.
  " changing header ... and more
  MODIFY p_package INDEX gv_tabix.

Here the header line gets changed and the table is updated using modify and index

Unfortunately I do not see how to use the index keyword on tables without a header.

So far I coded:

LOOP AT p_package into p_package_line.
  gv_tabix = sy-tabix.
  " changing p_package_line ...
  MODIFY table p_package from p_package_line

But I'm not sure if it is correct.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Thorsten Niehues
  • 13,712
  • 22
  • 78
  • 113

1 Answers1

3

Use a field symbol. This eliminates the need to explicitly MODIFY the table completely:

LOOP AT p_package ASSIGNING FIELD-SYMBOL(<package_line>).
  <package_line>-foo = 'bar'.
ENDLOOP.

(or for older versions)

FIELD-SYMBOLS <package_line> TYPE LINE OF p_package.
LOOP AT p_package ASSIGNING <package_line>.
  <package_line>-foo = 'bar'.
ENDLOOP.

If you want to stick to the use of MODIFY:

MODIFY p_package FROM p_package_line INDEX foobarhyperprefixstuffthingy_tabix.

(And yes, it's in the documentation :-)).

vwegert
  • 18,371
  • 3
  • 37
  • 55