需求:给一个配置表,需要根据配置表来弹出选择框,并将选择的数据添加到SALES ORDER的项目

BSP_WD_CMPWB

新建组件:ZHSI_JPMPG

新建视图,适用VALUE NODE 参考表ZCRMT0057.(表视图,可配置,按钮)

在节点的IF_BSP_MODEL~INIT中设置选择模式:多选:

  method IF_BSP_MODEL~INIT.

    TYPES: BEGIN OF ltype_attr_struct,
mandt TYPE mandt,
zzzmodeno TYPE zmodeno,
zpart_group TYPE zpart_group,
product_id TYPE comt_product_id,
zgroup_des TYPE zgroup_des,
zproduct_des TYPE comt_prshtextx,
quantity TYPE zcrm_quan, END OF ltype_attr_struct. super->if_bsp_model~init( id = id
owner = owner ). SELECTION_MODE = SELMODE_MULTI."多选 DATA: lv_struct_ref TYPE REF TO ltype_attr_struct,
lv_value_node TYPE REF TO cl_bsp_wd_value_node,
lv_bo_coll TYPE REF TO if_bol_bo_col. CREATE DATA lv_struct_ref.
CREATE OBJECT lv_value_node
EXPORTING
iv_data_ref = lv_struct_ref.
CREATE OBJECT lv_bo_coll TYPE cl_crm_bol_bo_col. lv_bo_coll->add( lv_value_node ). set_collection( lv_bo_coll ). endmethod.

在组件控制器中添加参数节点:OPTION,值节点,字段参考ZCRMT0057中个别字段

在组件控制器中添加返回结果节点:ZJPPJM,值节点,字段参考ZCRMT0057

根据参数条件初始化查询结果TABLE:DO_INIT_CONTEXT

  METHOD do_init_context.
**SUPER->DO_INIT_CONTEXT( ).
DATA:gt_zcrmt0057 TYPE TABLE OF zcrmt0057,
gw_zcrmt0057 LIKE LINE OF gt_zcrmt0057,
lr_line TYPE REF TO zcrmt0057,
lr_valuenode TYPE REF TO cl_bsp_wd_value_node,
lr_col TYPE REF TO if_bol_bo_col,
lr_comp TYPE REF TO zl_zhsi_jpm_bspwdcomponen_impl,
gr_cond TYPE REF TO if_bol_bo_property_access,
gw_cond TYPE zmodeno. lr_comp ?= me->comp_controller.
IF lr_comp IS BOUND.
gr_cond = lr_comp->typed_context->option->collection_wrapper->get_current( ).
IF gr_cond IS BOUND.
gr_cond->get_property_as_value(
EXPORTING
iv_attr_name = 'ZZZMODENO'
IMPORTING
ev_result = gw_cond ).
SELECT * INTO TABLE gt_zcrmt0057 FROM zcrmt0057 WHERE zzzmodeno = gw_cond.
ENDIF.
ENDIF.
CREATE OBJECT lr_col TYPE cl_crm_bol_bo_col.
LOOP AT gt_zcrmt0057 INTO gw_zcrmt0057.
CREATE DATA lr_line.
CREATE OBJECT lr_valuenode
EXPORTING
iv_data_ref = lr_line.
lr_valuenode->set_properties( gw_zcrmt0057 ).
lr_col->add( lr_valuenode ).
ENDLOOP. me->typed_context->zjppmj->collection_wrapper->set_collection( lr_col ).
ENDMETHOD.

重定义GET_LOCAL_TOOLBAR_BUTTONS方法,添加选择按钮(点击将选择结果返回到程序中)

  METHOD if_bsp_wd_dyn_btn_control~get_local_toolbar_buttons.
DATA:gw_button TYPE crmt_thtmlb_button.
rt_result = super->if_bsp_wd_dyn_btn_control~get_local_toolbar_buttons( ).
gw_button-id = 'CHOOSE'.
gw_button-type = cl_thtmlb_util=>gc_done.
gw_button-text = '選択'.
gw_button-on_click = 'ZCHOOSE'.
gw_button-enabled = abap_true.
APPEND gw_button TO rt_result.
ENDMETHOD.

重定义GET_NO_OF_VISIBLE_TOOLBAR_BTNS方法,修改显示的按钮数量

  METHOD if_bsp_wd_dyn_btn_control~get_no_of_visible_toolbar_btns.
rv_result = super->if_bsp_wd_dyn_btn_control~get_no_of_visible_toolbar_btns( ).
rv_result = .
ENDMETHOD.

在Event Handler中添加前面设置的ZCHOOSE:

(将选择的结果添加到组件控制器的返回节点中)

  METHOD eh_onzchoose.
DATA lr_context_node_tree TYPE REF TO cl_bsp_wd_context_node_tree.
DATA lr_node TYPE REF TO if_bsp_wd_tree_node.
DATA lr_tree_event TYPE REF TO cl_thtmlb_tree.
DATA lr_choose TYPE REF TO if_bol_bo_col_iterator.
DATA:lr_bol TYPE REF TO if_bol_bo_col.
DATA lv_sel_index TYPE int4.
DATA :lv_row_index TYPE int4,
lr_comp TYPE REF TO zl_zhsi_jpm_bspwdcomponen_impl,
lr_window TYPE REF TO cl_bsp_wd_window. lr_choose = me->typed_context->zjppmj->collection_wrapper->get_iterator( ).
lr_bol = lr_choose->get_marked( ). lr_comp ?= me->comp_controller.
lr_comp->typed_context->zjppjm->collection_wrapper->clear_collection( ).
lr_comp->typed_context->zjppjm->collection_wrapper->set_collection( lr_bol ).
lr_window = me->view_manager->get_window_controller( ).
lr_window->call_outbound_plug( iv_outbound_plug = 'PRD_SELECT' ).
ENDMETHOD.

WINDOW中添加外向跳转对象:

  METHOD op_prd_select.
me->fire_outbound_plug( iv_outbound_plug = 'PRD_SELECT'
iv_data_collection = iv_data_collection ).
ENDMETHOD.

将组件添加InterfaceView,将组件控制器的参数节点和返回结果节点添加:

在使用的组件中添加ComponentUsage:

以上将搜索帮助的查询和返回值处理完成,现在来使用位置调用组件并处理返回结果:

在BT115IT_SLSO的中添加按钮:

  METHOD do_prepare_output.
CALL METHOD super->do_prepare_output
EXPORTING
iv_first_time = abap_false.
* CHECK sy-uname = zcl_crm_attributes=>gc_chenguoguang.
**********************************************************************20170501-Begin
*ZSO1/ZSO2/ZSO5 放出product ID 字段,ITEM增加exploed view按钮
***数据定义
DATA:
ls_button TYPE crmt_thtmlb_button,
ls_crmt_orgman_wrk TYPE crmt_orgman_wrk,
ls_crmst_adminh_btil TYPE crmst_adminh_btil,
lr_btitems TYPE REF TO cl_crm_bol_entity,
lr_btorder TYPE REF TO cl_crm_bol_entity,
lr_btadminh TYPE REF TO cl_crm_bol_entity.
***数据准备
lr_btitems ?= me->typed_context->btitems->collection_wrapper->get_current( ).
IF lr_btitems IS BOUND.
lr_btorder = lr_btitems->get_root( ).
ENDIF.
IF lr_btorder IS BOUND.
lr_btadminh = lr_btorder->get_related_entity( iv_relation_name = 'BTOrderHeader' ).
ENDIF.
CHECK lr_btadminh IS BOUND.
lr_btadminh->get_properties( IMPORTING es_attributes = ls_crmst_adminh_btil ).
CALL FUNCTION 'CRM_ORGMAN_READ_OW'
EXPORTING
iv_ref_guid = ls_crmst_adminh_btil-guid
iv_ref_kind = 'A'
IMPORTING
es_orgman_wrk = ls_crmt_orgman_wrk
EXCEPTIONS
entry_does_not_exist =
OTHERS = .
IF sy-subrc <> .
* Implement suitable error handling here
ENDIF. zl_bt115it__items_impl=>gv_sales_org = ls_crmt_orgman_wrk-sales_org.
ls_button-type = cl_thtmlb_util=>gc_icon_goto..
ls_button-on_click = 'ZEXPLODE'.
ls_button-text = 'Explode view'.
ls_button-enabled = abap_true.
APPEND ls_button TO gt_button_tib.
"在ZSO5的行项目中增加“部品リスト選択”按钮,只针对日本分公司显示。在点击该按钮时,弹出对话框,显示字段如下:
"ADD BY LY 20171031
IF ls_crmt_orgman_wrk-sales_org = 'O 50000231' AND ls_crmst_adminh_btil-process_type = 'ZSO5'.
ls_button-type = cl_thtmlb_util=>gc_icon_add..
ls_button-on_click = 'ZPDEX'.
ls_button-text = '部品リスト選択'.
ls_button-enabled = abap_true.
APPEND ls_button TO gt_button_tib.
ENDIF.
**********************************************************************20170501-End
"日语登陆,默认带出日语的物料描述,如无则取英语描述
"ADD BY LY 20170613
DATA:
lv_langu TYPE sy-langu,
lv_text TYPE abap_bool.
DATA lr_item_iter TYPE REF TO if_bol_bo_col_iterator.
DATA lr_admini TYPE REF TO cl_crm_bol_entity.
DATA ls_admini TYPE crmst_admini_btil.
DATA:lr_core TYPE REF TO cl_crm_bol_core.
CLEAR:lv_langu.
IF sy-langu = 'J'"加的by 李渊 20170613
OR sy-langu = 'F'."20170731 法国逻辑
lv_langu = sy-langu.
ENDIF. IF lv_langu IS NOT INITIAL.
lr_item_iter = me->typed_context->btadmini->collection_wrapper->if_bol_bo_col~get_iterator( ).
CHECK lr_item_iter IS BOUND.
lr_admini ?= lr_item_iter->get_first( ).
WHILE lr_admini IS BOUND.
lr_admini->get_properties( IMPORTING es_attributes = ls_admini ).
IF sy-langu = lv_langu."加的by 李渊 20170606
SELECT SINGLE short_text INTO ls_admini-description
FROM comm_prshtext
WHERE product_guid = ls_admini-product
AND langu = lv_langu.
IF sy-subrc <> .
SELECT SINGLE short_text INTO ls_admini-description
FROM comm_prshtext
WHERE product_guid = ls_admini-product
AND langu = 'E'.
ENDIF.
ENDIF.
lr_admini->set_properties( EXPORTING is_attributes = ls_admini ).
lr_admini ?= lr_item_iter->get_next( ).
ENDWHILE.
lr_core = cl_crm_bol_core=>get_instance( ).
lr_core->modify( ).
ENDIF. ENDMETHOD.

事件控制器中添加处理事件:ZPDEX

  METHOD eh_onzpdex.
* Added by wizard: Handler for event 'ZPDEX'
OP_PRD_SELECT( ).
ENDMETHOD.

添加外向链接:PRD_SELECT

  METHOD op_prd_select.
* Added by wizard: Outbound plug 'PRD_SELECT'
TYPES:BEGIN OF ty_cond,
product_id TYPE comt_product_id,
zzzmodeno TYPE zmodeno,
END OF ty_cond.
DATA:lr_entity TYPE REF TO cl_crm_bol_entity,
lv_interface_view_name TYPE string,
lv_title TYPE string,
gw_cond TYPE ty_cond,
gr_cond TYPE REF TO ty_cond,
lr_valuenode TYPE REF TO cl_bsp_wd_value_node,
lr_context TYPE REF TO cl_bsp_wd_context_node.
DATA:ls_crmst_adminh_btil TYPE crmst_adminh_btil,
lr_btitems TYPE REF TO cl_crm_bol_entity,
lr_btorder TYPE REF TO cl_crm_bol_entity,
lr_btadminh TYPE REF TO cl_crm_bol_entity.
***数据准备
”not use begin
lr_btitems ?= me->typed_context->btitems->collection_wrapper->get_current( ).
IF lr_btitems IS BOUND.
lr_btorder = lr_btitems->get_root( ).
ENDIF.
IF lr_btorder IS BOUND.
lr_btadminh = lr_btorder->get_related_entity( iv_relation_name = 'BTOrderHeader' ).
ENDIF.
CHECK lr_btadminh IS BOUND.
lr_btadminh->get_properties( IMPORTING es_attributes = ls_crmst_adminh_btil ).
"not use end
lv_interface_view_name = 'ZHSI_JPMPG/MainWindow'.
lv_title = '部品リスト選択'. "弹出框的标题
comp_popup = comp_controller->window_manager->create_popup("实例化弹出框,search_belnr_popup
iv_interface_view_name = lv_interface_view_name "对应的类型为IF_BSP_WD_POPUP为全局变量
iv_usage_name = 'PRD_SELECT '
iv_title = lv_title ).
comp_popup->set_on_close_event( iv_view = me iv_event_name = 'ZJPP_CLOSE' ). "设置弹出窗口对应的关闭事件
** set display mode "此事件用于接受对应的选中返回值
comp_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_surrounded ).
** Open the Popup
comp_popup->set_window_width( ).
comp_popup->set_window_height( ).
DATA:lr_cond TYPE REF TO if_bol_bo_col.
CREATE OBJECT lr_cond TYPE cl_crm_bol_bo_col.
CREATE DATA gr_cond.
CREATE OBJECT lr_valuenode
EXPORTING
iv_data_ref = gr_cond.
gw_cond-zzzmodeno = ls_crmst_adminh_btil-zzzmodeno.
lr_valuenode->set_properties( gw_cond ).
lr_cond->add( lr_valuenode ).
" Get Query Context node
lr_context = comp_popup->get_context_node( 'OPTION' ).
CHECK lr_context IS BOUND. lr_context->set_collection( collection = lr_cond ). comp_popup->open( iv_inbound_plug = 'PRD_SELECT'
iv_collection = lr_cond
).
ENDMETHOD.

处理返回结果:新建事件:ZJPP_CLOSE

  METHOD eh_onzjpp_close.
* Added by wizard: Handler for event 'ZJPP_CLOSE'
DATA lr_item TYPE REF TO cl_crm_bol_entity.
DATA:lr_schedext TYPE REF TO cl_crm_bol_entity,
lr_schedlin TYPE REF TO cl_crm_bol_entity.
DATA:lr_btitems TYPE REF TO cl_crm_bol_entity,
lr_btorder TYPE REF TO cl_crm_bol_entity,
lr_btadminh TYPE REF TO cl_crm_bol_entity,
lr_context_node TYPE REF TO cl_bsp_wd_context_node,
lr_iterator TYPE REF TO if_bol_bo_col_iterator,
lr_access TYPE REF TO if_bol_bo_property_access,
ls_crmt0057 TYPE zcrmt0057,
gw_item TYPE crmst_admini_btil,
gv_quantity TYPE crmt_schedlin_quan,
ls_schedlin TYPE crmst_schedlin_btil,
gv_string TYPE string,
gr_cx_crm_genil_model_error TYPE REF TO cx_crm_genil_model_error. CHECK comp_popup IS BOUND.
lr_context_node = comp_popup->get_context_node( iv_cnode_name = 'ZJPPJM' ).
CHECK lr_context_node IS BOUND.
lr_iterator = lr_context_node->collection_wrapper->get_iterator( ).
IF lr_iterator->size( ) > .
lr_btitems ?= me->typed_context->btitems->collection_wrapper->get_current( ).
lr_access = lr_iterator->get_first( ).
WHILE lr_access IS BOUND.
CLEAR:gv_string.
lr_access->get_properties( IMPORTING es_attributes = ls_crmt0057 ).
TRY.
lr_item ?= lr_btitems->create_related_entity( 'BTOrderItemAll' ).
CATCH cx_crm_genil_model_error INTO gr_cx_crm_genil_model_error.
gv_string = gr_cx_crm_genil_model_error->get_text( ).
ENDTRY.
IF lr_item IS BOUND.
CLEAR:gw_item.
lr_item->get_properties( IMPORTING es_attributes = gw_item ).
IF gw_item-guid IS INITIAL.
CALL FUNCTION 'CRM_GUID_CREATE'
IMPORTING
ev_guid = gw_item-guid.
ENDIF.
gw_item-ordered_prod = ls_crmt0057-product_id.
lr_item->set_properties( EXPORTING is_attributes = gw_item ).
lr_schedext ?= lr_item->get_related_entity( 'BTItemSchedlinExt' ).
IF lr_schedext IS NOT BOUND.
lr_schedext ?= lr_item->create_related_entity( 'BTItemSchedlinExt' ).
ENDIF.
IF lr_schedext IS BOUND.
lr_schedlin ?= lr_schedext->get_related_entity( 'BTSchedlinAll' ).
IF lr_schedlin IS NOT BOUND.
lr_schedlin ?= lr_schedext->create_related_entity( 'BTSchedlinAll' ).
ENDIF.
IF lr_schedlin IS BOUND.
CLEAR:ls_schedlin.
ls_schedlin-quantity = ls_crmt0057-quantity.
lr_schedlin->if_bol_bo_property_access~set_properties( is_attributes = ls_schedlin ).
ENDIF.
ENDIF.
typed_context->btitems->collection_wrapper->add( lr_item ).
ENDIF.
lr_access = lr_iterator->get_next( ).
ENDWHILE.
ENDIF. ENDMETHOD.

效果:

UI基础五:简单的OP组件POPUP搜索帮助的更多相关文章

  1. UI基础二:下拉,F4,OP等

    常用的搜索帮助有SE11的SH,域,值列表,组件等...下面介绍一下经常用的: 一:下拉 dropdown是最经常用的,也是最简单的一种. 不管是查询条件,还是结果清单,还是明细界面,下拉都是一样的 ...

  2. Android UI基础之五大布局

    Android  UI基础之五大布局 Android的界面是有布局和组件协同完成的,布局好比是建筑里的框架,而组件则相当于建筑里的砖瓦.组件按照布局的要求依次排列,就组成了用户所看见的界面.Andro ...

  3. 转发-UI基础教程 – 原生App切图的那些事儿

    UI基础教程 – 原生App切图的那些事儿 转发:http://www.shejidaren.com/app-ui-cut-and-slice.html 移动APP切图是UI设计必须学会的一项技能,切 ...

  4. HTML5 UI框架Kendo UI Web中如何创建自定义组件(二)

    在前面的文章<HTML5 UI框架Kendo UI Web自定义组件(一)>中,对在Kendo UI Web中如何创建自定义组件作出了一些基础讲解,下面将继续前面的内容. 使用一个数据源 ...

  5. amaze ui各个模块简单说明

    amaze ui各个模块简单说明 导航添加依据 http://amazeui.org/css/  下面内容属学习笔记,如有理解偏差和错误请留言相告,感谢!* =(官网这块写的很详细) 一.基本样式 1 ...

  6. ASP.NET Core MVC 设计模式 - ASP.NET Core 基础教程 - 简单教程,简单编程

    原文:ASP.NET Core MVC 设计模式 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core MVC 设计模式 上一章节中,我们提到 ASP.NET Co ...

  7. 组件 popup 设计和源码剖析

    前言 NutUI 是一套京东风格的移动端 Vue 组件库,生态系统覆盖面广,支持按需加载.主题定制.多语言等,功能强大.目前 40+ 京东项目正在使用,设计精美,风格统一.在开发组件库的过程中,Nut ...

  8. 20145210 20145226 《信息安全系统设计基础》实验五 简单嵌入式WEB服务器实验

    20145210 20145226 <信息安全系统设计基础>实验五 简单嵌入式WEB服务器实验 结对伙伴:20145226 夏艺华 实验报告封面 实验目的与要求 · 掌握在ARM开发板实现 ...

  9. iOS开发UI篇—Modal简单介绍

    iOS开发UI篇—Modal简单介绍 一.简单介绍 除了push之外,还有另外一种控制器的切换方式,那就是Modal 任何控制器都能通过Modal的形式展⽰出来 Modal的默认效果:新控制器从屏幕的 ...

随机推荐

  1. (转载)C#工具箱Menustrip控件中分割线的设置方法

    最近编C#程序,因为初学,不是太清楚,碰到了toolstripMenu中分割线设置的问题.遍寻中文网页,都是语言不详的,甚是呕人. 上网找了个外文网站,给的答案甚是详细,先贴在下面. http://w ...

  2. 【译】第12节---数据注解-ConcurrencyCheck

    原文:http://www.entityframeworktutorial.net/code-first/concurrencycheck-dataannotations-attribute-in-c ...

  3. 【Java】【事件处理机制】

    import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.Actio ...

  4. Intent 类型

    Intent 分为两种类型: 显式 Intent:按名称(完全限定类名)指定要启动的组件. 通常,您会在自己的应用中使用显式 Intent 来启动组件,这是因为您知道要启动的 Activity 或服务 ...

  5. 1. dubbo概述

    dubbo简介: 官网:http://dubbo.io 最大程度进行解耦,降低系统耦合性,可以跨工程,跨项目; 生产者/消费者模式; jdk:1.6以上 maven:3.0以上 国际maven仓库:h ...

  6. django认证系统 Authentication

    Django自带一个用户认证系统,用于处理用户账户.群组.许可和基于cookie的用户会话. Django的认证系统包含了身份验证和权限管理两部分.简单地说,身份验证用于核实某个用户是否合法,权限管理 ...

  7. <script src="../build/browser.min.js"></script> 是用来里面babel工具把ES6的语法转成ES5

    <!DOCTYPE html> <html> <head> <script src="../build/react.js">< ...

  8. 日志log4cxx 封装、实例讲解、配置文件log4cxx.properties

    日志log4cxx 封装.实例讲解.配置文件log4cxx.properties 1. 日志作用 程序运行过程中,需要记录程序中的运行状况,方便排查问题,记录数据.可以根据日志的记录快速定位错误发生的 ...

  9. AtCoder Grand Contest 025 B - RGB Coloring

    B - RGB Coloring 求ax + by = k (0<=x<=n && 0<=y<=n)的方案数,最后乘上C(n, x)*C(n,y) 代码: #i ...

  10. h5调用手机相册摄像头以及文件夹

    在之前一家公司的时候要做一个app里面有上传头像的功能,当时研究了好久,找到了一篇文章关于h5摄像头以及相册的调用的,所以就解决了这个问题了!!我这里记录一下以便后面有人需要,可以参考一下!!!! 下 ...