Skip to Content
Technical Articles
Author's profile photo Ishani Goel

Transportation Management : Read Freight documents from Delivery

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 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.
  3. In real time, document flow looks like below example:


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
    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
    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(
    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
    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.

Thus, if we pass delivery number as 80000451 in the IT_DELIVERY_NUMBER and execute the code, we will get freight order data as below in internal table LT_TOR_DATA.

(For display purpose, have shown the screenshot of only few fields but its a very big structure )

Hope you enjoyed reading.

Thank You


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Dominik Tylczynski
      Dominik Tylczynski

      Formatting the code correctly will definitely improve readability.

      Author's profile photo Ishani Goel
      Ishani Goel
      Blog Post Author

      Thank you so much for positive feedback, have tried formatting the code. Please let me know how it looks now 😊

      Author's profile photo Dominik Tylczynski
      Dominik Tylczynski

      It's much better now!

      Author's profile photo Norbert Purgal
      Norbert Purgal

      If you use the wrong type, the code will just stop without dumping, which is not very convenient. If someone is struggling with the types to use for certain parameters, please use the following.

      DATA lt_freightunit_keys TYPE /bobf/t_frw_key.
      DATA lt_tor_key TYPE /bobf/t_frw_key.
      DATA lt_tor_data TYPE /scmtms/t_tor_root_k.
      Author's profile photo Ishani Goel
      Ishani Goel
      Blog Post Author

      Thank you so much for sharing this. This is indeed useful for the readers