zoukankan      html  css  js  c++  java
  • 动态控制SAP CRM附件的可编辑性

    In production code it is ususally necessary to also have authorization control on attachment maintenance.
    Most of the time it is done via authorization object.
    In this example I just use a checkbox to control it during the whole session, in the screenshot below all buttons are disable since the “Allow Edit” checkbox is not selected.

    The idea of control is, in GS_CM component controller there is a value node ATTRIBUTES which could be bound by consuming component.

    in the controller class below, Content management framework will firstly check whether the current BOR type is valid ( line 13 ~ line 18), an invalid type will lead to read only mode.

    then the display mode flag will be set according to the field display of value node.
    based on these findings, we can start development in our ui component.

    step1:
    create an event handler for checkbox status change and just use a global variable to store the flag:

    step2:
    create a new value node ATTRIBUTE in custom controller

    redefine INIT.
    here we buffer the collection wrapper reference into a global variable of component controller for later usage.

     method IF_BSP_MODEL~INIT.
      super->if_bsp_model~init( id    = id
                                owner = owner ).
      mr_owner ?= owner.
      DATA: lv_struct_ref TYPE REF TO crmt_cm_comp_st,
            lv_value_node TYPE REF TO cl_bsp_wd_value_node,
            lv_bo_coll    TYPE REF TO if_bol_bo_col.
      CREATE DATA lv_struct_ref.
      CREATE OBJECT lv_value_node
        EXPORTING
          iv_data_ref = lv_struct_ref.
      CREATE OBJECT lv_bo_coll
        TYPE
          cl_crm_bol_bo_col.
      lv_bo_coll->add( lv_value_node ).
      set_collection( lv_bo_coll ).
      CL_ZSMCATT_BSPWDCOMPONENT_IMPL=>GO_ATTR_WRAPPER = me->collection_wrapper.
      endmethod.
    

    redefine ON_NEW_FOCUS. The bufferred collection wrapper for ATTRIBUTE node is used here:

     method ON_NEW_FOCUS.
         DATA:
         lr_entity          TYPE REF TO cl_crm_bol_entity,
         lr_parent          TYPE REF TO cl_crm_bol_entity,
         lv_entity_name     TYPE string,
         ls_cm_attr         TYPE crmt_cm_comp_st,
         lv_product_type    TYPE comt_product_type,
         lr_bo_attr         TYPE REF TO if_bol_bo_property_access,
         ls_prtyp_cust      TYPE coms_prtyp_cust,
         lv_object_guid     TYPE ib_recno_16,
         lv_current         TYPE flag,
         ls_button          TYPE crmt_thtmlb_button.
      CHECK focus_bo IS BOUND.
      lr_entity ?= focus_bo.
      lv_entity_name = lr_entity->get_name( ).
      IF CL_ZSMCATT_BSPWDCOMPONENT_IMPL=>gv_can_edit = 'X'.
        ls_cm_attr-display = ''.
      ELSE.
        ls_cm_attr-display = 'X'.
      ENDIF.
      CHECK CL_ZSMCATT_BSPWDCOMPONENT_IMPL=>GO_ATTR_WRAPPER IS NOT INITIAL.
      lr_bo_attr = CL_ZSMCATT_BSPWDCOMPONENT_IMPL=>GO_ATTR_WRAPPER->get_current( ).
      CHECK lr_bo_attr IS BOUND.
      lr_bo_attr->set_properties( ls_cm_attr ).
      endmethod.
    

    step3:
    in WD_USAGE_INITIALIZE method of ZSMCATTR component controller, bind the context node of custom controller to GS_CM’s attributes node.

    CALL METHOD iv_usage->bind_context_node
            EXPORTING
              iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
              iv_name             = 'ZSMCATT/CMBO'
              iv_target_node_name = 'ATTRIBUTE'                "#EC NOTEXT
              iv_node_2_bind      = 'ATTRIBUTES'.                "#EC NOTEXT
    lr_cuco_attachement ?= get_custom_controller( 'ZSMCATT/CMBO' ).
    IF lr_cuco_attachement IS BOUND.
            lr_property = me>typed_context->socialpost->collection_wrapper->get_current( ).
            lr_cuco_attachement->typed_context->cmbo->on_new_focus( lr_property ).
            lr_cuco_attachement->typed_context->attribute->on_new_focus( lr_property ).
    ENDIF. 
    

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

  • 相关阅读:
    Atitti  css   transition Animation differ区别
    Atitit 游戏引擎物理系统(1)爆炸效果
    Atitit.rsa密钥生成器的attilax总结
    新特性AAtitti css3 新特性attilax总结titti css
    Atitit 异常的实现原理 与用户业务异常
    Atitit.uke 团队建设的组织与运营之道attilax总结
    atitit 业务 触发器原理. 与事件原理 docx
    Atitit 基于dom的游戏引擎
    Atitit 团队建设的知识管理
    Javascript判断页面刷新或关闭的方法(转)
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13419907.html
Copyright © 2011-2022 走看看