8

Transportation Management : Read Freight documents from Delivery

 1 year ago
source link: https://blogs.sap.com/2022/07/18/transportation-management-read-freight-documents-from-delivery/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
July 18, 2022 1 minute read

Transportation Management : Read Freight documents from Delivery

3 3 131

Hello Everyone,

This is a very simple blog post but my intention here is to explain simple things to the beginners out there who are struggling and enthusiastic to learn technical side of Transportation Management.

So, lets start with baby steps and today we will learn how to get details of Freight documents linked with any delivery document.

First, understand the flow of documents that are created when we create any delivery. The process is as below:

document%20flow

document flow

  1. When we create any delivery document, Freight unit gets created
  2. Number of the delivery document is saved as label text in the freight unit detail.

Delivery numbers : Lets assume that delivery numbers are stored in an internal table IT_DELIVERY_NUMBER

  • Get an instance of a service manager i,e BO Freight Order
    go_srv_mgr_fo = /bobf/cl_tra_serv_mgr_factory=>get_service_manager
                                      ( /scmtms/if_tor_c=>sc_bo_key ).
  • First step is to create list of Label from the delivery number using below code.
DATA(lt_torlabel_uc) = VALUE /scmtms/t_tor_label
                      ( FOR ls_del IN it_delivery_number
                      ( |{ ls_del ALPHA = OUT }| ) '
                       ).
  • Second step is to get the keys of freight unit by passing label ( which are basically delivery numbers)
    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.
  • Third step is to get Freight Order/Freight booking keys based on Freight unit keys fetched in above step.
    CALL METHOD go_srv_mgr_fo->retrieve_by_association(
    EXPORTING
    iv_node_key         = /scmtms/if_tor_c=>sc_node-root
    it_key              = lt_freightunit_keys
    iv_association      = /scmtms/if_tor_c=>sc_association-root-top_level_tors
    iv_fill_data        = abap_true
    iv_invalidate_cache = abap_true
    IMPORTING
    eo_message          = lo_message
    et_target_key       = lt_tor_key
    et_data             = lt_tor_data ).

Here, lt_tor_key will store the Keys of freight order or freight booking created from the freight unit keys that we passed via lt_freightunit_keys and lt_tor_data will contain the header level details of freight order and freight booking that are fetched.

Since, we have passed iv_fill_data = X, that’s why we are getting the data along with the keys.

Hope you enjoyed reading.

Thank You

Ishani


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK