我还在SAP ABAP的学习阶段,请多多包涵。所以我正在尝试创建一个将从 vbak 表中检索数据的报告,但有一些条件:1)启用和禁用单选按钮。2) 使用“AT SELECTION-SCREEN ON”语句。3) 复选框“组织”(以一种可呈现的方式打印数据) 4) 复选框“下载为文本文件”以将数据下载为文本文件。
我的代码:
REPORT z_testingdemo.
TABLES: vbak.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME NO INTERVALS.
PARAMETERS: rb_on RADIOBUTTON GROUP g1.
PARAMETERS: rb_off RADIOBUTTON GROUP g1.
PARAMETERS: p_name TYPE char15.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
PARAMETERS: c_check AS CHECKBOX DEFAULT 'X'.
PARAMETERS: c_check2 AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP g1.
IF rb_on IS INITIAL.
MESSAGE 'Please Press ENABLE to ENABLE the FIELDS' TYPE 'E'.
ENDIF.
"--------I don't really know why this part didn't work -----------
* IF rb_off = 'X'.
* screen-active = 0.
* modify screen.
* ELSE.
* screen-active = 1.
* modify screen.
* ENDIF.
"------------------------------------------------------------------
TYPES: BEGIN OF itab,
vbeln TYPE vbak-vbeln,
vkorg TYPE vbak-vkorg,
vtweg TYPE vbak-vtweg,
spart TYPE vbak-spart,
END OF itab.
DATA: wa_ma TYPE itab,
it_ma TYPE STANDARD TABLE OF itab.
SELECT vbeln vkorg vtweg spart
FROM vbak
INTO TABLE it_ma
WHERE vbeln IN s_vbeln.
IF sy-subrc = 0 AND c_check = '' AND c_check2 = ''.
LOOP AT it_ma INTO wa_ma.
WRITE : / wa_ma-vbeln, wa_ma-vkorg , wa_ma-vtweg, wa_ma-spart.
ENDLOOP.
ELSEIF sy-subrc = 0 AND c_check = 'X' AND c_check2 = ''.
LOOP AT it_ma INTO wa_ma.
WRITE : / wa_ma-vbeln, 17 wa_ma-vkorg , 37 wa_ma-vtweg, 51 wa_ma-spart.
ENDLOOP.
ELSEIF sy-subrc = 0 AND c_check2 = 'X'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:/REPORT4.TXT'
write_field_separator = ','
TABLES
data_tab = it_ma.
ELSEIF sy-subrc = 0 AND c_check = '' AND c_check2 = 'X'.
ENDIF.
TOP-OF-PAGE .
PERFORM display_heading .
FORM display_heading.
WRITE : / sy-uline .
WRITE: / 'REPORT 4'.
IF c_check = 'X'.
WRITE: / .
WRITE : /'For Mr./Mrs.: ', p_name.
WRITE : /'SALES DOCUMENT', 17 'SALES ORGANIZATION', 37 'DISTRIBUTION', 51 'CHANN. DIVISION'.
WRITE : / sy-uline .
ENDIF.
ENDFORM.
我的意思是,如果没有 AT SELECTION-SCREEN ON 语句,它基本上可以工作。但 AT SELECTION-SCREEN ON 是条件之一。非常感谢。