Relevance / Motivation
This is mainly intended for Freight Forwarders. Upon Forwarding Order creation the end user does not find the Pickup or Delivery location of the customer (shipper/consignee) and hence just types in the address data in order to create an one-time location. What if the user could find and reuse this address the next time? If you also think that would significantly increase the end users efficiency use this blog post to enhance SAP TM.
In the FWO UI if an end user changes address data of a location or enters address data from scratch, then the system creates a so called one-time-location. The ID is taken from a number range and the location is stored just as a regular location as master data. You can look up and edit the location data in the location master data transaction, but usually Forwarders delete them from the system once not needed anymore. Find more details in Marcus’ MKS-10 about One-Time-Locations .
By the way, one time locations can now also be crated from the fast order entry screen (from TM 9.4 on; note 2420582).
Finding an existing one-time-location takes usually more time than just creating a new one, because a performance intense address search is required using all address data, which the user has to enter. The idea here is to automatically connect the created one time location address to the shipper or consignee BP and when the user wants to find the address in a next order actually all existing locations of the relevant BP are looked up.
There is a BAdI, which allows to enhance a to-be-created one-time-location (BAdI /SCMTMS/OTA_LOCATION_DATA of enhancement spot /SCMTMS/ES_OTA_LOCATION).
The special challenge here is: Which location is about to be created – origin or destination ?
Which BP was entered as Shipper or Consignee?
The enhancement of this blog post is actually another use case for the UI context determination published here. Actually it is also very much recommended to implement the location search enhancement of this blog post first as a prerequisite. Once you create one-time-locations associated to BPs, you also want to find the locations easily – see result section below.
Details about enhancements
In order to be able to determine in your BAdI implementation whether the created one-time-location is an origin or destination location and hence belongs to either the shipper or the consignee, a small implicit enhancement is needed for class /SCMTMS/CL_OTA_LOCATION, method /SCMTMS/IF_OTA_LOCATION~CREATE_OTA_LOCATIONS:
export ota_requests from ct_ota_requests to MEMORY id 'ZSTF_OTL'.
As a next step you implement the BAdI /SCMTMS/OTA_LOCATION_DATA, method /SCMTMS/IF_OTA_LOCATION_DATA~CHANGE_LOCDATA:
You might want to put this code:
DATA: lr_txm TYPE REF TO /bobf/if_tra_transaction_mgr, lr_srvmgr_trq TYPE REF TO /bobf/if_tra_service_manager, ls_key TYPE /bobf/s_frw_key, lt_key TYPE /bobf/t_frw_key, lo_fpm TYPE REF TO if_fpm, ls_fpm_runtime_info TYPE fpm_s_runtime_info, lt_ota_requests TYPE /scmtms/t_otalm, lt_trq_data TYPE /scmtms/t_trq_root_k. FIELD-SYMBOLS: <ls_ota_requests> TYPE /scmtms/s_otalm, <ls_trq_root_data> TYPE /scmtms/s_trq_root_k, <ls_bapi_loc> TYPE /sapapo/bapi_loc, <ls_bapi_locx> TYPE /sapapo/bapi_locx_str. CHECK sy-batch IS INITIAL. READ TABLE ct_bapi_loc ASSIGNING <ls_bapi_loc> INDEX 1. "as this is a single instance creation call CHECK sy-subrc EQ 0. READ TABLE ct_bapi_locx ASSIGNING <ls_bapi_locx> INDEX 1. "as this is a single instance creation call CHECK sy-subrc EQ 0. IMPORT ota_requests TO lt_ota_requests FROM MEMORY ID 'ZSTF_OTL'. READ TABLE lt_ota_requests ASSIGNING <ls_ota_requests> WITH KEY city_name = is_postal_address-city_name street_name = is_postal_address-street_name house_id = is_postal_address-house_id org_name-first_line_name = is_org_name-first_line_name. CHECK sy-subrc EQ 0. * assuming this piece of code is only executed from UI and not in batch mode... (check sy-batch!) lo_fpm = cl_fpm_factory=>get_instance( ). ls_fpm_runtime_info = lo_fpm->get_runtime_info( ). * ... depending from which UI the one time location creation was triggered: IF ls_fpm_runtime_info-config_id = '/SCMTMS/FWD_ORDER_OCEAN'. * retrieve TRQ root data in order to get shipper / consignee BP ID lr_txm = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ). lr_srvmgr_trq = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_trq_c=>sc_bo_key ). ls_key-key = iv_btd_id. APPEND ls_key TO lt_key. CALL METHOD lr_srvmgr_trq->retrieve EXPORTING iv_node_key = /scmtms/if_trq_c=>sc_node-root it_key = lt_key IMPORTING et_data = lt_trq_data. READ TABLE lt_trq_data ASSIGNING <ls_trq_root_data> WITH KEY key = ls_key-key. IF sy-subrc EQ 0. * fill the BP field of the one time location * ... depending on whether it's the pick-up or the delivery location IF <ls_ota_requests>-request_id = 1. "=> source location <ls_bapi_loc>-partner_nr = <ls_trq_root_data>-shipper_id. ELSEIF <ls_ota_requests>-request_id = 2. "=> destination location <ls_bapi_loc>-partner_nr = <ls_trq_root_data>-consignee_id. ENDIF. <ls_bapi_locx>-partner_nr = 'X'. ENDIF. ENDIF.
Result – Screenshots
Once you implemented the enhancement above and the location search enhancement of the other blog post, then the system stores the one time location associated to the right Business Partner and from then on you can reuse the one time location quite easily => by just typing a * into the loc field the system proposes all locations of the BP…
Location search for next order: