ABAP grid的alv的如何增加checkbox列,可以选择和全选,请各位大虾批点。
各位大虾:我是ABAP初学者,做了一个查询窗口,不知如何grid的alv的如何增加checkbox列,可以选择和全选,发程序上来,不让发,因为行数太多,我的QQ:7710...
各位大虾:我是ABAP初学者,做了一个查询窗口,不知如何grid的alv的如何增加checkbox列,可以选择和全选,发程序上来,不让发,因为行数太多,我的QQ:77103055@qq.com,能否发给大虾,帮忙教一下如何
增加checkbox列,可以选择和全选。谢谢! 展开
增加checkbox列,可以选择和全选。谢谢! 展开
1个回答
展开全部
小伙子 在需要设置CHECKBOX字段的FIELDCAT表里面把CHECKBOX设置成"X'就行了啊
话不多说 发个例子 请观察65行:
*&---------------------------------------------------------------------*
*& Report ZR_MM_12
*&---------------------------------------------------------------------*
REPORT zr_mm_12.
TABLES : ekko,ekpo,ekbe,t001l.
DATA:BEGIN OF itab OCCURS 0 ,
mark TYPE c,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
bedat LIKE ekko-bedat,
matnr LIKE ekpo-matnr,
txz01 LIKE ekpo-txz01,
werks LIKE ekpo-werks,
lgort LIKE ekpo-lgort,
lgobe LIKE t001l-lgobe,
menge LIKE ekpo-menge,
menge2 LIKE ekpo-menge,
menge3 LIKE ekpo-menge,
menge4 LIKE ekpo-menge,
menge5 LIKE ekpo-menge,
menge6 LIKE ekpo-menge,
END OF itab.
TYPE-POOLS: slis.
***alv 结构定义
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_events TYPE slis_t_event, " ALV Event table
gd_repid LIKE sy-repid,
rpt_title(40) TYPE c,
space_11(15) TYPE c ,
dat_11(10) TYPE c.
DATA: wa_sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
SELECT-OPTIONS: s_matnr FOR ekpo-matnr,
s_bedat FOR ekko-bedat,
s_lgort FOR ekpo-lgort.
START-OF-SELECTION.
PERFORM getdata.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
PERFORM outdata.
*&---------------------------------------------------------------------*
*& Form getdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM getdata.
SELECT * INTO CORRESPONDING FIELDS OF TABLE itab FROM ekko INNER JOIN ekpo
ON ( ekko~ebeln = ekpo~ebeln )
WHERE ekpo~matnr IN s_matnr AND ekpo~loekz <> 'L' AND ekko~bedat IN s_bedat AND ekpo~lgort IN s_lgort.
ENDFORM. "getdata
*&---------------------------------------------------------------------*
*& Form build_fieldcatalog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'MARK'.
fieldcatalog-seltext_m = 'FLAG'.
fieldcatalog-checkbox = 'X'. "设置 MARK字段为CHECK BOX
fieldcatalog-edit = 'X'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = '采购订单号'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-seltext_m = '物料号码'.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'TXZ01'.
fieldcatalog-seltext_m = '物料描述'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'BEDAT'.
fieldcatalog-seltext_m = '凭证日期'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'WERKS'.
fieldcatalog-seltext_m = '工厂'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'LGORT'.
fieldcatalog-seltext_m = '库存地点'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'LGOBE'.
fieldcatalog-seltext_m = '库存地点描述'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = '订单数量'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
*
fieldcatalog-fieldname = 'MENGE2'.
fieldcatalog-seltext_m = '收货数量'.
fieldcatalog-col_pos = 7.
APPEND fieldcatalog TO fieldcatalog.
*
fieldcatalog-fieldname = 'MENGE3'.
fieldcatalog-seltext_m = '剩余收货'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
ENDFORM. "build_fieldcatalog
*&---------------------------------------------------------------------*
*& Form build_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_layout.
gd_layout-no_input = ' '.
GD_LAYOUT-box_fieldname = 'MARK'.
gd_layout-colwidth_optimize = 'X'.
ENDFORM. " build_layout
*&---------------------------------------------------------------------*
*& Form display_alv_report
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_events = gt_events[]
i_save = 'X' " i_grid_title = sy-title
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " display_alv_report
*&---------------------------------------------------------------------*
*& Form SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->EXTAB text
*----------------------------------------------------------------------*
FORM set_pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD'. " EXCLUDING EXTAB.
ENDFORM. "SET_PF_STATUS
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
READ TABLE itab INDEX selfield-tabindex.
CHECK sy-subrc = 0.
CASE ucomm.
WHEN 'DET'.
LOOP AT itab WHERE mark = 'X'.
WRITE : / itab-ebeln,itab-matnr.
ENDLOOP.
ENDCASE.
ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form outdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM outdata.
LOOP AT itab.
ENDLOOP.
ENDFORM. "outdata
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询