Hello All,
Can anyone help me how to Update/Modify the PPF document created under the attachment folder for given FO.
As per current process we are currently creating a new Document for every changes at FO level , doing this we are facing lot issues with performance as the Each FO would have atleast 10 documents created.
Can some one help me to update the document which is already generated.
Current logic for creation is below .
METHOD attach_file.
*
CHECK i_keys IS NOT INITIAL.
*
CHECK i_ppf_out IS NOT INITIAL.
DATA: lo_srv_mgr TYPE REF TO /bobf/if_tra_service_manager.
*-----------------------------------------------------------------------
* Local Internal Tables(lt_*)
*-----------------------------------------------------------------------
DATA: lt_tor_root TYPE /scmtms/t_tor_root_k,
lt_tor_items TYPE /scmtms/t_tor_item_tr_k,
lt_tor_items_pkg TYPE /scmtms/t_tor_item_tr_k,
lt_split_info TYPE ztmst_fu_split_data,
lo_txn_mgr TYPE REF TO /bobf/if_tra_transaction_mgr,
lv_changes TYPE char1,
lr_att_root_bo TYPE REF TO /bobf/s_atf_root_k,
lv_do_root_key TYPE /bobf/conf_key,
lv_do_doc TYPE /bobf/conf_key,
lt_doc TYPE /bobf/t_atf_document_k,
lt_target_key TYPE /bobf/t_frw_key,
lo_change TYPE REF TO /bobf/if_tra_change ,
lt_failed_key TYPE /bobf/t_frw_key,
lv_do_action_key TYPE /bobf/conf_key,
lv_updatedoc_key TYPE /bobf/conf_key,
lr_action_param TYPE REF TO /bobf/s_atf_a_create_file,
lt_doc_manifest TYPE /bobf/t_atf_document_k,
ls_doc_man_last TYPE /bobf/s_atf_document_k,
ls_modification TYPE /bobf/s_frw_modification,
lt_modification TYPE /bobf/t_frw_modification,
lo_message TYPE REF TO /bobf/if_frw_message,
lt_key TYPE /bobf/t_frw_key,
lv_name_old TYPE string,
lv_name_new TYPE string,
lv_name_first TYPE string,
lv_name_version TYPE string,
lv_full_name TYPE string,
lv_version TYPE i,
lv_versions TYPE i.
DATA: lv_rejected.
*-----------------------------------------------------------------------
* Local Work Areas(ls_*)
*-----------------------------------------------------------------------
DATA: ls_key TYPE /bobf/s_frw_key.
*-----------------------------------------------------------------------
* Local Variables(lv_*)
*-----------------------------------------------------------------------
* Field Symbols(<*>
*-----------------------------------------------------------------------
FIELD-SYMBOLS: <fs_tor_root> TYPE /scmtms/s_tor_root_k.
CONSTANTS: lc_underscore(2) TYPE c VALUE '_V'.
*-----------------------------------------------------------------------
* Get the required service manager instances
*-----------------------------------------------------------------------
lo_srv_mgr = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( /scmtms/if_tor_c=>sc_bo_key ).
lo_txn_mgr = /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( ).
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
lt_key = i_keys.
lo_srv_mgr->retrieve(
EXPORTING
iv_node_key = /scmtms/if_tor_c=>sc_node-root
it_key = lt_key
iv_edit_mode = 2
iv_fill_data = abap_true
IMPORTING
et_data = lt_tor_root ).
CLEAR: lv_changes.
LOOP AT lt_tor_root ASSIGNING <fs_tor_root> .
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
CLEAR: ls_key, lt_key.
ls_key-key = <fs_tor_root>-key.
INSERT ls_key INTO TABLE lt_key.
/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_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 ).
*----------------------------------------------------------------------
CREATE DATA lr_att_root_bo.
lr_att_root_bo->key = /bobf/cl_frw_factory=>get_new_key( ).
lr_att_root_bo->host_bo_key = /scmtms/if_tor_c=>sc_bo_key.
lr_att_root_bo->host_node_key = /scmtms/if_tor_c=>sc_node-attachmentfolder.
lr_att_root_bo->host_key = ls_key-key.
lr_att_root_bo->att_schema = 'DEFAULT'.
ls_modification-key = lr_att_root_bo->key.
ls_modification-change_mode = /bobf/if_frw_c=>sc_modify_create.
ls_modification-node = lv_do_root_key.
ls_modification-data = lr_att_root_bo.
ls_modification-association = /scmtms/if_tor_c=>sc_association-root-attachmentfolder.
ls_modification-source_node = /scmtms/if_tor_c=>sc_node-root.
ls_modification-source_key = ls_key-key.
APPEND ls_modification TO lt_modification.
*
lo_srv_mgr->modify(
EXPORTING
it_modification = lt_modification
IMPORTING
eo_message = lo_message
).
CLEAR lt_modification.
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
IMPORTING
eo_message = lo_message
et_target_key = lt_target_key
).
lo_srv_mgr->retrieve_by_association(
EXPORTING
iv_node_key = /scmtms/if_tor_c=>sc_node-attachmentfolder
it_key = lt_target_key
iv_fill_data = abap_true
iv_association = lv_do_doc
IMPORTING
eo_message = lo_message
et_data = lt_doc
).
CREATE DATA lr_action_param.
*----------------------------------------------------------------------
* Logic for document versioning
*----------------------------------------------------------------------
CLEAR : lv_name_old, lv_name_new, lv_name_first, lv_name_version, lv_full_name, lv_version.
IF lt_doc IS NOT INITIAL.
lt_doc_manifest = lt_doc.
DELETE lt_doc_manifest WHERE attachment_type <> text-003.
SORT lt_doc_manifest BY datetime_cr DESCENDING.
READ TABLE lt_doc_manifest INTO ls_doc_man_last INDEX 1.
lv_name_old = ls_doc_man_last-name.
SPLIT lv_name_old AT lc_underscore INTO lv_name_first lv_name_version.
lv_version = lv_name_version.
lv_version = lv_version + 1.
ELSE.
lv_name_first = text-001.
lv_version = 1.
ENDIF.
lv_name_new = lv_event_code && lc_underscore && lv_version .
lv_full_name = lv_name_new && text-002.
lr_action_param->name = lv_name_new.
lr_action_param->description_language_code = ycl_tms_fo_attachment=>i_ppf_out-langu.
lr_action_param->attachment_type = text-003.
lr_action_param->description_content = lv_name_new.
lr_action_param->alternative_name = lv_full_name.
lr_action_param->mime_code = text-004.
lr_action_param->file_name = lv_full_name.
IF i_ppf_out-pdf IS NOT INITIAL.
lr_action_param->content = i_ppf_out-pdf.
ENDIF.
IF lv_versions <= 2.
lr_action_param->visibility_type = 'X'.
ENDIF.
CLEAR lt_key.
ls_key-key = lr_att_root_bo->key.
APPEND ls_key TO lt_key.
*----------------------------------------------------------------------
* Do Action Create a file
*----------------------------------------------------------------------
lo_srv_mgr->do_action(
EXPORTING
iv_act_key = lv_do_action_key
it_key = lt_key
is_parameters = lr_action_param
IMPORTING
eo_change = lo_change
eo_message = lo_message
et_failed_key = lt_failed_key
).
ENDLOOP.
ENDMETHOD.
Regards
Kiran Kumar P.