Ansicht
Dokumentation

ABENBDL_FIELD_CHAR - BDL FIELD CHAR

ABENBDL_FIELD_CHAR - BDL FIELD CHAR

rdisp/max_wprun_time - Maximum work process run time   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

- field characteristics

... field(readonly) Field1, Field2, ...;
       $| (mandatory) Field1, Field2, ...;
       $| (suppress) Field1, Field2, ...;
       $| (features:instance) Field1, Field2, ...;
       $| (mandatory:create) Field1, Field2, ...;
       $| (readonly:update) Field1, Field2, ...;


Variants:

1. ... field(readonly) Field1, Field2, ...

2. ... field(mandatory) Field1, Field2, ...

3. ... field(suppress) Field1, Field2, ...

4. ... field(features:instance) Field1, Field2, ...

5. ... field(mandatory:create) Field1, Field2, ...

6. ... field(readonly:update) Field1, Field2, ...

Effect

This topic lists field attributes for the fields of a RAP BO entity.

Commas can be used to classify multiple fields in the same way. Example: field(readonly) Field1, Field2, Field3;

A field can have multiple characteristics, divided by commas within the brackets. Example: field(mandatory:create, readonly:update) Field1, Field2, Field3;. Certain restrictions apply on the combination of field characteristics. They are indicated by a syntax check warning.

Availability

  • Development guide for the ABAP RESTful Application Programming Model, section Feature Control Definition: Fields

Note

In UI scenarios, field characteristics are displayed as RAP consumer hint.

Variant 1

... field(readonly) Field1, Field2, ...


Effect

  • Defines that the values of the specified fields must not be created or updated by the RAP BO consumer.

Variant 2

... field(mandatory) Field1, Field2, ...


Effect

  • Defines that it is mandatory to enter values into the specified fields before persisting them on the database. These fields are marked as mandatory on the user interface in an OData scenario. However, there's no runtime check for mandatory fields and no runtime error occurs if a mandatory field is not filled. If a runtime check is required, the application developer should implement it using a validation on save.
  • No implementation in the ABAP behavior pool required.

Example

The following example shows a managed BDEF that defines the field char_field1 as mandatory.

The ABAP program DEMO_RAP_MANAGED_MANDATORY uses EML to access to RAP business object. It creates three entity instances by specifying a value for the primary key field key_field. No value is entered for the mandatory field char_field1. It commits the three new entity instances to the database. Using the SELECT statement, it displays the content of the underlying database table.

Code Snippet:

Result: The mandatory field char_field1 contains the initial value, no syntax check warning or syntax check error occurs.

IMAGE @@ABDOC_MANDATORY.png@@353@@104@@



Variant 3

... field(suppress) Field1, Field2, ...


Effect

  • Field(suppress) can be used to remove a field from the BDEF derived types, OData, and all RAP APIs. This is possible for all fields except for key fields, foreign key fields, and fields used by the current BDEF, such as ETag fields.
  • Currency key fields of data type CUKY can be suppressed only if all amount fields that draw a reference to this particular CUKY field are also suppressed.
  • If a RAP BO consumer tries to modify a suppressed field, an error message occurs that tells the consumer that no field of this name exists.

Example

The following example shows an interface BDEF that suppresses the field DataFieldRoot.

The ABAP program DEMO_RAP_INTERFACE_DRAFT creates a variable typed with the BDEF derived type of the RAP BO DEMO_RAP_INTERFACE_DRAFT and displays the structure of this variable.

Code Snippet:

Result: The suppressed field DataFieldRoot is not part of structure.

IMAGE @@field_suppress.png@@375@@268@@



Variant 4

... field(features:instance) Field1, Field2,...


Effect

  • If a RAP BO consumer tries to breach the dynamic access restrictions, it is ignored. There's no error or warning message. In a managed RAP BO, there's also no entry in the response structures. In an unmanaged RAP BO, the reported structure can be filled, depending on the BO implementation.

Example

The following example shows a managed BDEF that defines dynamic feature control for field int_field2.

In the ABAP behavior pool, it specifies the following condition: if field int_field1 contains the value '1', then int_field2 is read-only.

Code snippet:

... %field-int_field2 = COND #(
                        WHEN ls_variable-int_field1 = '1'
                        THEN if_abap_behv=>fc-f-read_only
                        ELSE if_abap_behv=>fc-f-unrestricted
                        ) ) ).

The ABAP program DEMO_RAP_INSTANCE_FEATURES uses EML to access to RAP business object.

  • First, it inserts an entity instance directly onto the database using INSERT. This entity instance has the value '1' for field int_field1. Therefore, it fulfills the condition that triggers feature control: if this instance is updated, field int_field2 should be read-only.
  • An EML UPDATE operation is executed on the same instance. This update operation tries to enter a value into field int_field2.
  • The updated entity instance is committed to the database. Using the SELECT statement, the content of the underlying database table is displayed.

Result: The update operation is prevented by the dynamic feature control. Field int_field2 contains the initial value. No syntax check warning or syntax check error occurs.

IMAGE @@ABDOC_INSTANCE_FEATURES.png@@415@@64@@

ABAP EML - RAP Calculator



Variant 5

... field(mandatory:create) Field1, Field2, ...


Effect

  • No implementation in the ABAP behavior pool required.
  • If a RAP BO consumer tries to create a new entity instance without entering a value into the field defined as mandatory:create, a runtime error occurs.

Note

A typical use case is to combine mandatory:create with readonly:update for key fields (external numbering by RAP BO consumer).

Variant 6

... field(readonly:update) Field1, Field2, ...


Effect

  • Dynamic field attribute that defines a field as read-only during update operations, that means, the field in question cannot be changed anymore after the create operation.
  • No implementation in the ABAP behavior pool required.
  • If a RAP BO consumer tries to update a field defined as readonly:update, a runtime error occurs.






Fill RESBD Structure from EBP Component Structure   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 17046 Date: 20240512 Time: 090656     sap01-206 ( 169 ms )