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: 

Is there any way to Catch the event of Checkboxes on Selection Screen

Former Member
0 Kudos

Hi,

I am quite naive in ABAP.

I want to know, is it possible to code some thing for the check and un-check event of Checkboxes on selection screen.

Or if at all something of this sort exists for checkboxes in selection screen.I mean to say events for checkboxes in selection screen.

If so please let me know.

Thanks in Advance,

Mayank.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I think Max is right. AT SELECTION-SCREEN is PAI event. You can <b>not</b> modify SCREEN in PAI. So First check SY-UCOMM in AT SELECTION-SCREEN and after that modify it in AT SELECTION-SCREEN OUTPUT (PBO).

data output(1).

SELECTION-SCREEN BEGIN OF BLOCK BL3 WITH FRAME TITLE TEXT-BL3.

parameters: EPDF as checkbox USER-COMMAND FPDF,

FILEPDF type RLGRAP-FILENAME MODIF ID M01.

SELECTION-SCREEN END OF BLOCK BL3.

****

initialization.

.....

at selection-screen output.

if output is initial.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'M01'.

SCREEN-ACTIVE = '0'.

modify screen.

endif.

endloop.

else.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'M01'.

SCREEN-ACTIVE = '1'.

modify screen.

endif.

endloop.

endif.

at selection-screen.

if sscrfields-ucomm = 'FPDF' and EPDF = 'X'.

output = 'X'.

else.

clear output.

endif.

Svetlin

Message was edited by: Svetlin Rusev

13 REPLIES 13

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Sure, check out this example.



report zrich_0002
       no standard page heading.


parameters: p_check1 as checkbox <b>user-command check</b>,
            p_check2 as checkbox <b>user-command check</b>.

data: cursorfield(20) type c.

at selection-screen.


  get cursor field cursorfield.

  if cursorfield = 'P_CHECK1'.
    p_check2 = space.
  elseif  cursorfield = 'P_CHECK2'.
    p_check1 = space.
  endif.

Regards,

Rich Heilman

0 Kudos

Here is a small example


REPORT ztest1 .

TABLES sscrfields.

DATA: v_checked TYPE c.

PARAMETERS: p_chk1 AS CHECKBOX USER-COMMAND ch1.


AT SELECTION-SCREEN.

  CASE sscrfields-ucomm.
    WHEN 'CH1'.
      IF p_chk1 = 'X'.
        v_checked = 'Y'.
      ELSE.
        v_checked = 'N'.
      ENDIF.
    WHEN OTHERS.
  ENDCASE.

START-OF-SELECTION.

  WRITE:/ 'V_CHECKED = ', v_checked.

0 Kudos

Please make sure that you award points for helpful answers and mark this post as solved. Thanks.

Regards,

Rich Heilman

Former Member
0 Kudos

Just see report DEMO_SEL_SCREEN_USER_COMMAND

is SE38 .

Cheers

Former Member
0 Kudos

if a checkbox is select, it has value 'X' else '

thanks

Former Member
0 Kudos

Hi all,

Half of my problem got solved with the posts ,

I am not able to figure out the problem I am facing.

I have 5 checkboxes and 5 textboxes. Each checkbox is used for enabling or disabling corresponding textbox.

I am using the solution given in previous posts for catching the click of checkboxes.Till this point everything is fine.

But when I am enabling one of the textbox,each and every text box is getting enabled. I want to know the cause of this.

Below is the code i am using to enable/disable.

AT SELECTION-SCREEN.

CASE SSCRFIELDS-UCOMM.

WHEN 'CHECK1'.

IF P_UGENCD = 'X'.

LOOP AT SCREEN.

IF SCREEN-NAME EQ 'P_BUSUNT'.

SCREEN-INPUT = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

elseIF P_UGENCD = ''.

LOOP AT SCREEN.

IF SCREEN-NAME EQ 'P_BUSUNT'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

endif.

ENDCASE.

I disabled the Textboxes in the INITIALIZATION Event of selection screen,

FORM SUB_DISABLE_FIELDS .

LOOP AT SCREEN.

IF SCREEN-NAME EQ 'P_BUSUNT'

OR SCREEN-NAME EQ 'P_FLDIND'

OR SCREEN-NAME EQ 'P_DIV'

OR SCREEN-NAME EQ 'P_REGION'

OR SCREEN-NAME EQ 'P_EEO'

OR SCREEN-NAME EQ 'P_O_GRCD'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDFORM. "sub_disable_fields

Please let me the problem with this...

Thanks in advance.

Mayank

0 Kudos

Check this link

http://www.sapdevelopment.co.uk/reporting/selscr/selscrhome.htm

[code]*AT SELECTION-SCREEN OUTPUT.

AT SELECTION-SCREEN OUTPUT.

loop at screen.

if screen-name eq 'PNPS$MSL'.

screen-active = 0.

endif.

modify screen.

endloop.[/code]

0 Kudos

Hi

I think the problem is the event: you should use the AT SELECTION-SCREEN OUTPUT to update screen attribute and not AT SELECTION-SCREEN or INITIALIZATION.

Infact the attribute INPUT (of screen parameter and select-options) is 1 by default, so you should set 0 in it everytime the selection-screen is run.

You should use a code like this

AT SELECTION-SCREEN.

CASE SSCRFIELDS-UCOMM.

WHEN 'CHECK1'.

IF P_UGENCD = 'X'.

FL_INPUT_FIELD = 'P_BUSUNT'

ELSE.

FL_INPUT_FIELD = SPACE.

ENDIF.

AT SELECTION-SCREEN OUTPUT.

PERFROM SUB_DISABLE_FIELDS.

FORM SUB_DISABLE_FIELDS.

LOOP AT SCREEN.

IF SCREEN-NAME EQ 'P_BUSUNT'

OR SCREEN-NAME EQ 'P_FLDIND'

OR SCREEN-NAME EQ 'P_DIV'

OR SCREEN-NAME EQ 'P_REGION'

OR SCREEN-NAME EQ 'P_EEO'

OR SCREEN-NAME EQ 'P_O_GRCD'.

IF FL_INPUT_FIELD <> SCREEN-NAME.

SCREEN-INPUT = 0.

ENDIF.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDFORM.

Max

Message was edited by: max bianchi

0 Kudos

HI,

try this

REPORT Z_TESTING .

parameters : p_test like mara-matnr,

p_usta AS CHECKBOX, "User Status

p_quan AS CHECKBOX.

AT SELECTION-SCREEN OUTPUT.

IF NOT P_USTA IS INITIAL.

LOOP AT SCREEN.

if screen-name = 'P_TEST'.

screen-active = 1.

modify screen.

endif.

ENDLOOP.

ENDIF.

INITIALIZATION.

loop at screen.

if screen-name = 'P_TEST'.

screen-Active = 0.

modify screen.

endif.

endloop.

START-OF-SELECTION.

0 Kudos

Hi,

Try this -

PARAMETERS:

p_chbox1 AS CHECKBOX,

p_chtxt1(20) TYPE c,

P_CHBOX2 AS CHECKBOX,

P_CHTXT2(20) TYPE C,

p_chbox3 AS CHECKBOX,

p_chtxt3(20) TYPE c.

AT SELECTION-SCREEN OUTPUT.

IF p_chbox1 = 'X'.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT1'.

screen-input = 0.

screen-output = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF p_chbox2 = 'X'.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT2'.

screen-input = 0.

screen-output = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF p_chbox3 = 'X'.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT3'.

screen-input = 0.

screen-output = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

AT SELECTION-SCREEN.

IF p_chbox1 = 'X'.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT1'.

screen-input = 0.

screen-output = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT1'.

screen-input = 1.

screen-output = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF p_chbox2 = 'X'.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT2'.

screen-input = 0.

screen-output = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT2'.

screen-input = 1.

screen-output = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF p_chbox3 = 'X'.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT3'.

screen-input = 0.

screen-output = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

IF screen-name = 'P_CHTXT3'.

screen-input = 1.

screen-output = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

Former Member
0 Kudos

Hi,

Try to use,

AT SELECTION-SCREEN

CASE SSCRFIELDS.

WHEN 'SAVE'.

LOOP AT SCREEN

<b>SCREEN-ACTIVE = 1.</b>

MODIFY SCREEN

ENDLOOP.

ENDCASE.

Hope it helps u.

Thanks&Regards,

Ruthra.R

Former Member
0 Kudos

Hi,

I think Max is right. AT SELECTION-SCREEN is PAI event. You can <b>not</b> modify SCREEN in PAI. So First check SY-UCOMM in AT SELECTION-SCREEN and after that modify it in AT SELECTION-SCREEN OUTPUT (PBO).

data output(1).

SELECTION-SCREEN BEGIN OF BLOCK BL3 WITH FRAME TITLE TEXT-BL3.

parameters: EPDF as checkbox USER-COMMAND FPDF,

FILEPDF type RLGRAP-FILENAME MODIF ID M01.

SELECTION-SCREEN END OF BLOCK BL3.

****

initialization.

.....

at selection-screen output.

if output is initial.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'M01'.

SCREEN-ACTIVE = '0'.

modify screen.

endif.

endloop.

else.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'M01'.

SCREEN-ACTIVE = '1'.

modify screen.

endif.

endloop.

endif.

at selection-screen.

if sscrfields-ucomm = 'FPDF' and EPDF = 'X'.

output = 'X'.

else.

clear output.

endif.

Svetlin

Message was edited by: Svetlin Rusev

Former Member
0 Kudos

Hi

This is the one with 5 fields and 5 check boxes. See if it suits your need .

DATA NAME(50).

PARAMETER P1 AS CHECKBOX USER-COMMAND SEL .

PARAMETER PTEST1(5) MODIF ID MOD .

PARAMETER P2 AS CHECKBOX USER-COMMAND SEL .

PARAMETER PTEST2(5) MODIF ID MOD.

PARAMETER P3 AS CHECKBOX USER-COMMAND SEL .

PARAMETER PTEST3(5) MODIF ID MOD.

PARAMETER P4 AS CHECKBOX USER-COMMAND SEL .

PARAMETER PTEST4(5) MODIF ID MOD.

PARAMETER P5 AS CHECKBOX USER-COMMAND SEL .

PARAMETER PTEST5(5) MODIF ID MOD.

DEFINE CHANGE_SCREEN.

LOOP AT SCREEN .

CHECK SCREEN-NAME = &1.

IF &2 EQ 'X'.

SCREEN-INPUT = 1.

ELSE.

SCREEN-INPUT = 0.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

END-OF-DEFINITION.

INITIALIZATION.

LOOP AT SCREEN.

CHECK SCREEN-GROUP1 = 'MOD'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDLOOP.

AT SELECTION-SCREEN OUTPUT.

NAME = 'PTEST1'.

CHANGE_SCREEN NAME P1.

NAME = 'PTEST2'.

CHANGE_SCREEN NAME P2.

NAME = 'PTEST3'.

CHANGE_SCREEN NAME P3.

NAME = 'PTEST4'.

CHANGE_SCREEN NAME P4.

NAME = 'PTEST5'.

CHANGE_SCREEN NAME P5.

Cheers