ITPub博客

首页 > 应用开发 > IT综合 > 如何动态修改SAP CRM WebClient UI表格栏的宽度

如何动态修改SAP CRM WebClient UI表格栏的宽度

原创 IT综合 作者:i042416 时间:2020-08-19 11:25:13 0 删除 编辑

Achievement

By clicking down or up button, the table width could be changed dynamically - each time the button is clicked, the width increases or shrinks at 10 px interval.



(1) Create a table view with toolbar defined:



(2) Create the attribute gt_toolbar_button in controller class:



Define the on click handling logic for button DOWN and UP:



(3) Create two event handler for DOWN and UP: ```ABAP method EH_ONDOWN. change( iv_up = abap_false ). endmethod.

method EH_ONUP. change( iv_up = abap_true ). endmethod.  The implementation of change method:ABAP method CHANGE. CALL METHOD me->configuration_descr->get_config_data RECEIVING rv_result = DATA(lv_xml) EXCEPTIONS config_not_found = 1. CHECK sy-subrc = 0. DATA(ls_config_data) = cl_bsp_dlc_table_utility=>conf_xml_to_abap( lv_xml ). LOOP AT ls_config_data-columndefinition ASSIGNING FIELD-SYMBOL(). -width = GET_WIDTH( iv_up = iv_up iv_old_value = -width ). ENDLOOP. DATA(lv_xml_changed) = cl_bsp_dlc_table_utility=>conf_abap_to_xml( ls_config_data ). DATA(lr_configuration2) = CAST if_bsp_dlc_config_table_layout( me->configuration_descr ). lr_configuration2->set_active_table_layout( iv_config_data = lv_xml_changed ). endmethod.

The implementation of get_width method:
```ABAP
  method GET_WIDTH.
     DATA lv_new TYPE i.
     DATA lv_temp TYPE string.
     lv_temp = iv_old_value.
     REPLACE ALL OCCURRENCES OF 'px' IN lv_temp WITH space.
     CONDENSE lv_temp NO-GAPS.
     lv_new = lv_temp.
     IF iv_up = abap_true.
       lv_new = lv_new + 10.
     ELSE.
       lv_new = lv_new - 10.
     ENDIF.
     lv_temp = lv_new.
     value = lv_temp && 'px'.
     CONDENSE value NO-GAPS.
  endmethod.

Signature of these two methods:

methods CHANGE
    importing
      !IV_UP type ABAP_BOOL .
  methods GET_WIDTH
    importing
      !IV_OLD_VALUE type STRING
      !IV_UP type ABAP_BOOL
    returning
      value(VALUE) type STRING .

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


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24475491/viewspace-2712831/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
SAP成都研究院开发专家,SAP社区导师,SAP中国技术大使。

注册时间:2018-01-20

  • 博文量
    1957
  • 访问量
    890300