Get Example source ABAP code based on a different SAP table
• FROM READ ENTITY • FROM READ ENTITIES • FIELDS, WITH READ ENTITY • FIELDS, WITH READ ENTITIES • ALL FIELDS WITH READ ENTITY • ALL FIELDS WITH READ ENTITIES
READ ENTITY>, ENTITIES>, field_spec>
ABAP_SYNTAX ... ${ FROM fields_tab> $} $| ${ FIELDS ( comp1 comp2 ... ) WITH fields_tab> $} $| ${ ALL FIELDS WITH fields_tab> $} ... >
ABAP_VARIANTS: 1 ... FROM fields_tab ...> 2 ... FIELDS ( comp1 comp2 ... ) WITH fields_tab ...> 3 ... ALL FIELDS WITH fields_tab ...>
What does it do? The field specification expressions are used to specify input parameters on whose basis read operations can be performed for on RAP BO instances>. All variants can be used for direct read> and read-by-association operations>. The variant FROM > is the only option for read operations executing functions (using the keyword EXECUTE>) in most cases. The parameters that are taken into account for read operations must be specified in an internal table (fields_tab >>). It is essential that the internal table is typed with the required BDEF derived type>. Depending on the operation and the variant, the parameters of the internal table comprise special components >. The following table provides an overview on the operations, which field specification expressions are possible for the operations, and which type and components of the required internal table are relevant: Operation>Field Specification Expression>Type of Internal Tablefields_tab>>Components of Internal Table> Direct read operation (for example, READ ENTITY bdef FROM>) FROM> lbr FIELDS (...) WITH> lbr ALL FIELDS WITH> TYPE TABLE FOR READ IMPORT bdef> %control> lbr %key > lbr %pky> lbr %tky> Read-by-association operation (... BY _assoc ...>) FROM> lbr FIELDS (...) WITH> lbr ALL FIELDS WITH > TYPE TABLE FOR READ IMPORT bdef _assoc> %control> lbr %key> lbr %pky> lbr %tky> Read operation executing a function (using the keyword EXECUTE>) FROM > TYPE TABLE FOR FUNCTION IMPORT bdef~function> %key> lbr %pky> lbr %tky> bdef> is the root entity name, _assoc> the name of the association defined in the underlying CDS view of the root entity, and function> the name of a function specified in the BDEF. See the details on the components in the documentation for Components of BDEF Derived Types>.
Latest notes:
The read statement must be completed by specifying a result> after fields_tab>. Optionally, response_param>> can also be specified after fields_tab>.
Depending on the context, the components listed in the Components> column of the overview table might cover more than mentioned there. For example, the draft indicator %is_draft> is available in case of drafts only. %pid> is only available in late numbering scenarios.
In the internal table (fields_tab>), all key fields must be specified, otherwise the read operation fails. In read-by-association operations, all key fields of an associated entity are returned by default.
The additions FIELDS ( ... ) WITH> and SET FIELDS WITH>> are only possible for read operations executing functions (using EXECUTE>) if the function is defined with ABAP Alternative 2@2@>deep $[table$] parameter>> and without a selective>> parameter in the BDEF. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_1 ... FROM fields_tab ...>
What does it do? The read operation considers input parameters specified in an internal table (fields_tab>>). It can be used for all operations. The %control>> structure must be filled explicitly in fields_tab >.
ABAP_EXAMPLE_VX5 The following source code section taken from CL_DEMO_RAP_EML_READ_OP_FIELDS>> shows the use of FROM> with a READ> operation. The %control> structure shows that some fields are requested, some are not. ABEXA 01514 ABAP_EXAMPLE_END
What does it do? Fields to be returned by the read operation are specified in a field list in brackets after the keyword FIELDS>. The input parameters for the read operation are specified in an internal table ( fields_tab>>). The fields ( comp1>, comp2>, etc.) can be any of the entity's fields. Key fields can but need not be explicitly specified since they are read and returned by default even if not specified. At least one field must be specified in the field list. The fields are not separated by a comma. The order of the fields is irrelevant. However, the order of the columns, for example, of the read result table corresponds to the order in the database table. The variant is a convenience variant and shortcut for FROM>. %control> is filled implicitly in fields_tab>.
ABAP_EXAMPLE_VX5 The following source code section taken from CL_DEMO_RAP_EML_READ_OP_FIELDS>> shows the use of FIELDS ... WITH> with a read-by-association operation. ABEXA 01515 ABAP_EXAMPLE_END