
export ota_requests from ct_ota_requests to MEMORY id 'ZSTF_OTL'.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |