zoukankan      html  css  js  c++  java
  • 如何阻止指定类型的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

    (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(<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.
    

    Activate the BAdI implementation:

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

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

  • 相关阅读:
    虚函数和纯虚函数
    MS CRM 2011中PartyList类型字段的实例化
    MS CRM 2011的自定义与开发(12)——表单脚本扩展开发(4)
    MS CRM 2011的自定义与开发(12)——表单脚本扩展开发(2)
    MS CRM 2011的自定义和开发(10)——CRM web服务介绍(第二部分)——IOrganizationService(二)
    MS CRM 2011 SDK 5.08已经发布
    MS CRM 2011 Q2的一些更新
    最近很忙
    Microsoft Dynamics CRM 2011最近的一些更新
    补一篇,Update Rollup 12 终于发布了
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13420168.html
Copyright © 2011-2022 走看看