on 2019 Jul 08 9:04 AM
Hello Everyone,
I have a requirement to update a link in the attachment folder of a fright order in TM from ECC using inbound proxy.
I have tried first to test out a sample code to update the attachment folder in a FO.
Below is the code :
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 /BOBF/T_ATF_DOCUMENT_K,
lo_message TYPE REF TO /bobf/if_frw_message.
DATA: lref_srvmgr_tor TYPE REF TO /bobf/if_tra_service_manager,
lt_doc TYPE TABLE OF /bobf/s_atf_document_k,
lref_doc TYPE REF TO /bobf/s_atf_document_k,
root_key TYPE /bobf/conf_key,
lt_mod TYPE /bobf/t_frw_modification,
lref_change TYPE REF TO /bobf/if_tra_change,
lref_message TYPE REF TO /bobf/if_frw_message,
lt_failed_key TYPE /bobf/t_frw_key,
lt_doc_trkey TYPE /bobf/t_frw_key,
lo_chg TYPE REF TO /bobf/if_tra_change,
lo_msg_all TYPE REF TO /bobf/if_frw_message,
lo_tra TYPE REF TO /bobf/if_tra_transaction_mgr,
lv_rejected TYPE abap_bool,
lt_rej_bo_key TYPE /bobf/t_frw_key2,
lt_tor_source TYPE /bobf/t_atf_root_k,
lv_text_assoc_key TYPE /bobf/conf_key.
FIELD-SYMBOLS: <ls_item> TYPE /scmtms/s_tor_root_k,
<ls_modification> TYPE /bobf/s_frw_modification,
<lfs_attach> TYPE /bobf/s_atf_root_k,
<lfs_root_key> TYPE /bobf/s_frw_key.
* Make instance of BO TOR
DATA(lo_srv_mgr) = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(
/scmtms/if_tor_c=>sc_bo_key ).
DATA(lo_frw_conf) = /bobf/cl_frw_factory=>get_configuration(
iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ).
* Sample root key of BO Tor
ls_key-key = '022AB6755DFC1EE9A4D2D7496D17CC26'.
APPEND ls_key TO lt_key.
* Set nodes and association
DATA(lv_root_node) = /scmtms/if_tor_c=>sc_node-root.
DATA(lv_target_node) = /scmtms/if_tor_c=>sc_node-ATTACHMENTFOLDER.
DATA(lv_association) = /scmtms/if_tor_c=>sc_association-root-ATTACHMENTFOLDER.
DATA(lv_do_assoc_key) = /BOBF/IF_ATTACHMENT_FOLDER_C=>sc_association-root-document.
* Word - blacklist warning!!!
* 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
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 attachment folder
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 ).
** Now create a new link in the folder
read table lt_target_key into data(lw_attach_key) index 1.
data(lv_attach_key) = lw_attach_key-key.
APPEND INITIAL LINE TO lt_doc REFERENCE INTO lref_doc.
lref_doc->key = lo_srv_mgr->get_new_key( ).
lref_doc->parent_key = lv_attach_key.
lref_doc->root_key = ls_key-key.
lref_doc->name = 'URL'.
lref_doc->alternative_name = 'URL'.
*lref_doc->schema = 'DEFAULT'.
lref_doc->attachment_type = 'LINK'.
lref_doc->external_link_web_uri = 'https://testurl.com'.
*
/scmtms/cl_mod_helper=>mod_create_single(
EXPORTING
is_data = lref_doc->*
iv_node = /scmtms/if_tor_c=>sc_node-attachmentfolder
iv_key = lref_doc->key
iv_root_key = lref_doc->root_key
iv_association = lv_assoc_key
iv_source_node = /scmtms/if_tor_c=>sc_node-root
iv_parent_key = lref_doc->parent_key
IMPORTING
es_mod = DATA(ls_modification) ).
*
APPEND ls_modification TO lt_mod.
CLEAR ls_modification.
READ TABLE lt_mod ASSIGNING FIELD-SYMBOL(<lfs_mod>) INDEX 1.
IF sy-subrc = 0.
<lfs_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.
ENDIF.
APPEND INITIAL LINE TO lt_doc_trkey ASSIGNING FIELD-SYMBOL(<lfs_doc_tr_key>).
<lfs_doc_tr_key>-key = lref_doc->key.
IF lt_mod IS NOT INITIAL.
lo_srv_mgr->modify(
EXPORTING
it_modification = lt_mod ).
ENDIF.
*"Report the event
lo_srv_mgr->do_action(
EXPORTING
it_key = lt_doc_trkey
iv_act_key = /BOBF/IF_ATTACHMENT_FOLDER_C=>sc_association-root-document "'483ED376A4351B4EE10000000A42172E'
IMPORTING
et_failed_key = lt_failed_key
eo_change = lref_change
eo_message = lref_message ).
lo_tra = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).
lo_tra->save(
IMPORTING ev_rejected = lv_rejected
eo_change = lo_chg
eo_message = lo_message
et_rejecting_bo_key = lt_rej_bo_key ).
but i am getting a dump while performing "DO_ACTION".If i skip that part, the attachment folder doesnt get updated.
Can you please help me with the same.
Request clarification before answering.
Hi ,
I am also having same problem , data is getting updated in attachment folder , but the link is not getting updated , how we can solve it ?
any help is appreciated
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
6 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.