Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FOR loop With Same Field-Symbol For Different Structure

hatrigt
Participant
0 Likes
1,275

I always wonder is there any solution for this.

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 an error stating <FS_STRUCT> used in the 2nd expression is not compatible since LT_FINAL is of a different structure compared to Lt_table.

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.

2 REPLIES 2
Read only

former_member598787
Participant
0 Likes
1,151

Normal syntax for this uses Work Areas not field symbols

Read only

Sandra_Rossi
Active Contributor
1,151

FYI this question was asked in Stack Overflow and answered there in details.