I wonder is there any solution for this.
TYPES: BEGIN OF ty_table1,
field1 TYPE string,
END OF ty_table1,
tt_table1 type STANDARD TABLE OF ty_table1 with EMPTY KEY,
BEGIN OF ty_table2,
field1 TYPE string,
END OF ty_table2,
tt_table2 type STANDARD TABLE OF ty_table2 with EMPTY KEY.
DATA: lt_table TYPE table OF ty_table1,
lt_final TYPE table OF ty_table2.
DATA(lt_table1) = VALUE tt_table1( FOR <fs_struct> IN lt_table WHERE ( field1 EQ 'TEST' )
( CORRESPONDING #( <fs_struct> ) ) ).
DATA(lt_table2) = VALUE tt_table2( FOR <fs_struct> IN lt_final WHERE ( field1 EQ 'TEST1' )
( CORRESPONDING #( <fs_struct> ) ) ).
Here, we will be getting a syntax error in the 2nd constructor expression stating:
"<FS_STRUCT>" was already declared with the type "TY_TABLE1" and cannot be used with the type "TY_TABLE2" here.
Is there any way to "unassign" <FS_STRUCT> after the 1st statement? So that, it can be used in the next forthcoming FOR statements for different tables.
The normal UNASSIGN statement can't be used to unassign <fs_struct> since it won't have scope outside the FOR loop.