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: 

How to group and loop dynamic internal table ?

JamesG
Participant
0 Kudos
1,582

Hi experts,

The dynamic internal table that how to group and loop?

1 ACCEPTED SOLUTION

JamesG
Participant
0 Kudos
912
  LOOP AT <fs_dytable> ASSIGNING <fs_dywa>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_dywa> TO FIELD-SYMBOL(<fs_matnr>).
AT END OF <fs_matnr>.
ENDAT.
ENDLOOP.
5 REPLIES 5

FredericGirod
Active Contributor
0 Kudos
912

What do you mean with Group an internal table ?

JamesG
Participant
0 Kudos
912

like this

LOOP AT <dy_table> ASSIGNING <dyn_wa> GROUP BY (  belnr  = ( lv_field )  waers  = ( lv_field1 )  ) ASSIGNING FIELD-SYMBOL(<group>).
endloop.

Sandra_Rossi
Active Contributor
0 Kudos
912

Hmmm according to your example, you seem to say that you want ( lv_field ) to be dynamic, but it's already dynamic by definition.

If you mean to make BELNR dynamic, The latest ABAP documentation doesn't refer to the possibility of indicating a dynamic name at runtime, so...

JamesG
Participant
0 Kudos
912

Actually, I want handle this:

  LOOP AT <fs_dytable> ASSIGNING <fs_dywa> GROUP BY SWITCH string( lv_flag WHEN 'A' THEN |MATNR = <FS_DYWA>-MATNR|
WHEN 'B' THEN |MATNR = <FS_DYWA>-MATNR WERKS = <FS_DYWA>-WERKS STLAN = <FS_DYWA>-STLAN STLAL = <FS_DYWA>-STLAL ZKZM = <FS_DYWA>-ZKZM| )
ASCENDING ASSIGNING FIELD-SYMBOL(<group>).
LOOP AT GROUP <group> ASSIGNING FIELD-SYMBOL(<fs>).
MOVE-CORRESPONDING <fs> TO gs_handle.
ENDLOOP.
ENDLOOP.

But, the <fs_dywa>-matnr was not assigning,So,any method can sovle it?

JamesG
Participant
0 Kudos
913
  LOOP AT <fs_dytable> ASSIGNING <fs_dywa>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_dywa> TO FIELD-SYMBOL(<fs_matnr>).
AT END OF <fs_matnr>.
ENDAT.
ENDLOOP.