2023 Aug 13 1:12 PM
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):
Is it a compiler error or by design? Is it documented? Or any other reason?
Thank you!
Sandra
2023 Aug 15 2:50 PM
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.rossiThanks. 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.
2023 Aug 14 8:00 AM
Hi Sandra,
I have the feeling the problem is VALUE statement.
Like if depending of a constructor expression the memory could not be shared
2023 Aug 14 6:44 PM
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.
2023 Aug 15 6:35 AM
Hi sandra.rossi maybe you should post it as answer
(Hope you will not come as it is the 15th august 😉 )
2023 Aug 15 2:50 PM
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.rossiThanks. 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.
2023 Aug 15 2:51 PM
2023 Aug 15 2:52 PM
2023 Aug 15 3:11 PM
2023 Aug 15 3:12 PM