We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!
... ${ FROM fields_tab $}
$| ${ AUTO FILL CID WITH fields_tab $}
$| ${ $[AUTO FILL CID$] FIELDS ( comp1 comp2 ... ) WITH fields_tab $}
$| ${ $[AUTO FILL CID$] SET FIELDS WITH fields_tab $} ...
1. ... FROM fields_tab
2. ... AUTO FILL CID WITH fields_tab
3. ... $[AUTO FILL CID$] FIELDS ( comp1 comp2 ... ) WITH fields_tab
4. ... $[AUTO FILL CID$] SET FIELDS WITH fields_tab
The field specification expressions are used to specify input parameters on whose basis modify operations can be performed on entity instances.
The variants FIELDS (...) WITH and SET FIELDS WITH can be used for the operations CREATE, CREATE BY and UPDATE. The variant FROM is the only option for DELETE and EXECUTE. The variants with AUTO FILL CID can be used for the operations CREATE and CREATE BY.
The parameters that are respected for modify 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 of the operations, which field specification expressions are possible for the operations, and which type and components of the required internal table are relevant. Depending on the context, the components listed in the Components column might cover more than mentioned. For example, the draft indicator %is_draft is available in case of draft scenarios only. %pid is only available in late numbering scenarios.
Operation | Field Specification Expression | Type of Internal Table fields_tab | Components of Internal Table |
CREATE | FROM \lbr AUTO FILL CID WITH \lbr FIELDS (...) WITH \lbr SET FIELDS WITH | TABLE FOR CREATE bdef | %cid \lbr %control \lbr %data \lbr %key \lbr \lbr In case of FROM and AUTO FILL CID WITH, %control must be filled explicitly. |
CREATE BY _assoc | FROM \lbr AUTO FILL CID WITH \lbr FIELDS (...) WITH \lbr SET FIELDS WITH | TABLE FOR CREATE bdef\_assoc | %cid_ref \lbr %key \lbr %pky \lbr %target \lbr %tky \lbr \lbr In case of FROM and AUTO FILL CID WITH, %control must be filled explicitly within %target. |
UPDATE | FROM \lbr FIELDS (...) WITH \lbr SET FIELDS WITH | TABLE FOR UPDATE bdef | %cid_ref \lbr %control \lbr %data \lbr %key \lbr %pky \lbr %tky \lbr \lbr In case of FROM, %control must be filled explicitly. |
DELETE | FROM | TABLE FOR DELETE bdef | %cid_ref \lbr %key \lbr %pky \lbr %tky |
EXECUTE | FROM | TABLE FOR ACTION IMPORT bdef~action | %cid_ref \lbr %key \lbr %param \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 action the name of an action specified in the BDEF. See the details on the components in the documentation for Components of BDEF Derived Types.
... FROM fields_tab
The modify operation respects input parameters specified in an internal table (fields_tab). It can be used for all operations (CREATE, CREATE BY, UPDATE, DELETE, EXECUTE) and it is the only option for DELETE and EXECUTE. The %control structure must be filled explicitly in the internal table fields_tab for CREATE, CREATE BY and UPDATE.
The following source code section taken from DEMO_RAP_EML_MODIFY_OPERATIONS demonstrates the keyword FROM within a MODIFY statement.
... AUTO FILL CID WITH fields_tab
It is basically the variant ... FROM fields_tab using the addition AUTO FILL CID. In this
case, the keyword WITH must be used before fields_tab instead of FROM. The %control
structure must be filled explicitly in the internal table fields_tab. The variant can be used for CREATE and CREATE BY. See the details on AUTO FILL CID further down.
The following source code section taken from DEMO_RAP_EML_AUTO_FILL_CID
demonstrates the use of AUTO FILL CID WITH with a create operation as part of an MODIFY statement.
... FIELDS ( comp1 comp2 ... ) WITH fields_tab
Using this variant, you specify the fields that should considered for a RAP BO operation in a field list in parentheses after the keyword FIELDS. For example, you specify the fields of RAP BO instances that should be updated. The input parameters are specified in an internal table (fields_tab). The fields (comp1, comp2, etc.) can be any of the entity's fields. At least one field must be specified in the field list. The fields are not separated by a comma. The order of the fields provided in this list is irrelevant.
The variant is a convenience variant and a shortcut for FROM. It cannot be used for DELETE and EXECUTE. %control is filled implicitly in fields_tab. If a field is specified within the brackets of FIELDS (...) WITH, it is set to 01 in the %control structure. Otherwise, it is set to 00.
The following source code demonstrates the implicit setting of the %control structure component values using FIELDS (...) WITH within MODIFY statements.
First, an internal table typed with a BDEF derived type is created and filled. This table is used to create a RAP BO instance in the context of a RAP create operation. All data fields are specified within the parentheses of the FIELDS (...) WITH addition as part of an MODIFY statement. As a next step, the internal table is filled with other values followed by another MODIFY statement. Here, the fields specified within the parentheses of FIELDS (...) WITH purposely do not include all fields.
The outcome shows the effect of the field specification and the implicit setting of the %control structure. Before the modify request, all values of the input table are 00. For the first modify request in which all fields are specified, all values in the %control structure are set to 01. For the second modify request, only those components in the %control structure are set to 01 that are specified within the parentheses of the FIELDS (...) WITH addition. Consequently, despite specifying values in the input table, these fields have their initial value in the created instance.
The following source code section taken from DEMO_RAP_EML_MODIFY_OPERATIONS
demonstrates the keywords FIELDS (...) WITH within a MODIFY statement.
... $[AUTO FILL CID$] SET FIELDS WITH fields_tab
It is a convenience variant and shortcut for FROM. The modify operation respects input parameters specified in an internal table (fields_tab).
Using this variant is not recommended for the following reasons:
The variant cannot be used for DELETE and EXECUTE. %control is filled implicitly in fields_tab. If a field is specified in fields_tab, it is set to 01 in the %control structure. Otherwise, it is set to 00.
The following source code section taken from DEMO_RAP_EML_MODIFY_OPERATIONS demonstrates the keywords SET FIELDS WITH within an
MODIFY statement.
... AUTO FILL CID
The addition AUTO FILL CID is used for create and create-by-association operations as well as factory actions and static actions to create %cid automatically to ensure that %cid is filled. Specifying %cid should be done even if the RAP BO consumer is not interested. Especially in the context of early numbering and late numbering scenarios, %cid must be specified to avoid issues.
If the addition is specified and %cid is initial, %cid gets automatically filled with dummy values that have the prefix %abap_eml_cid__. This prefix is followed by numbers, for example, %abap_eml_cid__1, %abap_eml_cid__2, and so on. If the addition is specified and %cid is specified manually, too, only the manually specified value for %cid is valid.
If %cid_ref is to be used, %cid must be specified manually since %cid_ref cannot refer to an automatically created value.
The following source code (see more examples here:
DEMO_RAP_EML_AUTO_FILL_CID) demonstrates the use of AUTO FILL CID and FIELDS ( ... ) WITH with a create-by-association operation as part of an
MODIFY statement.
Leave us your contact details and we will call you back. Fields marked with * are mandatory.
We offer holistic SAP solutions from a single source to shape digital change and develop new business areas.
Switzerland
Schaffhausen
Germany
Mannheim, Düsseldorf, Munich
USA
Haverhill
Greece
Thessaloniki