Allow the end user to select what he or she wants via checkboxes in the report. Presenting a nice overview in a report sometimes needs a multi line selection mechanism, for which checkboxes can be the solution. Check out a simple setup where checkboxes are dispayed using the AS CHECKBOX
option from the WRITE
statement:
Here's an example of a report that writes a checkbox, along with information to enable to determine which box was checked.
REPORT ZZCHECK. DATA: I_PLANT LIKE MARC-WERKS OCCURS 5 WITH HEADER LINE, G_PLANT LIKE MARC-WERKS. * .... assume there are a few entries in the I_PLANT table START-OF-SELECTION. LOOP AT I_PLANT. WRITE: /4 'X' AS CHECKBOX, I_PLANT. G_PLANT = I_PLANT. HIDE: G_PLANT. ENDLOOP.
In short: a report will be displayed showing a checkbox and a value. The functionality described here can be used to "untick" plants from a certain selection. Thus: the table I_PLANT
contains entries that will be deleted in the following block if the checkbox that percedes it is unticked.
AT USER-COMMAND. * A menu with one button is available, it's function code is 'PROCEED'. IF SY-UCOMM EQ 'PROCEED'. DO. "Do forever (until there are no report lines left) CLEAR: G_PLANT. "Clear the fields that were held with HIDE READ LINE SY-INDEX. "Pick up a line from the report IF SY-SUBRC NE 0. "Last line is handled here EXIT. ENDIF. IF NOT G_PLANT IS INITIAL. "It was held with HIDE READ TABLE R_WERKS WITH KEY LOW = G_PLANT. IF SY-LISEL+3(1) NE 'X' AND "It's ticked off ! (tick on position 4 SY-SUBRC EQ 0. "Read Table did not fail DELETE R_WERKS INDEX SY-TABIX. ENDIF. ENDIF. ENDDO. ENDIF. "SY-UCOMM
Note: the system variabele SY-LISEL
was used in this example, but using the READ LINE
options is the more elegant solution.
As a checkbox - not accepting changes
You may find it's quite strange that a checkbox field is defaulted accepting input in a report. It's strange. But it can easily be controlled, use the option INPUT OFF
to display your report value as a checkbox - readonly version:
write: lv_myflag as checkbox INPUT OFF.