2020 Dec 15 3:11 PM
I have a simple ASSIGN statement as shown below..issue I am facing is SY-SUBRC is not set..it retains its previous value eventhough field symbol is successfully assigned. Any thoughts? Is it because am assigning a deep/nested structure?
FIELD-SYMBOLS: <lf_deep_str> TYPE t_deep_structure.
ASSIGN deep_strucutre TO <lf_deep_str>.
IF sy-subrc = 0.
..........
ENDIF
2020 Dec 15 3:33 PM
Hello antony.paul2
Look at ASSIGN keyword documentation on SAP Help. It explains:
The return value is set only for the dynamic variants and the table expression variant of mem_area. Your case is a static variant of mem_area.
Therefore sy-subrc is not set.
Honestly I find this logic convoluted and I wouldn't rely on that. I'd rather put UNASSIGN before ASSIGN and then check if assignment is successful with IS ASSIGNED expression:
FIELD-SYMBOLS: <lf_deep_str> TYPE t_deep_structure.
UNASSIGN <lf_deep_str>.
ASSIGN deep_strucutre TO <lf_deep_str>.
IF <lf_deep_str> IS ASSIGNED.
..........
ENDIF.<br>
That seems safer and more readable to me.
Best regards
Dominik Tylczynski
2020 Dec 15 3:33 PM
Hello antony.paul2
Look at ASSIGN keyword documentation on SAP Help. It explains:
The return value is set only for the dynamic variants and the table expression variant of mem_area. Your case is a static variant of mem_area.
Therefore sy-subrc is not set.
Honestly I find this logic convoluted and I wouldn't rely on that. I'd rather put UNASSIGN before ASSIGN and then check if assignment is successful with IS ASSIGNED expression:
FIELD-SYMBOLS: <lf_deep_str> TYPE t_deep_structure.
UNASSIGN <lf_deep_str>.
ASSIGN deep_strucutre TO <lf_deep_str>.
IF <lf_deep_str> IS ASSIGNED.
..........
ENDIF.<br>
That seems safer and more readable to me.
Best regards
Dominik Tylczynski
2020 Dec 15 3:46 PM