I'm still in the learning phase of SAP ABAP, so please bear with me. So I am trying to create a report that will retrieve data from vbak table, but there are some conditions: 1) Enable and Disable radio buttons. 2) Use a "AT SELECTION-SCREEN ON " statement. 3) Checkbox'organize' (To print out the data in a presentable way) 4) Checkbox 'Download as a Text File' to download the data as a text file.
My Code:
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.
I mean, without the AT SELECTION-SCREEN ON statement, it mostly works. But the AT SELECTION-SCREEN ON is one of the conditions. Thanks a lot.
You start your code without a
START-OF_SELECTION
.By default, your report start with the event
START-OF_SELECTION
, but withAT SELECTION-SCREEN
you define another event and your code doesn't start atSTART-OF_SELECTION
.So you have two solutions:
AT SELECTION-SCREEN
below your main code.START-OF_SELECTION
before your main code.And as vwegert already mentioned, to change the setting on the selection screen, you need a
LOOP AT SCREEN
.