Fig 1. Business Object /SCMTMS/TRQ
*************************************************************************
* Coding 1 - read items of root
* Navigate within a BO from one node to another
*************************************************************************
DATA: ls_key TYPE /bobf/s_frw_key,
lt_key TYPE /bobf/t_frw_key,
lt_item type /SCMTMS/T_TRQ_ITEM_K,
lo_message TYPE REF TO /bobf/if_frw_message.
* Make instance of BO TRQ
DATA(lo_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(
/scmtms/if_trq_c=>sc_bo_key ).
* Sample root key of BO TRQ
ls_key-key = '0050568176441ED2A1FDA55C17A3E60F'.
APPEND ls_key TO lt_key.
* Retrieve item data
lo_srv_mgr->retrieve_by_association(
EXPORTING
iv_node_key = /scmtms/if_trq_c=>sc_node-root
it_key = lt_key
iv_association = /scmtms/if_trq_c=>sc_association-root-item
iv_fill_data = abap_true
iv_edit_mode = /bobf/if_conf_c=>sc_edit_read_only
IMPORTING
eo_message = lo_message
et_data = lt_item ).
Fig 2. Coding 1 - Retrieve_by_association
Fig 3. Delegation class of node ORDPTYADDRESS
Fig 4. Delegation class of node ORDPTYADDRESS
*************************************************************************
* Coding 2 - read postal address of DO
* Navigate from BO to node data of a DO
*************************************************************************
DATA: ls_key TYPE /bobf/s_frw_key,
lt_key TYPE /bobf/t_frw_key,
lt_target_key TYPE /bobf/t_frw_key,
lt_data TYPE /BOFU/T_ADDR_POSTAL_ADDRESSK,
lo_message TYPE REF TO /bobf/if_frw_message.
* Make instance of BO TRQ
DATA(lo_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(
/scmtms/if_trq_c=>sc_bo_key ).
DATA(lo_frw_conf) = /bobf/cl_frw_factory=>get_configuration(
iv_bo_key = /scmtms/if_trq_c=>sc_bo_key ).
* Sample root key of BO TRQ
ls_key-key = '0050568176441ED2A1FDA55C17A3E60F'.
APPEND ls_key TO lt_key.
* Set nodes and association
DATA(lv_root_node) = /scmtms/if_trq_c=>sc_node-root.
DATA(lv_target_node) = /scmtms/if_trq_c=>sc_node-ordptyaddress.
DATA(lv_association) = /scmtms/if_trq_c=>sc_association-root-ordptyaddress.
DATA(lv_do_assoc_key) = /bofu/if_addr_constants=>sc_association-root-postal_address.
* Word - blacklist warning!!!
* Hey - I didn't wrote the word a_s_s!!!! 😉 - ok let's try it like this:
DATA(lv_content_cat) = /bobf/if_conf_c=>sc_content_a$$.
* Read association key of target node
*/SMCTMS/TRQ-ROOT -> /BOFU/ADDRESS-ROOT-POSTAL_ADDRESS"
DATA(lv_assoc_key) = lo_frw_conf->get_content_key_mapping(
iv_content_cat = lv_content_cat
iv_do_content_key = lv_do_assoc_key
iv_do_root_node_key = lv_target_node ).
* read target key(s)
lo_srv_mgr->retrieve_by_association(
EXPORTING
iv_node_key = lv_root_node
it_key = lt_key
iv_association = lv_association
IMPORTING
et_target_key = lt_target_key ).
* Retrieve data of node ordptyaddress
lo_srv_mgr->retrieve_by_association(
EXPORTING
iv_node_key = lv_target_node "Here we have to use the target node as node key
it_key = lt_target_key "...and the target key as key
iv_association = lv_assoc_key "...and the mapped association key
iv_fill_data = abap_true
IMPORTING
eo_message = lo_message
et_data = lt_data ).
Fig 5. Coding 2 - get_content_key_mapping
Fig 6. Test /SCMTMS/TOR with BOBT transaction
Fig 7. Reading associations with BOBT transaction
Fig 8. Structure /SCMTMS/S_FRGHT_AGREEMENT_UUID
*&---------------------------------------------------------------*
*& Report ZREP_DC_TEST
*&---------------------------------------------------------------*
*& This report demonstrates the usage of a Data Crawler Profile to
*& read and retrieve data from a business object.
*&---------------------------------------------------------------*
REPORT zrep_dc_test.
DATA: ls_dc_prof_id TYPE /scmtms/dc_profile_id,
lt_dc_prof_id TYPE /scmtms/t_dc_profile_id,
ls_bo_inst_key TYPE /bobf/s_frw_key,
lt_bo_inst_key TYPE /bobf/t_frw_key,
lo_crawler TYPE REF TO /scmtms/cl_data_crawler,
lt_dc_data TYPE /scmtms/cl_data_crawler=>tt_data,
lo_message TYPE REF TO /bobf/if_frw_message.
CLEAR: ls_dc_prof_id, lt_dc_prof_id.
* Secify the Data Crawler Profile to be used
ls_dc_prof_id = 'ZENH_TRQ_ITEM'.
APPEND ls_dc_prof_id TO lt_dc_prof_id.
* Specify the key of an example BO instance (here: a TRQ instance)
ls_bo_inst_key-key = '4D08C2BEC9015E16E10000000A421A6A'.
APPEND ls_bo_inst_key TO lt_bo_inst_key.
* Create an instance of the Data Crawler class
CREATE OBJECT lo_crawler EXPORTING it_profile_id = lt_dc_prof_id.
* Call the Data Crawler with the given profile and BO instance
CALL METHOD lo_crawler->get_data
EXPORTING
it_profile_id = lt_dc_prof_id
it_key = lt_bo_inst_key
IMPORTING
et_data = lt_dc_data
eo_message = lo_message.
* The resulting data can be found in LT_DC_DATA
Fig 9. Coding 3 - Using data crawler to read data
[Source: SAP Transportation Management 9.x™ - Enhancement Guide Page 108]
Fig 10. Path steps configuration in data crawler profile
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |