sap挂附件到文档服务器,如何阻止指定类型的SAP CRM附件被上传到服务器

Requirement: end user could not be allowed to upload attachment whose size is greater than a given limit for example 400KB.

Solution:

(1) Create a BAdI implementation via SPRO->Customer Relationship Management->Basic Functions->Content Management->Business Add-Ins->

Confirmation of Changed Documents

00f66de290d5

(2) copy the following source code to BAdI Implementation. For code detail please refer to comment for each line.

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() 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 -action = 'CREATE_DOCUMENT'.

DATA(ls_bo) = VALUE sibflporb( instid = -instidbor

typeid = -typeidbor

catid = -catidbor ).

DATA(ls_loios) = VALUE skwf_io( objtype = -objtype class = -class objid = -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.

Activate the BAdI implementation:

00f66de290d5

Now if an attachment is uploaded which exceeds 400KB, the end user will see an error message in UI.

00f66de290d5

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

00f66de290d5

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值