cancel
Showing results for 
Search instead for 
Did you mean: 

Clear selection-screen

FredericGirod
Active Contributor
0 Kudos

It is possible to clear all the parameters and select-options in a selection-screen ? (instead of clear : param1, param2, ...).

Frédéric.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you want clear event to occur at the initilization of the screen than you can use the code below. And it will not be reexecuted when enter key is used. The screen paramteres will be clean when it is first called.

INITIALIZATION.

LOOP AT SCREEN.

  • clears all the screen values that are parameters.

CHECK screen-group3 EQ 'PAR'.

ASSIGN (screen-name) TO <fs>.

CLEAR <fs>.

ENDLOOP.

-


If the solution helps please give points. Thanks.

FredericGirod
Active Contributor
0 Kudos

Fuat, initialization won't work. I call the selection-screen with a 'call selection-screen'.

Initilization is like a PBO.

Message was edited by: Frédéric Girod

Former Member
0 Kudos

Initilization is not exactly as PBO

it only runs at initialization but will not work again unless you recall the screen.

Sorry, maybe I did not really understand what you need.

Message was edited by: Fuat Ulugay

Former Member
0 Kudos

Hi,

I'm sure you know this, but I'm just posting this anyways, in case you have forgotten it.

From what I have understood, you have used the clear statements in the AT SELECTION-SCREEN OUTPUT event, but since this event gets triggered even when the user hits the enter key, your values are getting cleared even when they are supposed to be retained.

If this is the case,

You can try out something like this -

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


tables sscrfields.

data temp_fcode type syucomm.

parameters: p_var1 type i.

selection-screen pushbutton /2(10) button1 user-command ABC.

initialization.
    button1  = 'Clear'.

at selection-screen output.
  check temp_fcode ne space.
  clear p_var1.

at selection-screen.
  temp_fcode = sscrfields-ucomm.

start-of-selection.
  write p_var1.

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

The SSCRFIELDS structure is for exclusive use in the selection-screen processing. When the user hits a button this field will contain the corresponding function-code (just like in case of the SY-UCOMM field in case of normal screens). And when the user hits enter, this field will get cleared. Catch the contents of this screen in the PAI and query it in the PBO.

Hope this solves the problem.

Regards,

Anand Mandalika.

p.s. As usual, don't forget the points if this works.

Former Member
0 Kudos

Hello Fuat,

I would disagree with you on this one. Initialization event will only run once per execution of the report program, regardless of how many times you call a screen.

The word initialization itself refers to the initialization of the program. It does not have anything to do with screen processing.

For example,let us say you have a date field on your selection screen. When the user executes the program, you want the date to be defaulted to exactly 15 days back from the current date (sy-datum). This logic is typically written in the initialization event.

The reason you do not code something like this in your PBO event ( AT SELECTION-SCREEN OUTPUT ) is because the user , after seeing the screen, might want to change the value of the date field. and his cahnges should remain in the next disply of the screen. The PBO cannot reset the contents of the date field to 15 days back from the current date.

So, no matter how many screens you have in your program, the initialization event will get executed only once. And if you would want to set some similar default values for the fields on various other screens, you would do all that in the INITIALIZATION event.

Hope the concept is clear.

Regards,

Anand Mandalika.

FredericGirod
Active Contributor
0 Kudos

Very good idea Poornanand !

Thanks.

Frédéric

Former Member
0 Kudos

Thanks Poornanand Mandalika for your correction.

FredericGirod
Active Contributor
0 Kudos

little modification.

When I call the selection screen it won't go to the event 'at selection-screen'. So I have to set a dummy value on the temp_fcode.

Answers (1)

Answers (1)

Former Member
0 Kudos

REPORT zsilf .

TABLES sscrfields.

FIELD-SYMBOLS:

<fs>.

PARAMETERS:

vbeln LIKE vbak-vbeln.

SELECTION-SCREEN PUSHBUTTON /10(20) pushy USER-COMMAND abcd.

INITIALIZATION.

MOVE 'Clear' TO pushy.

AT SELECTION-SCREEN.

CHECK sscrfields-ucomm = 'ABCD'.

LOOP AT SCREEN.

  • clears all the screen values that are parameters.

CHECK screen-group3 EQ 'PAR'.

ASSIGN (screen-name) TO <fs>.

CLEAR <fs>.

ENDLOOP.

START-OF-SELECTION.

FredericGirod
Active Contributor
0 Kudos

Thanks for the tip, but I whish to find a command not a trip.

Frédéric.

Former Member
0 Kudos

Hi Frédéric,

It seems to me that your requirement is sort of peculiar. You say that you want all the selection screen variables, but at the same time , you do not want to use the clear statement. Even if there were some kind of a function module or something, there would have to be some kind of usage of the CLEAR statement.

However, I have another another interesting solution, where you will not need to use the clear statement at all.

Consider the following code snippet :

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



parameters: p_var1 type i,
            p_var2 type i,
            p_var3 type i.

selection-screen pushbutton /2(10) but_text user-command CLEAR.

at selection-screen output.
  but_text = 'Clear'.

at selection-screen.
  if sy-ucomm eq 'CLEAR'.
    submit (sy-repid) via selection-screen..
  endif.

start-of-selection.
  write: / p_var1,
           p_var2,
           p_var3.

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

When you execute this report, you will see a selection-screen with three parameters and one pushbutton. Just try entering some values in the input fields and then click the pushbutton ( the pushbutton will ahve the text "Clear" ).

Yuo will find that the values you have entered are all gone. the same will happen in case of a select-options on the selection-screen.

The point here is that you are restarting the program execution through the SUBMIT statement.

I cannot imagine what restriction you have to use the CLEAR statement. I have given the above code snippet only as a matter of academic interest. I would advise you to however use the CLEAR statement in the selection-screen processing events.

Please do get back if you have any further queries on this.

Regards,

Anand Mandalika.

p.s. : if you have liked the solution, don't forget to award the points.

FredericGirod
Active Contributor
0 Kudos

Hi Poornamand,

I thought I'm a violent dev, but, I think you are more violent than me

Thanks for the trip, but I can use trip like this because I use complexe selection-screen with call screen ...

My problem his, I can call several time the same selection-screen (In fact I have several selection-screen with selection-screen include ...). And when I call the second time I see value of the first time.

I have tried to use event, but the output event occurs even user press ENTER (to validate the value).

Thanks again.

(I will try to give you reward point