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: 

Checkbox as user command in report

Former Member
0 Kudos

Hi all,

i maked a chechbox as user-command like below:

REPORT ZTEST_CHECKBOX.

parameters: p_date type sy-datum,

p_chec1 as checkbox user-command aaa1.

p_chec2 as checkbox user-command aaa2.

p_chec3 as checkbox user-command aaa3.

at selection-screen output.

etc etc.

my problem is: when i click on check-box, la variable sy-ucomm is empty, so I do not know wich checkbox is pressed ( if p_chec1 or p_chec2 or p_chec3) .

( for other reason I can't use p_chec1 = 'x' )

( if in dynpro I set checkbox as exit command, when i press on the checkbox the report end )

Any idea ?

tks a lot

1 ACCEPTED SOLUTION

Former Member

Hello

Try this

Declare structure SSCRFIELDS using table statement. When the user selects the checkbox on the selection screen, function code will be transferred to the component ucomm of the work area sscrfields.

TABLES: sscrfields.

parameters: p_date type sy-datum,
p_chec1 as checkbox user-command AAA1,
p_chec2 as checkbox user-command AAA2,
p_chec3 as checkbox user-command AAA3.

at SELECTION-SCREEN.

case sscrfields-ucomm.
when 'AAA1'.
---
when 'AAA2'.
---
when 'AAA3'.
---
endcase.

Edited by: Sathar RA on Oct 1, 2008 9:13 AM

16 REPLIES 16

JozsefSzikszai
Active Contributor
0 Kudos

hi,

you have to check the sy-ucomm:

CASE sy-ucomm.
WHEN 'AAA1'.
==> 1st checkbox was checked/unchecked.
WHEN 'AAA2'.
==> 2nd...
...
ENDCASE.

hope this helps

ec

Former Member
0 Kudos

WRITE your code in the event AT SELECTION SCREEN.

do not use at selection screen output.

It will work definately...

and if u want to use at selection screen output then follow the below procedure..

REPORT ZTESTNATESH.

PARAMETERS: A AS CHECKBOX USER-COMMAND AAA.

AT SELECTION-SCREEN OUTPUT.

IF A = 'X'.

MESSAGE 'HI' TYPE 'I'.

ENDIF.

Edited by: Naresh Patel on Oct 1, 2008 8:53 AM

Former Member
0 Kudos

REPORT ZTEST_CHECKBOX.

DO LIKE THIS:

parameters: p_date type sy-datum,

p_chec1 as checkbox user-command aaa1.

p_chec2 as checkbox user-command aaa2.

p_chec3 as checkbox user-command aaa3.

at selection-screen.

case sy-ucomm.

when 'aaa1'.

---

when 'aaa2'.

---

when 'aaa3'.

---

endcase.

Edited by: Amit Gupta on Oct 1, 2008 8:53 AM

Edited by: Amit Gupta on Oct 1, 2008 8:54 AM

Former Member
0 Kudos

if you cant use p_chec1 = 'x'

the may be function module

DYNP_VALUES_READ can be useful.

Former Member
0 Kudos

Hi

i send one program... U read this u have get idea..

REPORT ZBA_CHKBOX_IN_OUTPUT NO STANDARD PAGE HEADING.

TYPE-POOLS: slis.

TABLES: ZPROGMENU.

DATA: FLAG VALUE 1,

SEL,

WA_PROG LIKE ZPROGMENU.

DATA: lt_progmenu like ZPROGMENU OCCURS 0 WITH HEADER LINE,

lt_progmenu1 like ZPROGMENU OCCURS 0 WITH HEADER LINE,

lt_progmenu2 TYPE TABLE OF ZPROGMENU.

DATA : lt_listheader TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

DATA : gv_toutdt TYPE prps-post1,

gv_touttm TYPE prps-post1.

  • FOR ALV Display

DATA: gr_table TYPE REF TO cl_salv_table.

data: gr_funct type ref to cl_salv_functions.

data: gr_columns type ref to cl_salv_columns_table.

data: gr_column type ref to CL_SALV_COLUMN_table.

*****************TOP OF PAGE*****************************

TOP-OF-PAGE.

ULINE (135).

NEW-LINE.

WRITE : SY-VLINE, (3) TEXT-000 COLOR COL_HEADING,

SY-VLINE, (3) TEXT-001 COLOR COL_HEADING,

SY-VLINE, (20) TEXT-002 COLOR COL_HEADING,

SY-VLINE, (40) TEXT-003 COLOR COL_HEADING,

SY-VLINE, (40) TEXT-004 COLOR COL_HEADING,

SY-VLINE, (10) TEXT-005 COLOR COL_HEADING,

SY-VLINE.

NEW-LINE.

ULINE (135).

NEW-LINE.

*****************START OF SELECTION***********************

START-OF-SELECTION.

select * from ZPROGMENU INTO TABLE lt_progmenu.

DELETE lt_progmenu WHERE PROG IS INITIAL.

SORT lt_progmenu BY APPL TCODE PROG.

LOOP AT lt_progmenu.

PERFORM CHANGE_COLOR.

WRITE 😕 SY-VLINE,

SEL UNDER TEXT-000 AS CHECKBOX, 7 SY-VLINE,

(3) lt_progmenu-appl UNDER TEXT-001, SY-VLINE,

(20) lt_progmenu-tcode UNDER TEXT-002, SY-VLINE,

(40) lt_progmenu-prog UNDER TEXT-003, SY-VLINE,

(40) lt_progmenu-ltext UNDER TEXT-004, SY-VLINE,

(10) lt_progmenu-hit_rate UNDER TEXT-005, SY-VLINE.

ENDLOOP.

NEW-LINE.

WRITE: SY-ULINE(135).

*******************END-OF-SELECTION**************************

END-OF-SELECTION.

SET PF-STATUS 'GUISTAT'.

SET TITLEBAR 'ACN'.

AT USER-COMMAND.

CASE SY-UCOMM .

WHEN 'DISPLAY'.

DO.

CLEAR SEL.

CLEAR WA_PROG.

READ LINE SY-INDEX FIELD VALUE

SEL INTO SEL

lt_progmenu-appl INTO WA_PROG-APPL

lt_progmenu-tcode INTO WA_PROG-tcode

lt_progmenu-PROG INTO WA_PROG-PROG

lt_progmenu-ltext INTO WA_PROG-ltext

lt_progmenu-hit_rate INTO WA_PROG-hit_rate.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

IF SEL = 'x' OR SEL = 'X'.

MOVE-CORRESPONDING WA_PROG TO lt_progmenu1.

APPEND lt_progmenu1.

ENDIF.

ENDDO.

ENDCASE.

IF NOT lt_progmenu1 IS INITIAL.

lt_progmenu2[] = lt_progmenu1[].

TRY.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = gr_table

CHANGING

t_table = lt_progmenu2.

CATCH cx_salv_msg .

ENDTRY.

gr_table->display( ).

ENDIF.

CLEAR: SEL,lt_progmenu,lt_progmenu1,lt_progmenu2.

REFRESH: lt_progmenu,lt_progmenu1,lt_progmenu2.

&----


*& Form CHANGE_COLOR

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form CHANGE_COLOR .

IF FLAG = 1.

FORMAT COLOR 2 INTENSIFIED ON.

FLAG = 2.

ELSE.

FORMAT COLOR 2 INTENSIFIED OFF.

FLAG = 1.

ENDIF.

endform. " CHANGE_COL

Former Member

Hello

Try this

Declare structure SSCRFIELDS using table statement. When the user selects the checkbox on the selection screen, function code will be transferred to the component ucomm of the work area sscrfields.

TABLES: sscrfields.

parameters: p_date type sy-datum,
p_chec1 as checkbox user-command AAA1,
p_chec2 as checkbox user-command AAA2,
p_chec3 as checkbox user-command AAA3.

at SELECTION-SCREEN.

case sscrfields-ucomm.
when 'AAA1'.
---
when 'AAA2'.
---
when 'AAA3'.
---
endcase.

Edited by: Sathar RA on Oct 1, 2008 9:13 AM

0 Kudos

Hi Sathar,

tks for your help but the sctructure sscrfields-ucomm is ever empty.

How I can fil it?

tks

0 Kudos

>

> Hi Sathar,

>

> tks for your help but the sctructure sscrfields-ucomm is ever empty.

>

>

> How I can fil it?

>

> tks

sy-ucomm you have to check (not sscrfields-ucomm), just check my code sample above!

0 Kudos

Hi Roberto

If u have declared TABLES: SSCRFIELDS in ur program, when u click the check box in selection screen the fcode assigned to that check box will get transferred to sscrfield-ucomm. You can confirm this by switching on the debugger before u click check box and I am very sure that sscrfield-ucomm will have the function code assigned to the check box u clicked.

This is the explanation in SAP help.

The addition USER-COMMAND can be used to assign a function code fcode to the parameter. The function code fcode must be directly specified and may have a maximum length of 20 characters. To evaluate the function code, an interface work area of the structure SSCRFIELDS from the ABAP Dictionary must be declared using the statement TABLES. When the user selects the checkbox on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and transfers the function code fcode to the component ucomm of the interface work area sscrfields. If a function code used in the GUI status of the selection screen is specified for fcode, the selection screen processing is affected accordingly.

Regards

Sathar

0 Kudos

Hi Roberto

If u have declared TABLES: SSCRFIELDS in ur program, when u click the check box in selection screen the fcode assigned to that check box

will get transferred to sscrfield-ucomm. You can confirm this by switching on the debugger before u click check box and

I am very sure that sscrfield-ucomm will have the function code assigned to the check box u clicked.

This is the explanation in SAP help.

The addition USER-COMMAND can be used to assign a function code fcode to the parameter. The function code fcode must be directly specified and may have a maximum length of 20 characters.

To evaluate the function code, an interface work area of the structure SSCRFIELDS from the ABAP Dictionary must be declared using the statement TABLES.

When the user selects the checkbox on the selection screen, the runtime environment triggers the event AT SELECTION-SCREEN and transfers the function code fcode to the component ucomm of the interface work area sscrfields.

If a function code used in the GUI status of the selection screen is specified for fcode, the selection screen processing is affected accordingly.

Regards

Sathar

Edited by: Sathar RA on Oct 1, 2008 10:48 AM

0 Kudos

Tks a lot for the message,

but i tried and it's run only with "AT SELECTION-SCREEN".

Unfortunatly, I have to use AT SELECTION-SCREEN OUTPUT ( i have to disable screen option ).

and with AT SELECTION-SCREEN OUTPUT that structure is empty.

any idea ??

0 Kudos

Please try whether this will work for you..

TABLES: sscrfields.
data: gv_ucomm type sy-ucomm.

AT SELECTION-SCREEN.

gv_ucomm = sscrfields-ucomm.

AT SELECTION-SCREEN OUTPUT.

case gv_ucomm.

when 'AAA1'.

when 'AAA2'.

when 'AAA3'.

endcase.

Regards

Sathar

0 Kudos

Tks Sathar,

I solved my problem!

Former Member
0 Kudos

You need to check for sy-ucomm in at selection-screen instead of at selection-screen output.

The sy-ucomm for the parameters will be populated during PAI ( at selection-screen) and not in PBO ( at selection-screen output).

regards,

Advait

Former Member
0 Kudos

Hi Roberto,

try it this way:

parameters: p_date type sy-datum,
p_chec1 as checkbox user-command aaa1,
p_chec2 as checkbox user-command aaa2,
p_chec3 as checkbox user-command aaa3.

at selection-screen.


if sy-ucomm = 'AAA1'.

  message 'p_chec1 is checked' type 'S'.

elseif sy-ucomm = 'AAA2'.

  message 'p_chec2 is checked' type 'S'.

elseif sy-ucomm = 'AAA3'.

  message 'p_chec3 is checked' type 'S'.
endif.

With luck,

Pritam.

amit_singh20
Explorer
0 Kudos

Try out this:-

----


----


SELECTION SCREEN DETAILS -

----


***Selection criteria for the account type

SELECTION-SCREEN: BEGIN OF BLOCK a1 WITH FRAME TITLE text-t01.

PARAMETERS : p_glacc AS CHECKBOX USER-COMMAND ucom,

p_cc AS CHECKBOX USER-COMMAND ucom,

p_pc AS CHECKBOX USER-COMMAND ucom.

***Selection criteria for general filtering

SELECTION-SCREEN: BEGIN OF BLOCK a2 WITH FRAME TITLE text-t02.

SELECT-OPTIONS: s_kokrs FOR zusf_cc_chg_hist-kokrs

NO-EXTENSION NO INTERVALS DEFAULT 'US00',

"CO Area

s_bukrs FOR zusf_gl_change-bukrs , "Company Code

s_kostl FOR zusf_cc_chg_hist-kostl, "Cost Center

s_saknr FOR zusf_gl_change-saknr, "G/L Account

s_prctr FOR zusf_pc_change-prctr, "Profit Center

s_cdate FOR zusf_cc_chg_hist-cdate

NO-EXTENSION NO INTERVALS, "Changed on

s_req FOR trdyse01cm-username

NO-EXTENSION NO INTERVALS, "Requester

  • s_create FOR zusf_pc_change-name

  • NO-EXTENSION NO INTERVALS, "Created by

s_create FOR trdyse01cm-username

NO-EXTENSION NO INTERVALS, "Created by

s_appr FOR zusf_cc_chg_hist-appname

NO-EXTENSION NO INTERVALS. "Approved by

SELECTION-SCREEN:

END OF BLOCK a2.

AT SELECTION-SCREEN OUTPUT.

***If only g/l account is selected.

***display only those fileds which

***are in the Record requested changes for GL Account

IF NOT p_glacc IS INITIAL .

LOOP AT SCREEN.

IF screen-name ='S_BUKRS-LOW'

OR screen-name ='S_BUKRS-HIGH'

OR screen-name ='%_S_BUKRS_%_APP_%-VALU_PUSH'

OR screen-name ='S_SAKNR-LOW' OR screen-name ='S_SAKNR-HIGH'

OR screen-name ='%_S_SAKNR_%_APP_%-VALU_PUSH'

OR screen-name ='P_GLACC' OR screen-name ='P_CC'

OR screen-name ='P_PC' OR screen-name ='P_RCHNG'

OR screen-name = 'P_RCRT' OR screen-name = 'P_BOTH'

OR screen-name ='S_CDATE-LOW'

OR screen-name ='S_REQ-LOW'

OR screen-name ='S_CREATE-LOW'

OR screen-name ='S_APPR-LOW'.

screen-input = 1.

MODIFY SCREEN.

ELSE.

screen-input = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

***If both g/l account and profit center is selected

***display fields relevant to both of them.

IF NOT p_glacc IS INITIAL AND NOT p_pc IS INITIAL.

LOOP AT SCREEN.

IF screen-name ='S_BUKRS-LOW' OR screen-name ='S_BUKRS-HIGH'

OR screen-name ='%_S_BUKRS_%_APP_%-VALU_PUSH'

OR screen-name = 'S_KOKRS-LOW'

OR screen-name = 'S_KOKRS-HIGH'

OR screen-name = '%_S_KORKS_%_APP_%-VALU_PUSH'

OR screen-name = 'S_PRCTR-LOW'

OR screen-name ='S_PRCTR-HIGH'

OR screen-name ='%_S_PRCTR_%_APP_%-VALU_PUSH'

OR screen-name ='S_SAKNR-LOW' OR screen-name ='S_SAKNR-HIGH'

OR screen-name ='%_S_SAKNR_%_APP_%-VALU_PUSH' OR

screen-name ='P_GLACC' OR screen-name ='P_CC'

OR screen-name ='P_PC' OR screen-name ='P_RCHNG'

OR screen-name = 'P_RCRT' OR screen-name = 'P_BOTH'

OR screen-name ='S_CDATE-LOW'

OR screen-name ='S_REQ-LOW'

OR screen-name ='S_CREATE-LOW'

OR screen-name ='S_APPR-LOW'.

screen-input = 1.

MODIFY SCREEN.

ENDIF.

Similary you can try for your problem.

Hope it works.