Application Development 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: 

AT END OF F1/F2 on same itab; LOOP AT <itab1/itab2> INTO wa

Former Member
0 Kudos

Hi All,

1)

I need to get the itab dynamically.

LOOP AT itab_dyn INTO wa.

ENDLOOP.

Here, itab_dyn can be itab1 or itab2 (based on a condition) and both of which have same fields only change in order of table fields. ex: table1 - F1, F2 ; table2- F2, F1

Can we have field symbols for that? Please tell any other possible solutions.

2)

But my basic requirement is to use AT END OF F1/F2 inside a single LOOP.

But even if we give SORT itab BY F1 F2 and F2 F1 based on condition, AT END OF won't work in both cases (ex: struct-F1 F2, SORT F2 F1. it will consider change of F1, when you write AT END OF F2) because I think the field should be first one while defining structure

Thanks in advance,

Nunu Vengal.

1 REPLY 1

Former Member
0 Kudos

1) Define a field symbol as TYPE TABLE and assign the internal table itab1 or itab2 to that field symbol using the ASSIGN TABLE statement.

ASSIGN TABLE itab1 TO <fs>.

2) Sort the field symbol (internal table) by the desired field (F1/F2) and use ON CHANGE OF <Field> instead of AT END OF...

Please mark points and close the thread if the solution was useful.

Regards,

Manoj