cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger RAP BO Business Event in SAP S/4HANA On Premise 2022 from GUI and FIORI UI (Object EVER)

TillHeinen
Participant
0 Kudos

Hi

I am implementing RAP Business Events in SAP S/4HANA On Premise 2022 using the following blog:

How to Create RAP Business Events in SAP S/4HANA On Premise 2022 | SAP Blogs

To use the ADT function 'Generate ABAP Repository Object I appendend the admin fields to the table EVER (Contract ISU)

local_last_changed type ABP_LOCINST_LASTCHANGE_TSTMPL
last_changed type ABP_LASTCHANGE_TSTMPL

After creating the BO Objects I implemented the Event ContrachtChanged for the Behaviour definition (managed with additonals save). Then I implemented the logic in the 'save modified' method. I have already done outbound bindings etc so that an event is triggered and received from Event Mesh.

When I change a contract from the Fiori its working fine, an event is triggered and Lastchanged is filled.

When I do so from Backend ES21, the Lastchanged is not filled (as ists not standard) and also no event is triggered.

If I got the logic right, whenever EVER is touched, the entry will also be ‚copied‘ with the mapping to ZI_EVER. But the event is triggered from a change in LastChanged (Etag). And than runs into my derived lcl_handler method.


Goal: I’m searching for a consistent way to trigger the event whenever a contract is changed (fiori or gui)

QUESTION: How can my RAP BO Event get triggered from gui eg tcode ES21.

Idea: Can I use another field as trigger eg. AEDAT ( change date)

managed with additional save implementation in class ZBP_I_EVER unique;
strict ( 2 );
with draft;
define behavior for ZI_EVER alias Contract
persistent table ever
draft table ZRAP_EVER_D
etag master LocalLastChanged
lock master total etag LastChanged
authorization master( global )
{
field ( mandatory : create )
Vertrag;
field ( readonly )
LastChanged,
LocalLastChanged;
field ( readonly : update )
Vertrag;

create;
update;
delete;
draft action Edit;
draft action Activate;
draft action Discard;
draft action Resume;
draft determine action Prepare;
event ContractChanged parameter ZEVENT_D_CONTRACT_CHANGED;
mapping for EVER
{
Vertrag = VERTRAG;
Bukrs = BUKRS;
Sparte = SPARTE;
...
Erdat = ERDAT;
Ernam = ERNAM;
Aedat = AEDAT;
Aenam = AENAM;
...
CologrpInst = COLOGRP_INST;
LastChanged = LAST_CHANGED;
LocalLastChanged = LOCAL_LAST_CHANGED;
.....
}
}

Thank you

Till

TillHeinen
Participant
0 Kudos

andre.fischer I read a lot of blogs about that topic, written by you. Maybe you can have a look. I would be thankful. Best wishes Till 🙂

Accepted Solutions (0)

Answers (1)

Answers (1)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Hi Till,

thank you very much for your interest in my blogs.

Looking at your implementation I first have to comment that it is not a good practise to write directly to tables delivered by SAP. Though I am not an application expert I assume that this can lead to inconsitencies. So you would have to check whether there are any released API's available that would allow you to write data finally into tabel EVER.

Having said that the second problem you mentioned can be explained as follows. The event that you have configured is raised when the implementation of your RAP business object is called by your Fiori app, or the preview.

When you update the data via the SAP standard transactions the RAP business object is not notified about these changes.

I would recommend the following.

1. Change the implementation of your RAP BO such that the data is stored into EVER using a released API using an unmanaged SAVE or as an additional SAVE. If you choose the latter you would have to implement the API call in the addtional save.

2. Check if there are means in the SAP standard that would allow to raise the event via EML if data is changed via SAP standard transactions, e.g. there might be a suitable BADI for that.

Kind regards,

Andre