Supply Chain Management Blogs by SAP
Expand your SAP SCM knowledge and stay informed about supply chain management technology and solutions with blog posts by SAP. Follow and stay connected.
cancel
Showing results for 
Search instead for 
Did you mean: 
alvin_fan
Advisor
Advisor

Introduction

In my previous blog How to Integrate SAP S/4HANA with SAP Business Network Global Track and Trace, 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 customers and partners may want to know, for SAP ECC or SAP TM (standalone) or S/4HANA or S/4HANA(TM), is it possible to set up the integration with SAP Business Network Global Track and Trace to replicate the transactional data?

The answer is yes. But you need to do extra work.
Here are some possible solutions for your reference.

Option 1:
You can build your own extractor and send out the IDOC to SAP Business Network Global Track and Trace. To know how to build your own extractor, follow the steps in the chapter 5. Configuration and Coding Guide – Advanced in Sample Code Configuration Guide for Integration with SAP Business Network Global Track and Trace.

Option 2:
Because there is no template code for versions lower than SAP S/4HANA 1909 SP03, (The background is that these integrations are very individual, and it would be very difficult to provide a generic code for any ECC/TM standalone version. ) You can adjust the sample extractor code (you may encounter syntax error when down porting the sample extractor code to ECC or TM standalone system) 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 elaborate on option 2 and provide some ideas to adjust the sample extractor code.
It includes the following steps:

1.Download the sample extractor code and implement them to SAP ECC or SAP TM (standalone)
2.Fix syntax error
3.Configure the extractor code
4.Build the relationship between freight unit and inbound/outbound delivery. (Only applies to standalone TM)
 

1.Download the sample extractor code and implement them to SAP ECC or SAP TM (standalone)

Here are the packages that are 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 deploying the code to SAP ECC as an example.

1.1 Download ABAP Code from GitHub

1.1.1 Open the following link to the GTT repository on Github.com to download the code:
https://github.com/SAP-samples/logistics-business-network-gtt-standardapps-samples

1.1.2 Click “Code” button, then select “Download ZIP”.


1.1.3 Open the file you’ve downloaded “logistics-business-network-gtt-standardapps-samples-main.zip”.
1.1.4 Delete the following unnecessary folders in the ZIP file.

    • “zgtt_sts” folder: As you want to install the code to SAP ECC, so TM relevant folder “zgtt_sts” should be deleted. (This folder located in logistics-business-network-gtt-standardapps-samples-main.zip\logistics-business-network-gtt-standardapps-samples-main\lbn-gtt-standard-app\abap\zsrc\)
    • “Documents” folder: delete it to accelerate the installation process. (This folder located in logistics-business-network-gtt-standardapps-samples-main.zip\logistics-business-network-gtt-standardapps-samples-main\lbn-gtt-standard-app\)

After deletion, 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 completed, 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.

1.3.3 Click “Create Offline Repo

1.3.4 Import the zip file you downloaded by clicking “Import zip”.


Select the file “logistics-business-network-gtt-standardapps-samples-main.zip”.

1.3.5 Click “Pull” to save the changes to a workbench request.

1.3.6 Select an existing transport request (TR) or create a new transport request (TR) and click “Save”.

1.3.7 Once all the objects imported, active the objects.



2.Fix syntax error

When down porting the sample extractor code which developed and verified in S/4HANA 1909 SP03 and afterwards to ECC or TM standalone system, you may encounter syntax error. But 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.

Because in this chapter we take ECC as an example, below unnecessary objects(Used for get data from TM system) can be deleted in your local system.

Function ModuleZGTT_CTP_TOR_TO_DL
ClassZCL_GTT_SOF_TM_TOOLS
ClassZCL_GTT_CTP_TOR_TO_DL_BASE
ClassZCL_GTT_CTP_TOR_TO_ODLVHD
ClassZCL_GTT_CTP_TOR_TO_ODLVIT
ClassZCL_GTT_CTP_TOR_TO_IDLVHD
ClassZCL_GTT_CTP_TOR_TO_IDLVIT
Function ModuleZGTT_SSOF_CTP_TOR_TO_DL
ClassZCL_GTT_SOF_CTP_SND
ClassZCL_GTT_SOF_CTP_TOR_CHANGES
ClassZCL_GTT_SOF_CTP_DAT_TOR_TO_DLH
ClassZCL_GTT_SOF_CTP_SND_TOR_TO_DLH
ClassZCL_GTT_SOF_CTP_DAT_TOR_TO_DLI
ClassZCL_GTT_SOF_CTP_SND_TOR_TO_DLI
Function ModuleZGTT_MIA_CTP_TOR_TO_DL
ClassZCL_GTT_CTP_SND
ClassZCL_GTT_MIA_CTP_TOR_CHANGES
ClassZCL_GTT_MIA_CTP_DAT_TOR_TO_DLH
ClassZCL_GTT_MIA_CTP_SND_TOR_TO_DLH
ClassZCL_GTT_MIA_CTP_DAT_TOR_TO_DLI
ClassZCL_GTT_MIA_CTP_SND_TOR_TO_DLI

3.Configure the extractor code


Regarding the extractor configuration, you can refer to chapter 4. ERP Integration Configuration Option 2 (Manual Configuration) in Sample Code Configuration Guide for Integration with SAP Business Network Global Track and Trace.

If you cannot see the GTT configuration entries (node “Interface to Global Track and Trace”) in the IMG - SPRO transaction, you can check notes 2396373.

Or you can use T-code directly.Here are all the T-code used in GTT.

MenuT-CodeWorkaround 1Workaround 2
Define RFC Connection for SAP GTTSM59  
Define Logical SystemOMTXSALESM30 input V_TBDLS as view name
Define PortsWE21  
Define Partner ProfilesWE20  
Define CI Tenant for SAP GTT/SAPTRX/ASC0TS_CTTSM30 input /SAPTRX/V_CTTSRV as view name 
Define SAP GTT Extraction Functions/SAPTRX/ASC0TF_CTTSM34 input /SAPTRX/VC_ASFUNC_CTT as View Cluster name 
Define Used Business Process Types, Appl. Object Types and Event Types/SAPTRX/ASC0AO_CTTSM34 input /SAPTRX/VC_AOTYPE_CTT as View Cluster name 


For ECC system, the integration is now completed. But if you integrate the standalone TM with SAP Business Network Global Track and Trace, you still need to proceed to finish the last step.

4.Build the relationship between freight unit and inbound/outbound delivery. (Only applies to standalone TM)

4.1 Overview


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:

General process flow.png


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:

Cross TP process.png


This chapter aims to show you how to make the “cross TP process” between the ECC system and TM standalone system work.
 

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(import parameter it_item_sstring)
4.2.2 Generate the delivery header IDOC.

    1. Prepare the control parameter data for delivery header
    2. Prepare planned event data for delivery header
    3. Prepare tracking ID data for delivery header

4.2.3 Send out the delivery header IDOC
4.2.4 Generate delivery item IDOC

    1. Prepare control parameter data for delivery item
    2. Prepare planned event data for delivery item
    3. 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

FieldField Value
YN_DLV_NOFill in delivery number
YN_DL_FU_RELEVANTIf a delivery has freight unit, fill in the value “X”. Otherwise, leave it blank.
ACTUAL_BUSINESS_TIMEZONEUse the function module GET_SYSTEM_TIMEZONE to get the system time zone
ACTUAL_BUSINESS_DATETIMEFill in the current timestamp
ACTUAL_TECHNICAL_TIMEZONEUse the function module GET_SYSTEM_TIMEZONE to get the system time zone
ACTUAL_TECHNICAL_DATETIMEFill in the current timestamp
REPORTED_BYFill in the current system user ID

Expected Event

Planned Event CodeDescription
GOODS_ISSUEIf a delivery is “Goods Issue” relevant, then add the planned event “Goods Issue”
ODLV_ITEM_PODIf delivery is “POD” relevant, then add the planned event “Item POD”
ODLV_IT_COMPLETEDIn the TM scenario, add the planned event “delivery item complete”
ODLV_HD_COMPLETEDIn the LE-TRA scenario, add the planned event “Delivery Header Completed”
ODLV_PLANNED_DLVAlways plan this event

Tracking ID

Tracking ID Code SetTracking ID
FT1_OUT_DELIVERYFill 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

FieldField Value
YN_DLV_NOFill in the delivery number
YN_DLV_ITEM_NOFill in the delivery item number
YN_DL_FU_LINE_COUNTFill in the line number
YN_DL_FU_NOFill in the freight unit number
YN_DL_FU_ITEM_NOFill in the freight unit item number
YN_DL_FU_QUANTITYFill in the quantity of the product
YN_DL_FU_UNITSFill in the unit of measure for quantity
YN_DL_FU_PRODUCTFill in the name of the product
YN_DL_FU_PRODUCT_DESCRFill in the description of the product
YN_DL_FU_NO_LOGSYSFill in the logical system ID in TM standalone system
E1EHPTID_APPSYSFill in the logical system ID in TM standalone system
E1EHPTID_TRXCODFill in the fixed value “FT1_FREIGHT_UNIT”
E1EHPTID_TRXIDFill in the freight unit number
ACTUAL_BUSINESS_TIMEZONEUse the function module GET_SYSTEM_TIMEZONE to get the system time zone
ACTUAL_BUSINESS_DATETIMEFill in the current timestamp
ACTUAL_TECHNICAL_TIMEZONEUse the function module GET_SYSTEM_TIMEZONE to get the system time zone
ACTUAL_TECHNICAL_DATETIMEFill in the current timestamp
REPORTED_BYFill in the current system user ID

Expected Event

Planned Event CodeDescription
PICKINGIf the delivery item is “Picking” relevant, then add the planned event “Picking”
PACKINGIf the delivery item is “Packing” relevant, then add the planned event “Packing”
GOODS_ISSUEIf the delivery item is “Goods Issue” relevant, then add the planned event “Goods Issue”
ODLV_ITEM_PODIf the delivery item is “POD” relevant, then add the planned event “Item POD”
FU_COMPLETEDIn the TM scenario, add the planned event “Freight Unit Completed”
ODLV_HD_COMPLETEDIn the LE-TRA scenario, add the planned event “Delivery Deader Completed”

Tracking ID

Tracking ID Code SetTracking ID
FT1_ODLV_ITEMFill 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

FieldField Value
YN_DL_DELEVERYFill in the delivery number
YN_DL_FU_RELEVANTIf the delivery has freight units, fill in the value “X”.  Otherwise, leave it blank.
ACTUAL_BUSINESS_TIMEZONEUse function module GET_SYSTEM_TIMEZONE to get the system time zone
ACTUAL_BUSINESS_DATETIMEFill in the current timestamp
ACTUAL_TECHNICAL_TIMEZONEUse function module GET_SYSTEM_TIMEZONE to get the system time zone
ACTUAL_TECHNICAL_DATETIMEFill in the current timestamp
REPORTED_BYFill in the current system user ID

Expected Event

Planned Event codeDescription
GOODS_RECEIPTAdd the planned event “Goods Receipt” with the event match key (delivery number and delivery item number)
IDLV_PLANNED_DLVAlways plan this event
IDLV_IT_COMPLETEDIn the TM scenario, add the planned event “Delivery Item Completed”.
GOODS_RECEIPTIn 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 SetTracking ID
FT1_IN_DELIVERYFill 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

FieldField Value
YN_DL_DELEVERYFill in the delivery number
YN_DL_DELEVERY_ITEMFill in the delivery item number
YN_DL_FU_LINE_COUNTFill in the line number
YN_DL_FU_NOFill in the freight unit number
YN_DL_FU_ITEM_NOFill in the freight unit item number
YN_DL_FU_QUANTITYFill in the quantity of product
YN_DL_FU_UNITSFill in the unit of measure for quantity
YN_DL_FU_PRODUCTFill in the name of the product
YN_DL_FU_PRODUCT_DESCRFill in the description of the product
YN_DL_FU_NO_LOGSYSFill in the logical system ID in TM standalone system
E1EHPTID_APPSYSFill in the logical system ID in TM standalone system
E1EHPTID_TRXCODFill in the fixed value “FT1_FREIGHT_UNIT”
E1EHPTID_TRXIDFill in the freight unit number
ACTUAL_BUSINESS_TIMEZONEUse function module GET_SYSTEM_TIMEZONE to get the system time zone
ACTUAL_BUSINESS_DATETIMEFill in the current timestamp
ACTUAL_TECHNICAL_TIMEZONEUse function module GET_SYSTEM_TIMEZONE to get the system time zone
ACTUAL_TECHNICAL_DATETIMEFill in the current timestamp
REPORTED_BYFill in the current system user ID

Expected Event

Planned Event CodeDescription
PUT_AWAYIf the delivery item is “Put Away” relevant, then add the planned event “Put Away”
PACKINGIf the delivery item is “Packing” relevant, then add the planned event “Packing”
GOODS_RECEIPTIf 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_COMPLETEDIn the TM scenario, add the planned event “Freight Unit Completed”
GOODS_RECEIPTIn 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 SetTracking ID
FT1_IN_DELIVERY_ITEMFill 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 example codes below.(The example codes in this blog are not for productive use. These codes are only intended to better explain and visualize the syntax and phrasing rules. You need to change the codes to meet your own business requirements.)

In below example, we'll use C4V/001 as TM system,Q7Q/513 as ECC system.

All of the change points listed below.

SystemSystem IDFunction module/ClassMethodMemo
TMC4V/001ZCL_GTT_STS_SEND_TOR_DATAGENERATE_DLV_IDOCa new method,will calling RFC function module ZTEST_CTP_DLV_NEW to generate the delivery related IDOCs
ZCL_GTT_STS_BO_FU_READERGET_DATA_FROM_ITEMAdjust this method,add logical system ID for inbound/outbound delivery
ZTEST_GET_FU_BY_DELIVERY a new RFC function module,this function module mainly used to get the freight unit
ERPQ7Q/513ZGTT_SSOF_EE_DE_HD Adjust this function module,will calling RFC function module ZTEST_GET_FU_BY_DELIVERY to get the corresponding freight unit
ZGTT_SSOF_EE_DE_ITM Adjust this function module,will calling RFC function module ZTEST_GET_FU_BY_DELIVERY to get the corresponding freight unit
ZTEST_CTP_DLV_NEW a new RFC function module, this function module mainly used to generate the delivery related IDOCs


In this chapter we'll focus on the cross TP process.

First create structure ZTS_FU_LIST and table type ZTS_FU_LIST_T and ZVBELN_T .

Components in structure ZTS_FU_LIST

ComponentComponent TypeShort Description
VBELNVBELN_VLDelivery
POSNRPOSNR_VLDelivery Item
TOR_IDCHAR20TM Document
ITEM_IDCHAR10Item
QUANTITYMENGE_DQuantity
QUANTITYUOMMEINSBase Unit of Measure
PRODUCTCHAR40Product
PRODUCT_DESCRCHAR40Item Description

Table type ZTS_FU_LIST_T with the row type ZTS_FU_LIST in it.
Table type ZVBELN_T with the line type VBELN_VL in it.

Code in TM standalone system(C4V/001)

Below method GENERATE_DLV_IDOC should be called in method /SCMTMS/IF_SEND_TOR_DATA~CALL_EVENT_MGR of class ZCL_GTT_STS_SEND_TOR_DATA.

methods GENERATE_DLV_IDOC
importing
!IT_TOR_ROOT_SSTRING type /SCMTMS/T_EM_BO_TOR_ROOT
!IT_ITEM_SSTRING type /SCMTMS/T_EM_BO_TOR_ITEM .

 

 

  METHOD generate_dlv_idoc.



    DATA:

      ls_fu     TYPE zts_fu_list,

      lt_fu     TYPE zts_fu_list_t,

      lv_appsys TYPE logsys,

      lt_return TYPE bapiret2_t,

      lt_vbeln  TYPE zvbeln_t.



    LOOP AT it_item_sstring INTO DATA(ls_item)

      WHERE item_cat = /scmtms/if_tor_const=>sc_tor_item_category-product

        AND ( base_btd_tco = zcl_gtt_sts_bo_fu_reader=>cs_base_btd_tco_inb_dlv

         OR base_btd_tco = zcl_gtt_sts_bo_fu_reader=>cs_base_btd_tco_outb_dlv ).

      READ TABLE it_tor_root_sstring INTO DATA(ls_root)

        WITH KEY node_id = ls_item-parent_node_id

                 tor_cat = /scmtms/if_tor_const=>sc_tor_category-freight_unit.

      IF sy-subrc = 0.

        ls_fu-vbeln         = |{ ls_item-base_btd_id ALPHA = IN }|.

        ls_fu-posnr         = ls_item-base_btditem_id.

        ls_fu-tor_id        = ls_root-tor_id.

        ls_fu-item_id       = ls_item-item_id.

        ls_fu-quantity      = ls_item-qua_pcs_val.

        CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'

          EXPORTING

            input    = ls_item-qua_pcs_uni

            language = sy-langu

          IMPORTING

            output   = ls_fu-quantityuom.

        ls_fu-product       = ls_item-product_id.

        ls_fu-product_descr = ls_item-item_descr.

        APPEND ls_fu TO lt_fu.



        READ TABLE lt_vbeln TRANSPORTING NO FIELDS

          WITH KEY table_line = ls_fu-vbeln.

        IF sy-subrc <> 0.

          APPEND ls_fu-vbeln TO lt_vbeln.

        ENDIF.



      ENDIF.

      CLEAR ls_fu.

    ENDLOOP.



    CHECK lt_vbeln IS NOT INITIAL.



*   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 'Q7QCLNT513_GTT'

      EXPORTING

        it_vbeln              = lt_vbeln

        it_fu                 = lt_fu

        iv_appsys             = lv_appsys

      IMPORTING

        et_bapireturn         = lt_return

      EXCEPTIONS

        system_failure        = 1

        communication_failure = 2

        OTHERS                = 3.



  ENDMETHOD.

 

 


Code in ECC system(Q7Q/513)
RFC Function module: ZTEST_CTP_DLV_NEW

 

 

FUNCTION ztest_ctp_dlv_new.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(IT_VBELN) TYPE  ZVBELN_T OPTIONAL

*"     VALUE(IT_FU) TYPE  ZTS_FU_LIST_T OPTIONAL

*"     VALUE(IV_APPSYS) TYPE  LOGSYS OPTIONAL

*"  EXPORTING

*"     VALUE(ET_BAPIRETURN) TYPE  BAPIRET2_T

*"----------------------------------------------------------------------

  DATA:

    lt_tmp_return TYPE bapiret2_t.



  CLEAR gt_idoc_data.



  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.



  LOOP AT it_vbeln INTO DATA(ls_vbeln).



*   Prepare IDOC data(Delivery Header)

    PERFORM frm_prepare_idoc_data TABLES it_fu

                                   USING ls_vbeln.



*   Send IDOC data(Delivery Header)

    PERFORM frm_send_idoc_data TABLES lt_tmp_return.



*   Prepare IDOC data(Delivery Item)

    PERFORM frm_prepare_itm_idoc_data TABLES it_fu

                                      USING ls_vbeln.



*   Send IDOC data(Delivery Item)

    PERFORM frm_send_idoc_data TABLES lt_tmp_return.



    APPEND LINES OF lt_tmp_return TO et_bapireturn.

    CLEAR lt_tmp_return.

  ENDLOOP.



* When calling the ALE/Idoc layer from custom program you have to run a COMMIT WORK after the call.(see notes 1575852)

  COMMIT WORK.



ENDFUNCTION.

 

 


Code for include LZTEST_FUNCTOP

 

 

FUNCTION-POOL ZTEST_FUNC.                   "MESSAGE-ID ..



* INCLUDE LZTEST_FUNCD...                    " Local class definition



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 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_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,

    lv_vbeln        TYPE likp-vbeln.



  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,

      lv_vbeln.

    lv_vbeln = iv_vbeln.

    SHIFT lv_vbeln LEFT DELETING LEADING '0'.

    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      = lv_vbeln  ) ).



*   Control data table

    CLEAR: ls_control.

    ls_control-appsys  = gv_appsys.

    ls_control-appobjtype = ls_aotype-aot_type.

    ls_control-appobjid   = lv_vbeln.

    ls_control-paramname = 'YN_DLV_NO'.

    ls_control-value     = lv_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   = lv_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.



    LOOP AT it_fu INTO DATA(ls_fu) WHERE vbeln = iv_vbeln.

      CLEAR ls_expeventdata.

      ls_expeventdata-appsys     = gv_appsys.

      ls_expeventdata-appobjtype = ls_aotype-aot_type.

      ls_expeventdata-appobjid   = lv_vbeln.

      ls_expeventdata-language   = sy-langu.

      ls_expeventdata-milestone  = 'ODLV_IT_COMPLETED'.

      ls_expeventdata-locid2     = |{ ls_fu-vbeln ALPHA = OUT }{ ls_fu-posnr ALPHA = IN }|.

      CONDENSE ls_expeventdata-locid2 NO-GAPS.

      APPEND ls_expeventdata TO lt_expeventdata.

    ENDLOOP.



    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    = lv_vbeln

      trxcod      = 'FT1_OUT_DELIVERY'

      trxid       = lv_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 WHERE vbeln = iv_vbeln.

      CLEAR:

        ls_control,

        lt_control,

        lt_expeventdata.



      lv_appobjid = |{ ls_fu-vbeln }{ ls_fu-posnr }|.

      CONDENSE lv_appobjid NO-GAPS.

      SHIFT lv_appobjid LEFT DELETING LEADING '0'.



*     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_DLV_NO'.

      ls_control-value     = |{ ls_fu-vbeln ALPHA = OUT }|.

      APPEND ls_control TO lt_control.



      ls_control-paramname = 'YN_DLV_ITEM_NO'.

      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 ALPHA = OUT }|.

      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.



      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 = 'FU_COMPLETED'.

      ls_expeventdata-locid2 = |{ ls_fu-tor_id ALPHA = OUT }|.

      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.

 

 

4.3.6 Create RFC function module ZTEST_GET_FU_BY_DELIVERY in TM system(C4V/001)


This function module ZTEST_GET_FU_BY_DELIVERY should be called in ECC system(Q7Q/513).

ECC function module ZGTT_SSOF_EE_DE_HD calling RFC ZTEST_GET_FU_BY_DELIVERY to get the freight unit.

ECC function module ZGTT_SSOF_EE_DE_ITM calling RFC ZTEST_GET_FU_BY_DELIVERY to get the freight unit.

 

 

FUNCTION ztest_get_fu_by_delivery.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(IV_VBELN) TYPE  VBELN_VL OPTIONAL

*"     VALUE(IV_POSNR) TYPE  POSNR_VL OPTIONAL

*"     VALUE(IV_VBTYP) TYPE  VBTYP OPTIONAL

*"     VALUE(IV_LOGICAL_SYSTEM) TYPE  LOGSYS OPTIONAL

*"  EXPORTING

*"     VALUE(ET_FU) TYPE  ESPCHAR20_TAB

*"----------------------------------------------------------------------



  DATA:

    lt_base_doc   TYPE /scmtms/t_base_document_w_item,

    ls_base_doc   TYPE /scmtms/s_base_document_w_item,

    lo_srvmgr_tor TYPE REF TO /bobf/if_tra_service_manager,

    lt_result     TYPE /bobf/t_frw_keyindex,

    ls_result     TYPE /bobf/s_frw_keyindex,

    lt_fu_root    TYPE /scmtms/t_tor_root_k,

    lv_fu_no      TYPE /scmtms/tor_id.



  CLEAR et_fu.



  ls_base_doc-base_btd_logsys = iv_logical_system.



  CASE iv_vbtyp.

    WHEN 'J'. "Delivery

      ls_base_doc-base_btd_tco = /scmtms/if_common_c=>c_btd_tco-outbounddelivery.

    WHEN '7'. "Delivery/shipping notification

      ls_base_doc-base_btd_tco = /scmtms/if_common_c=>c_btd_tco-inbounddelivery.

    WHEN OTHERS.

  ENDCASE.



  ls_base_doc-base_btd_id = |{ iv_vbeln ALPHA = IN }|.

  IF iv_posnr IS NOT INITIAL.

    ls_base_doc-base_btditem_id = |{ iv_posnr ALPHA = IN }|.

  ENDIF.



  APPEND ls_base_doc TO lt_base_doc.



***********************************************************************

** get instance service manager for BO /SCMTMS/TOR                    *

***********************************************************************

* instance servicemanger for BO

  lo_srvmgr_tor = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ).



***********************************************************************

**  Converts an alternative key to the technical key                  *

***********************************************************************

  lo_srvmgr_tor->convert_altern_key(

    EXPORTING

      iv_node_key   = /scmtms/if_tor_c=>sc_node-item_tr

      iv_altkey_key = /scmtms/if_tor_c=>sc_alternative_key-item_tr-base_document

      it_key        = lt_base_doc

    IMPORTING

      et_result     = lt_result ).  " Key table with explicit index



  IF lt_result IS INITIAL.

    RETURN.

  ENDIF.



***********************************************************************

**  FU Root Assocation                                                *

***********************************************************************

  lo_srvmgr_tor->retrieve_by_association(

    EXPORTING

      iv_node_key    = /scmtms/if_tor_c=>sc_node-item_tr

      it_key         = CORRESPONDING #( lt_result  )

      iv_association = /scmtms/if_tor_c=>sc_association-item_tr-fu_root

      iv_fill_data   = abap_true

    IMPORTING

      et_data        = lt_fu_root ).



  LOOP AT lt_fu_root INTO DATA(ls_fu_root) USING KEY tor_cat

    WHERE tor_cat   =  /scmtms/if_tor_const=>sc_tor_category-freight_unit

      AND lifecycle <> /scmtms/if_tor_status_c=>sc_root-lifecycle-v_canceled.

    lv_fu_no = ls_fu_root-tor_id.

    APPEND lv_fu_no TO et_fu.

  ENDLOOP.



ENDFUNCTION.

 

 

ECC(Q7Q/513) Calling example:

 

 

    CALL FUNCTION 'ZTEST_GET_FU_BY_DELIVERY' DESTINATION 'C4VCLNT001'

      EXPORTING

        iv_vbeln              = <ls_xlikp>-vbeln

        iv_vbtyp              = <ls_xlikp>-vbtyp

        iv_logical_system     = i_appsys

      IMPORTING

        et_fu                 = lt_fu

      EXCEPTIONS

        system_failure        = 1

        communication_failure = 2

        OTHERS                = 3.

 

 

4.3.7 Adjust the freight unit extractor in TM system(C4V/001)

1.Add field mapping in class ZCL_GTT_STS_BO_FU_READER

Go to SE24,input the class name ZCL_GTT_STS_BO_FU_READER,and switch to "Attributes" tab,double click attribute 'CS_MAPPING',it will navigator to class ZCL_GTT_STS_BO_TOR_READER.

Add below field mapping for constants cs_mapping 

 

 

      dlv_item_inb_logsys   TYPE /saptrx/paramname VALUE 'YN_SHP_DLV_ITM_INB_ALT_ID_LOGSYS',
      dlv_item_oub_logsys   TYPE /saptrx/paramname VALUE 'YN_SHP_DLV_ITM_OUB_ALT_ID_LOGSYS',

 

 

2.In class ZCL_GTT_STS_BO_FU_READER add defination

 

 

    BEGIN OF ts_freight_unit,

        .....
        "Add below two fields
        dlv_item_inb_logsys   TYPE STANDARD TABLE OF /scmtms/logsys_sending       WITH EMPTY KEY,
        dlv_item_oub_logsys   TYPE STANDARD TABLE OF /scmtms/logsys_sending       WITH EMPTY KEY,
        .....
      END OF ts_freight_unit .

 

 

3.Add logical system to freight unit
Below code should be added in method GET_DATA_FROM_ITEM of class ZCL_GTT_STS_BO_FU_READER.

 

 

      IF <ls_tor_item>-base_btd_tco     = cs_base_btd_tco_inb_dlv  AND	

         <ls_tor_item>-base_btditem_tco = cs_base_btd_tco_delivery_item.	

        APPEND lv_base_btd_alt_item_id TO cs_freight_unit-dlv_item_inb_alt_id.	

        "Add logical system to the freight unit TP

        APPEND <ls_tor_item>-base_btd_logsys TO cs_freight_unit-dlv_item_inb_logsys.	

      ELSE.	

        APPEND '' TO cs_freight_unit-dlv_item_inb_alt_id.	

      ENDIF.	

	

      IF <ls_tor_item>-base_btd_tco     = cs_base_btd_tco_outb_dlv AND	

         <ls_tor_item>-base_btditem_tco = cs_base_btd_tco_delivery_item.	

        APPEND lv_base_btd_alt_item_id TO cs_freight_unit-dlv_item_oub_alt_id.	

        "Add logical system to the freight unit TP

        APPEND <ls_tor_item>-base_btd_logsys TO cs_freight_unit-dlv_item_oub_logsys.	

      ELSE.	

        APPEND '' TO cs_freight_unit-dlv_item_oub_alt_id.	

      ENDIF.	

 

 

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://help.sap.com/docs/SAP_LBN_GTT_OPTION/d0802f41861a4f81a3610d873fdcf148/8fb08ab5e6ca44b6b53343...
https://help.sap.com/docs/SAP_LBN_GTT_OPTION/d0802f41861a4f81a3610d873fdcf148/c667ee93eaa8461da2dcfc...
https://github.com/SAP-samples/logistics-business-network-gtt-standardapps-samples
https://github.com/SAP-samples/logistics-business-network-gtt-standardapps-samples/tree/main/lbn-gtt... 

10 Comments