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

how to clear parameters defined in selection screen on back button

Former Member
0 Likes
8,787

Hi,

I have a report with parameters, few being input fields, and check boxes. After report is executed when user selects the back button, the selection screen is displayed again but with the old selection values. I want to clear them.

So in the Initialization even I added the code to clear all these parameters;

CLEAR: p_aaa, p_bbb, p_ccc.

I debugged and control passes through this code but still the fields are not cleared and they retain the old input values.

How to clear them ?

thnks

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,305

can you just try

SET HOLD DATA OFF.

or you can try placing your code in at selection-screen output event, make sure this doesnt happen when you hit the execute button, check it with sy-ucomm = ONLI

Hi,

I have a report with parameters, few being input fields, and check boxes. After report is executed when user selects the back button, the selection screen is displayed again but with the old selection values. I want to clear them.

So in the Initialization even I added the code to clear all these parameters;

CLEAR: p_aaa, p_bbb, p_ccc.

I debugged and control passes through this code but still the fields are not cleared and they retain the old input values.

How to clear them ?

thnks

16 REPLIES 16
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,306

can you just try

SET HOLD DATA OFF.

or you can try placing your code in at selection-screen output event, make sure this doesnt happen when you hit the execute button, check it with sy-ucomm = ONLI

Read only

3,305

Thanks. Where should I place SET HOLD DATA OFF ? I tried before Initialization event, and under that , but did not work !!

And I have already tried clearing the parameters under At selection screen output event. It so happens that after I enter value in one of the fields and press ENTER, the screen is cleared So that way I will never be able to proceed with report execution.

any other ideas ?

Read only

0 Likes
3,305

You should try placing it in the begining.

or

Check what is the sy-ucomm value of back button in debugging mode, in the event check if the sy-ucomm = BACK ( for example) & sy-pfkey = f2 .... Only then clear

the values.

Read only

0 Likes
3,305

Thanks Keshav, tried but did not help.

It so happens that sy-ucomm is '&F03' but it gets cleared by the time the control comes to AT selection screen output and it is blank !! So my check fails there.

Any other ideas ?

Read only

0 Likes
3,305

Or else you can do it like in

at selection-screen event move the selection screen values to new variables and clear the screen inputs.

Later in the program make your logic using the new variables & ranges. This must only happen if sy-ucomm = ONLI. This is not a best approach. But will solve your problem.

at selection-screen.

if sy-ucomm = 'ONLI'.

lf_dat = p_dat.

clear p_dat.

endif.

Read only

0 Likes
3,305

Hmm..Before trying this, a simple question, Why does not SAP clear the values when I use CLEAR: p_aaa, p_bbb, p_ccc.

under Initialization ? This event is definetely triggered when I click the back button, so why is not the code effective ?

thnks

Read only

0 Likes
3,305

>

> Hmm..Before trying this, a simple question, Why does not SAP clear the values when I use CLEAR: p_aaa, p_bbb, p_ccc.

> under Initialization ? This event is definetely triggered when I click the back button, so why is not the code effective ?

>

> thnks

This blog answers your question

http://www.s[ABAP Geek 4 u2013 The Mystery of SUBMIT Unveiled|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/970] [original link is broken] [original link is broken] [original link is broken];

Check the concluding senteces in the blog

So if you ever wondered, why the heck values, that you have assigned to input fields of the 
selection screen  during LOAD-OF-PROGRAM or INITIALIZATION, are superseded by other values
 u2013 the above program flow tells you why!* 

*If you definitely want to fill selection screen fields with your own values, you must do so 
during the event AT SELECTION-SCREEN OUTPUT, i.e. during PBO of the 
selection screen, of course.

-Rajesh

Moderator message - Please do not use code tags to format text Edited by: Rob Burbank on Sep 8, 2010 5:42 PM

Edited by: Rajesh Paruchuru on Sep 9, 2010 3:17 AM

Removed the code tags

Actually, you removed the re-formatting that I did!

Edited by: Rajesh Paruchuru on Sep 9, 2010 3:29 AM

Is the formatting fine now?

Read only

0 Likes
3,305

I did what Keshav said and it worked.. Thanks

at selection-screen.

if sy-ucomm = 'ONLI'.

lf_dat = p_dat.

clear p_dat.

endif.

Read only

Former Member
0 Likes
3,305

Use AT SELECTION-SCREEN OUTPUT.

clear all the parameters and select option table.

Read only

Former Member
0 Likes
3,305

Yes - did you even try the solution proposed by abhilasha gupta?

Rob

Read only

0 Likes
3,305

>

> Yes - did you even try the solution proposed by abhilasha gupta?

>

> Rob

I believe the OP has already tried the proposed solution and published the results as well

"And I have already tried clearing the parameters under At selection screen output event. It so happens that after I enter value in one of the fields and press ENTER, the screen is cleared So that way I will never be able to proceed with report execution.

"

-Rajesh.

Read only

0 Likes
3,305

Yes he did. My mistake.

But isn't this what he wants? To clear the Selection screen so that something has to be entered?

Rob

Read only

0 Likes
3,305

>

> Yes he did. My mistake.

>

> But isn't this what he wants? To clear the Selection screen so that something has to be entered?

>

> Rob

IMO, he only wants to clear the selection screen parameters on the click of 'BACK' button

in the list screen. If the OP clears the selection screen variables in AT SELECTION-SCREEN OUTPUT

even, the values assinged to the selection parameters in the INITIALIZATION and with the DEFAULT addition of the PARAMETERS and SELECTION-OPTIONS statements will also be overwritten even when the report is executed for the

first time.

-Rajesh.

Read only

0 Likes
3,305

Well, they are over-written after the program executes. If filled in manually, they are still there at START-OF-SELECTION.

AT SELECTION-SCREEN ON EXIT-COMMAND doesn't seem to do the trick either.

Rob

Read only

0 Likes
3,305

>

> Well, they are over-written after the program executes. If filled in manually, they are still there at START-OF-SELECTION.

I'm not sure if I have understood your comment the way it was intended to be, could you please elucidate?

-Rajesh.

Read only

rajesh_paruchuru
Active Participant
0 Likes
3,305
PARAMETERS:
  p_pernr TYPE pernr_d.

DATA:
  first_time TYPE char1 VALUE 'X'.

INITIALIZATION.
  p_pernr = '456'.


AT SELECTION-SCREEN OUTPUT.
  IMPORT first_time FROM MEMORY ID 'MEMID'.

  IF first_time = 'N'.
    CLEAR p_pernr.
  ENDIF.

START-OF-SELECTION.

  first_time = 'N'.
  EXPORT first_time TO MEMORY ID 'MEMID'.
  WRITE : p_pernr.

This could be a possible solution, not sure if it works in all possible scenarios.

-Rajesh

.

Edited by: Rajesh Paruchuru on Sep 9, 2010 3:47 AM

re-formatting of coge tags