Businesses often need to track internal or external events that are specific to their industry or driven by internal KPIs to monitor the status of business documents. SAP Business Network Global Track and Trace(BN4L GTT) offers public APIs that support many common, industry-standard event types. Additionally, customers can use the "Other" event type to track events that fall outside predefined event types.
However, when even that is not sufficient, SAP Business Network Global Track and Trace(BN4L GTT) provides a flexible framework to define and integrate custom event, allowing customers to capture and monitor events that are uniquely relevant to their business processes.
In this blog, I will share how easily the customers can create their own custom events via the standard apps available.
Prerequisites:
Overview of Steps:
Detailed Steps:
Step 1: Create and Extend the Custom Event in S/4Hana TM
In this example, I am sending the departure date and time of the source location as the planned timestamp for the custom event. However, you can implement your own logic to calculate the appropriate date and time based on other available fields from the Freight Order, and then include that information in the IDoc accordingly.
Method Declaration and Code Snippet:
methods ZZ_CUSTOMSHIP_EVENT
importing
!IV_TOR_ID type /SCMTMS/TOR_ID optional
!IT_STOP type /SCMTMS/T_EM_BO_TOR_STOP optional
!IT_LOC_ADDR type /BOFU/T_ADDR_POSTAL_ADDRESSK
!IT_STOP_POINTS type ZIF_GTT_STS_EF_TYPES=>TT_STOP_POINTS optional
!IS_APP_OBJECTS type TRXAS_APPOBJ_CTAB_WA
changing
!CT_EXPEVENTDATA type ZIF_GTT_STS_EF_TYPES=>TT_EXPEVENTDATA .
METHOD ZZ_CUSTOMSHIP_EVENT.
DATA: ls_loc_addr TYPE REF TO /bofu/s_addr_postal_addressk,
lt_loc_root TYPE /scmtms/t_bo_loc_root_k.
FIELD-SYMBOLS <ls_root> TYPE /scmtms/s_em_bo_tor_root.
ASSIGN is_app_objects-maintabref->* TO <ls_root>.
IF sy-subrc <> 0.
RETURN.
ENDIF.
LOOP AT it_stop USING KEY parent_seqnum ASSIGNING FIELD-SYMBOL(<ls_stop>) WHERE parent_node_id = <ls_root>-node_id.
CHECK <ls_stop>-stop_cat = /scmtms/if_common_c=>c_stop_category-outbound AND
<ls_stop>-plan_trans_time IS NOT INITIAL.
READ TABLE it_stop_points REFERENCE INTO DATA(ls_stop_points)
WITH KEY log_locid = <ls_stop>-log_locid
seq_num = <ls_stop>-seq_num.
CHECK sy-subrc = 0.
* TEST-SEAM shp_dep_lt_loc_root.
/scmtms/cl_pln_bo_data=>get_loc_data(
EXPORTING
it_key = VALUE #( ( key = <ls_stop>-log_loc_uuid ) )
CHANGING
ct_loc_root = lt_loc_root ).
* END-TEST-SEAM.
READ TABLE lt_loc_root REFERENCE INTO DATA(ls_loc_root)
WITH KEY key COMPONENTS key = <ls_stop>-log_loc_uuid.
CHECK sy-subrc = 0.
DATA(lv_tz) = COND tznzone( WHEN ls_loc_root->time_zone_code IS NOT INITIAL
THEN ls_loc_root->time_zone_code
ELSE sy-zonlo ).
DATA(lv_exp_datetime) = <ls_stop>-plan_trans_time.
zcl_gtt_sts_tools=>convert_utc_timestamp(
EXPORTING
iv_timezone = lv_tz
CHANGING
cv_timestamp = lv_exp_datetime ).
mv_milestonecnt += 1.
APPEND VALUE #(
appsys = mo_ef_parameters->get_appsys( )
appobjtype = mo_ef_parameters->get_app_obj_types( )-aotype
language = sy-langu
appobjid = is_app_objects-appobjid
milestone = zif_gtt_sts_constants=>cs_milestone-fo_cust_event
evt_exp_datetime = |0{ lv_exp_datetime }|
evt_exp_tzone = lv_tz
locid1 = <ls_stop>-log_locid
locid2 = ls_stop_points->stop_id
loctype = zcl_gtt_sts_tools=>get_location_type( iv_locno = <ls_stop>-log_locid ) ) TO ct_expeventdata.
CLEAR: lt_loc_root, ls_loc_root.
ENDLOOP.
ENDMETHOD.
zz_customship_event(
EXPORTING
iv_tor_id = lv_tor_id
it_stop = lt_stop
it_loc_addr = lt_loc_address
it_stop_points = lt_stop_points
is_app_objects = is_app_objects
CHANGING
ct_expeventdata = ct_expeventdata ).
By implementing the above method in the class ZCL_GTT_STS_PE_FO_FILLER, you complete the process of sending the new custom event to BN4L GTT via the IDoc.
Step 2: Configure the Custom Event in BN4L GTT
The first step is to add the custom event in the relevant tracked process. A tracked process in SAP Global Track and Trace (GTT) represents a business process that involves multiple parties and may also include other interrelated processes. It defines a sequence of planned events—referred to as milestones in systems like SAP Event Management—that are expected to occur during process execution. As the process unfolds, GTT captures actual events, which can either be the realization of planned events or unexpected/unplanned occurrences, providing real-time visibility and actionable insights.
A common example of a standard tracked process is a shipment, and this blog will focus primarily on how to enhance and customize event tracking within a shipment tracked process.
In this step, I will configure the newly created event by classifying it as either an Admissible Planned or Admissible Unplanned event for a tracked process. This classification should be based on your specific business requirements.
For this example, I will configure the custom event as a Planned event for the 'Shipment' tracked process.
In this step, we will map the newly created custom event for the Shipment tracked process to the corresponding IDoc segment in the incoming shipment data—either from an external system or from SAP S/4HANA Transportation Management. (Extending the S/4Hana TM extractor code for sending the data for custom events will be covered in another blog)
Since the custom event has been added as an Admissible Planned Event, the planned timestamps will be provided by the source system through the shipment document.
This will complete the configuration required on BN4L GTT to add any custom event and map it to the incoming IDOC from an external system or SAP S/4Hana Transporation Management.
Testing Results:
The new custom event will appear in the Track Shipment app for shipments created after the implementation is completed. Since the event was configured as a Planned Event under the Shipment Tracked Process, it will be visible in the Tracking Timeline of the shipment.
You can also test the setup by manually reporting the event via the same app using the “Report” button, which allows you to simulate and validate the event flow.
In my upcoming blog, I will explain how to recieve the actual event from an external system or a third-party systems using the SAP Business Network Global Track and Trace API's.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
6 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |