UI界面按钮增强

(我是菜鸟,知道的少)

1.有HTML页面代码的,可以编辑

<%@page language="abap" %>
<%@extension name="thtmlb" prefix="thtmlb" %>
<%@extension name="chtmlb" prefix="chtmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<%--<thtmlb:toolbar buttons = "<%= controller->IF_BSP_WD_DYN_BTN_CONTROL~GET_LOCAL_TOOLBAR_BUTTONS( ) %>"
id = "toolbar"
maxButtonNumber = "<%= controller->IF_BSP_WD_DYN_BTN_CONTROL~GET_NO_OF_VISIBLE_TOOLBAR_BTNS( ) %>" />--%>
<%--<chtmlb:config displayMode = " "
mode = "RUNTIME"
xml = "<%= controller->configuration_descr->get_config_data( ) %>" />--%> <chtmlb:configGrid columnSize="16" rowSize="3" width="100%">
<chtmlb:configGridCell colSpan="5" columnIndex="1" rowIndex="1" rowSpan="1" >
<thtmlb:label id = "upload_label"
for = "upload"
design = "LABELRIGHT"
text = "<%= page->otr_trim( 'CRM_UIU_GS_CM/UPLOAD_DOC' ) %>"
tooltip = "<%= page->otr_trim( 'CRM_UIU_GS_CM/UPLOAD_DOC' ) %>"
width = "100%"/>
</chtmlb:configGridCell> <chtmlb:configGridCell colSpan="11" columnIndex="6" rowIndex="1" rowSpan="1" >
<thtmlb:fileUpload id = "upload"
size = "45" />
</chtmlb:configGridCell> <chtmlb:configGridCell colSpan="16" columnIndex="1" rowIndex="3" rowSpan="1" >
<thtmlb:button id = "attach"
onClick = "ATTACH"
enabled = "TRUE"
text = "<%=otr(CRM_UIU_GS_CM/UPLOAD)%>" /> <thtmlb:button id = "cancel"
onClick = "cancel"
enabled = "TRUE"
text = "<%=otr(CRM_UIU_GS_CM/CANCEL)%>" />
</chtmlb:configGridCell> </chtmlb:configGrid>

这种是在页面对应位置加按钮,并把按钮对应到相应事件,然后在事件中实现按钮功能

2.普通的页面可以在工具栏相关方法GET_BUTTONS中

METHOD IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS.
DATA: LS_BUTTON TYPE CRMT_THTMLB_BUTTON_EXT.
DATA: LV_URL TYPE STRING,
LV_URL2 TYPE STRING,
LV_OBJECT_ID TYPE CRMT_OBJECT_ID,
LV_SRV_TYPE TYPE ZDTEL00003Y,
LV_SMARTFORM_NAME TYPE TDSFNAME. DATA: LR_ENTITY TYPE REF TO CL_CRM_BOL_ENTITY,
LR_COLL TYPE REF TO IF_BOL_ENTITY_COL,
LR_CURRENT TYPE REF TO IF_BOL_BO_PROPERTY_ACCESS,
LR_ENTITY_ORG TYPE REF TO CL_CRM_BOL_ENTITY,
LV_PROCESS_TYPE TYPE STRING,
LS_ORGSET_BTIL TYPE CRMST_ORGSET_BTIL. FIELD-SYMBOLS: <FS_OBJECT_ID> TYPE CRMT_OBJECT_ID. CALL METHOD SUPER->IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS
RECEIVING
RT_BUTTONS = RT_BUTTONS. DELETE RT_BUTTONS WHERE ON_CLICK = 'OUTPUT'.
DELETE RT_BUTTONS WHERE ON_CLICK = 'PRINT_PREVIEW'. LR_ENTITY ?= ME->ZTYPED_CONTEXT->BTADMINH->COLLECTION_WRAPPER->GET_CURRENT( ).
IF LR_ENTITY IS BOUND.
TRY.
LV_PROCESS_TYPE = LR_ENTITY->GET_PROPERTY_AS_STRING( IV_ATTR_NAME = 'PROCESS_TYPE').
CALL METHOD LR_ENTITY->IF_BOL_BO_PROPERTY_ACCESS~GET_PROPERTY_AS_VALUE
EXPORTING
IV_ATTR_NAME = 'OBJECT_ID'
IMPORTING
EV_RESULT = LV_OBJECT_ID.
LR_COLL = LR_ENTITY->GET_RELATED_ENTITIES( IV_RELATION_NAME = 'BTHeaderOrgmanSet' ). "
LR_CURRENT = LR_COLL->GET_CURRENT( ).
IF LR_CURRENT IS BOUND.
LR_ENTITY_ORG ?= LR_CURRENT.
LR_ENTITY_ORG->IF_BOL_BO_PROPERTY_ACCESS~GET_PROPERTIES( IMPORTING ES_ATTRIBUTES = LS_ORGSET_BTIL ).
ENDIF.
CATCH CX_CRM_CIC_PARAMETER_ERROR.
ENDTRY.
ENDIF. CHECK LV_OBJECT_ID IS NOT INITIAL. CHECK LV_PROCESS_TYPE = 'ZSR2' OR LV_PROCESS_TYPE = 'ZSR3' OR LV_PROCESS_TYPE = 'ZSV1' OR LV_PROCESS_TYPE = 'ZSV2' OR LV_PROCESS_TYPE = 'ZSV3' OR LV_PROCESS_TYPE = 'ZWO4'. CASE LV_PROCESS_TYPE.
WHEN 'ZSR2'.
LV_SMARTFORM_NAME = 'ZEXCH'.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' LV_OBJECT_ID '&smartform_name=' LV_SMARTFORM_NAME '");' INTO LV_URL. WHEN 'ZSR3'.
LV_SMARTFORM_NAME = 'ZREFUND'.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' LV_OBJECT_ID '&smartform_name=' LV_SMARTFORM_NAME '");' INTO LV_URL. WHEN 'ZSV1'.
IF LS_ORGSET_BTIL-SALES_ORG = 'O 50000178'.
LV_SMARTFORM_NAME = 'ZSRV_ORD'.
ELSEIF LS_ORGSET_BTIL-SALES_ORG = 'O 50000192' OR LS_ORGSET_BTIL-SALES_ORG = 'O 50000194'.
LV_SMARTFORM_NAME = 'ZSRV_ORD_ZA'.
ELSE.
LV_SMARTFORM_NAME = 'ZSRV_ORD_N'.
ENDIF.
* lv_smartform_name = 'ZSERVICE_ORD'.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' LV_OBJECT_ID '&smartform_name=' LV_SMARTFORM_NAME '");' INTO LV_URL. * lv_smartform_name = 'ZSRV_ORD_N'.
* CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' lv_object_id '&smartform_name=' lv_smartform_name '");' INTO lv_url2. WHEN 'ZSV2'.
IF LS_ORGSET_BTIL-SALES_ORG = 'O 50000192' OR LS_ORGSET_BTIL-SALES_ORG = 'O 50000194'.
LV_SMARTFORM_NAME = 'ZSERVICE_ORD_ZA'.
ELSE.
LV_SMARTFORM_NAME = 'ZSERVICE_ORD'.
ENDIF.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' LV_OBJECT_ID '&smartform_name=' LV_SMARTFORM_NAME '");' INTO LV_URL. WHEN 'ZSV3'.
IF LS_ORGSET_BTIL-SALES_ORG = 'O 50000131'.
LV_SMARTFORM_NAME = 'ZSERVICE_ORD_AU'.
ELSEIF LS_ORGSET_BTIL-SALES_ORG = 'O 50000192' OR LS_ORGSET_BTIL-SALES_ORG = 'O 50000194'.
LV_SMARTFORM_NAME = 'ZSERVICE_ORD_ZA'.
ELSE.
LV_SMARTFORM_NAME = 'ZSERVICE_ORD'.
ENDIF.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' LV_OBJECT_ID '&smartform_name=' LV_SMARTFORM_NAME '");' INTO LV_URL. WHEN 'ZWO4'.
LV_SMARTFORM_NAME = 'ZSERVICE_ORD'.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' LV_OBJECT_ID '&smartform_name=' LV_SMARTFORM_NAME '");' INTO LV_URL. WHEN OTHERS.
ENDCASE. * CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' lv_object_id '&smartform_name=' lv_smartform_name '");' INTO lv_url.
*
CLEAR LS_BUTTON.
LS_BUTTON-TEXT = CL_WD_UTILITIES=>GET_OTR_TEXT_BY_ALIAS( 'ZCRM/PDFPRINT' ). "#EC NOTEXT
LS_BUTTON-ON_CLIENT_CLICK = LV_URL.
LS_BUTTON-ENABLED = ABAP_TRUE. "#EC NOTEXT
INSERT LS_BUTTON INTO RT_BUTTONS INDEX . CALL METHOD LR_ENTITY->IF_BOL_BO_PROPERTY_ACCESS~GET_PROPERTY_AS_VALUE
EXPORTING
IV_ATTR_NAME = 'ZZFLD00000N'
IMPORTING
EV_RESULT = LV_SRV_TYPE. CLEAR:LV_URL,LS_BUTTON.
LV_SMARTFORM_NAME = 'ZREPAIR_REP01'.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' LV_OBJECT_ID '&smartform_name=' LV_SMARTFORM_NAME '");' INTO LV_URL.
LS_BUTTON-TEXT = 'Repair Rep Print'. "#EC NOTEXT
LS_BUTTON-ON_CLIENT_CLICK = LV_URL.
LS_BUTTON-ENABLED = ABAP_TRUE. "#EC NOTEXT
INSERT LS_BUTTON INTO RT_BUTTONS INDEX . IF LV_PROCESS_TYPE = 'ZSV1'.
CLEAR:LV_URL,LS_BUTTON.
LV_SMARTFORM_NAME = 'ZCRM_SERVICE_01'.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' LV_OBJECT_ID '&smartform_name=' LV_SMARTFORM_NAME '");' INTO LV_URL.
LS_BUTTON-TEXT = 'Repair Follow Print'. "#EC NOTEXT
LS_BUTTON-ON_CLIENT_CLICK = LV_URL.
LS_BUTTON-ENABLED = ABAP_TRUE. "#EC NOTEXT
INSERT LS_BUTTON INTO RT_BUTTONS INDEX .
ENDIF. * CLEAR ls_button.
* ls_button-text = cl_wd_utilities=>get_otr_text_by_alias( 'ZCRM/DELIVPRT' ). "#EC NOTEXT
* ls_button-on_client_click = lv_url2.
* ls_button-enabled = abap_true. "#EC NOTEXT
* INSERT ls_button INTO rt_buttons INDEX 10. ENDMETHOD.

这个就相当与DIALOG中的SET_PF_STATUS

3.申请处理的DO_PREPARE_OUTPUT方法,这个相当于PBO

  METHOD do_prepare_output.
CALL METHOD super->do_prepare_output
EXPORTING
iv_first_time = abap_false.
*初始化按钮-Begin
do_init_button( ).
*初始化按钮-End
ENDMETHOD.
  METHOD do_init_button.
DATA:
lv_enabled TYPE abap_bool,
ls_button TYPE crmt_thtmlb_button,
lv_script TYPE string,
lv_true_false TYPE string,
lv_smartform_name TYPE tdsfname VALUE 'ZCRM_SERVICE_02',
lv_zserialno TYPE zserialno,
lv_zstatus TYPE zsrve_status,
lv_object TYPE crmt_object_id_db,
lv_url TYPE string,
lv_index TYPE i VALUE .
DATA:lv_bol TYPE REF TO if_bol_bo_col,
lv_access TYPE REF TO if_bol_bo_property_access.
* 导入
CLEAR:ls_button .
READ TABLE gt_button INTO ls_button WITH KEY on_click = 'ZUPLOAD'.
IF sy-subrc <> .
CLEAR ls_button.
ls_button-type = cl_thtmlb_util=>gc_icon_new.
ls_button-tooltip = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_MKTRRG/IMPORT' ).
ls_button-text = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_MKTRRG/IMPORT' ).
ls_button-on_click = 'ZUPLOAD' . "#EC NOTEXT
ls_button-enabled = abap_true .
APPEND ls_button TO gt_button .
ENDIF.
* 下载模板
CLEAR:ls_button .
READ TABLE gt_button INTO ls_button WITH KEY on_click = 'DOWNLOAD'.
IF sy-subrc <> .
CLEAR :
lv_url, lv_script,ls_button .
lv_url = '../../sap/ZCRM_EXCEL_IMP/ZSRVS_QUERY_002_RESULT_UI.xlsx' .
* CONCATENATE `thtmlbExcelExportGen('`
CONCATENATE `javascript:window.open('`
lv_url
`',`
'false'
`)`
INTO lv_script .
***模版下载另类处理方式 CONCATENATE `javascript:window.open('`
ls_button-type = cl_thtmlb_util=>gc_icon_file_spreadsheet.
ls_button-tooltip = text- .
ls_button-text = text- .
ls_button-on_click = 'DOWNLOAD' . "#EC NOTEXT
ls_button-on_client_click = lv_script .
ls_button-enabled = abap_true .
APPEND ls_button TO gt_button .
ENDIF. "ADD BY LY 20170220 FRO PRINT
lv_bol = me->typed_context->searchresultnode->collection_wrapper->get_marked( ).
IF lv_bol IS BOUND.
lv_access = lv_bol->get_current( ).
IF lv_access IS BOUND.
lv_access->get_property_as_value(
EXPORTING
iv_attr_name = 'ZSTATUS'
IMPORTING
ev_result = lv_zstatus ).
IF lv_zstatus = ''.
lv_access->get_property_as_value(
EXPORTING
iv_attr_name = 'ZSERIALNO'
IMPORTING
ev_result = lv_zserialno ).
ENDIF.
ENDIF.
ENDIF.
CLEAR:ls_button .
READ TABLE gt_button INTO ls_button WITH KEY id = 'PRNT'.
IF sy-subrc <> .
CLEAR :
lv_url, lv_script,ls_button .
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' lv_object '&smartform_name=' lv_smartform_name
'&zserialno=' lv_zserialno '");' INTO lv_url.
ls_button-id = 'PRNT'.
ls_button-text = text-.
ls_button-on_client_click = lv_url .
ls_button-enabled = abap_false .
APPEND ls_button TO gt_button.
ELSE.
lv_index = sy-tabix.
CLEAR:lv_script,ls_button .
IF lv_zstatus = ''.
CONCATENATE 'javascript:window.open( "/sap/bc/webdynpro/sap/ZCRM_PRINT' '?object_id=' lv_object '&smartform_name=' lv_smartform_name
'&zserialno=' lv_zserialno '");' INTO lv_url.
ls_button-enabled = abap_true .
ELSE.
ls_button-enabled = abap_false .
ENDIF. ls_button-on_client_click = lv_url . MODIFY gt_button FROM ls_button INDEX lv_index TRANSPORTING on_client_click enabled .
ENDIF.
ENDMETHOD.
上一篇:web04-LoginServlet


下一篇:使用canal分析binlog(二) canal源码分析