🎓beginner⏱15 min.SAP BTP ABAP EnvironmentBeginnerABAP DevelopmentSAP Business Technology Platform
You will learn
✔How to define determinations
✔How to implement determinations
✔How to preview and test enhanced travel app In the previous exercise, you’ve defined and implemented the early numbering for assigning automatically an identifier (ID) for a new instance of the BO entity Travel. In the present exercise, you will define and implement a determination, setStatusToOpen, which will be used to set a default value for the overall status of a Travel entity instance. You will use the Entity Manipulation Language (EML) to implement the transactional behavior of the Travel business object.
You need to have access to an SAP BTP, ABAP environment, or SAP S/4HANA Cloud, ABAP environment or SAP S/4HANA (release 2022 or higher) system.
For example, you can create free trial user on SAP BTP, ABAP environment.
Make sure, your system has the ABAP flight reference scenario. If your system hasn’t this scenario. You can download it here. The trial systems have the flight scenario included.
Reminder: Do not forget to replace the suffix placeholder ### with your chosen or assigned group ID in the exercise steps below.
About: Determinations
A determination is an optional part of the business object behavior that modifies instances of business objects based on trigger conditions. A determination is implicitly invoked by the RAP framework if the trigger condition of the determination is fulfilled. Trigger conditions can be modify operations and modified fields.
The Entity Manipulation Language (EML) is an extension of the ABAP language which offers an API-based access to RAP business objects. EML is used to implement the transactional behavior of RAP business objects and also access existing RAP business objects from outside the RAP context.
PS: Some EML statements can be used in the so-called local mode - by using the addition IN LOCAL MODE - to exclude feature controls and authorization checks. This addition can currently only be used in RAP business object implementations for the particular RAP business object itself, i. e. not for other RAP business objects.
The EML reference documentation is provided in the ABAP Keyword Documentation. You can use the classic F1 Help to get detailed information on each statement by pressing F1 in the ABAP editors.
Define the determination setStatusToOpen in the behavior definition of the Travel entity. This determination will be used to set the default value of the field OverallStatus to open (O) at the creation time new Travel instances.
Go to the behavior definition of the Travel BO entitybdef iconZRAP100_R_TravelTP_### and insert the following statement after the statement delete; as shown on the screenshot below:
Add following code:
ABAP
determinationsetStatusToOpenonmodify{create;}
Travel BO Definition
Short explanation: The statement specifies the name of the new determination, setStatusToOpen and on modify as the determination time when creating new travel instance ({ create }).
Now, declare the required method in behavior implementation class with ADT Quick Fix.
Set the cursor on the determination name setStatusToOpen and press Ctrl+1 to open the Quick Assist view and select the entry Add method for determination setStatusToOpen of entity zrap100_i_travel_### in the view.
As result, the FOR DETERMINE method setStatusToOpen will be added to the local handler class lcl_travel of the behavior pool of the Travel BO entityclass iconZRAP100_BP_TRAVEL_###.
You are through with the definition of the determination.
Step 2Implement determination setStatusToOpen
+
You will now implement the logic of the defined determination in the behavior pool.
First check the interface of the method setStatusToOpen in the declaration part of the local handler class lcl_travel.
For that, set the cursor on the method name, setStatusToOpen, press F2 to open the ABAP Element Info view, and examine the full method interface.
Travel BO Behavior Pool
Short explanation:
The addition FOR DETERMINE indicates that the method provides the implementation of a determination and the addition ON MODIFY indicates the specified trigger time.
IMPORTING parameter keys - an internal table containing the keys of the instances the determination will be executed on
includes all entities for which keys must be assigned
Implicit CHANGING parameter reported - used to return messages in case of failure
Now go ahead and implement the method in the implementation part of the local handler class.
Define the local constant travel_status to store the allowed value of the overall status of a Travel instance. Insert the following code snippet in the definition part of the local handler class lcl_travel as shown on the screenshot below.
ABAP
CONSTANTS:BEGIN OFtravel_status,openTYPE cLENGTH1VALUE'O',"Open
acceptedTYPE cLENGTH1VALUE'A',"Accepted
rejectedTYPE cLENGTH1VALUE'X',"Rejected
END OFtravel_status.
Travel BO Behavior Pool
Now implement the method setStatusToOpen in the implementation part of the class.
The logic consists of the following steps:
Read the travel instance(s) of the transferred keys (keys) using the EML statement READ ENTITIES
The addition IN LOCAL MODE is used to exclude feature controls and authorization checks
Removed all Travel instances where the overall status is already set
Set the overall status to open(O) for the remaining entries using the EML statement MODIFY ENTITIES
Set the changing parameter reported
Insert the following code snippet in the method and replace all occurrences of the placeholder ### with your group ID. You can use the F1 help to get detailed information on each EML statement.
ABAP
"Read travel instances of the transferred keys
READENTITIESOFZRAP100_R_TravelTP_###INLOCALMODEENTITYTravelFIELDS(OverallStatus)WITHCORRESPONDING#(keys)RESULT DATA(travels)FAILEDDATA(read_failed)."If overall travel status is already set, do nothing, i.e. remove such instances
DELETEtravelsWHEREOverallStatusIS NOT INITIAL.CHECKtravelsIS NOT INITIAL."else set overall travel status to open ('O')
MODIFYENTITIESOFZRAP100_R_TravelTP_###INLOCALMODEENTITYTravelUPDATESETFIELDSWITHVALUE#(FORtravelINtravels(%tky=travel-%tkyOverallStatus=travel_status-open))REPORTEDDATA(update_reported)."Set the changing parameter
reported=CORRESPONDING#(DEEPupdate_reported).
You can now preview and test the changes by creating a new travel instance in the Travel app.
Refresh your application in the browser using F5 if the browser is still open, or go to your service binding ZRAP100_UI_TRAVEL_O4_### and start the Fiori elements App preview for the Travel entity set.
Create a new Travel instance. The overall status should now be set automatically by the logic you just implemented. The initial overall status of the created should now be set to open(O).
Share feedback on this tutorial or join the conversation in SAP Community.
Submit detailed feedbackDiscuss in Community
Steps
Step 1 of 4
1. Define determination setStatusToOpen2. Implement determination setStatusToOpen3. Preview and test enhanced travel app4. Test yourself
Joule
AI Notice
Joule is an AI assistant. Generative AI may produce inaccurate, incomplete, or biased information. Always verify important details before acting on them.
Conversations are sent to SAP-hosted large language models for processing. Do not include personal data, credentials, or confidential information in your messages.
Joule's responses are based on the SAP tutorial catalog and may not reflect the latest product changes. For authoritative guidance, consult the linked tutorials and official SAP documentation.