Application Development and Automation 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: 
Read only

Selection Screen Parameter behaving strangely.

Former Member
0 Likes
1,222

This one is too weird to believe. Here's what's happening. I have a normal abap list report with a checkbox parameter. I set the value to 'X' initialization and it works the first time the selection screen is presented. Upon running the program I turn off the checkbox. I want the value to be re-initialized to 'X' whenever the selection screen appears. The problem is when F3 is pressed on the list screen, the initialization is invoked and the parameter set to 'X' but the selection screen appears without the checkbox selected. I have verified this through the debugger. Is there a better to change the values of selection screen parameters?

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,154

Try doing the initialization of the field in the AT SELECTION-SCREEN OUTPUT event.

Like this.

AT SELECTION-SCREEN OUTPUT.

p_check = 'X'.

Regards,

Rich Heilman

Read only

0 Likes
1,154

yep, that works and I tried that before but I didn't like the fact that if the checkbox was selected and you just pressed enter not execute then the checkbox is reset which makes it seems squirrelly. maybe checking the command for enter in selection screen output and skip the setting to 'x' for enter would work?

Read only

0 Likes
1,154

Hmmm.....ok, I really don't like it, but, try this. Maybe someone else has a better way.

Regards,

Rich Heilman

REPORT ZRICH_0002 .

parameters: p_check as checkbox default 'X'.

at selection-screen.

case sy-ucomm.

when space.

when others.

p_check = 'X'.

endcase.

start-of-selection.

write:/ p_check.

Read only

0 Likes
1,154

that didn't work either. sy-ucomm is still space even when ending out of the report. Here's what I did but it gets ugly. it works but if someone has a better idea, please let me know.

p_check as checkbox default = 'X'.

AT SELECTION-SCREEN OUTPUT.

IMPORT w_from_end_of_selection FROM MEMORY ID 'key1'.

IF w_from_end_of_selection = 'X'.

p_test = 'X'.

CLEAR w_from_end_of_selection.

EXPORT w_from_end_of_selection TO MEMORY ID 'key1'.

ENDIF.

END-OF-SELECTION.

w_from_end_of_selection = 'X'.

EXPORT w_from_end_of_selection TO MEMORY ID 'key1'.

Read only

0 Likes
1,154

here's a cleaner solution.

  • Test Option.

PARAMETERS: p_test AS CHECKBOX.

INITIALIZATION.

w_from_initialization = 'X'.

AT SELECTION-SCREEN OUTPUT.

IF w_from_initialization = 'X'.

  • can only get here from initialization

  • use this to reset the test option to "on".

p_test = 'X'.

CLEAR w_from_initialization.

ENDIF.

Read only

0 Likes
1,154

Hello Scott,

I'm not sure if you know about this, so I would explain it to you.

In case of selection-screen processing, the UCOMM value is to be obtained from the structure SSCRFIELDS, as against the structure SY(ST) in case of normal screen processing.

Consider the following code snippet.

====================================================



tables sscrfields.

parameters : p_check          as checkbox.
data        :w_do_not_reset type flag.


at selection-screen output.
  if w_do_not_reset eq space.
    p_check = 'X'.
  endif.

at selection-screen.
  if sscrfields-ucomm eq space.
    w_do_not_reset = 'X'.
  else.
    clear w_do_not_reset.
  endif.

start-of-selection.
  write : p_check.

====================================================

As the example illustrates, we need to declare the structure SSCRFIELDS with a tables statement and use the value of SSCRFIELDS-UCOMM.

Hope this helps.

Regards,

Anand Mandalika.

P.S. : If you are satisfied with the solution, please award the points.

Read only

0 Likes
1,154

Why not just try

parameters : p_check as checkbox memory id xxx .

Regards

Raja