Skip to Content
2
Nov 23, 2018 at 05:46 AM

New ABAP Syntax for modifying internal tables

13244 Views Last edit Nov 23, 2018 at 06:04 AM 2 rev

Hi,

Is there any way to modify an internal table using new abap syntax, possibly within FOR...IN iteration? I need to modify the value in a column of each row of an existing internal table and assign it to a new internal table. I was trying to use something like this:

TYPES: tt_1 TYPE TABLE OF YGT_COST WITH EMPTY KEY.

DATA: lr_gen TYPE REF TO data.

FIELD-SYMBOLS: <tab> TYPE STANDARD TABLE.

FIELD-SYMBOLS: <line1> TYPE ANY.

CREATE DATA lr_gen TYPE STANDARD TABLE OF YGT_COST WITH EMPTY KEY.

ASSIGN lr_gen->* TO <tab>.

CREATE DATA lr_gen TYPE YGT_COST.

ASSIGN lr_gen->* TO <line1>.*

<tab> = ct_table.

DATA(lt_table) = VALUE tt_1( FOR <line> IN <tab> ( new_update = 'X' ) ).

*// However, the above statement is creating an internal table lt_table with the line type of <line> but it's only populating new_update colum with 'X'. Remaining columns are rendering as initial into the new internal table lt_table.

What i am expecting is to only update column new_update with 'X' and remaining columns should have values from <line> structure. Please note, Column to column mapping from <line> to the corresponding fields of lt_table is not feasible because of large number of columns involved.

Best Rgds,

Vish