Abap 带有数据库表中数据的自定义弹出窗口
我需要显示一个弹出窗口,其中包含数据库表字段中的数据(Abap 带有数据库表中数据的自定义弹出窗口,abap,sap-crm,Abap,Sap Crm,我需要显示一个弹出窗口,其中包含数据库表字段中的数据(Tab1-camp_type) 此时,我创建了一个UI组件(ZUIC_TYPES),一个表视图(VWTYPES),并添加了必要的表字段 在我的上下文节点的DO\u PREPARE\u OUTPUT方法中,我编写了代码,它应该会给出camp\u type字段中的所有值,但我只得到一个值重复37次(我的表中有37行) 如何在弹出窗口中获取所有数据 这是我的密码: DATA:lr_table TYPE REF TO crmc_mkt
Tab1-camp_type
)
此时,我创建了一个UI组件(ZUIC_TYPES
),一个表视图(VWTYPES
),并添加了必要的表字段
在我的上下文节点的DO\u PREPARE\u OUTPUT
方法中,我编写了代码,它应该会给出camp\u type
字段中的所有值,但我只得到一个值重复37次(我的表中有37行)
如何在弹出窗口中获取所有数据
这是我的密码:
DATA:lr_table TYPE REF TO crmc_mktpl_ctype,
lr_struct TYPE crmc_mktpl_ctype,
lt_tabledata TYPE TABLE OF crmc_mktpl_ctype,
ls_tabledata LIKE LINE OF lt_tabledata,
lr_camptype TYPE REF TO cl_bsp_wd_value_node,
lr_col TYPE REF TO cl_crm_bol_bo_col.
"fetch the data.
SELECT DISTINCT camp_type FROM crmc_mktpl_ctype INTO CORRESPONDING FIELDS OF TABLE lt_tabledata.
CHECK sy-subrc = 0.
"create collection object.
CREATE OBJECT lr_col.
CREATE DATA lr_table.
"create one empty value node with the required structure.
CREATE OBJECT lr_camptype
EXPORTING
iv_data_ref = lr_table.
"create value node for each record foound.
LOOP AT lt_tabledata INTO ls_tabledata.
"set the data into the value node.
lr_camptype->if_bol_bo_property_access~set_properties( is_attributes = ls_tabledata ).
"add node to the collection.
lr_col->if_bol_bo_col~add( lr_camptype ).
ENDLOOP.
"all records are processed. set the collection to the collection wrapper of
" context node to make it visible on web ui
me->typed_context->camptype->collection_wrapper->set_collection( lr_col ).
在循环之前只创建了一个节点(
lr\u camptype
),因此要多次添加相同的节点。请记住,在每个循环中,您都会向同一对象添加一个引用,因此在以后处理该对象时,该对象将只包含最新的值
通过将节点的创建移动到循环中,每行应创建一个节点,如下所示:
...
"create collection object.
CREATE OBJECT lr_col.
CREATE DATA lr_table.
"create value node for each record found.
LOOP AT lt_tabledata INTO ls_tabledata.
"create one empty value node with the required structure.
CREATE OBJECT lr_camptype " <=== must be inside the loop !
EXPORTING
iv_data_ref = lr_table.
"set the data into the value node.
lr_camptype->if_bol_bo_property_access~set_properties( is_attributes = ls_tabledata ).
"add node to the collection.
lr_col->if_bol_bo_col~add( lr_camptype ).
ENDLOOP.
...
。。。
“创建集合对象。
创建对象lr_col。
创建数据LRU表。
“为找到的每个记录创建值节点。
将lt_tabledata循环到ls_tabledata。
“创建一个具有所需结构的空值节点。
创建对象lr_camptype“如果添加(lr_camptype)。
结束循环。
...
- 创建Z-UI组件李>
- 通过向导(在创建视图时)创建视图(类型:表 选择必要的表和字段)
- 将视图绑定到窗口
- 为Z窗口创建组件接口
- 在
方法中编写以下代码:DO\u PREPARE\u OUTPUT
- 在标准组件中(从您要调用弹出窗口的位置),为InterfaceView创建组件用法,并在按钮事件中输入代码:
实例属性
公共
类型
参考
IF\BSP\u WD\u POPUP
。
gr_弹出它的类属性 我已经编辑了你的文本,添加了一些“胶水”(更明确地告诉事情),请检查它是否适合你。谢谢你,我将确保在将来更好地解释事情。你的解释对很多人来说都很好。我根据你的建议解决了这部分任务。你能帮我处理弹出部分吗?我应该如何在弹出窗口中显示我的Z组件?
TYPES: BEGIN OF ltype_attr_struct,
camp_type TYPE crm_mktpl_camptype,
description TYPE crm_mktpl_camptypetx, "Added by wizard
END OF ltype_attr_struct.
DATA: lr_table TYPE REF TO crmc_mktpl_ctype,
lr_struct TYPE crmc_mktpl_ctype,
lt_tabledata TYPE TABLE OF ltype_attr_struct,
ls_tabledata LIKE LINE OF lt_tabledata,
lr_camptype TYPE REF TO cl_bsp_wd_value_node,
lr_col TYPE REF TO cl_crm_bol_bo_col.
"fetch the data.
SELECT DISTINCT
A~camp_type,
B~description
FROM TabA AS A INNER JOIN
TabB AS B ON A~camp_type = B~camp_type AND B~langu = 'EN'
INTO TABLE @lt_tabledata.
CHECK sy-subrc = 0.
"create collection object.
CREATE OBJECT lr_col.
CREATE DATA lr_table.
"create one empty value node with the required structure.
CREATE OBJECT lr_camptype
EXPORTING
iv_data_ref = lr_table.
"create value node for each record foound.
LOOP AT lt_tabledata INTO ls_tabledata.
"set the data into the value node.
lr_camptype->if_bol_bo_property_access~set_properties( is_attributes = ls_tabledata ).
"add node to the collection.
lr_col->if_bol_bo_col~add( NEW cl_bsp_wd_value_node( iv_data_ref = REF ltype_attr_struct( ls_tabledata ) ) ).
ENDLOOP.
"all records are processed. set the collection to the collection wrapper of context node to make it visible on web ui
me->typed_context->camptype->set_collection( lr_col ).
me->typed_context->camptype->build_table( ).
gr_popup = me->comp_controller->window_manager->create_popup( iv_interface_view_name = 'ZUIC_CAMP_TYPES/MainWindow'
iv_usage_name = 'ZCUTypes'
iv_title = 'Title' ).
gr_popup->set_window_width( iv_width = 400 ).
gr_popup->set_window_height( iv_height = 600 ).
gr_popup->set_on_close_event( iv_event_name = 'PP_CTYPE_CLOSED'
iv_view = me ).
gr_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_surrounded ).
gr_popup->open( ).