Ansicht
Dokumentation

ABAPMODIFY_ENTITY_ENTITIES_FIELDS - MODIFY ENTITY ENTITIES FIELDS

ABAPMODIFY_ENTITY_ENTITIES_FIELDS - MODIFY ENTITY ENTITIES FIELDS

SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   ABAP Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

MODIFY ENTITY, ENTITIES, field_spec

...  ${ 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 $} ...


Variants:

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

Addition:

... AUTO FILL CID

Effect

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.

Notes

  • In case of operations for which %cid_ref can be specified in the internal table, the mandatory specification of the keys in the internal table can be omitted if a clear reference to the instance that is to be modified is given using %cid_ref.
  • In case of create and create-by-association operations, %cid should be specified even if the RAP BO consumer is not interested in %cid.

Variant 1

... FROM fields_tab


Effect

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.

  • Due to the explicit filling of the %control structure, more lines of code are necessary compared to the variants FIELDS (...) WITH and SET FIELDS WITH.
  • A syntax check on static read-only fields is not possible with this variant (in contrast to FIELDS (...) WITH).
  • Fields can be set to initial values.

Example

The following source code section taken from DEMO_RAP_EML_MODIFY_OPERATIONS demonstrates the keyword FROM within a MODIFY statement.

Variant 2

... AUTO FILL CID WITH fields_tab


Effect

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.

Example

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.

Variant 3

... FIELDS ( comp1 comp2 ... ) WITH fields_tab


Effect

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.

  • A syntax check on static read-only fields is possible with this variant when specifying the fields within the brackets of FIELDS (...) WITH.
  • Fields can be set to initial values.

Example

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.

Example

The following source code section taken from DEMO_RAP_EML_MODIFY_OPERATIONS demonstrates the keywords FIELDS (...) WITH within a MODIFY statement.

Variant 4

... $[AUTO FILL CID$] SET FIELDS WITH fields_tab


Effect

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 is very slow for large inputs. Hence, using it leads to a syntax warning that can be removed by the pragma ##SETFIELDS_OK. Note that the syntax warning does not come up if the internal table following SET FIELDS WITH is specified using a constructor expression with the VALUE.
  • A syntax check on static read-only fields is not possible with this variant (in contrast to FIELDS (...) WITH).
  • Fields cannot be set to initial values.

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.

  • A syntax check on static read-only fields is not possible with this variant (in contrast to FIELDS (...) WITH).
  • Fields cannot be set to initial values.

Example

The following source code section taken from DEMO_RAP_EML_MODIFY_OPERATIONS demonstrates the keywords SET FIELDS WITH within an MODIFY statement.

Addition

... AUTO FILL CID

Effect

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.

Example

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.

  • The example MODIFY: Field Specification Expressions demonstrates the variants of field selection when setting up internal tables for different modify statements and hence the manipulation of a simple managed RAP BO.
  • The program DEMO_RAP_EML_AUTO_FILL_CID demonstrates create and create-by-association operations with manually specified %cid components and automatically created ones using AUTO FILL CID. The output shows the MAPPED responses of the operations as well as the instances that are persisted to the database following COMMIT ENTITIES statements.





rdisp/max_wprun_time - Maximum work process run time   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.

Length: 18121 Date: 20240425 Time: 025855     sap01-206 ( 250 ms )