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: 

ABAP "FOR GROUPS ... OF ... IN VALUE type( ... )" syntax error: No group is bound to "..."

Sandra_Rossi
Active Contributor
2,349

Hi experts,

My program is running fine in ABAP 7.52 and 7.57:

REPORT.
TYPES ty_objectnames TYPE STANDARD TABLE OF ob_object WITH EMPTY KEY.
TYPES: BEGIN OF ty_int,
         int_id      TYPE i,
         objectnames TYPE ty_objectnames,
       END OF ty_int.
TYPES ty_ints TYPE STANDARD TABLE OF ty_int WITH EMPTY KEY.
TYPES ty_int_ids TYPE STANDARD TABLE OF ty_int-int_id WITH EMPTY KEY.
TYPES: BEGIN OF ty_object,
         objectname TYPE cus_actobj-objectname,
         int_ids    TYPE ty_int_ids,
       END OF ty_object.
TYPES ty_objects TYPE STANDARD TABLE OF ty_object WITH EMPTY KEY.

DATA(ints) = VALUE ty_ints(
    ( int_id = 1 objectnames = VALUE #( ( 'a' ) ) )
    ( int_id = 2 objectnames = VALUE #( ( 'a' ) ( 'b' ) ) ) ).

DATA(objects) = VALUE ty_objects(
            FOR <int> IN ints
            FOR <objectname> IN <int>-objectnames
            ( objectname = <objectname>
              int_ids    = VALUE #( ( <int>-int_id ) ) ) ).

DATA(objects_2) = VALUE ty_objects(
        FOR GROUPS <group_object> OF <object> IN objects
        GROUP BY ( objectname = <object>-objectname )
        ( objectname = <group_object>-objectname
          int_ids    = REDUCE #( INIT int_ids TYPE ty_int_ids
                                 FOR <object_2> IN GROUP <group_object>
                                 NEXT int_ids = VALUE #( BASE int_ids ( <object_2>-int_ids[ 1 ] ) ) ) ) ).

ASSERT objects_2 = VALUE ty_objects(
    ( objectname = 'a' int_ids = VALUE #( ( 1 ) ( 2 ) ) )
    ( objectname = 'b' int_ids = VALUE #( ( 2 ) ) ) ).
Now, I want to get rid of the intermediate "OBJECTS" internal table ("DATA(objects) = ..." and "FOR GROUPS ... IN objects"), so I replace the line "FOR GROUPS ... IN objects" with "FOR GROUPS ... IN VALUE ty_objects( ... )":
*        FOR GROUPS <group_object> OF <object> IN objects
        FOR GROUPS <group_object> OF <object> IN VALUE ty_objects(
            FOR <int> IN ints
            FOR <objectname> IN <int>-objectnames
            ( objectname = <objectname>
              int_ids    = VALUE #( ( <int>-int_id ) ) ) )

But I get the ABAP syntax error (MESSAGEGDZ in TRMSG) (both in ABAP 7.52 and ABAP 7.57):

  • No group is bound to "<GROUP_OBJECT>"

Is it a compiler error or by design? Is it documented? Or any other reason?

Thank you!

Sandra

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
2,187

Extract from the comments, how it can be solved with LET. Any other answer is welcome. Thanks!

frdric.girod

Hi Sandra,

I have the feeling the problem is VALUE statement.

Like if depending of a constructor expression the memory could not be shared.

sandra.rossi

Thanks. You must be right. Thinking of what you say, the solution is "just" using LET:

*        FOR GROUPS <group_object> OF <object> IN objects
        LET aux_objects = VALUE ty_objects(
            FOR <int> IN ints
            FOR <objectname> IN <int>-objectnames
            ( objectname = <objectname>
              int_ids    = VALUE #( ( <int>-int_id ) ) ) )
        IN
        FOR GROUPS <group_object> OF <object> IN aux_objects

Solved on ABAP 7.52 and 7.57.

8 REPLIES 8

FredericGirod
Active Contributor
0 Kudos
2,187

Hi Sandra,

I have the feeling the problem is VALUE statement.

Like if depending of a constructor expression the memory could not be shared

Sandra_Rossi
Active Contributor
2,187

Thanks. You must be right. Thinking of what you say, the solution is "just" using LET:

*        FOR GROUPS <group_object> OF <object> IN objects
        LET aux_objects = VALUE ty_objects(
            FOR <int> IN ints
            FOR <objectname> IN <int>-objectnames
            ( objectname = <objectname>
              int_ids    = VALUE #( ( <int>-int_id ) ) ) )
        IN
        FOR GROUPS <group_object> OF <object> IN aux_objects

Solved on ABAP 7.52.

FredericGirod
Active Contributor
2,187

Hi sandra.rossi maybe you should post it as answer

(Hope you will not come as it is the 15th august 😉 )

Sandra_Rossi
Active Contributor
2,188

Extract from the comments, how it can be solved with LET. Any other answer is welcome. Thanks!

frdric.girod

Hi Sandra,

I have the feeling the problem is VALUE statement.

Like if depending of a constructor expression the memory could not be shared.

sandra.rossi

Thanks. You must be right. Thinking of what you say, the solution is "just" using LET:

*        FOR GROUPS <group_object> OF <object> IN objects
        LET aux_objects = VALUE ty_objects(
            FOR <int> IN ints
            FOR <objectname> IN <int>-objectnames
            ( objectname = <objectname>
              int_ids    = VALUE #( ( <int>-int_id ) ) ) )
        IN
        FOR GROUPS <group_object> OF <object> IN aux_objects

Solved on ABAP 7.52 and 7.57.

Sandra_Rossi
Active Contributor
0 Kudos
2,187

frdric.girod

I'm not French 😉

FredericGirod
Active Contributor
0 Kudos
2,187

You have not working for big company in France ?

Sandra_Rossi
Active Contributor
2,187

I was joking.

Sandra_Rossi
Active Contributor
0 Kudos
2,187

frdric.girod I was joking.