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: 

Expand a dynamic structure

Former Member
0 Kudos

Hello,

in German we say: "I am on the hose!"


I need your help.


In the CoQC Templates are different count of characteristics.


For Example - CoQC Profile for material XYZ has 10 characteristics and the profile for material ABC has 5 characteristics.


I want to read the characteristics, but not line by line, but by columns.


For example:


In ABAP I have define an structure:

Then each column for the characteristic needs to be added to this structure exactly.


For Example:



I've read that there are field symbols, but I do not understand how you then inserts these fields to the structure.


My definition:



<f> has the correct value. How do I get this value to the structure OUTPUT_CHAR?

Can anyone help me?


I hope you can understand me and my problem. ..


Best Regards,


Ulrike



1 ACCEPTED SOLUTION

nishantbansal91
Active Contributor
0 Kudos

Dear Ulrike,

http://scn.sap.com/docs/DOC-42525

Please reffer the below link

Thanks

Nishant

3 REPLIES 3

nishantbansal91
Active Contributor
0 Kudos

Dear Ulrike,

http://scn.sap.com/docs/DOC-42525

Please reffer the below link

Thanks

Nishant

alisson_fragozo
Explorer
0 Kudos

Hey Ulrike,

see the code below:

REPORT ZTEST.

DATA: go_struct TYPE REF TO cl_abap_structdescr,

       go_table  TYPE REF TO cl_abap_tabledescr,

       gd_dyn    TYPE REF TO data,

       gt_comp   TYPE cl_abap_structdescr=>component_table,

       gs_comp   TYPE cl_abap_structdescr=>component.

FIELD-SYMBOLS: <gs_dyn> TYPE ANY,

                <gt_dyn>  TYPE STANDARD TABLE.

* Character field

gs_comp-name = 'F1'.

gs_comp-type = cl_abap_elemdescr=>get_c( 10 ).

APPEND gs_comp TO gt_comp. CLEAR gs_comp.

* Packed field

gs_comp-name = 'F2'.

gs_comp-type = cl_abap_elemdescr=>get_p( p_length = 10 p_decimals = 2 ).

APPEND gs_comp TO gt_comp. CLEAR gs_comp.

* String field

gs_comp-name = 'F3'.

gs_comp-type = cl_abap_elemdescr=>get_string( ).

APPEND gs_comp TO gt_comp. CLEAR gs_comp.

TRY.

*   Create the dynamic structure

     go_struct = cl_abap_structdescr=>create( gt_comp ).

     CREATE DATA gd_dyn TYPE HANDLE go_struct. "Create dyn. data ref.

     ASSIGN gd_dyn->* TO <gs_dyn>. "Dereference the data ref.

     CLEAR gd_dyn.

*   Create the dyn. table

     go_table = cl_abap_tabledescr=>create( go_struct ).

     CREATE DATA gd_dyn TYPE HANDLE go_table. "Create dyn. data ref.

     ASSIGN gd_dyn->* TO <gt_dyn>. "Dereference the data ref.

   CATCH cx_sy_struct_creation .

   CATCH cx_sy_table_creation .

ENDTRY.

BREAK-POINT.

Former Member
0 Kudos

Thank you - the examples have helped me!


Best Regards,


Ulrike