前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SAP WebClient UI创建Value help最详细的步骤

SAP WebClient UI创建Value help最详细的步骤

作者头像
Jerry Wang
发布2020-08-10 11:17:38
3120
发布2020-08-10 11:17:38
举报

This document could be used for beginners for Webclient UI development who wants to know how to implement value help.

Example:

When clicking F4 on BusinessPartner ID,

a new window pops up as value help, you can click search button to get a list of business partners and choose one of them:

Once you mark the first search result, both ID and name would be automatically written back to your host page.

Step1: Implement GET_P method for field “BusinessPartner ID”:

代码语言:javascript
复制
CASE iv_property.
     WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
       rv_value = cl_bsp_dlc_view_descriptor=>field_type_input.
  ENDCASE.

Implement GET_V method:

代码语言:javascript
复制
create object rv_valuehelp_descriptor type cl_bsp_wd_valuehelp_navdescr
       exporting
          iv_outbound_plug = 'OP_PARTNER_SEARCH'.

Step2: Create a new outbound plug OP_PARTNER_SEARCH: ( the name must equal to the value passed to exporting parameter in GET_V method )

define a private attribute mv_popup with TYPE REF TO if_bsp_wd_popup in your view controller. Implement the following code:

代码语言:javascript
复制
DATA: lv_node  TYPE REF TO cl_bsp_wd_context_node.
DATA: lv_title TYPE string.

lv_title = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_PROD_CUST/SEARCH_CUSTOMER' ).
mv_popup = comp_controller->window_manager->create_popup(
  iv_interface_view_name = 'SearchHelpWindow'
  iv_usage_name          = 'BPSearch'
  iv_title               = lv_title ).
mv_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_surrounded ).
mv_popup->set_on_close_event( iv_view = me iv_event_name = 'CLOSEPOPUP' ).
mv_popup->open( 'CLEAR_ALL' ).​

Step3: in step2 we try to open the popup window defined in component usage BPSearch, so we have to define that usage in runtime repository:

in code it is defined when value help window is closed, event CLOSEPOPUP will be triggered. So we create this event handler and implement it: In the event handler, we get the selected BP information from context node PARTNER of component BP_HEAD_SEARCH and set the content into our own field “BusinessPartner ID” and “Employee Name”:

代码语言:javascript
复制
method EH_ONCLOSEPOPUP.

DATA: lv_target_node TYPE REF TO cl_bsp_wd_context_node.
DATA: lr_node      TYPE REF TO cl_bsp_wd_context_node,
             lr_entity    TYPE REF TO if_bol_bo_property_access,
             lr_entity_bp TYPE REF TO if_bol_bo_property_access,
             lv_fullname TYPE BU_DESCRIP,
             lv_bp_id    TYPE bu_partner.

  lr_entity ?= me->typed_context->bpinfo->collection_wrapper->get_current( ).
  ASSERT lr_entity IS NOT INITIAL.
  lr_node = mv_popup->get_context_node( 'PARTNER' ).
  CHECK lr_node IS BOUND.

  lr_entity_bp = lr_node->collection_wrapper->get_current( ).
  CHECK lr_entity IS BOUND AND lr_entity_bp IS BOUND.
  lv_bp_id = lr_entity_bp->get_property_as_string( 'BP_NUMBER' ).
  CHECK lv_bp_id IS NOT INITIAL.

  lr_entity->set_property( iv_attr_name = 'BP_ID' iv_value     = lv_bp_id ).
  CALL FUNCTION 'CRM_BUPA_DESCRIPTION_READ'
      EXPORTING
         iv_partner          = lv_bp_id
      IMPORTING
         ev_description_name = lv_fullname
      EXCEPTIONS
         no_partner_specified  = 1
         no_valid_record_found = 2
         OTHERS                = 3.
   lr_entity->set_property( iv_attr_name = 'BP_NAME' iv_value     = lv_fullname ).

Note: when you create the outbound plug OP_PARTNER_SEARCH in step2, the method is created with Protected by default. You should change the visibility manually to Public:

or else you will meet with CX_BSP_WD_INCORRECT_IMPLEMENT exception, since in the runtime the framework would expect to call it as public method as below:

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-08-08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档