Skip to Content

Is there a new syntax (740, 750, 751) to MODIFY same internal table?

Apr 17, 2017 at 09:42 AM


avatar image

Hello All,

I was wondering if there's a new way to modify same internal table with new syntax. The old way would be looping thru and modify it.

For condition based, MODIFY internal_table FROM work_area WHERE (condition) would do the trick, however, doing it unconditionally would require a LOOP.

LOOP AT internal_table ASSIGNING FIELD-SYMBOL(<field_symbol>).
  <field_symbol>-field = value.

Since ABAP lang has evolved - right from 740, 750 and now 751; and it still is evolving, is there a new way to do it which I probably missed?

If no, then can we have something like

internal_table[ 1..lines( internal_table ) ]-field = value.

I know it's like always asking for more which raises some eye-brows because there are a few, (who I know), are still averse to using the new syntax.

But, as they say - When the storm has swept by, the wicked are gone, but the righteous stand firm forever! ;-)


10 |10000 characters needed characters left characters exceeded

Duh! It came out to be very simple. Thanks Horst, your blogs always help me!

internal_table = VALUE #( FOR <field_symbol> IN internal_table
                   LET lv_value = value IN
                   ( VALUE #( BASE CORRESPONDING #( <field_symbol> ) field = lv_value ) )
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Horst Keller
Apr 18, 2017 at 09:04 AM

Look up the documentation and examples for the constructor operators VALUE, REDUCE, FILTER, CORRESPONDING, COND, ....

You can combine them and use the same table at LHS and RHS.

itab = operator #( ... FOR wa IN itab ... )

10 |10000 characters needed characters left characters exceeded
Evgeniy Astafev Apr 17, 2017 at 12:05 PM
DATA lt TYPE some_table.
DATA ls TYPE LINE OF some_table.
ls-field = some_value.
MODIFY lt FROM ls WHERE field <> some_value TRANSPORTING field.

That will change whole table.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Could be re-written as

DATA lt TYPE some_table.
MODIFY lt FROM VALUE #( field = some_value ) WHERE field <> some_value TRANSPORTING field.