Introduction
In the ABAP RESTful Application Programming Model (RAP), there’s a method to create screens that allow simultaneous editing of multiple rows. Such applications are commonly used to maintain custom master data. This approach is detailed in the following SAP Help documentation:
Developing Transactional Apps with Multi-Inline-Edit Capabilities
How Multiline Editing is Achieved
In a List Report, the table isn’t directly editable; instead, you must navigate to the Object Page to edit the table. To enable multiline editing, you need to create a business object with a parent-child relationship, where the child entity is the one being edited. Since only one parent is needed, it’s created as a “singleton.” Specifically, you retrieve any data source with conditions that always result in a single record and add the most recent update timestamp of the child entity as an ETag field. In the example below, data is fetched from the I_Language view using the login language as the key.
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: ‘Carrier Singleton Root View’
define root view entity /DMO/I_CarriersLockSingleton_S
as select from I_Language
left outer join /dmo/carrier as carr on 0 = 0
composition [0..*] of /DMO/I_Carrier_S as _Airline
{
key 1 as CarrierSingletonID,
max (carr.last_changed_at) as LastChangedAtMax,
_Airline
}
where
I_Language.Language = $session.system_language
The most notable difference from a standard RAP BO is that the parent entity is defined as a singleton and set to read-only. Other than that, you add the child entity and define the behavior as usual.
Default Behavior
When following the documentation, the following steps are required to create a new record:
Select a row from the List Report and navigate to the Object Page.Click the edit button.Press “Create” to add a row.Enter the key in the dialog.Input other fields in the Object Page and press “Apply”.
However, this process involves multiple steps, making it quite different from the user experience of SM30.
Objective of This Blog
Building upon the SAP Help example, this blog aims to achieve the following enhancements:
Enable inline creation of rows.Open the Object Page directly in edit mode, bypassing the List Report.
The first enhancement is achieved through configurations in the Fiori app and the RAP Business Object, while the second is accomplished by setting parameters in SAP Build Work Zone (or target mapping in SAP S/4HANA).
1. Enabling Inline Row Creation
1.1. Set Creation Mode to Inline
To enable inline row creation, select the table from the Page Map and set the Creation Mode to Inline.
However, simply setting it to Inline can result in errors when clicking the “Create” button due to mandatory key fields being empty.
This occurs because the table’s key is an input field and is set as “mandatory: create” in the Behavior Definition:
field ( mandatory : create, readonly : update ) AirlineID;
If marked only as mandatory (not mandatory: create), a draft with a blank key is registered, leading to duplication errors on subsequent entries.
1.2. Use UUID as the Key
To prevent errors, the key should be auto-generated. The following example is not from the SAP Help document, but illustrates a case where the business key (division_code) is user-input, while a technical key using UUID is auto-generated.
@EndUserText.label : ‘Division Code Master’
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zyasu_division {
key client : abap.clnt not null;
key uuid : sysuuid_x16 not null;
division_code : abap.char(2) not null;
name : text100;
local_created_by : abp_creation_user;
local_created_at : abp_creation_tstmpl;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
last_changed_at : abp_lastchange_tstmpl;
}
1.3. Auto-Generate UUID and Set Business Key as Mandatory
In the Behavior Definition, set the UUID to numbering: managed and mark the business key as mandatory:
field ( numbering: managed, readonly ) ID;
field ( mandatory ) DivisionCode;
This ensures that the business key is marked as mandatory, indicated by an asterisk.
1.4. Optional: Validation and Feature Control
Optionally, you can add the following logic:
Validation: Trigger an error if mandatory fields are empty upon saving.Feature Control: Make the business key editable only during creation.
2. Opening Object Page Directly in Edit Mode
To open the Object Page directly in without navigating through the List Report, pass the key of the parent entity as a URL parameter when launching the application. Additionally, by specifying preferredMode=edit, the Object Page will open in edit mode.
For example:#?DivisionSingletonID=1&preferredMode=edit
Please refer to the SAPUI5 SDK for details.
The method for achieving this is the same whether you are using SAP Build Work Zone or SAP S/4HANA. However, this section focuses on the procedure for SAP Build Work Zone.
2.1. Configuring Navigation in SAP Build Work Zone
In SAP Build Work Zone, standard edition, you can set these parameters in the “Visualization” tab of the application. Since the parent entity always has a single record, you can set a fixed key.
Navigate to the application’s “Visualization” tab.In the parameters section, set the key of the parent entity and preferredMode=edit.
With this configuration, clicking the tile will open the Object Page directly in edit mode.
Conclusion
With this setup, we have successfully created a table update screen similar to SM30.
Additionally, in BTP ABAP Environment and S/4HANA Cloud Public Edition, there is a similar feature called Business Configuration Maintenance Object, which can also be used for this purpose.
IntroductionIn the ABAP RESTful Application Programming Model (RAP), there’s a method to create screens that allow simultaneous editing of multiple rows. Such applications are commonly used to maintain custom master data. This approach is detailed in the following SAP Help documentation:Developing Transactional Apps with Multi-Inline-Edit CapabilitiesHow Multiline Editing is AchievedIn a List Report, the table isn’t directly editable; instead, you must navigate to the Object Page to edit the table. To enable multiline editing, you need to create a business object with a parent-child relationship, where the child entity is the one being edited. Since only one parent is needed, it’s created as a “singleton.” Specifically, you retrieve any data source with conditions that always result in a single record and add the most recent update timestamp of the child entity as an ETag field. In the example below, data is fetched from the I_Language view using the login language as the key. @AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: ‘Carrier Singleton Root View’
define root view entity /DMO/I_CarriersLockSingleton_S
as select from I_Language
left outer join /dmo/carrier as carr on 0 = 0
composition [0..*] of /DMO/I_Carrier_S as _Airline
{
key 1 as CarrierSingletonID,
max (carr.last_changed_at) as LastChangedAtMax,
_Airline
}
where
I_Language.Language = $session.system_language The most notable difference from a standard RAP BO is that the parent entity is defined as a singleton and set to read-only. Other than that, you add the child entity and define the behavior as usual.Default BehaviorWhen following the documentation, the following steps are required to create a new record:Select a row from the List Report and navigate to the Object Page.Click the edit button.Press “Create” to add a row.Enter the key in the dialog.Input other fields in the Object Page and press “Apply”.However, this process involves multiple steps, making it quite different from the user experience of SM30.Objective of This BlogBuilding upon the SAP Help example, this blog aims to achieve the following enhancements:Enable inline creation of rows.Open the Object Page directly in edit mode, bypassing the List Report.The first enhancement is achieved through configurations in the Fiori app and the RAP Business Object, while the second is accomplished by setting parameters in SAP Build Work Zone (or target mapping in SAP S/4HANA).1. Enabling Inline Row Creation1.1. Set Creation Mode to InlineTo enable inline row creation, select the table from the Page Map and set the Creation Mode to Inline.However, simply setting it to Inline can result in errors when clicking the “Create” button due to mandatory key fields being empty.This occurs because the table’s key is an input field and is set as “mandatory: create” in the Behavior Definition: field ( mandatory : create, readonly : update ) AirlineID; If marked only as mandatory (not mandatory: create), a draft with a blank key is registered, leading to duplication errors on subsequent entries.1.2. Use UUID as the KeyTo prevent errors, the key should be auto-generated. The following example is not from the SAP Help document, but illustrates a case where the business key (division_code) is user-input, while a technical key using UUID is auto-generated. @EndUserText.label : ‘Division Code Master’
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zyasu_division {
key client : abap.clnt not null;
key uuid : sysuuid_x16 not null;
division_code : abap.char(2) not null;
name : text100;
local_created_by : abp_creation_user;
local_created_at : abp_creation_tstmpl;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
last_changed_at : abp_lastchange_tstmpl;
} 1.3. Auto-Generate UUID and Set Business Key as MandatoryIn the Behavior Definition, set the UUID to numbering: managed and mark the business key as mandatory: field ( numbering: managed, readonly ) ID;
field ( mandatory ) DivisionCode; This ensures that the business key is marked as mandatory, indicated by an asterisk.1.4. Optional: Validation and Feature ControlOptionally, you can add the following logic:Validation: Trigger an error if mandatory fields are empty upon saving.Feature Control: Make the business key editable only during creation.2. Opening Object Page Directly in Edit ModeTo open the Object Page directly in without navigating through the List Report, pass the key of the parent entity as a URL parameter when launching the application. Additionally, by specifying preferredMode=edit, the Object Page will open in edit mode.For example:#?DivisionSingletonID=1&preferredMode=editPlease refer to the SAPUI5 SDK for details.The method for achieving this is the same whether you are using SAP Build Work Zone or SAP S/4HANA. However, this section focuses on the procedure for SAP Build Work Zone.2.1. Configuring Navigation in SAP Build Work ZoneIn SAP Build Work Zone, standard edition, you can set these parameters in the “Visualization” tab of the application. Since the parent entity always has a single record, you can set a fixed key.Navigate to the application’s “Visualization” tab.In the parameters section, set the key of the parent entity and preferredMode=edit.With this configuration, clicking the tile will open the Object Page directly in edit mode.ConclusionWith this setup, we have successfully created a table update screen similar to SM30.Additionally, in BTP ABAP Environment and S/4HANA Cloud Public Edition, there is a similar feature called Business Configuration Maintenance Object, which can also be used for this purpose. Read More Technology Blogs by Members articles
#SAP
#SAPTechnologyblog