2023 Jan 02 12:31 PM
Hello there ,
I'm trying to build the internal table from the dynamic table using FOR loop or want to know whether its possible or not
Data in the dynamic table
<gt_data>
Since I became an avid fan of the constructor expressions Value, Cond, etc I tried building this with the new syntax.
I want to assign the above data into new internal table which has fixed structure define using FOR syntax .
GT_TABLE should contain following data from the above dynamic internal table.
P.S -
I'm aware I can use the syntax as
LOOP
ASSIGN 'COMPONENT' OF STRUCTURE .....
But I would like to know whether the same can be achieved with FOR loop or not.
Thanks
Shashank
2023 Jan 04 5:23 PM
Hi,
have you tried class cl_abap_corresponding?
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abencl_abap_corr_itab_abexa.htm
Regards
Thorsten
2023 Jan 02 3:41 PM
It depends which ABAP version you are using. I remember in a blog post by a SAP expert, new expressions like OREF->(COMPNAME) in latest versions, maybe we also have STRUCT-(NAME)...
2023 Jan 04 5:23 PM
Hi,
have you tried class cl_abap_corresponding?
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abencl_abap_corr_itab_abexa.htm
Regards
Thorsten
2023 Jan 05 7:33 AM
2023 Jan 05 7:39 AM
As Lena said, STRUCT-(NAME) can be used only with ASSIGN, but ASSIGN can't be directly used in a constructor expression, it means that you must use the workaround of calling a method equivalent to ASSIGN, which can be one of CL_ABAP_CORRESPONDING methods as Thorsten suggested.