Online Tutorials & Training Materials | STechies.com
Register Login

Using a checkbox in a report

|| 3

Using a checkbox in a report
Stechies

In a report you can use a checkbox to select one ore more records.

* Define field for the checkbox
data markfield(1) type c value space.
* Define filed for counting line numbers
data lineno type i.


* Writing the report with a checkbox
write: / markfield as checkbox,
i_ejitabel-zzbukrs,
i_ejitabel-zzsaknr.

* Reading the lines and cehcking if the line has been checked
lineno = 0.
do.
* Counting the line numbers
lineno = lineno + 1.

* Read the value of markfield
read line lineno field value markfield.

* Test for end of report
if sy-subrc ne 0. exit. endif.

* If the value of the checkbox is X ( The checkbox is checked) the read

* the rest of the fields of the report line into the internal table itab.
if markfield = 'X'.
read current line field value i_ejitabel-zzbukrs into itab
i_ejitabel-zzsaknr into itab.
endif.


enddo.


Comments

  • 13 Jun 2008 6:29 pm
    i want to include a button in the report ,click on which gives secondary report that lists the further details of the checked records,hw can i do that?
  • 29 Jan 2009 12:30 pm
    Great, It works fine. If you want to include a button, you can create a PF-STATUS and add a button in the application toolbar.
    ex : - START-OF-SELECTION.
    SET pf-status 'your_GUI_Status'.
    ......

    Then you can handle the events at the AT USER-COMMAND.

  • 17 Sep 2013 1:40 pm
    * copy this example

    REPORT ZTEST_FRED .

    types : begin of s_list,
    sel type c,
    txt type char10,
    end of s_list.

    DATA : lt_list type standard table of s_list.
    DATA : ls_list type s_list.
    DATA : lineno type i.

    PARAMETERS : go type c as checkbox.

    set pf-status 'ZTEST'.
    ls_list-sel = 'X'.
    ls_list-txt = 'test1'.
    append ls_list to lt_list.

    ls_list-sel = ' '.
    ls_list-txt = 'test2'.
    append ls_list to lt_list.


    loop at lt_list into ls_list.
    write:/ ls_list-sel as checkbox.
    write: ls_list-txt.
    endloop.

    AT USER-COMMAND.

    CASE SY-UCOMM.
    WHEN OTHERS.
    lineno = 2.
    DO 2 times.
    lineno = lineno + 1.
    * Read the value of markfield
    read line lineno field value ls_list-sel.

    * Test for end of report
    if sy-subrc ne 0. exit. endif.

    * If the value of the checkbox is X ( The checkbox is checked) the read
    * the rest of the fields of the report line into the internal table itab.
    if ls_list-sel = 'X'.
    * read current line field value i_ejitabel-sel into itab
    * i_ejitabel-zzsaknr into itab.
    endif.

    enddo.
    ENDCASE.