cancel
Showing results for 
Search instead for 
Did you mean: 

Delete an attachment in freight order

former_member846564
Discoverer
0 Kudos
349

Hi All,

i have code to attach a pdf to freight order as an attachment. now i want to delete an existing attachment before attaching the new attachment. Below is the code for your reference

 IF lo_srv_mgr IS NOT BOUND.
lo_srv_mgr = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( iv_bo_key = /scmtms/if_tor_c=>sc_bo_key ).
ENDIF.

"Get the root instances of the attachment folder node for which the agreement would be created

lo_srv_mgr->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"root_att_folder
iv_fill_data = abap_true
IMPORTING
et_data = lt_atf_root_data
et_target_key = lt_target_key " Data Return Structure
).
/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 ).
/scmtms/cl_common_helper=>get_do_keys_4_action(
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_action_key = /bobf/if_attachment_folder_c=>sc_action-root-create_file
IMPORTING
ev_action_key = lv_do_action_key
).
lo_srv_mgr->retrieve_by_association(
EXPORTING
it_key = lt_target_key
iv_fill_data = abap_true
iv_node_key = lv_do_root_key
iv_association = lv_do_root_to_doc
IMPORTING
et_data = lt_atf_doc_data_bi ).

IF it_tor_root IS NOT INITIAL.
LOOP AT it_tor_root ASSIGNING FIELD-SYMBOL(<ls_tor_root>).
* Delete existing attachements
LOOP AT lt_atf_doc_data_bi ASSIGNING FIELD-SYMBOL(<lfs_atf_doc_data>)
WHERE name CS 'BOL' .
ls_modification-key = <lfs_atf_root_data_1>-key.
ls_modification-association = /scmtms/if_tor_c=>sc_association-root-attachmentfolder.
ls_modification-node = lv_do_root_key.
ls_modification-change_mode = /bobf/if_frw_c=>sc_modify_delete.
ls_modification-source_node = /scmtms/if_tor_c=>sc_node-root.
ls_modification-source_key = <ls_tor_root>-key.
ls_modification-root_key = <ls_tor_root>-key.
APPEND ls_modification TO lt_modification.
CLEAR : ls_modification.
ENDLOOP.
io_modify->do_modify( it_modification = lt_modification ).

Accepted Solutions (0)

Answers (0)