cancel
Showing results for 
Search instead for 
Did you mean: 

Adding an attachement to an execution step

Former Member
0 Kudos

Hello TM Experts,

I am looking for an easy way to add an attachment to an execution step in TM.

Is it possible ?

The goal is to create an event in TM and then push it to EM with the attachment.

The easiest way for the user (if it was possible) would be :

- report an event in the execution tab

- select the document to attach to this event

- the program does the rest

If it is not possible to do it this way, I was thinking about using the  attachment tab:

- The user put an attachment in this tab

- If a new document has been added when the transport document is saved, an event "Document added" is generated.

In this case, can somebody tell me how to access the attachments from abap code?

Thank you for your answers.

Perrine

Accepted Solutions (1)

Accepted Solutions (1)

former_member186607
Active Contributor
0 Kudos

Hi Perrine,

in the model of the business object /SCMTMS/TOR there is already a node available for attachments that are related to a specific execution information - but so far this is not used in the standard and not offered on the UI. For node EXECUTIONINFORMATION there is the subnode EXECUTIONATF, which could be used to persist attachments for a specifc execution information. You would have to build your custom UI for this ( enhance the standard execution tab). It should then be also possible to create your own event extractor that includes the attachment into the event message that is sent from TM to EM. There is an association available to retrieve the attachment data (EXECUTIONINFORMATION-EXECUTIONATF). This will retrieve you the root node of the BO /BOBF/ATTACHMENT_FOLDER which has the nodes ROOT -> DOCUMENT -> FILE_CONTENT. You will then soomehow have to map this into the BAPI structure for sending event message.

I am not aware of anybode who did this already, but it should be possible by enhancing the standard.

Best regards, Daniel

former_member186607
Active Contributor
0 Kudos

I forgot the following: I you want to use the attachments, that can already be added to the freight document on the standard UI (tab Attachments), that should also be possible. These attachments can be retrieved via association ROOT -> ATTACHMENTFOLDER. This leads to root node of BO  /BOBF/ATTACHMENT_FOLDER as described above.

Best regards, Daniel

Former Member
0 Kudos

Hello Daniel,

First of all thank you for your answer, that was what I was looking for.

But in fact, I am quite new in BO manipulations and I have some issues getting my document file content.

I created my service manager based on the class /scmtms/if_tor_c which allows me to retrieve the attachment folder of transportation document.

And then I see that the nodes I need are ine the class /bobf/if_attachment_folder_c and I do not know how to make the link between these two different classes.

Do I have to create a new service manager ? I tried but as the attachment_folder is a dépendent objet it does not seem to work.

Maybe these are some stupid questions, but once again I a new.

Don't hesitate to tell me if it is to complicated to explain here but I can really use some advices

Thank you.

Perrine

bharath_k6
Active Participant
0 Kudos

Dear Perrine,

Check this thread -

SAP Library - BS-FND Reusable Objects for BOPF Environment

If the above links does not solve your issue, answer below questions to help you better.

What kind of attachment you want to send?

Where do you want to keep your document?

Why do you want to create a new service manager?

Thanks,

Bharath.

former_member186607
Active Contributor
0 Kudos

Hi,

please see the below example coding, in which for a given TOR root key

1) first the keys of the node ATTACHMENTFOLDER is retrieved

2) then method /scmtms/cl_common_helper=>get_do_keys_4_rba is called to get the node and association key for the next retrieve

3) which is the retrieve to get the documents

4) and finally another retrieve to get the file content of the attachments available for the TOR.

DATA: lr_srvmgr_tor     TYPE REF TO /bobf/if_tra_service_manager,
      lr_srvmgr_att     TYPE REF TO /bobf/if_tra_service_manager,
      ls_key            TYPE /bobf/s_frw_key,
      lt_key            TYPE /bobf/t_frw_key,
      lt_k_doc          TYPE /bobf/t_frw_key,
      lt_k_attachment   TYPE /bobf/t_frw_key,
      lv_do_root_key    TYPE /bobf/conf_key,
      lv_do_root_to_doc TYPE /bobf/conf_key,
      lt_d_doc          TYPE /bobf/t_atf_document_k,
      lo_srv_lyr        TYPE REF TO /bobf/if_frw_service_layer,
      lt_k_fc           TYPE /bobf/t_frw_key,
      lt_d_fc           TYPE /bobf/t_atf_file_content_k.

lr_srvmgr_tor = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ).
ls_key-key = '005056AC01921ED4B4DCC26C34DD813C'.
INSERT ls_key INTO TABLE lt_key.


CALL METHOD lr_srvmgr_tor->retrieve_by_association
  EXPORTING
    iv_node_key    = /scmtms/if_tor_c=>sc_node-root
    it_key         = lt_key
    iv_association = /scmtms/if_tor_c=>sc_association-root-attachmentfolder
  IMPORTING
    et_target_key  = lt_k_attachment.

/scmtms/cl_common_helper=>get_do_keys_4_rba( EXPORTING iv_host_bo_key      = /scmtms/if_tor_c=>sc_bo_key
                        iv_host_do_node_key = /scmtms/if_tor_c=>sc_node-attachmentfolder
                        iv_do_node_key      = /bobf/if_attachment_folder_c=>sc_node-root
                        iv_do_assoc_key     = /bobf/if_attachment_folder_c=>sc_association-root-document
  IMPORTING ev_node_key         = lv_do_root_key
                       ev_assoc_key        = lv_do_root_to_doc ).

CALL METHOD lr_srvmgr_tor->retrieve_by_association
  EXPORTING
    iv_node_key    = lv_do_root_key
    it_key         = lt_k_attachment
    iv_association = lv_do_root_to_doc
    iv_fill_data   = abap_true
  IMPORTING
    et_target_key  = lt_k_doc
    et_data        = lt_d_doc.

lo_srv_lyr ?= /bobf/cl_frw_factory=>get_bopf( /bobf/if_attachment_folder_c=>sc_bo_key ).
CALL METHOD lo_srv_lyr->retrieve_by_association
  EXPORTING
    iv_node_key    = /bobf/if_attachment_folder_c=>sc_node-document
    it_key         = lt_k_doc
    iv_association = /bobf/if_attachment_folder_c=>sc_association-document-file_content
    iv_fill_data   = abap_true
  IMPORTING
    et_target_key  = lt_k_fc
    et_data        = lt_d_fc.

This should work.

Best regards, Daniel

Former Member
0 Kudos

Thank you Daniel,

It is working fine and then I understand better how to navigate between nodes.

Thank you again.

Perrine

0 Kudos

Thank you very much Daniel

Answers (0)