REPORT ztest_6.
**********************************************************************
*Table Declaration
**********************************************************************
TABLES: ekko.
TYPE-POOLS: cntl,slis.
**********************************************************************
*DATA DECLARATION
**********************************************************************
DATA: BEGIN OF it_ekko OCCURS 0,
sel(1),
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
statu LIKE ekpo-statu,
aedat LIKE ekpo-aedat,
matnr LIKE ekpo-matnr,
menge LIKE ekpo-menge,
meins LIKE ekpo-meins,
peinh LIKE ekpo-peinh,
btn(10),
drdbox(20),
dd_handle TYPE int4,
cellstyle TYPE lvc_t_styl,
END OF it_ekko.
**********************************************************************
*DATA declaration for ALV
**********************************************************************
DATA: it_fieldcatalog TYPE lvc_t_fcat,
wa_fieldcatalog TYPE lvc_s_fcat,
g_tab_group TYPE slis_sp_group_alv,
g_layout TYPE slis_layout_alv,
g_repid LIKE sy-repid,
w_layout TYPE lvc_s_layo,
g_stylerow TYPE lvc_s_styl,
g_t_ddval TYPE lvc_t_drop,
g_ddval TYPE lvc_s_drop,
g_events TYPE slis_t_event,
g_event TYPE slis_alv_event,
g_styletab TYPE TABLE OF lvc_s_styl.
*----------------------------------------------------------------------*
* CLASS lcl_event_handlers DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_event_handlers DEFINITION.
PUBLIC SECTION.
METHODS: handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING es_col_id es_row_no.
ENDCLASS. "lcl_event_handlers DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_handlers IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_event_handlers IMPLEMENTATION.
METHOD handle_button_click.
DATA: l_row(10),
l_str TYPE string.
l_row = es_row_no-row_id.
CONCATENATE 'You have clicked on column :' es_col_id-fieldname ',row:' l_row INTO l_str.
MESSAGE l_str TYPE 'I'.
ENDMETHOD. "handle_button_click
ENDCLASS. "lcl_event_handlers IMPLEMENTATION
**********************************************************************
*START-OF-SELECTION
**********************************************************************
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM create_dropdown_values.
PERFORM create_event_exits.
PERFORM display_alv_report.
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* retrieve data from table ekpo
*----------------------------------------------------------------------*
FORM data_retrieval .
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
LOOP AT it_ekko.
it_ekko-btn = sy-tabix.
it_ekko-dd_handle = 1.
CLEAR g_styletab.REFRESH g_styletab.
*>IF the item no is equal to 1, this cell will can not be edited.
IF it_ekko-ebelp EQ 1.
g_stylerow-fieldname = 'SEL'.
g_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
APPEND g_stylerow TO g_styletab.
ENDIF.
*>let the column display as pushbutton
g_stylerow-fieldname = 'BTN'.
g_stylerow-style = cl_gui_alv_grid=>mc_style_button.
APPEND g_stylerow TO g_styletab.
it_ekko-cellstyle[] = g_styletab[].
MODIFY it_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* populate fieldcatalog
*----------------------------------------------------------------------*
FORM build_fieldcatalog .
*>The column will be displayed as checkbox
wa_fieldcatalog-col_pos = 1.
wa_fieldcatalog-fieldname = 'SEL'.
wa_fieldcatalog-scrtext_l = 'Check'.
wa_fieldcatalog-checkbox = 'X'.
wa_fieldcatalog-edit = 'X'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
wa_fieldcatalog-col_pos = 2.
wa_fieldcatalog-fieldname = 'EBELN'.
wa_fieldcatalog-scrtext_l = 'TST1'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
wa_fieldcatalog-col_pos = 3.
wa_fieldcatalog-fieldname = 'EBELP'.
wa_fieldcatalog-scrtext_l = 'TST2'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
wa_fieldcatalog-col_pos = 4.
wa_fieldcatalog-fieldname = 'STATU'.
wa_fieldcatalog-scrtext_l = 'TST3'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
wa_fieldcatalog-col_pos = 5.
wa_fieldcatalog-fieldname = 'AEDAT'.
wa_fieldcatalog-scrtext_l = 'TST4'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
wa_fieldcatalog-col_pos = 6.
wa_fieldcatalog-fieldname = 'MATNR'.
wa_fieldcatalog-scrtext_l = 'TST5'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
wa_fieldcatalog-col_pos = 7.
wa_fieldcatalog-fieldname = 'MENGE'.
wa_fieldcatalog-scrtext_l = 'TST6'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
wa_fieldcatalog-col_pos = 8.
wa_fieldcatalog-fieldname = 'MEINS'.
wa_fieldcatalog-scrtext_l = 'TST7'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
wa_fieldcatalog-col_pos = 9.
wa_fieldcatalog-fieldname = 'PEINH'.
wa_fieldcatalog-scrtext_l = 'TST8'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
*>The column will be displayed as button
wa_fieldcatalog-col_pos = 10.
wa_fieldcatalog-fieldname = 'BTN'.
wa_fieldcatalog-scrtext_l = 'TST9'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
*>The column will be displayed as dropdownbox
wa_fieldcatalog-col_pos = 11.
wa_fieldcatalog-fieldname = 'DRDBOX'.
wa_fieldcatalog-edit = 'X'.
wa_fieldcatalog-drdn_field = 'DD_HANDLE'.
wa_fieldcatalog-scrtext_l = 'TST10'.
APPEND wa_fieldcatalog TO it_fieldcatalog.CLEAR wa_fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form CREATE_DROPDOWN_VALUES
*&---------------------------------------------------------------------*
FORM create_dropdown_values.
g_ddval-handle = 1.
g_ddval-value = 'yes'.
APPEND g_ddval TO g_t_ddval.
g_ddval-handle = 1.
g_ddval-value = 'no'.
APPEND g_ddval TO g_t_ddval.
ENDFORM. "CREATE_DROPDOWN_VALUES
*&---------------------------------------------------------------------*
*& Form create_event_exits
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM create_event_exits.
g_event-name = 'CALLER_EXIT'.
g_event-form = 'CALLER_EXIT'.
APPEND g_event TO g_events.
ENDFORM. "create_event_exits
*&---------------------------------------------------------------------*
*& Form CALLER_EXIT
*&---------------------------------------------------------------------*
FORM caller_exit USING ls_data TYPE slis_data_caller_exit.
DATA: l_ref_alv TYPE REF TO cl_gui_alv_grid,
l_ref_handler TYPE REF TO lcl_event_handlers.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_ref_alv.
CALL METHOD l_ref_alv->set_drop_down_table
EXPORTING
it_drop_down = g_t_ddval.
CREATE OBJECT l_ref_handler.
SET HANDLER l_ref_handler->handle_button_click FOR l_ref_alv.
ENDFORM. "CALLER_EXIT
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* populate layout
*----------------------------------------------------------------------*
FORM build_layout .
w_layout-stylefname = 'CELLSTYLE'.
w_layout-zebra = 'X'.
w_layout-box_fname = 'SEL'.
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* display alv report
*----------------------------------------------------------------------*
FORM display_alv_report .
* CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
* EXPORTING
* i_callback_program = sy-repid
* i_callback_user_command = 'USER_COMMAND'
* is_layout = g_layout
* it_fieldcat = it_fieldcatalog
** i_save = 'X'
* TABLES
* t_outtab = it_ekko
* EXCEPTIONS
* program_error = 1
* OTHERS = 2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = w_layout
it_events = g_events
i_callback_user_command = 'USER_COMMAND'
it_fieldcat_lvc = it_fieldcatalog
TABLES
t_outtab = it_ekko[].
ENDFORM. " DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* USER-COMMAND
*----------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
*>Check function code
CASE r_ucomm.
WHEN '&IC1'.
*>Check field clicked on within alv grid report
IF rs_selfield-fieldname = 'EBELN'.
READ TABLE it_ekko INDEX rs_selfield-tabindex.
SET PARAMETER ID 'BES' FIELD it_ekko-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
* IF rs_selfield-fieldname = 'SEL'.
* READ TABLE it_ekko INDEX rs_selfield-tabindex.
* it_ekko-sel = 'X'.
* MODIFY it_ekko.
* ENDIF.
WHEN '&DATA_SAVE'.
LOOP AT it_ekko.
IF it_ekko-sel EQ 'X'.
WRITE: / it_ekko-ebeln.
ENDIF.
ENDLOOP.
* LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 1000.
ENDCASE.
rs_selfield-refresh = 'X'.
ENDFORM. "user_command
- 大小: 25 KB
分享到:
相关推荐
REUSE_ALV_GRID_DISPLAY超详细讲解 REUSE_ALV_GRID_DISPLAY是一个功能强大的ABAP函数模块,主要用于在ABAP程序中显示ALV网格控件。该函数模块提供了大量的参数和事件,使得开发者可以根据需要自定义ALV网格控件的...
而将 Checkbox(复选框)集成到 StringGrid 中,则为用户提供了一种直观的方式来选择或标记特定行或列的数据。本文将深入探讨如何在 Delphi 的 StringGrid 中使用 Checkbox,并提供相关的编程技巧。 1. **添加 ...
### 编程动态 ALV 在 WebDynpro for ABAP 中的应用 #### 概述 本文旨在探讨如何在 WebDynpro for ABAP 中编程实现动态 ALV(Application List Viewer)。通过本教程,您将学会如何根据用户的选择动态地构建 ALV 的...
PARAMETERS: p_loekz TYPE C AS CHECKBOX DEFAULT ''. "显示有删除标志的信息记录 SELECT-OPTIONS: s_ekorg FOR EINE-EKORG MEMORY ID EKO. "采购组织 SELECT-OPTIONS: s_matnr FOR EINA-MATNR MEMORY ID MAT. ...
在ASP.NET开发中,CheckBox控件常常用于实现用户界面中的多选功能,而"CheckBox全选并删除"这个主题涉及到两个关键操作:全选和删除。全选功能允许用户一次性选择多个选项,删除则通常指的是从数据库或其他数据存储...
+ CHECKBOX ALV:控制作为复选框输出。 + JUST ALV:控制对齐方式:'R':右对齐,'L':左对齐,'C':居中对齐。 + LZERO ALV:控制输出前导零。 + NO_SIGN ALV:控制输出抑制符号。 + NO_ZERO ALV:控制为输出...
2. 调用方法:ALV可以通过多种方式调用,例如通过`REUSE_ALV_GRID_DISPLAY`、`CALL_REPORT_OUTPUT`等函数模块,或者使用CL_GUI_ALV_GRID类。 3. 示例代码:提供的DEMO代码展示了如何在SAP ABAP程序中集成ALV并进行...
3. 调用ALV生成函数,如`CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'`,传递内表和其他参数。 4. 处理用户交互,如排序、过滤或导出。 5. 关闭ALV,释放资源。 ALV还支持许多高级功能,比如列的动态隐藏和显示、列的...
var checkBox = sender as CheckBox; var item = VisualTreeHelper.GetParent(checkBox) as TreeViewItem; // 更新数据模型和子节点的IsChecked状态 } ``` 总的来说,"带CheckBox的TreeView控件"通过结合...
代码中展示了如何通过调用`REUSE_ALV_GRID_DISPLAY`函数来显示ALV网格,并注册了回调函数(`i_callback_program`),以便处理用户命令(`I_CALLBACK_USER_COMMAND`)。当用户点击保存按钮(`'&SAVE'`)时,代码会先...
压缩包中的`CheckBoxItem.as`可能是一个自定义的Checkbox类,它扩展了Flex内置的Checkbox类,并可能添加了额外的功能或属性。而`CheckBox.txt`可能是关于如何使用这些Checkbox的文档或者示例代码。 总的来说,Flex...
foreach (ListItem item in CheckBoxList1.Items) { if (item.Selected) { string selectedText = item.Text; string selectedValue = item.Value; // 进行相关操作 } } ``` 在客户端(浏览器端)使用...
在调用`REUSE_ALV_GRID_DISPLAY`时,需要传递一系列的参数来定义ALV表格的外观和行为。下面详细介绍这些参数: 1. **i_interface_check**:此参数用于指定是否进行接口一致性检查。如果设置了此参数,则系统会验证...
ListItem selectedItem = (sender as CheckBox).Parent as ListItem; // 使所有其他列表项处于未选中状态 foreach (ListItem item in cblSingleSelect.Items) { if (item != selectedItem) item.Selected = ...
1、ListView item中加入checkbox后onListItemClick 事件无法触发。 原因:checkbox的优先级高于ListItem于是屏蔽了ListItem的单击事件。 解决方案:设置checkbox的android:focusable="false" 2、选择其中的...
### SAP ALV Grid 控制器详解 #### 一、ALV Grid 控制器简介 **ALV Grid 控制器**(ALV = SAP List Viewer)是SAP开发环境中的一个非常重要的工具,它用于在SAP GUI应用程序中展示数据列表。ALV Grid 控制器不仅...
本文将深入探讨如何利用字体图标来自定义CheckBox控件,从而提升应用的视觉效果。 首先,我们需要理解WPF中的CheckBox控件。CheckBox是WPF中的一个标准控件,用于提供用户可以选择或取消选择的选项。它的默认样式...