Supply Chain Management Blogs by Members
Learn about SAP SCM software from firsthand experiences of community members. Share your own post and join the conversation about supply chain management.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member204244
Active Participant
3,182
Hello Everyone,

Welcome to the technical series of the SAP Transportation Management where we are aiming to learn basic codes that are used in SAP TM.

In this blog post, we will learn how to get Default Route details from freight unit. The system considers default routes as possible routes for a shipment between two locations.

Request you all to check part1 of the series to understand how to retrieve freight unit details from outbound delivery.

Transportation Management : Read Freight documents from Delivery | SAP Blogs

  • So, delivery numbers are stored in an internal table LT_DELIVERY_NUMBER

  • Create list of Label from the delivery number using below code as Delivery number is stored as label in the freight unit.
    DATA(lt_torlabel_uc) = VALUE /scmtms/t_tor_label
    ( FOR ls_del IN lt_delivery_number
    ( |{ ls_del ALPHA = OUT }| )
    ).​


  • Now retrieve the list of Freight units by passing Label as alternate Key to get the data using below code
    DATA: lt_freightunit_keys  TYPE /bobf/t_frw_key.
    CALL METHOD go_srv_mgr_fo->convert_altern_key
    EXPORTING
    iv_node_key = /scmtms/if_tor_c=>sc_node-root
    iv_altkey_key = /scmtms/if_tor_c=>sc_alternative_key-root-labeltxt
    it_key = lt_torlabel_uc
    IMPORTING
    et_key = lt_freightunit_keys.​


  • Next step is to get the stop data of freight units since default route is maintained in the stop data of the freight unit
    DATA : lt_d_stop_fu TYPE /scmtms/t_tor_stop_k.

    CALL METHOD go_srv_mgr_fo->retrieve_by_association(
    EXPORTING
    it_key = lt_freightunit_keys
    iv_association = /scmtms/if_tor_c=>sc_association-root-stop
    iv_node_key = /scmtms/if_tor_c=>sc_node-root
    iv_fill_data = abap_true
    IMPORTING
    et_data = lt_d_stop_fu
    et_target_key = DATA(lt_target_key_stop) ).​


  • Now we need to get the Route key from Stop data and store it into different internal table that will store only the keys of Default route.
    DATA(lt_def_route_key) = VALUE  /bobf/t_frw_key
    ( FOR ls_stop_data IN lt_d_stop_fu
    ( key = ls_stop_data-route_root_key ) ).


  • Now create an instance of service manager of type Schedule using below code
    DATA(lob_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( 
    /scmtms/if_fo_schedule_c=>sc_bo_key ).


  • Last step is to retrieve the Route( schedule ) header data using route keys and above service manager object.
    CALL METHOD lob_srv_mgr->retrieve(
    EXPORTING
    it_key = lt_def_route_key
    iv_node_key = /scmtms/if_fo_schedule_c=>sc_node-root
    IMPORTING
    eo_message = DATA(lo_message)
    et_data = lt_schedule_data ). " This will have Route data​


  • After passing the required delivery as input, we will get  output as below for schedule data ( which is nothing but header details of default route)Please note this is very big structure however, for display purpose , have showed only few fields.


Hope you enjoyed reading.

Thank you

Ishani

 
3 Comments
Labels in this area