Step 1: Create the RAP Project
In ABAP Development Tools (ADT):
Go to File → New → ABAP Project.
Connect to your system.
Create a new ABAP Package (e.g.,
Z_RAP_BUTTONS).
Create the RAP artifacts:
Business Object (BO):
Right-click the package → New → Other ABAP Repository Object → Business Object → RAP Business Object.
Example:
ZBO_SALESORDER.
Step 2: Define the Behavior (Behavior Definition)
In your Behavior Definition (
.behavior):
define behavior for ZI_SALESORDER
persistent table ZI_SALESORDER
lock master
{
create;
update;
delete;
// Add custom action button
action confirm order result [0..1];
}
Step 3: Implement the Behavior Logic
In Behavior Implementation (
.behavior.abap):
implementation in class zbp_i_salesorder unique;
method confirm_order.
” Your business logic goes here
loop at it_entity into data(ls_entity).
ls_entity-status = ‘CONFIRMED’.
modify table et_entity from ls_entity.
endloop.
endmethod.
endimplementation.
Step 4: Expose Action in Service Definition
Open Service Definition (
.service):
define service ZC_SALESORDER_SRV {
expose ZI_SALESORDER;
// Optionally expose action explicitly
action confirm order;
}
Step 5: Register & Test Service
Go to /IWFND/MAINT_SERVICE → register your RAP service.
Test via SAP Gateway Client (
/IWFND/GW_CLIENT) to see the metadata:You should see your
confirm orderaction exposed.
Step 6: Fiori/UI Integration
If you use Fiori Elements (List Report / Object Page):
The
action confirm orderwill automatically appear as a button in the Object Page or List Report.No extra UI5 code is required if you use standard Fiori Elements.
If you want custom UI5, you can bind a button like this:
<Button
text=”Confirm Order”
press=”.onConfirmOrder”
/>
And in your controller:
onConfirmOrder: function(oEvent) {
var oModel = this.getView().getModel();
var sPath = oEvent.getSource().getBindingContext().getPath();
oModel.callFunction(“/ConfirmOrder”, {
method: “POST”,
urlParameters: {
SalesOrderID: oModel.getProperty(sPath + “/SalesOrderID”)
},
success: function() {
MessageToast.show(“Order Confirmed!”);
},
error: function() {
MessageToast.show(“Error!”);
}
});
}