1. 程式人生 > >UI基礎四:簡單的assign block

UI基礎四:簡單的assign block

tro other 開發 初始化 proposal rop pla png 情況

經常會有需求讓在標準的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