In my previous blog, I’ve already introduced how to set up the connection between SAP S/4HANA (on premise) and SAP Business Network Global Track and Trace to replicating transactional data, some customer/partner may want to know for SAP ECC or SAP TM (standalone),is it possible to set up the connection to SAP Business Network Global Track and Trace to replicating transactional data?
The answer is yes. But you need to do extra work to set up the relationship between SAP ECC or SAP TM (standalone) and SAP Business Network Global Track and Trace.
Here are some possible solutions for your reference.
Option 1:
Following the chapter 5. Configuration and Coding Guide – Advanced in guide document to build your own extractor and send out the IDOC to SAP Business Network Global Track and Trace.
Option 2:
Adjust the sample extractor code (Because sample extractor code developed and verified in S/4HANA 1909 SP03 and afterwards, when down port the code to ECC or TM standalone system, you may encounter syntax error) and deploy the code in SAP ECC or SAP TM (standalone), then send out the IDOC to SAP Business Network Global Track and Trace.
In this blog, I will focus on option 2 and provide some ideas to adjust the sample extractor code.
It mainly contains several steps:
1.Download the sample extractor code and implement the code to SAP ECC or SAP TM (standalone)
2.Fix syntax error
3.Configuration for the extractor code
4.For standalone TM, build the relationship between freight unit and inbound/outbound delivery.
1.Download the sample extractor code and implement the code to SAP ECC or SAP TM (standalone)
Here are the packages that we used for our standard sample code:
- zgtt_common: shared by zgtt_mia & zgtt_pof & zgtt_sof
- zgtt_mia: Inbound delivery / Item, Inbound & Outbound shipments
- zgtt_pof: PO / Item
- zgtt_sof: SO / Item, Outbound delivery / Item
- zgtt_sts: Freight Unit / Freight Order
If you want to implement the code to SAP ECC, please install below packages:
- zgtt_common: shared by zgtt_mia & zgtt_pof & zgtt_sof
- zgtt_mia: Inbound delivery / Item, Inbound & Outbound shipments
- zgtt_pof: PO / Item
- zgtt_sof: SO / Item, Outbound delivery / Item
If you want to implement the code to SAP TM (standalone), please install below packages:
- zgtt_sts: Freight Unit / Freight Order
Now we can install the code to our local ERP system, please follow below steps.
Let’s take deploy the code to SAP ECC as an example.
1.1 Download ABAP Code from GitHub
1.1.1 Open the browser and visit the website which stored the simple code.
Link:
https://github.com/SAP-samples/logistics-business-network-gtt-standardapps-samples
First click “Code” button, then select “Download ZIP”, download the source code and save it in your local PC.
1.1.2 Double click the file you’ve downloaded “logistics-business-network-gtt-standardapps-samples-main.zip”.
1.1.3 Then deleted the unnecessary folders.
Now we want to install the code to SAP ECC, so TM relevant folder “zgtt_sts” should be deleted. Meanwhile to accelerate the install progress, the folder “Documents” also can be deleted.
You can delete below folders in the ZIP file.
1) logistics-business-network-gtt-standardapps-samples-main.ziplogistics-business-network-gtt-standardapps-samples-mainlbn-gtt-standard-appDocuments
Once the folder “Documents” was deleted, the file structure should be like below.
2) logistics-business-network-gtt-standardapps-samples-main.ziplogistics-business-network-gtt-standardapps-samples-mainlbn-gtt-standard-appabapzsrczgtt_sts
Once the folder “zgtt_sts” was deleted, the file structure should be like below.
1.2 Install ABAPGit
To install ABAPGit, follow the instructions on Installation | abapGit Docs. Make sure you Install the standalone version in your dev system. When installation is complete, a new report ZABAPGIT_STANDALONE is created.
1.3 Install the ABAP Code from Zip file
1.3.1 Enter T-code SE38 and fill in the report name ZABAPGIT_STANDALONE. Click Execute to run the report.
1.3.2 Click New Offline, then following below steps to install the code to ECC system.
Then select the file “logistics-business-network-gtt-standardapps-samples-main.zip”.
Save the changes to a TR.
Once all the objects imported, active the objects.
2.Fix syntax error
Sample extractor code developed and verified in S/4HANA 1909 SP03 and afterwards, when down port the code to ECC or TM standalone system, you may encounter syntax error, you can fix these errors one by one. Under the menu “Advanced”, there is a “Syntax Check” menu, through this menu, you can easily check the errors for the newly created objects.
3.Configuration for the extractor code
Regarding the extractor configuration, you can refer to chapter 4. ERP Integration Configuration Option 2 (Manual Configuration) in the guide document.
4.For standalone TM, build the relationship between freight unit and inbound/outbound delivery.
4.1 Introduction
When an inbound/outbound delivery is created and saved in the ECC system, and its subsequent freight unit is created in the TM standalone system based on this delivery, then the corresponding inbound/outbound delivery header IDOC, item IDOC and freight unit IDOC are generated simultaneously and sent to the GTT system. The process flow is as follows:
When the freight unit is created or updated, to make sure its relationship with its preceding delivery is updated, a new delivery header and item IDOC needs to be generated and sent to the GTT system. This process is internally referred as “Cross TP process”, and its process flow is as follows:
This chapter aims to support the “cross TP process” between the ECC system and TM standalone system.
4.2 Detailed Instructions
To support the cross TP process, do the following:
4.2.1 Get the relationship between delivery item and freight unit based on the TOR_ITEM table
4.2.2 Generate the delivery header IDOC.
- Prepare the control parameter data for delivery header
- Prepare planned event data for delivery header
- Prepare tracking ID data for delivery header
4.2.3 Send out the delivery header IDOC
4.2.4 Generate delivery item IDOC
- Prepare control parameter data for delivery item
- Prepare planned event data for delivery item
- Prepare tracking ID data for delivery item
4.2.5 Send out the delivery item IDOC
To know how to prepare the data of control parameter, planned event and tracking ID for generating delivery header and delivery item IDOC, see the following chapter.
4.3 Data Preparation for Generating Delivery Header and Delivery Item IDOC
4.3.1. Generate Outbound Delivery Header IDOC
To generate the outbound delivery header IDOC, prepare the data of control parameter, expected event and tracking ID as follows:
Control Parameter
Field | Field Value |
YN_DLV_NO | Fill in delivery number |
YN_DL_FU_RELEVANT | If a delivery has freight unit, fill in the value “X”. Otherwise, leave it blank. |
ACTUAL_BUSINESS_TIMEZONE | Use the function module GET_SYSTEM_TIMEZONE to get the system time zone |
ACTUAL_BUSINESS_DATETIME | Fill in the current timestamp |
ACTUAL_TECHNICAL_TIMEZONE | Use the function module GET_SYSTEM_TIMEZONE to get the system time zone |
ACTUAL_TECHNICAL_DATETIME | Fill in the current timestamp |
REPORTED_BY | Fill in the current system user ID |
Expected Event
Planned Event Code | Description |
GOODS_ISSUE | If a delivery is “Goods Issue” relevant, then add the planned event “Goods Issue” |
ODLV_ITEM_POD | If delivery is “POD” relevant, then add the planned event “Item POD” |
ODLV_IT_COMPLETED | In the TM scenario, add the planned event “delivery item complete” |
ODLV_HD_COMPLETED | In the LE-TRA scenario, add the planned event “Delivery Header Completed” |
ODLV_PLANNED_DLV | Always plan this event |
Tracking ID
Tracking ID Code Set | Tracking ID |
FT1_OUT_DELIVERY | Fill in the delivery number |
4.3.2. Generate Outbound Delivery Item IDOC
To generate the outbound delivery item IDOC, prepare the data of control parameter, expected event and tracking ID as follows:
Control Parameter
Field | Field Value |
YN_DL_DELEVERY | Fill in the delivery number |
YN_DL_DELEVERY_ITEM | Fill in the delivery item number |
YN_DL_FU_LINE_COUNT | Fill in the line number |
YN_DL_FU_NO | Fill in the freight unit number |
YN_DL_FU_ITEM_NO | Fill in the freight unit item number |
YN_DL_FU_QUANTITY | Fill in the quantity of the product |
YN_DL_FU_UNITS | Fill in the unit of measure for quantity |
YN_DL_FU_PRODUCT | Fill in the name of the product |
YN_DL_FU_PRODUCT_DESCR | Fill in the description of the product |
YN_DL_FU_NO_LOGSYS | Fill in the logical system ID in TM standalone system |
E1EHPTID_APPSYS | Fill in the logical system ID in TM standalone system |
E1EHPTID_TRXCOD | Fill in the fixed value “FT1_FREIGHT_UNIT” |
E1EHPTID_TRXID | Fill in the freight unit number |
ACTUAL_BUSINESS_TIMEZONE | Use the function module GET_SYSTEM_TIMEZONE to get the system time zone |
ACTUAL_BUSINESS_DATETIME | Fill in the current timestamp |
ACTUAL_TECHNICAL_TIMEZONE | Use the function module GET_SYSTEM_TIMEZONE to get the system time zone |
ACTUAL_TECHNICAL_DATETIME | Fill in the current timestamp |
REPORTED_BY | Fill in the current system user ID |
Expected Event
Planned Event Code | Description |
PICKING | If the delivery item is “Picking” relevant, then add the planned event “Picking” |
PACKING | If the delivery item is “Packing” relevant, then add the planned event “Packing” |
GOODS_ISSUE | If the delivery item is “Goods Issue” relevant, then add the planned event “Goods Issue” |
ODLV_ITEM_POD | If the delivery item is “POD” relevant, then add the planned event “Item POD” |
FU_COMPLETED | In the TM scenario, add the planned event “Freight Unit Completed” |
ODLV_HD_COMPLETED | In the LE-TRA scenario, add the planned event “Delivery Deader Completed” |
Tracking ID
Tracking ID Code Set | Tracking ID |
FT1_ODLV_ITEM | Fill in the delivery number and the delivery item number |
4.3.3. Generate Inbound Delivery Header IDOC
To generate the inbound delivery header IDOC, prepare the data of control parameter, expected event and tracking ID as follows:
Control Parameter
Field | Field Value |
YN_DLV_NO | Fill in the delivery number |
YN_DL_FU_RELEVANT | If the delivery has freight units, fill in the value “X”. Otherwise, leave it blank. |
ACTUAL_BUSINESS_TIMEZONE | Use function module GET_SYSTEM_TIMEZONE to get the system time zone |
ACTUAL_BUSINESS_DATETIME | Fill in the current timestamp |
ACTUAL_TECHNICAL_TIMEZONE | Use function module GET_SYSTEM_TIMEZONE to get the system time zone |
ACTUAL_TECHNICAL_DATETIME | Fill in the current timestamp |
REPORTED_BY | Fill in the current system user ID |
Expected Event
Planned Event code | Description |
GOODS_RECEIPT | Add the planned event “Goods Receipt” with the event match key (delivery number and delivery item number) |
IDLV_PLANNED_DLV | Always plan this event |
IDLV_IT_COMPLETED | In the TM scenario, add the planned event “Delivery Item Completed”. |
GOODS_RECEIPT | In the LE-TRA scenario, if the delivery is “Goods Receipt” relevant, add the planned event “Goods Receipt” without the event match key. |
Tracking ID
Tracking ID Code Set | Tracking ID |
FT1_IN_DELIVERY | Fill in the delivery number |
4.3.4. Generate Inbound Delivery Item IDOC
To generate the inbound delivery item IDOC, prepare the data of control parameter, expected event and tracking ID as follows:
Control Parameter
Field | Field Value |
YN_DL_DELEVERY | Fill in the delivery number |
YN_DL_DELEVERY_ITEM | Fill in the delivery item number |
YN_DL_FU_LINE_COUNT | Fill in the line number |
YN_DL_FU_NO | Fill in the freight unit number |
YN_DL_FU_ITEM_NO | Fill in the freight unit item number |
YN_DL_FU_QUANTITY | Fill in the quantity of product |
YN_DL_FU_UNITS | Fill in the unit of measure for quantity |
YN_DL_FU_PRODUCT | Fill in the name of the product |
YN_DL_FU_PRODUCT_DESCR | Fill in the description of the product |
YN_DL_FU_NO_LOGSYS | Fill in the logical system ID in TM standalone system |
E1EHPTID_APPSYS | Fill in the logical system ID in TM standalone system |
E1EHPTID_TRXCOD | Fill in the fixed value “FT1_FREIGHT_UNIT” |
E1EHPTID_TRXID | Fill in the freight unit number |
ACTUAL_BUSINESS_TIMEZONE | Use function module GET_SYSTEM_TIMEZONE to get the system time zone |
ACTUAL_BUSINESS_DATETIME | Fill in the current timestamp |
ACTUAL_TECHNICAL_TIMEZONE | Use function module GET_SYSTEM_TIMEZONE to get the system time zone |
ACTUAL_TECHNICAL_DATETIME | Fill in the current timestamp |
REPORTED_BY | Fill in the current system user ID |
Expected Event
Planned Event Code | Description |
PUT_AWAY | If the delivery item is “Put Away” relevant, then add the planned event “Put Away” |
PACKING | If the delivery item is “Packing” relevant, then add the planned event “Packing” |
GOODS_RECEIPT | If the delivery item is “Goods Receipt” relevant, then add the planned event “Goods Receipt” with the event match key (delivery number and delivery item number). |
FU_COMPLETED | In the TM scenario, add the planned event “Freight Unit Completed” |
GOODS_RECEIPT | In the LE-TRA scenario, if delivery item is “Goods Receipt” relevant, add the planned event “Goods Receipt” without the event match key. |
Tracking ID
Tracking ID Code Set | Tracking ID |
FT1_IN_DELIVERY_ITEM | Fill in the delivery number and delivery item number |
4.3.5 Reference
To have a better understanding of the whole cross TP process, you can refer to the logic of the sample codes in the function module ZGTT_CTP_TOR_TO_DL (which located in package ZGTT_SOF), or the sample codes below. You need to change the codes to meet your own business requirements.
Components in structure ZTS_FU_LIST
Component | Component Type | Short Description |
VBELN | VBELN_VL | Delivery |
POSNR | POSNR_VL | Delivery Item |
TOR_ID | /SCMTMS/TOR_ID | Document |
ITEM_ID | /SCMTMS/ITEM_ID | Item |
QUANTITY | MENGE_D | Quantity |
QUANTITYUOM | MEINS | Base Unit of Measure |
PRODUCT | /SCMTMS/PRODUCT_ID | Product |
PRODUCT_DESCR | /SCMTMS/ITEM_DESCRIPTION | Item Description |
Table type ZTS_FU_LIST_T with the row type ZTS_FU_LIST in it.
Code in TM standalone system
*&---------------------------------------------------------------------*
*& Report ZTEST_CTP_FU_NEW
*&---------------------------------------------------------------------*
*& Send freight unit data to TM standalone system
*&---------------------------------------------------------------------*
REPORT ztest_ctp_fu_new NO STANDARD PAGE HEADING.
DATA:
lv_vbeln TYPE vbeln_vl VALUE '80272876',
ls_fu TYPE zts_fu_list,
lt_fu TYPE zts_fu_list_t,
lt_return TYPE bapiret2_t,
lv_appsys TYPE logsys.
START-OF-SELECTION.
* Send data
PERFORM frm_send_data.
*&---------------------------------------------------------------------*
*& Form frm_send_data
*&---------------------------------------------------------------------*
*& Send data
*&---------------------------------------------------------------------*
FORM frm_send_data .
ls_fu-vbeln = lv_vbeln.
ls_fu-posnr = 10.
ls_fu-tor_id = '4100055900'.
ls_fu-item_id = '10'.
ls_fu-quantity = '5'.
ls_fu-quantityuom = 'KG'.
ls_fu-product = 'ZTM_MAT01'.
ls_fu-product_descr = 'ZTM_MAT01 DESC'.
APPEND ls_fu TO lt_fu.
ls_fu-vbeln = lv_vbeln.
ls_fu-posnr = 20.
ls_fu-tor_id = '4100055901'.
ls_fu-item_id = '10'.
ls_fu-quantity = '12'.
ls_fu-quantityuom = 'KG'.
ls_fu-product = 'ZTM_MAT02'.
ls_fu-product_descr = 'ZTM_MAT02 DESC'.
APPEND ls_fu TO lt_fu.
* Get current logical system
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = lv_appsys
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
CALL FUNCTION 'ZTEST_CTP_DLV_NEW' DESTINATION 'QW9170'
EXPORTING
iv_vbeln = lv_vbeln
it_fu = lt_fu
iv_appsys = lv_appsys
IMPORTING
et_bapireturn = lt_return
EXCEPTIONS
system_failure = 1
communication_failure = 2
OTHERS = 3.
READ TABLE lt_return TRANSPORTING NO FIELDS WITH KEY type = 'E'.
IF sy-subrc <> 0.
WRITE:'send ok'.
ELSE.
WRITE:'send failure'.
ENDIF.
ENDFORM.
Code in ECC system
RFC Function module: ZTEST_CTP_DLV_NEW
FUNCTION ZTEST_CTP_DLV_NEW.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_VBELN) TYPE VBELN_VL OPTIONAL
*" VALUE(IT_FU) TYPE ZTS_FU_LIST_T OPTIONAL
*" VALUE(IV_APPSYS) TYPE LOGSYS OPTIONAL
*" EXPORTING
*" VALUE(ET_BAPIRETURN) TYPE BAPIRET2_T
*"----------------------------------------------------------------------
gv_tm_appsys = iv_appsys.
* Set AOT types
PERFORM frm_set_aot.
* Get current logical system
PERFORM frm_get_logical_system.
* Get Time zone
PERFORM frm_get_time_zone.
* Prepare IDOC data(Delivery Header)
PERFORM frm_prepare_idoc_data USING iv_vbeln.
* Send IDOC data(Delivery Header)
PERFORM frm_send_idoc_data TABLES et_bapireturn.
* Prepare IDOC data(Delivery Item)
PERFORM frm_prepare_itm_idoc_data TABLES it_fu
USING iv_vbeln.
* Send IDOC data(Delivery Item)
PERFORM frm_send_idoc_data TABLES et_bapireturn.
ENDFUNCTION.
Code for include LZTEST_FUNCTOP
FUNCTION-POOL ztest_func. "MESSAGE-ID ..
TYPES:
tt_trxas_appobj_ctab TYPE STANDARD TABLE OF trxas_appobj_ctab_wa
WITH EMPTY KEY .
TYPES:
BEGIN OF ts_aotype,
obj_type TYPE /saptrx/trk_obj_type,
aot_type TYPE /saptrx/aotype,
server_name TYPE /saptrx/trxservername,
END OF ts_aotype .
TYPES:
BEGIN OF ts_idoc_data,
control TYPE /saptrx/bapi_trk_control_tab,
info TYPE /saptrx/bapi_trk_info_tab,
tracking_id TYPE /saptrx/bapi_trk_trkid_tab,
exp_event TYPE /saptrx/bapi_trk_ee_tab,
trxserv TYPE /saptrx/trxserv,
appsys TYPE logsys,
appobj_ctabs TYPE tt_trxas_appobj_ctab,
END OF ts_idoc_data .
DATA:
gt_aotype TYPE TABLE OF ts_aotype,
gt_aotype_item TYPE TABLE OF ts_aotype,
gt_idoc_data TYPE STANDARD TABLE OF ts_idoc_data,
gv_tzone TYPE timezone,
gv_appsys TYPE logsys,
gv_tm_appsys TYPE logsys.
Code for include LZTEST_FUNCF01
*----------------------------------------------------------------------*
***INCLUDE LZTEST_FUNCF01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form frm_set_aot
*&---------------------------------------------------------------------*
*& Set AOT types
*&---------------------------------------------------------------------*
FORM frm_set_aot .
DATA:
ls_aotype TYPE ts_aotype,
ls_aotype_item TYPE ts_aotype.
ls_aotype-obj_type = 'ESC_DELIV'.
ls_aotype-aot_type = 'GTT_ODLV_HD'.
APPEND ls_aotype TO gt_aotype."Delivery Header
ls_aotype_item-obj_type = 'ESC_DELIV'.
ls_aotype_item-aot_type = 'GTT_ODLV_IT'.
APPEND ls_aotype_item TO gt_aotype_item."Delivery Item
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_get_LOGICAL_SYSTEM
*&---------------------------------------------------------------------*
*& Get current logical system
*&---------------------------------------------------------------------*
FORM frm_get_logical_system .
* Get current logical system
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = gv_appsys
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_prepare_IDOC_Data
*&---------------------------------------------------------------------*
*& Prepare IDOC data
*&---------------------------------------------------------------------*
FORM frm_prepare_idoc_data USING iv_vbeln TYPE vbeln_vl.
DATA:
lv_tzone TYPE timezone,
lv_trxserver_id TYPE /saptrx/trxservername,
ls_trxserv TYPE /saptrx/trxserv,
ls_idoc_data TYPE ts_idoc_data,
ls_appobj_ctabs TYPE LINE OF trxas_appobj_ctabs,
ls_control TYPE LINE OF /saptrx/bapi_trk_control_tab,
lt_control TYPE /saptrx/bapi_trk_control_tab,
ls_expeventdata TYPE /saptrx/bapi_trk_exp_events,
lt_expeventdata TYPE /saptrx/bapi_trk_ee_tab,
ls_likp TYPE likp.
SELECT SINGLE *
INTO ls_likp
FROM likp
WHERE vbeln = iv_vbeln.
lv_tzone = gv_tzone.
LOOP AT gt_aotype INTO DATA(ls_aotype).
CLEAR:
ls_idoc_data,
lt_control,
lt_expeventdata.
SELECT SINGLE trxservername INTO lv_trxserver_id FROM /saptrx/aotypes
WHERE trk_obj_type EQ ls_aotype-obj_type
AND aotype EQ ls_aotype-aot_type.
SELECT SINGLE trx_server_id trx_server em_version INTO ( ls_trxserv-trx_server_id, ls_trxserv-trx_server , ls_trxserv-em_version )
FROM /saptrx/trxserv
WHERE trx_server_id = lv_trxserver_id.
* Logical System
ls_idoc_data-appsys = gv_appsys.
* Event Manager configuration table
MOVE-CORRESPONDING ls_trxserv TO ls_idoc_data-trxserv.
* Combination of AO and AOT
ls_idoc_data-appobj_ctabs = VALUE #( BASE ls_idoc_data-appobj_ctabs (
trxservername = ls_idoc_data-trxserv-trx_server_id
appobjtype = ls_aotype-aot_type
appobjid = iv_vbeln ) ).
* Control data table
CLEAR: ls_control.
ls_control-appsys = gv_appsys.
ls_control-appobjtype = ls_aotype-aot_type.
ls_control-appobjid = iv_vbeln.
ls_control-paramname = 'YN_DLV_NO'.
ls_control-value = iv_vbeln.
APPEND ls_control TO lt_control.
ls_control-paramname = 'YN_DL_FU_RELEVANT'.
ls_control-value = 'X'.
APPEND ls_control TO lt_control.
ls_control-paramname = 'ACTUAL_BUSINESS_TIMEZONE'.
ls_control-value = lv_tzone.
APPEND ls_control TO lt_control.
ls_control-paramname = 'ACTUAL_BUSINESS_DATETIME'.
CONCATENATE '0' sy-datum sy-uzeit INTO ls_control-value.
APPEND ls_control TO lt_control.
* Actual Technical Datetime & Time zone
ls_control-paramname = 'ACTUAL_TECHNICAL_TIMEZONE'.
ls_control-value = lv_tzone.
APPEND ls_control TO lt_control.
ls_control-paramname = 'ACTUAL_TECHNICAL_DATETIME'.
CONCATENATE '0' sy-datum sy-uzeit INTO ls_control-value.
APPEND ls_control TO lt_control.
ls_control-paramname = 'REPORTED_BY'.
ls_control-value = sy-uname.
APPEND ls_control TO lt_control.
ls_idoc_data-control = VALUE #( BASE ls_idoc_data-control
( LINES OF lt_control ) ).
* Expected event (milestones) table
CLEAR ls_expeventdata.
ls_expeventdata-appsys = gv_appsys.
ls_expeventdata-appobjtype = ls_aotype-aot_type.
ls_expeventdata-appobjid = iv_vbeln.
ls_expeventdata-language = sy-langu.
ls_expeventdata-milestone = 'GOODS_ISSUE'.
ls_expeventdata-loctype = 'ShippingPoint'.
ls_expeventdata-locid1 = ls_likp-vstel.
* Get Planned GI datetime
PERFORM set_local_timestamp
USING ls_likp-wadat
ls_likp-wauhr
CHANGING ls_expeventdata-evt_exp_datetime.
ls_expeventdata-evt_exp_tzone = lv_tzone.
APPEND ls_expeventdata TO lt_expeventdata.
ls_idoc_data-exp_event = VALUE #( BASE ls_idoc_data-exp_event
( LINES OF lt_expeventdata ) ).
* Tracking ID table
* Delivery Header
ls_idoc_data-tracking_id = VALUE #( BASE ls_idoc_data-tracking_id (
appsys = gv_appsys
appobjtype = ls_aotype-aot_type
appobjid = iv_vbeln
trxcod = 'FT1_OUT_DELIVERY'
trxid = iv_vbeln
timzon = lv_tzone ) ).
IF ls_idoc_data-appobj_ctabs[] IS NOT INITIAL AND
ls_idoc_data-control[] IS NOT INITIAL AND
ls_idoc_data-tracking_id[] IS NOT INITIAL.
APPEND ls_idoc_data TO gt_idoc_data.
ENDIF.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form set_local_timestamp
*&---------------------------------------------------------------------*
* Concateneate Time Stamp
*----------------------------------------------------------------------*
* --> EV_DATE Date
* --> EV_TIME Time
* <-- CV_TSMP Time stamp (Local date and time/format)
*----------------------------------------------------------------------*
FORM set_local_timestamp
USING ev_date LIKE sy-datum
ev_time LIKE sy-uzeit
CHANGING cv_tsmp TYPE /saptrx/event_exp_datetime.
DATA: lv_timestrg(15).
IF ev_date IS INITIAL.
CLEAR cv_tsmp.
ELSE.
CONCATENATE ev_date ev_time INTO lv_timestrg.
cv_tsmp = lv_timestrg.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_send_idoc_data
*&---------------------------------------------------------------------*
*& Send IDOC data
*&---------------------------------------------------------------------*
*& --> ET_BAPIRETURN Return parameter
*&---------------------------------------------------------------------*
FORM frm_send_idoc_data TABLES et_bapireturn TYPE bapiret2_t.
DATA: lt_bapiret1 TYPE bapiret2_t,
lt_bapiret2 TYPE bapiret2_t.
LOOP AT gt_idoc_data ASSIGNING FIELD-SYMBOL(<ls_idoc_data>).
CLEAR: lt_bapiret1[], lt_bapiret2[].
/saptrx/cl_send_idocs=>send_idoc_ehpost01(
EXPORTING
it_control = <ls_idoc_data>-control
it_info = <ls_idoc_data>-info
it_tracking_id = <ls_idoc_data>-tracking_id
it_exp_event = <ls_idoc_data>-exp_event
is_trxserv = <ls_idoc_data>-trxserv
iv_appsys = <ls_idoc_data>-appsys
it_appobj_ctabs = <ls_idoc_data>-appobj_ctabs
iv_upd_task = 'X'
IMPORTING
et_bapireturn = lt_bapiret1 ).
* When GTT V2 version
IF /saptrx/cl_send_idocs=>st_idoc_data[] IS NOT INITIAL.
/saptrx/cl_send_idocs=>send_idoc_gttmsg01(
IMPORTING
et_bapireturn = lt_bapiret2 ).
ENDIF.
* Collect messages, if it is necessary
APPEND LINES OF lt_bapiret1 TO et_bapireturn.
APPEND LINES OF lt_bapiret2 TO et_bapireturn.
ENDLOOP.
CLEAR:gt_idoc_data.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_get_time_zone
*&---------------------------------------------------------------------*
*& Get Time zone
*&---------------------------------------------------------------------*
FORM frm_get_time_zone .
* Get Time zone
CALL FUNCTION 'GET_SYSTEM_TIMEZONE'
IMPORTING
timezone = gv_tzone
EXCEPTIONS
customizing_missing = 1
OTHERS = 2.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_prepare_ITM_idoc_data
*&---------------------------------------------------------------------*
*& Prepare IDOC data(Delivery Item)
*&---------------------------------------------------------------------*
*& --> IT_FU Freight unit table
*& --> IV_VBELN Delivery number
*&---------------------------------------------------------------------*
FORM frm_prepare_itm_idoc_data TABLES it_fu TYPE zts_fu_list_t
USING iv_vbeln TYPE vbeln_vl.
DATA:
lv_tzone TYPE timezone,
lv_trxserver_id TYPE /saptrx/trxservername,
ls_trxserv TYPE /saptrx/trxserv,
ls_idoc_data TYPE ts_idoc_data,
ls_fu TYPE zts_fu_list,
ls_appobj_ctabs TYPE LINE OF trxas_appobj_ctabs,
ls_control TYPE LINE OF /saptrx/bapi_trk_control_tab,
lt_control TYPE /saptrx/bapi_trk_control_tab,
ls_expeventdata TYPE /saptrx/bapi_trk_exp_events,
lt_expeventdata TYPE /saptrx/bapi_trk_ee_tab,
lv_appobjid TYPE /saptrx/aoid,
lv_count TYPE i VALUE 0,
ls_likp TYPE likp.
SELECT SINGLE *
INTO ls_likp
FROM likp
WHERE vbeln = iv_vbeln.
lv_tzone = gv_tzone.
LOOP AT gt_aotype_item INTO DATA(ls_aotype_item).
CLEAR: ls_idoc_data.
SELECT SINGLE trxservername INTO lv_trxserver_id FROM /saptrx/aotypes
WHERE trk_obj_type EQ ls_aotype_item-obj_type
AND aotype EQ ls_aotype_item-aot_type.
SELECT SINGLE trx_server_id trx_server em_version INTO ( ls_trxserv-trx_server_id, ls_trxserv-trx_server , ls_trxserv-em_version )
FROM /saptrx/trxserv
WHERE trx_server_id = lv_trxserver_id.
* Logical System
ls_idoc_data-appsys = gv_appsys.
* Event Manager configuration table
MOVE-CORRESPONDING ls_trxserv TO ls_idoc_data-trxserv.
LOOP AT it_fu INTO ls_fu.
CLEAR:
ls_control,
lt_control,
lt_expeventdata.
lv_appobjid = |{ ls_fu-vbeln }{ ls_fu-posnr }|.
CONDENSE lv_appobjid NO-GAPS.
* Combination of AO and AOT
ls_idoc_data-appobj_ctabs = VALUE #( BASE ls_idoc_data-appobj_ctabs (
trxservername = ls_idoc_data-trxserv-trx_server_id
appobjtype = ls_aotype_item-aot_type
appobjid = lv_appobjid ) ).
* Control data table
ls_control-appsys = gv_appsys.
ls_control-appobjtype = ls_aotype_item-aot_type.
ls_control-appobjid = lv_appobjid.
ls_control-paramname = 'YN_DL_DELEVERY'.
ls_control-value = ls_fu-vbeln.
APPEND ls_control TO lt_control.
ls_control-paramname = 'YN_DL_DELEVERY_ITEM'.
ls_control-value = ls_fu-posnr.
APPEND ls_control TO lt_control.
ls_control-paramname = 'ACTUAL_BUSINESS_TIMEZONE'.
ls_control-value = lv_tzone.
APPEND ls_control TO lt_control.
ls_control-paramname = 'ACTUAL_BUSINESS_DATETIME'.
CONCATENATE '0' sy-datum sy-uzeit INTO ls_control-value.
APPEND ls_control TO lt_control.
* Actual Technical Datetime & Time zone
ls_control-paramname = 'ACTUAL_TECHNICAL_TIMEZONE'.
ls_control-value = lv_tzone.
APPEND ls_control TO lt_control.
ls_control-paramname = 'ACTUAL_TECHNICAL_DATETIME'.
CONCATENATE '0' sy-datum sy-uzeit INTO ls_control-value.
APPEND ls_control TO lt_control.
ADD 1 TO lv_count.
ls_control-paramindex = lv_count.
ls_control-paramname = 'YN_DL_FU_LINE_COUNT'.
ls_control-value = lv_count.
CONDENSE ls_control-value NO-GAPS.
APPEND ls_control TO lt_control.
ls_control-paramindex = lv_count.
ls_control-paramname = 'YN_DL_FU_NO'.
ls_control-value = ls_fu-tor_id.
APPEND ls_control TO lt_control.
ls_control-paramindex = lv_count.
ls_control-paramname = 'YN_DL_FU_ITEM_NO'.
ls_control-value = ls_fu-item_id.
APPEND ls_control TO lt_control.
ls_control-paramindex = lv_count.
ls_control-paramname = 'YN_DL_FU_QUANTITY'.
ls_control-value = ls_fu-quantity.
CONDENSE ls_control-value NO-GAPS.
APPEND ls_control TO lt_control.
ls_control-paramindex = lv_count.
ls_control-paramname = 'YN_DL_FU_UNITS'.
ls_control-value = ls_fu-quantityuom.
APPEND ls_control TO lt_control.
* Product & description
ls_control-paramindex = lv_count.
ls_control-paramname = 'YN_DL_FU_PRODUCT'.
ls_control-value = ls_fu-product.
APPEND ls_control TO lt_control.
ls_control-paramindex = lv_count.
ls_control-paramname = 'YN_DL_FU_PRODUCT_DESCR'.
ls_control-value = ls_fu-product_descr.
APPEND ls_control TO lt_control.
* FU logical system
ls_control-paramindex = lv_count.
ls_control-paramname = 'YN_DL_FU_NO_LOGSYS'.
ls_control-value = gv_tm_appsys.
APPEND ls_control TO lt_control.
* FU tracking
ls_control-paramindex = lv_count.
ls_control-paramname = 'E1EHPTID_APPSYS'.
ls_control-value = gv_tm_appsys.
APPEND ls_control TO lt_control.
ls_control-paramindex = lv_count.
ls_control-paramname = 'E1EHPTID_TRXCOD'.
ls_control-value = 'FT1_FREIGHT_UNIT'.
APPEND ls_control TO lt_control.
ls_control-paramindex = lv_count.
ls_control-paramname = 'E1EHPTID_TRXID'.
ls_control-value = |{ ls_fu-tor_id ALPHA = OUT }|.
APPEND ls_control TO lt_control.
ls_control-paramname = 'REPORTED_BY'.
ls_control-value = sy-uname.
APPEND ls_control TO lt_control.
ls_idoc_data-control = VALUE #( BASE ls_idoc_data-control
( LINES OF lt_control ) ).
* Expected event (milestones) table
CLEAR ls_expeventdata.
ls_expeventdata-appsys = gv_appsys.
ls_expeventdata-appobjtype = ls_aotype_item-aot_type.
ls_expeventdata-appobjid = lv_appobjid.
ls_expeventdata-language = sy-langu.
ls_expeventdata-milestone = 'PICKING'.
ls_expeventdata-loctype = 'ShippingPoint'.
ls_expeventdata-locid1 = ls_likp-vstel.
* Get Planned GI datetime
PERFORM set_local_timestamp
USING ls_likp-wadat
ls_likp-wauhr
CHANGING ls_expeventdata-evt_exp_datetime.
ls_expeventdata-evt_exp_tzone = lv_tzone.
APPEND ls_expeventdata TO lt_expeventdata.
ls_idoc_data-exp_event = VALUE #( BASE ls_idoc_data-exp_event
( LINES OF lt_expeventdata ) ).
* Tracking ID table
ls_idoc_data-tracking_id = VALUE #( BASE ls_idoc_data-tracking_id (
appsys = gv_appsys
appobjtype = ls_aotype_item-aot_type
appobjid = lv_appobjid
trxcod = 'FT1_ODLV_ITEM'
trxid = lv_appobjid
timzon = lv_tzone ) ).
ENDLOOP.
IF ls_idoc_data-appobj_ctabs[] IS NOT INITIAL AND
ls_idoc_data-control[] IS NOT INITIAL AND
ls_idoc_data-tracking_id[] IS NOT INITIAL.
APPEND ls_idoc_data TO gt_idoc_data.
ENDIF.
ENDLOOP.
ENDFORM.
Summary
By following the above steps, you can easily set up the connection between SAP ECC/SAP TM standalone and SAP Business Network Global Track and Trace.
You may use the comments section to provide feedback on this article and help in improving the content. Additional you may post your queries in the comment or in the community Q&A
Reference document
https://help.sap.com/docs/SAP_LBN_GTT_OPTION
https://github.com/SAP-samples/logistics-business-network-gtt-standardapps-samples