My scenario is that I am getting an IDOC segment's data into a field symbol and change some fields based on some validations.
My code:
READ TABLE idoc_data ASSIGNING FIELD-SYMBOL(<idocdata>) with key = 'E1EDK01'
IF sy-subrc = 0.
lcl_struc ?= cl_abap_typedescr=>describe_by_name( 'E1EDK01' ).
CREATE DATA dref TYPE HANDLE lcl_struc.
ASSIGN dref->* TO FIELD-SYMBOL(<sdata>).
IF <sdata> IS ASSIGNED.
<sdata> = <idocdata>-sdata.
....
<idocdata>-sdata = <sdata>.
ENDIF.
ENDIF.
Though the above snippet works fine, the continuity of field symbols is broken and now I have to pass back the changed data. How do I use ASSIGN and let the field symbols take care of the changes rather than an explicit statement?
Something similar to below snippet though this won't work since <IDOC_DATA>-SDATA and <SDATA> aren't compatible.
READ TABLE idoc_data ASSIGNING FIELD-SYMBOL(<idocdata>) with key = 'E1EDK01'
IF sy-subrc = 0.
FIELD-SYMBOLS: <sdata> TYPE E1EDK01.
ASSIGN <idocdata>-sdata TO <sdata>.
....
ENDIF.
My expectation is that when I change the data in <SDATA>-FIELD1, I want the changes to flow into <IDOCDATA>-SDATA without using <idocdata>-sdata = <sdata>.
FIELD-SYMBOLS <sdata>.). But now you have a field-symbol without a type which might cause other typing problems down the line. Depending on what"Logic goes heremeans, this might or might not be a problem which can or can't be easily solved. - Philipp<IDOCDATA>-SDATA" and "<SDATA>" have incompatible types. It just needs CASTING:ASSIGN <idocdata>-sdata TO <sdata> CASTING.- Sandra RossiCAST. Is there anything I should be careful of usingCASTin this scenario? - Ravi Rishie