on 07-20-2015 2:24 AM
Hi all,
I want to delete attachment from Z program for RFQ. Program does not dump, but RFQ is not updated. I'm doing where mistake?
Thanks you for your kindly help.
PARAMETERS : p_object TYPE crmd_orderadm_h-object_id DEFAULT '1000009913'.
START-OF-SELECTION.
PERFORM delete_attachments.
*&---------------------------------------------------------------------*
*& Form delete_attachments
*&---------------------------------------------------------------------*
FORM delete_attachments.
DATA : ls_bid_header TYPE bbp_pds_bid_header_d.
DATA : lt_bid_attach TYPE bbpt_pds_att_t.
DATA : wa_bid_attach TYPE LINE OF bbpt_pds_att_t.
DATA : ls_bid_attach TYPE /sapsrm/s_pdo_att.
CALL FUNCTION 'BBP_PD_BID_GETDETAIL'
EXPORTING
i_object_id = p_object
IMPORTING
e_header = ls_bid_header
et_attach = lt_bid_attach.
TRY.
CALL METHOD /sapsrm/cl_pdo_factory_rfq=>get_instance
EXPORTING
iv_header_guid = ls_bid_header-guid
iv_mode = /sapsrm/if_pdo_constants_gen_c=>gc_mode_edit
* iv_mode = /sapsrm/if_pdo_constants_gen_c=>gc_mode_display
IMPORTING
eo_instance = lo_pdo_rfq_adv
eo_message_handler = lo_message_handler.
CATCH /sapsrm/cx_pdo_wf_mode_ban.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_wrong_bus_type.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_pd_read_error.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_lock_failed.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_no_authorizatio.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_parameter_error.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_status_error.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_incons_user.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_abort.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_generic_bid_err.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_error.
lv_error = 'X'.
ENDTRY.
CREATE OBJECT lo_pdo_msg.
lo_message_handler ?= lo_pdo_msg.
IF lv_error NE abap_true.
LOOP AT lt_bid_attach INTO wa_bid_attach.
CLEAR : ls_bid_attach.
MOVE-CORRESPONDING : wa_bid_attach TO ls_bid_attach.
TRY.
CALL METHOD lo_pdo_rfq_adv->/sapsrm/if_pdo_do_attachments~delete_attachment
EXPORTING
is_attach = ls_bid_attach
CHANGING
co_message_handler = lo_message_handler.
CATCH /sapsrm/cx_pdo_abort.
lv_error = 'X'.
CATCH /sapsrm/cx_pdo_error.
lv_error = 'X'.
ENDTRY.
CALL METHOD lo_message_handler->get_messages
IMPORTING
et_messages = lt_pd_messages.
lo_pdo_rfq_adv->/sapsrm/if_pdo_base~submit_update( ).
lo_pdo_rfq_adv->/sapsrm/if_pdo_base~save( ).
* COMMIT WORK AND WAIT.
*
ENDLOOP.
* CALL FUNCTION 'BBP_PROCDOC_SAVE'
* EXPORTING
* iv_header_guid = ls_bid_header-guid
* iv_object_type = 'BUS2200'.
ENDIF.
ENDFORM. "delete_attachmentS
You are did not answer. Thank you.
There are two step for solution.
Step - 1 : You can use below code,
Step - 2 : If you want to physically delete files. Run this program : RS_REMOVE_DEL_ATT_CONTENT ( First run with simulation mode )
PARAMETERS : p_object TYPE crmd_orderadm_h-object_id OBLIGATORY.
START-OF-SELECTION.
PERFORM delete_attachments.
*&---------------------------------------------------------------------*
*& Form delete_attachmentS
*&---------------------------------------------------------------------*
FORM delete_attachments.
DATA : ls_pd_header_u TYPE bbp_pds_bid_header_u.
DATA : ls_header TYPE bbp_pds_bid_header_d.
DATA : lt_attach TYPE bbpt_pds_att_t.
DATA : wa_attach TYPE bbp_pds_att_t.
DATA : lv_changed TYPE xfeld.
CALL FUNCTION 'BBP_PD_BID_GETDETAIL'
EXPORTING
i_object_id = p_object
i_attach_with_doc = 'X'
IMPORTING
e_header = ls_header
et_attach = lt_attach.
MOVE-CORRESPONDING : ls_header TO ls_pd_header_u.
LOOP AT lt_attach INTO wa_attach.
wa_attach-del_ind = 'X'.
MODIFY lt_attach FROM wa_attach.
ENDLOOP.
CALL FUNCTION 'BBP_PD_BID_UPDATE'
EXPORTING
i_save = abap_true
iv_with_change_approval = ' '
i_header = ls_pd_header_u
it_attach = lt_attach
IMPORTING
e_changed = lv_changed.
IF lv_changed = abap_true.
CALL FUNCTION 'BBP_PD_BID_SAVE'
EXPORTING
iv_header_guid = ls_pd_header_u-guid
iv_create_hist_version = abap_false
iv_usertype = 'E'.
ELSE.
*-- Rfx is may be closed for change. İf so lv_changed is null
*-- This method is bad.But it is working correctly
LOOP AT lt_attach INTO wa_attach WHERE del_ind = 'X'.
UPDATE bbp_pdatt SET del_ind = 'X' WHERE guid = wa_attach-guid.
ENDLOOP.
COMMIT WORK AND WAIT.
ENDIF.
ENDFORM. "delete_attachmentS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.