Skip to Content
Feb 28, 2021 at 04:07 AM

FOR expressions with CORRESPONDING operator and modifying the internal table


Hi Experts,

Need your help in analyzing the below code.

My requirement is to create a new internal table( et_item_type) from an existing internal table( lt_item_type) by changing a few fields in the structure.

Please find the below code for reference.

The new table et_item_type should be able to switch the item type when it is 'ZABC' to 'ZXYZ' else it should be 2.

Somehow this logic does not seem to work.

Got my reference from

TYPES: BEGIN OF lty_itemtype,
v_itemtype TYPE /scdl/dl_itemtype,
v_itemcat TYPE /scdl/dl_itemtype,
END OF lty_itemtype.
DATA: lv_zdlv TYPE /scdl/dl_itemtype VALUE 'ZABC'.
DATA: lv_odlv TYPE /scdl/dl_itemtype VALUE 'ZXYZ'.
DATA : it_item_type TYPE STANDARD TABLE OF lty_itemtype,
et_item_type TYPE STANDARD TABLE OF lty_itemtype.

et_item_type = VALUE #( FOR wa IN it_item_type ( CORRESPONDING #(BASE ( VALUE #( v_itemtype = SWITCH /scdl/dl_itemtype( WHEN lv_odlv THEN lv_zdlv ELSE 2 ) ) ) wa ) ) ).