Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use checkbox in reports

Former Member
0 Kudos

Hi,

I am stuck a little here.I have given some selection-options,

few parameters on screen and two checkboxes.

How will i know which one is clicked.I will be glad if someone can provide me small snippet .

11 REPLIES 11

Former Member
0 Kudos

Hi,

Effect

Outputs the field f as a checkbox. The contents of the first character of f is interpreted as the "status":

' ' = not selected

'X' = selected

The user can change this as required.

Note

To prevent the user changing the contents of the checkbox, you can use the addition ... INPUT OFF . The checkbox is then nothing more than a status display and can only be changed by programming.

In technical terms, a checkbox behaves exactly like an input field with a length of 1 (FORMAT INPUT ).

Examples

DATA: MARKFIELD(1) TYPE C VALUE 'X'.

...

WRITE MARKFIELD AS CHECKBOX. "checkbox selected

MARKFIELD = SPACE.

WRITE MARKFIELD AS CHECKBOX. "deselected

WRITE MARKFIELD AS CHECKBOX INPUT OFF. "deselected, protected

Regards,

Jagadish

0 Kudos

will it be if chk1-status = 'X' or ' ' ,i could not carry on with this info.

0 Kudos

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.

Regards,

Jagadish

0 Kudos

hi

do the following way

if chckbox1 = 'X'.

<urcode>.

else.

<ur code>.

endif.

PARAMETERS : p_chck1 as CHECKBOX USER-COMMAND check,

p_chck2 AS CHECKBOX USER-COMMAND check1.

if p_chck1 = 'X'.

select dmbtr from bsid into corresponding fields of table it_opencredits

where kunnr = p_kunnr and

gsber = p_gsber and shkzg = 'H' and

budat <= l_tilldate

and umskz = ' '.

endif.

write:/5 'In Loop'.

endif.

if p_check2 = 'X'.

select dmbtr from bsid into corresponding fields of table it_opencredits

where kunnr = p_kunnr and

gsber = p_gsber and shkzg = 'H' and

budat <= l_tilldate

and umskz <> ' '.

write:/5 'In Loop'.

endif.

regards

prasanth

0 Kudos

I m using this

if chk1 = '' and chk2 = 'X'.

select dmbtr from bsid into corresponding fields of table it_opencredits

where kunnr = p_kunnr and

gsber = p_gsber and shkzg = 'H' and

budat <= l_tilldate

and umskz <> ' '.

write:/5 'In Loop'.

endif.

if chk1 = 'X' and chk2 = ''.

select dmbtr from bsid into corresponding fields of table it_opencredits

where kunnr = p_kunnr and

gsber = p_gsber and shkzg = 'H' and

budat <= l_tilldate

and umskz = ' '.

endif.

write:/5 'In Loop'.

endif.

and i find it is going in both even i select one.

0 Kudos

I corrected ur code as follows.

PARAMETERS : p_chck1 as CHECKBOX USER-COMMAND check,

p_chck2 AS CHECKBOX USER-COMMAND check1.

if p_chck1 = 'X'.

select dmbtr from bsid into corresponding fields of table it_opencredits

where kunnr = p_kunnr and

gsber = p_gsber and shkzg = 'H' and

budat <= l_tilldate

and umskz = ' '.

endif.

write:/5 'In Loop'.

endif.

if p_check2 = 'X'.

select dmbtr from bsid into corresponding fields of table it_opencredits

where kunnr = p_kunnr and

gsber = p_gsber and shkzg = 'H' and

budat <= l_tilldate

and umskz <> ' '.

write:/5 'In Loop'.

endif.

Reward if helpful.

0 Kudos

Hi,

see the sample code for interactive list and do accordingly

REPORT ZTEJ_INTAB1 LINE-SIZE 103 LINE-COUNT 35(5) NO STANDARD PAGE

HEADING.

*TABLES DECLARATION

TABLES : KNA1, VBAK, VBAP.

*SELECT OPTIONS

SELECT-OPTIONS: CUST_NO FOR KNA1-KUNNR.

*INITIALIZATION

INITIALIZATION.

CUST_NO-LOW = '01'.

CUST_NO-HIGH = '5000'.

CUST_NO-SIGN = 'I'.

CUST_NO-OPTION = 'BT'.

APPEND CUST_NO.

*SELECTION SCREEN VALIDATION

AT SELECTION-SCREEN ON CUST_NO.

IF CUST_NO-LOW < 1 OR CUST_NO-HIGH > 5000.

MESSAGE E001(ZTJ1).

ENDIF.

*BASIC LIST SELECTION

START-OF-SELECTION.

SELECT KUNNR NAME1 ORT01 LAND1 INTO

(KNA1-KUNNR, KNA1-NAME1,KNA1-ORT01,KNA1-LAND1)

FROM KNA1

WHERE KUNNR IN CUST_NO.

WRITE:/1 SY-VLINE,

KNA1-KUNNR UNDER 'CUSTOMER NO.' HOTSPOT ON,

16 SY-VLINE,

KNA1-NAME1 UNDER 'NAME',

61 SY-VLINE,

KNA1-ORT01 UNDER 'CITY',

86 SY-VLINE,

KNA1-LAND1 UNDER 'COUNTRY',

103 SY-VLINE.

HIDE: KNA1-KUNNR.

ENDSELECT.

ULINE.

*SECONDARY LIST ACCESS

AT user-command.

IF SY-UCOMM = 'IONE'.

PERFORM SALES_ORD.

ENDIF.

IF SY-UCOMM = 'ITWO'.

PERFORM ITEM_DET.

ENDIF.

*TOP OF PAGE

TOP-OF-PAGE.

FORMAT COLOR 1.

WRITE : 'CUSTOMER DETAILS'.

FORMAT COLOR 1 OFF.

ULINE.

FORMAT COLOR 3.

WRITE : 1 SY-VLINE,

3 'CUSTOMER NO.',

16 SY-VLINE,

18 'NAME',

61 SY-VLINE,

63 'CITY',

86 SY-VLINE,

88 'COUNTRY',

103 SY-VLINE.

ULINE.

FORMAT COLOR 3 OFF.

*TOP OF PAGE FOR SECONDARY LISTS

TOP-OF-PAGE DURING LINE-SELECTION.

*TOP OF PAGE FOR 1ST SECONDARY LIST

IF SY-UCOMM = 'IONE'.

ULINE.

FORMAT COLOR 1.

WRITE : 'SALES ORDER DETAILS'.

ULINE.

FORMAT COLOR 1 OFF.

FORMAT COLOR 3.

WRITE : 1 SY-VLINE,

3 'CUSTOMER NO.',

16 SY-VLINE,

18 'SALES ORDER NO.',

40 SY-VLINE,

42 'DATE',

60 SY-VLINE,

62 'CREATOR',

85 SY-VLINE,

87 'DOC DATE',

103 SY-VLINE.

ULINE.

ENDIF.

FORMAT COLOR 3 OFF.

*TOP OF PAGE FOR 2ND SECONDARY LIST

IF SY-UCOMM = 'ITWO'.

ULINE.

FORMAT COLOR 1.

WRITE : 'ITEM DETAILS'.

ULINE.

FORMAT COLOR 1 OFF.

FORMAT COLOR 3.

WRITE : 1 SY-VLINE,

3 'SALES ORDER NO.',

40 SY-VLINE,

42 'SALES ITEM NO.',

60 SY-VLINE,

62 'ORDER QUANTITY',

103 SY-VLINE.

ULINE.

ENDIF.

FORMAT COLOR 3 OFF.

*END OF PAGE

END-OF-PAGE.

ULINE.

WRITE :'USER :',SY-UNAME,/,'DATE :', SY-DATUM, 85 'END OF PAGE:',

SY-PAGNO.

SKIP.

&----


*& Form SALES_ORD

*&

*& FIRST SECONDARY LIST FORM

&----


FORM SALES_ORD .

SELECT KUNNR VBELN ERDAT ERNAM AUDAT INTO

(VBAK-KUNNR, VBAK-VBELN, VBAK-ERDAT, VBAK-ERNAM, VBAK-AUDAT)

FROM VBAK

WHERE KUNNR = KNA1-KUNNR.

WRITE:/1 SY-VLINE,

VBAK-KUNNR UNDER 'CUSTOMER NO.' HOTSPOT ON,

16 SY-VLINE,

VBAK-VBELN UNDER 'SALES ORDER NO.' HOTSPOT ON,

40 SY-VLINE,

VBAK-ERDAT UNDER 'DATE',

60 SY-VLINE,

VBAK-ERNAM UNDER 'CREATOR',

85 SY-VLINE,

VBAK-AUDAT UNDER 'DOC DATE',

103 SY-VLINE.

HIDE : VBAK-VBELN.

ENDSELECT.

ULINE.

ENDFORM. " SALES_ORD

&----


*& Form ITEM_DET

*&

*& SECOND SECONDARY LIST FORM

&----


FORM ITEM_DET .

SELECT VBELN POSNR KWMENG INTO

(VBAP-VBELN, VBAP-POSNR, VBAP-KWMENG)

FROM VBAP

WHERE VBELN = VBAK-VBELN.

WRITE : /1 SY-VLINE,

VBAP-VBELN UNDER 'SALES ORDER NO.',

40 SY-VLINE,

VBAP-POSNR UNDER 'SALES ITEM NO.',

60 SY-VLINE,

VBAP-KWMENG UNDER 'ORDER QUANTITY',

103 SY-VLINE.

ENDSELECT.

ULINE.

ENDFORM. " ITEM_DET

************************************************************************

REPORT demo_list_at_pf.

START-OF-SELECTION.

WRITE 'Basic List, Press PF5, PF6, PF7, or PF8'.

AT pf5.

PERFORM out.

AT pf6.

PERFORM out.

AT pf7.

PERFORM out.

AT pf8.

PERFORM out.

FORM out.

WRITE: 'Secondary List by PF-Key Selection',

/ 'SY-LSIND =', sy-lsind,

/ 'SY-UCOMM =', sy-ucomm.

ENDFORM.

After executing the program, the system displays the basic list. The user can press the function keys F5 , F6 , F7 , and

F8 to create secondary lists. If, for example, the 14th key the user presses is F6 , the output on the displayed

secondary list looks as follows:

Secondary List by PF-Key Selection

SY-LSIND = 14

SY-UCOMM = PF06

Example for AT USER-COMMAND.

REPORT demo_list_at_user_command NO STANDARD PAGE HEADING.

START-OF-SELECTION.

WRITE: 'Basic List',

/ 'SY-LSIND:', sy-lsind.

TOP-OF-PAGE.

WRITE 'Top-of-Page'.

ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.

CASE sy-pfkey.

WHEN 'TEST'.

WRITE 'Self-defined GUI for Function Codes'.

ULINE.

ENDCASE.

AT LINE-SELECTION.

SET PF-STATUS 'TEST' EXCLUDING 'PICK'.

PERFORM out.

sy-lsind = sy-lsind - 1.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'FC1'.

PERFORM out.

WRITE / 'Button FUN 1 was pressed'.

WHEN 'FC2'.

PERFORM out.

WRITE / 'Button FUN 2 was pressed'.

WHEN 'FC3'.

PERFORM out.

WRITE / 'Button FUN 3 was pressed'.

WHEN 'FC4'.

PERFORM out.

WRITE / 'Button FUN 4 was pressed'.

WHEN 'FC5'.

PERFORM out.

WRITE / 'Button FUN 5 was pressed'.

ENDCASE.

sy-lsind = sy-lsind - 1.

FORM out.

WRITE: 'Secondary List',

/ 'SY-LSIND:', sy-lsind,

/ 'SY-PFKEY:', sy-pfkey.

ENDFORM.

When you run the program, the system displays the following basic list with a the page header defined in the program:

You can trigger the AT LINE-SELECTION event by double-clicking a line. The system sets the status TEST and deactivates the function code PICK. The status TEST contains function codes FC1 to FC5. These are assigned to pushbuttons in the application toolbar. The page header of the detail list depends on the status.

Here, double-clicking a line no longer triggers an event. However, there is now an application toolbar containing five user-defined pushbuttons. You can use these to trigger the AT USER-COMMAND event. The CASE statement contains a different reaction for each pushbutton.

For each interactive event, the system decreases the SY-LSIND system field by one, thus canceling out the automatic increase. All detail lists now have the same level as the basic list and thus overwrite it. While the detail list is

being created, SY-LSIND still has the value 1.

Just refer this:

https://forums.sdn.sap.com/click.jspa?searchID=12296381&messageID=3504529

Regards,

Shiva Kumar

prasanth_kasturi
Active Contributor
0 Kudos

hi,

we can know using

if checkbox is checked its value will be 'X'.

otherwise ''

Former Member
0 Kudos

Hi Aditya,

if u have selected c1 checkbox then the value in c1 = 'X'. (capital X ).

plz reward if helpful,

thanks,

S.Gangireddy

Former Member
0 Kudos

Hi,

You can do like this.....

*********************************

Parameters : p_id1 as checkbox,

p_id2 as checkbox.

Lets say if p_id1 check box is ticked then p_id1 will have value 'X'..

then you can code like this..

If p_id1 = 'X'.

write: / 'Checkbox 1 is selected'.

endif.

if p_id2 checkbox is selected then it will have value 'X'.

If p_id2 = 'X'.

write: / 'Checkbox 2 is selected'.

endif.

************************************

Reward if helpful.

Regards,

Syed

0 Kudos

Hi..

while declaring the check box just add the command

user-command XX.

here xx can be any name .

parameter : p_check type C user-command ma.

select-option : s_matnr type mara-matnr MODIF ID SC1.

MODIF ID is for recognizng the screen field .

now if you want to disbale the select option s_matnr when the checkbox is selected just write your code at the at selection-screen output event.

AT SELECTION-SCREEN OUTPUT.

IF p_check = 'X' .

LOOP AT SCREEN.

IF screen-group1 = 'SC1'.

screen-input = 0.

screen-invisible = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

reward if useful.