UI基础四:简单的assign block

Posted ^ω^SAp傻X^o^

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UI基础四:简单的assign block相关的知识,希望对你有一定的参考价值。

经常会有需求让在标准的order加个assign block,那就来简单说一下:

1.创建assign block组件ZXXXXXX

2.添加BTORDER节点和GUID属性

3.创建表视图(可配置,根据情况是否按钮),在表的初始化中DO_INIT_CONTEXT或者DO_PREPARE_OUTPUT中根据GUID带出block信息

 

  METHOD do_init_context.
    DATA:gr_order     TYPE REF TO if_bol_bo_property_access,
         gw_order     TYPE crmst_guid_btil,
         lr_col       TYPE REF TO if_bol_bo_col,
         lr_valuenode TYPE REF TO cl_bsp_wd_value_node,
         gt_log       TYPE TABLE OF zcrm_proce_log,
         gw_log       LIKE LINE OF gt_log,
         gt_text      TYPE TABLE OF zdelay_reason,
         gw_text      LIKE LINE OF gt_text,
         gw_struct    TYPE zcrms0046,
         lr_line      TYPE REF TO zcrms0046.
    REFRESH:gt_log.
    CLEAR:gw_log.
    super->do_init_context( ).

    gr_order = me->typed_context->btorder->collection_wrapper->get_current( ).
    IF gr_order IS BOUND.
      gr_order->get_properties(
        IMPORTING
          es_attributes = gw_order ).
      SELECT * INTO TABLE gt_log FROM zcrm_proce_log WHERE guid = gw_order-crm_guid.
      SELECT * INTO TABLE gt_text FROM zdelay_reason WHERE spras = sy-langu.
      SORT gt_text BY estat.
    ENDIF.
*    SELECT * INTO TABLE gt_log FROM zcrm_proce_log WHERE guid = gw_order-crm_guid.
    CREATE OBJECT lr_col TYPE cl_crm_bol_bo_col.
    LOOP AT gt_log INTO gw_log.
      MOVE-CORRESPONDING gw_log TO gw_struct.
      READ TABLE gt_text INTO gw_text WITH KEY estat = gw_log-zzdlyrsn BINARY SEARCH.
      IF sy-subrc = 0.
        gw_struct-in_pro_des = gw_text-text.
      ENDIF.
      CREATE DATA lr_line.
      CREATE OBJECT lr_valuenode
        EXPORTING
          iv_data_ref = lr_line.
      lr_valuenode->set_properties( gw_struct ).
      lr_col->add( lr_valuenode ).
    ENDLOOP.

    me->typed_context->proce->collection_wrapper->set_collection( lr_col ).

  ENDMETHOD.

将组件添加InterfaceView 并把BTorder节点添加。

 

将组件添加到BT116H_SRVO的ComponentUsage

 

在BT116H_SRVO的组件控制器的WD_USAGE_INITIALIZE的方法中添加GUID节点的映射:

METHOD wd_usage_initialize.
  CONSTANTS:
    lc_node_name_totals TYPE seocmpname VALUE \'ADDPARENTTOTALS\',
    lc_komp_name_rel    TYPE name_komp  VALUE \'PARENTTOTALREL1\',
    lc_komp_name_total  TYPE name_komp  VALUE \'PARENTTOTAL1\',
    lc_rel_name_cumulat TYPE string     VALUE \'BTHeaderCumulatExt\',
    lc_komp_name_cost   TYPE string     VALUE \'COST_AMOUNT\'.

  DATA:
    lr_component_usage TYPE REF TO if_bsp_wd_component_usage,
    lr_context_node    TYPE REF TO cl_bsp_wd_context_node,
    lr_property_access TYPE REF TO if_bol_bo_property_access.


  CHECK iv_usage IS BOUND.

* late instantiation of CuCos for
* component usages

  CASE iv_usage->usage_name.
    WHEN \'CUBTQualif\'.
      get_custom_controller( \'BT116H_SRVO/CUBTQualifCuCo\' ).
    WHEN \'CUBTRefObj\'.
      get_custom_controller( \'BT116H_SRVO/CUBTRefObjCuCo\' ).
    WHEN \'CUBTOrgSet\'.
      get_custom_controller( \'BT116H_SRVO/CUBTOrgSetCuCo\' ).
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'
                                   iv_node_2_bind      = \'PARENTNODE\' ).
    WHEN \'CUBTAmntAll\'.
      get_custom_controller( \'BT116H_SRVO/CUBTAmntAllCuCo\' ).
    WHEN \'CUBTDates\'.
      get_custom_controller( \'BT116H_SRVO/CUBTDatesCuCo\' ).
    WHEN \'CUGSActions\'.
      get_custom_controller( \'BT116H_SRVO/CUGSActionsCuCo\' ).
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'
                                   iv_node_2_bind      = \'PARENTNODE\' ).
    WHEN \'CUGSText\'.
      get_custom_controller( \'BT116H_SRVO/CUGSTextCuCo\' ).
    WHEN \'CUBTAcAssign\'.
      get_custom_controller( \'BT116H_SRVO/CUBTAcAssignCuCo\' ).
    WHEN \'CUBTStatusUS\'.
      get_custom_controller( \'BT116H_SRVO/CUBTStatusUSCuCo\' ).
    WHEN \'CUBTPartner\'.
      get_custom_controller( \'BT116H_SRVO/CUBTPartnerCuCo\' ).
    WHEN \'CUBTChangeHistory\'.
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'
                                   iv_node_2_bind      = \'BTADMINH\' ).
    WHEN \'CUBTShipping\'.
* bind shipping usage
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTORDER\'        " name of component controller node
                                   iv_node_2_bind      = \'BTORDER\' ).      " name of usage interface node

    WHEN \'CUBTCounter\'.
* bind counter usage
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'        " name of component controller node
                                   iv_node_2_bind      = \'BTADMIN\' ).      " name of usage interface node

* custom controller needed for counter link proposal
      get_custom_controller( \'BT116H_SRVO/CUBTCounterCuCo\' ).

      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
                                    iv_target_node_name = \'PROPOSALCOMP\'        " name of custom controller node
                                    iv_name             = \'BT116H_SRVO/CUBTCounterCuCo\'
                                    iv_node_2_bind      = \'PROPOSALCOMP\' ).      " name of usage interface node

      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
                                    iv_target_node_name = \'PROPOSALPROD\'        " name of custom controller node
                                    iv_name             = \'BT116H_SRVO/CUBTCounterCuCo\'
                                    iv_node_2_bind      = \'PROPOSALPROD\' ).      " name of usage interface node

    WHEN \'CUBTServiceItem\'
      OR \'CUBTServicePartItem\'
      OR \'CUBTExpenseItem\'
      OR \'CUBTToolItem\'
      OR \'CUBTSalesItem\'.
* bind single item component usages
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINI\'
                                   iv_node_2_bind      = \'BTADMINI\' ).
    WHEN \'CUBTSalesQuotItem\'.
* special binding for sales quotation item
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINI\'
                                   iv_node_2_bind      = \'BTADMINI\' ).

      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTITEMS\'
                                   iv_node_2_bind      = \'BTITEMS\' ).

    WHEN \'CUItemTable\' OR \'CUItemTableHeader\'.
* bind item table component usages
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTITEMS\'
                                   iv_node_2_bind      = \'BTITEMS\' ).

      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINI\'
                                   iv_node_2_bind      = \'BTADMINI\' ).

    WHEN \'CUGSCMOverview\' OR \'CUGSCMEdit\'.
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
                                   iv_name             = \'BT116H_SRVO/CUGSCMCuCo\'
                                   iv_target_node_name = \'CMBO\'
                                   iv_node_2_bind      = \'CMBUSOBJ\' ).

      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
                                   iv_name             = \'BT116H_SRVO/CUGSCMCuCo\'
                                   iv_target_node_name = \'ATTRIBUTES\'
                                   iv_node_2_bind      = \'ATTRIBUTES\' ).

* bind parent node for locking
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'        " name of component controller node
                                   iv_node_2_bind      = \'PARENTNODE\' ).   " name of usage interface node

    WHEN \'CUGSSurvey\'.

      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'
                                   iv_node_2_bind      = \'ADMINH\' ).

      iv_usage->bind_context_node(
                  iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
                  iv_target_node_name = \'SURVEYVIEWTITLE\'
                  iv_name             = \'BT116H_SRVO/CUGSSurveyCuCo\'
                  iv_node_2_bind      = \'SURVEYVIEWTITLE\' ).

    WHEN \'CUBTPayments\'.
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTORDER\'
                                   iv_node_2_bind      = \'BTORDER\' ).
    WHEN \'CUGSPrices\'.

      get_custom_controller( \'BT116H_SRVO/CUGSPricesCuCo\' ).

* bind parent node
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
                                   iv_name             = \'BT116H_SRVO/CUGSPricesCuCo\'
                                   iv_target_node_name = \'BTADMINH\'        " name of component controller node
                                   iv_node_2_bind      = \'PARENTNODE\' ).      " name of usage interface node

* prepare for display of price totals of header
      lr_component_usage   = me->get_component_usage( iv_usage->usage_name ).
      lr_context_node      = lr_component_usage->get_context_node( lc_node_name_totals ).
      lr_property_access   = lr_context_node->collection_wrapper->get_first( ).
      lr_property_access->set_property_as_string( iv_attr_name = lc_komp_name_rel
                                                  iv_value     = lc_rel_name_cumulat ).
      lr_property_access->set_property_as_string( iv_attr_name = lc_komp_name_total
                                                  iv_value     = lc_komp_name_cost   ).


* Private Notes
    WHEN \'CUPrivNote\'.
      CALL METHOD iv_usage->bind_context_node
        EXPORTING
          iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
          iv_name             = \'BT116H_SRVO/CUPrivNoteCuCo\' "#EC NOTEXT
          iv_target_node_name = \'BOROBJECT\'                 "#EC NOTEXT
          iv_node_2_bind      = \'BOROBJECT\'.                "#EC NOTEXT


    WHEN \'CUBTDocFlow\'.
      get_custom_controller( \'BT116H_SRVO/CUBTDocFlowCuCo\' ).
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'
                                   iv_node_2_bind      = \'PARENTNODE\' ).
    WHEN \'CUBTSolution\' OR \'CUBTEMail\'.
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'
                                   iv_node_2_bind      = \'BTADMINH\' ).

    WHEN \'CUGSKnowArtDocFlow\'.
      get_custom_controller( \'BT116H_SRVO/CUGSDocFlowCuCo\' ).
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTADMINH\'
                                   iv_node_2_bind      = \'PARENTNODE\' ).
    WHEN \'CUBTCategories\'.
      get_custom_controller( \'BT116H_SRVO/CUBTCategoriesCuCo\' ).
*   bind payment cards
    WHEN \'CUBTPaycards\'.
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTORDER\'
                                   iv_node_2_bind      = \'BTORDER\' ).
    WHEN \'CUBTFollowUp\'.
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                             iv_target_node_name = \'BTADMINH\'
                             iv_node_2_bind      = \'BTADMINH\' ).

    WHEN \'CUCaseLink\'.
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                             iv_target_node_name = \'BTORDER\'
                             iv_node_2_bind      = \'EXTLINKOBJ\' ).

    WHEN \'CUCustomer_H\'.
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                              iv_target_node_name = \'BTADMINH\'
                              iv_node_2_bind      = \'BTADMINH\' ).

    WHEN \'CUGSProductCatalog\'.                              "#EC NOTEXT
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTITEMS\' "#EC NOTEXT
                                   iv_node_2_bind      = \'ITEMS\' ). "#EC NOTEXT
 "ADD BY LY 20170927 肖宇,增加in process 接口日志block
    WHEN \'CUZHSI_PROCE\'.                                     "#EC NOTEXT
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTORDER\' "#EC NOTEXT
                                   iv_node_2_bind      = \'BTORDER\' ). "#EC NOTEXT
  "ADD BY LY 20170927 肖宇,增加in process 接口日志block
    WHEN \'ZATTATCH\'.                                     "#EC NOTEXT
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                                   iv_target_node_name = \'BTORDER\' "#EC NOTEXT
                                   iv_node_2_bind      = \'BTORDER\' ). "#EC NOTEXT

    WHEN \'BTSubject\'.
      get_custom_controller( \'BT116H_SRVO/CuCoSubjectSet\' ).
**********************************************************************20161117-Begin
*开发顾问:陈国光
*业务顾问:龚慧文
*1,传数据列表中增加一列字段,当点完Upload按钮后,
*如果上传信息model NO\\serial NO\\product ID与原有信息不一致,给予黄色警告提示。
*由操作者决定是否继续上传,不上传则修改上传模板
*2、 物流信息日志做成一个assignment block,服务工单、退机订单上可以显示每次物流状态等信息的更新记录;
    WHEN \'ZCUZSA_LOGI_INFO\'.                                "#EC NOTEXT
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
      iv_target_node_name = \'BTADMINH\'                      "#EC NOTEXT
      iv_node_2_bind      = \'BTADMINH\' ).                   "#EC NOTEXT
**********************************************************************20161117-End
**********************************************************************20170117-Begin
*开发顾问:陈国光
*业务顾问:张弛
*FS《HOS_CRM_JP_06_周转机管理增强_V1.0_20170113》
    WHEN \'ZCUZSRV_JA_002\'.                                "#EC NOTEXT
      iv_usage->bind_context_node( iv_controller_type  = cl_bsp_wd_controller=>co_type_component
      iv_target_node_name = \'BTADMINH\'                      "#EC NOTEXT
      iv_node_2_bind      = \'BTADMINH\' ).                   "#EC NOTEXT
********************************************************************** 20170117 -End

    WHEN OTHERS.
      "Detect extension binding
      DATA: lv_binding_source TYPE string.
      lv_binding_source =
        cl_axt_assignment_block_binder=>get_binding_source_4_usage(
          iv_usage->usage_name ).

      IF lv_binding_source IS NOT INITIAL.
        CASE lv_binding_source.
          WHEN \'HEADER\'.
            "Bind Extension block
            CALL METHOD iv_usage->bind_context_node
              EXPORTING
                iv_controller_type  = cl_bsp_wd_controller=>co_type_component
                iv_target_node_name = \'BTAdminH\' " Your node
                iv_node_2_bind      = \'PARENT\'. " Always PARENT

        ENDCASE.
      ELSE.
        "No extension table
      ENDIF.
  ENDCASE.
ENDMETHOD.

 

在OverView Page中将组件视图添加进来,然后在配置中将组件放出,即可显示。

以上是关于UI基础四:简单的assign block的主要内容,如果未能解决你的问题,请参考以下文章

UI基础--按钮扩展动画

Vue报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object 的解决方法(代码片段

Verilog 阻塞赋值与非阻塞赋值 Blocking assignment和NonBlocking assignment

区别assign VS weak,__block VS __weak

如何从 Android 中的 Fragment 访问 UI 元素?

线程基础四 使用Monitor类锁定资源