0% found this document useful (0 votes)
179 views7 pages

Sap Rap Action

The document outlines the process of creating and using actions in Business Object (BO) modifications without standard CRUD operations. It details the steps for defining actions, implementing them in ABAP, and differentiates between factory and non-factory actions, including their respective use cases. Additionally, it explains save actions that are triggered during the save sequence for specific functionalities.

Uploaded by

muchau91
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
179 views7 pages

Sap Rap Action

The document outlines the process of creating and using actions in Business Object (BO) modifications without standard CRUD operations. It details the steps for defining actions, implementing them in ABAP, and differentiates between factory and non-factory actions, including their respective use cases. Additionally, it explains save actions that are triggered during the save sequence for specific functionalities.

Uploaded by

muchau91
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Mohammad Khalid Khan

RAP: ACTION
Action:
Actions are used to modify the BO without calling the standard operations (CRUD buttons).

Trigger points:

 Trigger via ui: In order to trigger the action via ui button.

Syntax:

 Trigger internally via eml: in order to trigger internally, like inside determination via eml.

Syntax: execute action_name

Over view of factory vs non factory action:


Steps to create action:

1. Define action in BDEF interface.

2. Implement the action method in abap behaviour pool.

3. Add the trigger point via EML or ui annotaion.

4. Expose the action to ui, using “use action” in BDEF projection.


1. Non-factory action:

Used to modify the existing Bo
By default, instance action. Need to explicitly provide static, for static action.
Instance non-factory action is used to modify the selected BO.
Static non-factory action has access to modify any Bo, bound to the entire entity.
Syntax:

1.1. Instance non-factory action:

Requirement:Toupdatethecountrycodebasedontheuserinput.

To achieve it, I have declared instance non-factory action with abstract entity as parameter, which
provides the country code from user. Since, it's an instance action, we would get the corresponding
keys of the selected BO(9e12812e-cf28-1fe0-81f6-be9f3d6f527b). We need to modify country
code(land1) via EML for the selected BO, with the input parameter from user. Additionally, it is
required to populate the result-derived type.
Action defined in BDEF:
Abstract entity for input parameter:

Action method in abp:

Note:

 Declaredresultasself,astheparameterresulthasthesametypeastheentityforwhichthe
action is executed.
 Youcanusedeepparameter(onlyodatav4),ifyouwanttomodifybothparentandchildentity.
 Resultparameterisoptional,butifyouhavedeclaredinBDEFinterface,itsmandatorytopass
result in action method, else in ui, you will get blank value.

1.2. Static non-factory action:


Requirement: To update Bo’s whose country code is IN to GE.

To achieve this, we can use a static non-factory action. First, we need to fetch details from the
persistence table for the BOs that have the country code set to 'IN'. To modify the country, use the
modify EML within a loop (use 'for' or 'loop at’) to modify all the BOs that satisfy the condition.
Action defined in BDEF:

Action method in abp:

2. Factory action:

Used to create a new Bo
Bound to the entire BO inside an entity
Instance factory action/copy action: Used to copy the existing Bo and replicate new Bo.
Static factory action: used to create BO with some default value.
Syntax:
2.1. Instance factory action(Copy action):
Requirement: To create vendor (BO) based on the selected vendor.

To achieve this, we can use an instance factory action. Fetch the data from the TX buffer to be
copied using the read EML statement, and create a new BO with a new key, while copying the
remaining fields from the reference BO. Since it’s a create operation, always pass %cid in the
mapped derived type.

Action defined in BDEF:

Action method in abp:


2.2. Static factory action:
Requirement:Tocreateavendor(BO)withdefaultvalue(country=INandname=Arunagirish)

To achieve this, we can use the modify EML with default values and pass %cid in the mapped
parameter, as shown below:

Action defined in BDEF:

Action method in abp:

3. Saveaction

 Save actions are triggered only in save sequence(finalize, adjust number).
A save(finalize) action can be called from the implementation of a RAP determination on save.
Even though its implemented in handler class, we cannot call it in interactive phase.

Use case:
Save action is used in situations where you require to achieve certain functionality without modify a
transactional buffer.

You might also like