|
Step |
Description |
Key Activity |
|
1 |
Identify the RAP Behavior |
Search BDEF in ADT (Eclipse) |
|
2 |
Create the Event Handler Class |
ABAP class with Local Types |
|
3 |
Implement the Event Logic |
Local class inheriting cl_abap_behavior_event_handler |
|
4 |
Register the Event in One Connect |
Table ZONTA_OC_EVENTS via SM30 |
|
Step 1: Identify the RAP Behavior Definition Search for the behavior in ADT and confirm it exposes events for your business process |
|
Field |
Value |
|
Object Name Pattern |
*PurchaseOrder* |
|
Property Filter |
type:bdef |
|
Event Name |
Triggers When |
|
Approved |
A purchase order is approved |
|
Changed |
A purchase order is modified |
|
Created |
A new purchase order is created |
|
ItemBlocked |
A line item is blocked |
|
ItemChanged |
A line item is modified |
|
ItemDeleted |
A line item is deleted |
|
ItemUnblocked |
A line item is unblocked |
|
Note If the behavior definition does not expose any events, RAP event-based integration is not available for that business object. Consider using alternative One Connect triggers such as Change Documents or BTE events. |
|
Step 2: Create the Event Handler Class Create an ABAP class bound to the RAP behavior events |
|
Property |
Value |
|
Class Name |
ZONCL_MM_PO_RAPEVENTS_HANDLER |
|
Behavior Reference |
R_PurchaseOrderTP |
|
CLASS zoncl_mm_po_rapevents_handler DEFINITION PUBLIC ABSTRACT FINAL FOR EVENTS OF r_purchaseordertp.
PUBLIC SECTION. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS.
CLASS zoncl_mm_po_rapevents_handler IMPLEMENTATION. ENDCLASS. |
|
Step 3: Implement the Event Logic Define the local event handler class and implement the One Connect data transmission call |
|
Info The alias (e.g., PurchaseOrder) is used in the FOR ENTITY EVENT clause, while the full behavior name (e.g., R_PURCHASEORDERTP) is used for the gc_typeid_bo constant. |
|
*"* use this source file for the definition and implementation of *"* local helper classes, interface definitions and type declarations
CLASS lcl_he_event DEFINITION INHERITING FROM cl_abap_behavior_event_handler. PRIVATE SECTION. METHODS on_created FOR ENTITY EVENT created FOR purchaseorder~created.
METHODS on_change FOR ENTITY EVENT change FOR purchaseorder~changed.
METHODS on_approved FOR ENTITY EVENT approved FOR purchaseorder~Approved.
"Methods to add messages to the business application log METHODS log RETURNING VALUE(log) TYPE REF TO if_xco_cp_bal_log. METHODS add_message IMPORTING log TYPE REF TO if_xco_cp_bal_log message TYPE string.
CONSTANTS: gc_typeid_bo TYPE sibflporb-typeid VALUE 'R_PURCHASEORDERTP', gc_catid_bo TYPE sibflporb-catid VALUE 'CL', gc_event_create TYPE sibfevent VALUE 'CREATE', gc_event_change TYPE sibfevent VALUE 'CHANGE', gc_event_approved TYPE sibfevent VALUE 'APPROVED', gc_event_delete TYPE sibfevent VALUE 'DELETE'.
DATA: go_log TYPE REF TO if_xco_cp_bal_log, go_json_automatic TYPE REF TO zoncl_fetch_data. "zoncl_fetch_data_v2
ENDCLASS. |
|
METHOD on_created. DATA: lt_attr_names TYPE swfdnamtab, ls_sender TYPE sibflporb, lv_event TYPE sibfevent.
" If not configured in One Connect, return IF zoncl_rapevent_factory=>rap_event_entities( gc_typeid_bo ) EQ abap_false. RETURN. ENDIF.
go_log = log( ).
LOOP AT created ASSIGNING FIELD-SYMBOL(<fs_created>). add_message( log = go_log message = |Key: "{ <fs_created>-purchaseorder }" / PO Event CREATED handled RAP EVENT| ).
go_json_automatic = NEW #( ).
ls_sender-typeid = gc_typeid_bo. ls_sender-catid = gc_catid_bo. ls_sender-instid = <fs_created>-purchaseorder. lv_event = gc_event_create.
go_json_automatic->send_event_automatic( is_sender = ls_sender i_event = lv_event ). ENDLOOP. ENDMETHOD. |
|
Tip The constants gc_typeid_bo and gc_event_create map to the values stored in table ZONTA_OC_EVENTS. The factory method zoncl_rapevent_factory=>rap_event_entities checks whether the event is registered before processing, providing a safe guard against unregistered objects. |
|
Step 4: Register the Event in One Connect Add the RAP event to the One Connect events configuration table |
|
Field |
Value |
|
Change doc. Object |
R_PURCHASEREQUISITIONTP |
|
Object Type |
PURCHASE REQUISITION RAP |
|
Important The value in the Change doc. Object field must exactly match the gc_typeid_bo constant defined in your event handler class (e.g., R_PURCHASEORDERTP). A mismatch will cause the factory check to fail and the event will not be processed. |
|
Symptom |
Possible Cause |
Resolution |
|
Event handler not triggered on document save |
Class not properly bound to behavior via FOR EVENTS OF |
Verify the global class definition includes FOR EVENTS OF r_purchaseordertp |
|
Factory check returns abap_false |
Event not registered in ZONTA_OC_EVENTS |
Add the correct entry in SM30 with the exact gc_typeid_bo value |
|
No events visible in BDEF outline |
Business object does not expose RAP events |
Confirm the BO supports events (S/4HANA 2022+); consider Change Documents or BTE as alternatives |
|
Data not arriving in target platform |
Smart Gateway unreachable or RFC destination misconfigured |
Test the RFC destination in SM59; verify the Smart Gateway is running |
|
Alias mismatch in method signature |
Using full BDEF name instead of alias in FOR clause |
Check the BDEF for the alias keyword (e.g., alias PurchaseOrder) and use it in the method declaration |