怎么阻止指定類型的SAP CRM附件被上傳到服務器,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
要求:不允許最終用戶上載大小大于給定限制(例如400KB)的附件。
解決方案:
(1) 通過SPRO->客戶關系管理->基本功能->內容管理->業務加載項->
更改文件的確認

(2) 將以下源代碼復制到BAdI實現。有關代碼詳細信息,請參閱每行的注釋。
METHOD if_ex_crm_documents~carry_out_action. CONSTANTS: cv_max_size TYPE int4 VALUE 409600. "400KB DATA: lt_loios TYPE skwf_ios, ls_error TYPE skwf_error, lv_size TYPE sdok_fsize, lt_badios TYPE skwf_ioerrs. READ TABLE changed_documents ASSIGNING FIELD-SYMBOL(<first_line>) INDEX 1. CHECK sy-subrc = 0. " The badi implementation will be called whenever there is change on attachment ( create, update and delete), since it is necessary to filter out the change " mode CHECK <first_line>-action = 'CREATE_DOCUMENT'. DATA(ls_bo) = VALUE sibflporb( instid = <first_line>-instidbor typeid = <first_line>-typeidbor catid = <first_line>-catidbor ). DATA(ls_loios) = VALUE skwf_io( objtype = <first_line>-objtype class = <first_line>-class objid = <first_line>-objid ). APPEND ls_loios TO lt_loios. CALL METHOD cl_crm_documents=>get_file_info EXPORTING loio = ls_loios IMPORTING file_size = lv_size. CHECK lv_size >= cv_max_size. " Since this BAdI implementation could only be called after the attachment is created, so technically speaking we could not prevent the attachment creation indeed, but could only delete the attachment after its creation CALL METHOD cl_crm_documents=>delete EXPORTING business_object = ls_bo ios = lt_loios IMPORTING bad_ios = lt_badios error = ls_error. COMMIT WORK AND WAIT. " raise an error message to prompt user to upload the attachment with smaller size lo_service->add_message( EXPORTING iv_msg_type = 'E' iv_msg_id = 'ZCM_JERRY_TEST' iv_msg_number = '000' ). ENDMETHOD.
激活BAdI實現:

現在,如果上傳的附件超過400KB,最終用戶將在UI中看到錯誤消息。

看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。