发现一个很方便的ALV函数REUSE_ALV_POPUP_TO_SELECT,通过这一个函数就可以实现在弹出窗口中显示带checkbox的ALV。
完整代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
REPORT z_popup_alv. TYPE-POOLS: slis. TABLES: spfli. *--------------------------------------------------------------* *Data Types *--------------------------------------------------------------* TYPES: BEGIN OF ty_spfli, check TYPE c. INCLUDE TYPE spfli. TYPES: END OF ty_spfli. *--------------------------------------------------------------* *Data Declaration *--------------------------------------------------------------* DATA: gt_spfli TYPE TABLE OF ty_spfli. DATA: gwa_spfli TYPE ty_spfli. DATA: gwa_selfield TYPE slis_selfield. *--------------------------------------------------------------* *Selection-Screen *--------------------------------------------------------------* SELECT-OPTIONS: s_carrid FOR spfli-carrid. *--------------------------------------------------------------* * Start-of-selection *--------------------------------------------------------------* START-OF-SELECTION. CLEAR: gwa_selfield. **Get data SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE gt_spfli. **Remove duplicates DELETE ADJACENT DUPLICATES FROM gt_spfli COMPARING carrid. CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT' EXPORTING i_checkbox_fieldname = 'CHECK' i_tabname = 'GT_SPFLI' " Internal table name i_structure_name = 'SPFLI' IMPORTING es_selfield = gwa_selfield TABLES t_outtab = gt_spfli " Internal table which contains entries EXCEPTIONS program_error = 1 OTHERS = 2. REFRESH s_carrid. |
运行,
ALV中的checkbox可以复选,所以本函数也可以用在F4 help上,允许用户选择多条数据作为选择画面的筛选条件。
以上。
发表评论