Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

IDOC data split by dynamic structure


In a specific program, I want to split a string (EDID4-SDATA)  with a dynamic structure.

The structure should not be defined with Data instruction. Because  the name of this structure (existing in dictionnary) is save in a table EDID4 field

SEGNAM. This structure can be any IDOC segment.

So my first solution is to declare (with data instruction)  all segments as structure that I use in this program.

And define the string EDID4-SDATA as a field symbol.

I am looking for another solution which avoid to create all segment as structure in data paragraph.

Best regards


Former Member
Former Member replied

Are you aware of RTTI/RTTC classes that can be used to create structure dynamically?

Have a look at below snippet. Once field symbol has the data, you can access specific field using assign component ... of structure statement.

DATA: lo_segment_type       TYPE REF TO cl_abap_structdescr,

      lo_segment_data       TYPE REF TO data,

      ls_edid4              TYPE edid4.

FIELD-SYMBOLS <ls_segment_data> TYPE any.

SELECT SINGLE * FROM edid4 INTO ls_edid4.

IF sy-subrc EQ 0.

  lo_segment_type ?= cl_abap_structdescr=>describe_by_name( ls_edid4-segnam ).

  CREATE DATA lo_segment_data TYPE HANDLE lo_segment_type.

  ASSIGN lo_segment_data->* TO <ls_segment_data>.

  IF <ls_segment_data> IS ASSIGNED.

    <ls_segment_data> = ls_edid4-sdata.





2 View this answer in context
Not what you were looking for? View more on this topic or Ask a question