cancel
Showing results for 
Search instead for 
Did you mean: 

How to update a link in the attachment folder of a freight order in TM from ECC?

0 Kudos

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.

Accepted Solutions (0)

Answers (5)

Answers (5)

former_member841251
Discoverer
0 Kudos

Hello, I was able to do it with an action, attached program example:

zzurl.txt

Best regards,

former_member763339
Discoverer
0 Kudos

Hello Team,

I am facing same issue is the issue resolved??

I had tried using the create Link action but I am facing same issue.

When I tried from UI its working but its calling same action.

So I am trying same from program but not working.

lref_srvmgr->do_action(
EXPORTING
iv_act_key = lv_act_key " Action
it_key = lt_tor_key " Key Table
is_parameters = lr_act_pat " Action
IMPORTING
* eo_change = " Interface of Change Object
eo_message = DATA(lo_message) " Interface of Message Object
et_failed_key = DATA(lt_faile_key) " Key Table
* et_failed_action_key = " Key Table
* ev_static_action_failed =
* et_data =
* et_data_link =
).

Regards,

rishilal061
Explorer
0 Kudos

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

0 Kudos

Hi Rajiv,

Thanks a lot for your inputs and the source code.

I tried executing the same and it did work for me but with an issue : - A record did got created in the attachment folder of the forwarding order but with a blank URL field. I am not able to figure out the exact reason for the same. The same thing is happening for the Freight order too. Is there anything which is missing in the config or any authorization issue?

Please help.

Regards,

Manish

former_member245015
Discoverer
0 Kudos

hi.

I am having a problem like this. Have you solved this problem?

rajiv_kanoria
Explorer
0 Kudos

Please find the sample code below.


DATA : lref_srvmgr   TYPE REF TO /bobf/if_tra_service_manager,

       lref_message  TYPE REF TO /bobf/if_frw_message,

       lref_trans    TYPE REF TO /bobf/if_tra_transaction_mgr,

       ls_key        TYPE /bobf/s_frw_key,

       lt_key        TYPE /bobf/t_frw_key,

       lt_trq_root   TYPE /scmtms/t_trq_root_k,

       lt_target_key TYPE /bobf/t_frw_key,

       lt_failed_key TYPE /bobf/t_frw_key,

       lt_item       TYPE /scmtms/t_trq_item_k,

       lt_item_db    TYPE /scmtms/t_trq_item_k,

       lt_key_link   TYPE /bobf/t_frw_key_link.







"Get Service Manager

CALL METHOD /bobf/cl_tra_serv_mgr_factory=>get_service_manager

  EXPORTING

    iv_bo_key          = /scmtms/if_trq_c=>sc_bo_key

  RECEIVING

    eo_service_manager = lref_srvmgr.





ls_key-key = '005056BA65A31ED692977687566553C0'.

APPEND ls_key TO lt_key.





"Retrieve

*lref_srvmgr->retrieve(

*  EXPORTING

*    iv_node_key             = /scmtms/if_trq_c=>sc_node-root    " Node

*    it_key                  = lt_key    " Key Table

**    iv_before_image         = ABAP_FALSE    " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')

**    iv_edit_mode            =     " Change Mode

*    iv_fill_data            = abap_true    " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')

**    iv_invalidate_cache     = ABAP_FALSE    " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')

**    it_requested_attributes =     " List of Names (e.g. Fieldnames)

*  IMPORTING

**    eo_message              =     " Interface of Message Object

**    eo_change               =     " Interface of Change Object

*    et_data                 =  lt_trq_root

*    et_failed_key           =  lt_failed_key   " Key Table

*).

*"Retrieve By Association

lref_srvmgr->retrieve_by_association(

  EXPORTING

    iv_node_key             = /scmtms/if_trq_c=>sc_node-root    " Node

    it_key                  = lt_key    " Key Table

    iv_association          = /scmtms/if_trq_c=>sc_association-root-attachmentfolder    " Association

*    is_parameters           =

*    it_filtered_attributes  =

    iv_fill_data            = abap_false   " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')

    iv_before_image         = abap_false    " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')

*    iv_invalidate_cache     = ABAP_FALSE    " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')

*    iv_edit_mode            =     " Change Mode

*    it_requested_attributes =     " List of Names (e.g. Fieldnames)

  IMPORTING

*    eo_message              =     " Interface of Message Object

*    eo_change               =     " Interface of Change Object

*    et_data                 =

*    et_key_link             = lt_key_link    " Key Link

    et_target_key           =  lt_target_key   " Key Table  "This is Key for Attachment folders  DO if created. If Not created you need to create it

*    et_failed_key           =     " Key Table

).





DATA : lr_root TYPE REF TO /bobf/s_atf_root_k.

DATA : lr_doc TYPE REF TO /bobf/s_atf_document_k.

DATA : lv_rej TYPE boolean.

DATA(lo_tra) = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).

DATA : lt_mod TYPE /bobf/t_frw_modification.

DATA: lv_root_key TYPE /bobf/conf_key.



IF lt_target_key IS INITIAL. " IF no attachement has been created yet.This will be empty.. we need to create now.



  CREATE DATA lr_root.

  lr_root->key             = /bobf/cl_frw_factory=>get_new_key( ).

  lr_root->host_bo_key     = /scmtms/if_trq_c=>sc_bo_key.

  lr_root->host_node_key   = /scmtms/if_trq_c=>sc_node-root.

  lr_root->host_key        = ls_key-key.

  INSERT VALUE #(

    change_mode = /bobf/if_frw_c=>sc_modify_create

    key         = lr_root->key

    data        = lr_root

    node        = /scmtms/if_trq_c=>sc_node-attachmentfolder

    association = /scmtms/if_trq_c=>sc_association-root-attachmentfolder

    source_node = /scmtms/if_trq_c=>sc_node-root

    source_key  = ls_key-key ) INTO TABLE lt_mod.



  lref_srvmgr->modify(

    EXPORTING

      it_modification =  lt_mod   " Changes

    IMPORTING

      eo_change       = DATA(lr_change)    " Interface of Change Object

      eo_message      = DATA(lr_msg)   " Interface of Message Object

      ).



  lo_tra->save(

*  EXPORTING

*    iv_transaction_pattern = /BOBF/IF_TRA_C=>GC_TP_SAVE_AND_CONTINUE    " Data element for a transaction pattern

    IMPORTING

      ev_rejected            =  lv_rej   " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')

*    eo_change              =     " Interface for transaction change objects

*    eo_message             =     " Interface of Message Object

*    et_rejecting_bo_key    =     " Key table

  ).

  CLEAR lt_mod.

ENDIF.

DATA: ls_root_key TYPE /bobf/s_frw_key.



IF lt_target_key IS INITIAL.

  lv_root_key = lr_root->key.

ELSE.

  READ TABLE lt_target_key INTO ls_root_key INDEX 1.

  lv_root_key = ls_root_key-key.

ENDIF.







" Above data is for Root.



" Now we need to create DOCUMENT Node for which we need runtime keys

DATA : lv_attachment_node_do_key    TYPE /bobf/obm_node_key,

       lv_attachment_node_assoc_key TYPE /bobf/obm_assoc_key,

       lv_attachment_node_root_key  TYPE /bobf/obm_node_key.



/scmtms/cl_common_helper=>get_do_keys_4_rba(

   EXPORTING

     iv_host_bo_key      = /scmtms/if_trq_c=>sc_bo_key

     iv_host_do_node_key = /scmtms/if_trq_c=>sc_node-attachmentfolder

     iv_do_node_key      = /bobf/if_attachment_folder_c=>sc_node-root

   IMPORTING

     ev_node_key         = lv_attachment_node_root_key ).





/scmtms/cl_common_helper=>get_do_keys_4_rba(

    EXPORTING

      iv_host_bo_key = /scmtms/if_trq_c=>sc_bo_key

      iv_host_do_node_key = /scmtms/if_trq_c=>sc_node-attachmentfolder

      iv_do_node_key = /bobf/if_attachment_folder_c=>sc_node-document

      iv_do_assoc_key = /bobf/if_attachment_folder_c=>sc_association-root-document

      IMPORTING

        ev_node_key = lv_attachment_node_do_key             "this is runtime Do Key for Attachement root

        ev_assoc_key = lv_attachment_node_assoc_key         "This is runtime association key for Attachement root to Doccument node.

                 ).







CREATE DATA lr_doc.

lr_doc->key        = /bobf/cl_frw_factory=>get_new_key( ).

lr_doc->parent_key = lv_root_key.

lr_doc->root_key = ls_key-key.

lr_doc->name = 'URL'.

lr_doc->alternative_name = 'URL'.

lr_doc->attachment_type = 'LINK'.

lr_doc->external_link_web_uri = 'https://testurl.com'.



INSERT VALUE #(

 change_mode = /bobf/if_frw_c=>sc_modify_create

 key         = lr_doc->key

 data        = lr_doc

 node        = lv_attachment_node_do_key

 association = lv_attachment_node_assoc_key

 source_node = lv_attachment_node_root_key

 source_key  = lv_root_key ) INTO TABLE lt_mod.





lref_srvmgr->modify(

    EXPORTING

      it_modification =  lt_mod   " Changes

    IMPORTING

      eo_change       = lr_change    " Interface of Change Object

      eo_message      = lr_msg   " Interface of Message Object

      ).





lo_tra->save(

*  EXPORTING

*    iv_transaction_pattern = /BOBF/IF_TRA_C=>GC_TP_SAVE_AND_CONTINUE    " Data element for a transaction pattern

  IMPORTING

    ev_rejected            =  lv_rej   " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')

*    eo_change              =     " Interface for transaction change objects

*    eo_message             =     " Interface of Message Object

*    et_rejecting_bo_key    =     " Key table

).





Madjid
Participant
0 Kudos

hi

in the first helper method

/scmtms/cl_common_helper=>get_do_keys_4_rba(
   EXPORTING
     iv_host_bo_key      = /scmtms/if_trq_c=>sc_bo_key
     iv_host_do_node_key = /scmtms/if_trq_c=>sc_node-attachmentfolder
     iv_do_node_key      = /bobf/if_attachment_folder_c=>sc_node-root
   IMPORTING
     ev_node_key         = lv_attachment_node_root_key ).

the return value "lv_attachment_node_root_key" and host do node key "/scmtms/if_trq_c=>sc_node-attachmentfolder" are equals

maybe not need use this method