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

Transportation Management : Get Freight settlement documents using selection options

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 the freight settlement documents using query.

Freight settlement documents are created to perform freight settlement with your suppliers or carriers. In document flow, Freight settlement documents are created after Freight Order/Booking.

Suppose our requirement is to read all the Freight settlement documents which are in status Accruals posted and those are posted in a particular date range.

So, for this , we will create Query selection Options.

  1. Suppose Date specified by user is stored in Internal table GT_FREIGHT_INV_DATE. Thus, we will create a Selection option as below and will set the attribute As invoice date.
    DATA : ls_selopt   TYPE  /bobf/s_frw_query_selparam,
           lt_selopt   TYPE  /bobf/t_frw_query_selparam.
    --- set Invoice date coming from selection to Query selection
        lt_selopt = VALUE #( FOR ls_date IN gt_freight_inv_date
                    ( attribute_name = /scmtms/if_suppfreightinvreq_c=>sc_node_attribute-root-inv_dt 
                     option = ls_date-option
                     sign   = ls_date-sign
                     low    = ls_date-low
                     high   = ls_date-high )
  2. Second Parameter to filter the data is Status of the Freight settlement documents which needs to be accruals posted. So we will add this criteria in the above created selection option using below code :
    *--- set Lifecycle = 04 ((accruals posted)
        APPEND VALUE /bobf/s_frw_query_selparam( attribute_name = /scmtms/if_suppfreightinvreq_c=>sc_query_attribute-root-query_by_elements-lifecycle
     sign =  /bobf/if_conf_c=>sc_sign_option_including
     option = /bobf/if_conf_c=>sc_sign_equal
     low    = gc_lifecycle_accrualsposted  ) TO lt_selopt.
  3. Now Create service manager of type FSD using below code:
    *-- Create service manager
    DATA(lo_srv_mgr_tor) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager
    ( iv_bo_key = /scmtms/if_suppfreightinvreq_c=>sc_bo_key ).
  4. Last step is to execute the query where we will pass the selection option to get the required FSD. We can understand this process as select query with where clause. And in this way, we can fetch any BOBF object data.
    *-- Execute the query
    iv_query_key  = /scmtms/if_suppfreightinvreq_c=>sc_query-root-query_by_elements " Query
    it_selection_parameters =  lt_selopt                                                                  "Query Selection Parameters
    iv_fill_data            = abap_true                                                                   "Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')
          et_data                 = lt_fsd_header_data  "FSD data is here
          et_key                  = DATA(lt_tor_item_key)
          eo_message              = DATA(lo_message)


Hope you enjoyed reading.

Thank You



Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Shreedhar Gangadhar
      Shreedhar Gangadhar

      Thanks for sharing. Very useful