The below code gives a syntax error.
DATA: lt_vbeln TYPE TABLE OF vbeln.
SELECT * FROM EDID4 INTO TABLE @DATA(lt_edid4).
lt_vbeln = value #( for ls_edid4 in lt_edid4 ( conv E1NTHDR( ls_edid4-sdata )-vbeln ).
Table EDID4
contains field SDATA
of type LCHR
(char
, length 1000).
I want to convert it into structure E1NTHDR
and immediately read its VBELN
property.
How to do this inline ?
EDIT: The system has SAP_ABA 75G SP 0003.
You may use this code in all versions since ABAP 7.40 SP 5, by defining an auxiliary variable with LET ... IN
:
DATA: lt_vbeln TYPE TABLE OF vbeln.
SELECT * FROM edid4 INTO TABLE @DATA(lt_edid4).
lt_vbeln = VALUE #( FOR ls_edid4 IN lt_edid4
WHERE ( segnam = 'E1NTHDR' )
LET aux_e1nthdr = CONV e1nthdr( ls_edid4-sdata )
IN
( aux_e1nthdr-vbeln ) ).
EDIT: There are new ways of accessing components dynamically in more recent ABAP versions.
In the latest ABAP version, 7.58, there is no better way. Reference in the ABAP documentation:
-
(e.g. in struct-comp
), it's not possible to use something like CONV e1nthdr( xx )-component
.CONV
, but the documentation doesn't add any precision.NEW
and CAST
(nothing allowed for other constructor operators): « Expressions with the operators NEW and CAST can be positioned directly in front of the object component selector -> and can occur in chainings. »LET
: « LET expressions can be used to define local helper fields in all suitable constructor expressions. »