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 the selection parameter values after execution

ravi_a3
Participant
0 Kudos
6,322

Hi SAP Gurus,

I hav 2 selection parameters in smartform. 2nd parameter is dependent on 1st using F4 help FM .I want to know tat is it possible to clear these parameter values in selection screen after returning back from execution of report.

Thanks in Advance.

Karthik S

1 ACCEPTED SOLUTION
Read only

Former Member
0 Kudos
2,801

Hi,

Generally Once the execution is over, we clear all the selection parameters, ITAB etc using the END OF SELECTION.

You can try using the same.

Regards

Shiva

13 REPLIES 13
Read only

Former Member
0 Kudos
2,801

Hi ,

After you call the generated function module.

write below logic:

PERFORM on_back. " On click of back button

FORM on_back .
CASE sy-ucomm.
  WHEN 'SBAC'.
  CLEAR : f1 , f2 . " Here f1 and f2 are selection screen parameters.
  WHEN OTHERS.
ENDCASE.
ENDFORM.

Let me know if any issue.

BR

Dep

Read only

Sandra_Rossi
Active Contributor
0 Kudos
2,801

Hi,

I guess that you called the smart form inside the START-OF-SELECTION event block (or you didn't even indicate an event explicitly, which means it belongs to START-OF-SELECTION), there, you can't clear the selection screen input fields.

Instead, it may work for instance during the PBO of the screen, i.e. inside the AT SELECTION-SCREEN OUTPUT event block.

Sandra

Read only

0 Kudos
2,801

I'm surprised to see all these medium or complex solutions (and the complex ones are also non-standard, by using internal "do not use" system calls).

The op just wants to clear the fields. Why do nobody simply propose to use

CLEAR param1. CLEAR param2. ...

in the PBO/PAI? Too much simple?

Sandra

Read only

0 Kudos
2,801

Hi Sandra

you're right, but my solution is just to place the code in INITIALIZATION event:

here it's easier to manage it (it's called once), AT SELECTION-SCREEN OUTPUT is also called if ENTER is pressed, so it needs to insert a validation to clear the parameters only under certain circumstances.

I know that control is simple....but sometimes I like to try the solution seems more elegant for me....probably I've been "abaping" for too long...:)

Max

Read only

0 Kudos
2,801

I'm surprised to see all these medium or complex solutions (and the complex ones are also non-standard, by using internal "do not use" system calls).

>

> The op just wants to clear the fields. Why do nobody simply propose to use

CLEAR param1. CLEAR param2. ...

in the PBO/PAI? Too much simple?

>

> Sandra

Hi Sandra,

I believe the reason behind proposing the medium/complex solutions is just to retain the values assigned

to the selection screen fields (either through the 'DEFAULT' addition or in the 'INITIALIZATION' event )before the selection screen is displayed when the report is executed for the very first time and on top of that( as already explained by Max) the users have to re-enter the selection screen contents everytime they hit the 'Enter' key, if the selection screen contents are cleared in PBO.

-Rajesh.

Read only

0 Kudos
2,801

Hi Max and Rajesh,

Okay, I was mainly mentioning in which event the CLEAR had to be placed, not the whole algorithm. That could be:


DATA g_time TYPE t.
AT SELECTION-SCREEN OUTPUT.
  IMPORT time TO g_time FROM MEMORY ID sy-repid. 
  IF sy-subrc NE 0 OR sy-uzeit >= g_time.
    CLEAR param1. CLEAR param2. etc.
  ENDIF.
START-OF-SELECTION.
  EXPORT time FROM sy-uzeit TO MEMORY ID sy-repid.

Sandra

Read only

0 Kudos
2,801

Hi Max and Rajesh,

> Okay, I was mainly mentioning in which event the CLEAR had to be placed, not the whole algorithm. That could be:

>


> DATA g_time TYPE t.
> AT SELECTION-SCREEN OUTPUT.
>   IMPORT time TO g_time FROM MEMORY ID sy-repid. 
>   IF sy-subrc NE 0 OR sy-uzeit >= g_time.
>     CLEAR param1. CLEAR param2. etc.
>   ENDIF.
> START-OF-SELECTION.
>   EXPORT time FROM sy-uzeit TO MEMORY ID sy-repid.
> 

> Sandra

Hi Sandra,

I have proposed a IMPORT/EXPORT based solution for a similar requirement in this discussion and as the OP has ignored

the proposal, so just thought of proposing a different solution this time, however, the IMP/EXP based approach seems to be the simple and easy solution.

-Rajesh

Read only

0 Kudos
2,801

And of course, now I have given an example how simple it could be, my code above doesn't work, line IF sy-subrc NE 0 OR, should be replaced with IF sy-subrc EQ 0 AND


PARAMETERS param1 TYPE string.
PARAMETERS param2 TYPE string.

DATA g_dummy.

AT SELECTION-SCREEN OUTPUT.
  IMPORT g_dummy FROM MEMORY ID sy-repid.
  IF sy-subrc EQ 0.
    CLEAR : param1, param2.
    FREE MEMORY ID sy-repid.
  ENDIF.

START-OF-SELECTION.
  EXPORT 'X' TO MEMORY ID sy-repid.
  WRITE / : param1, param2.

Sandra

Edited by: Sandra Rossi, 2 1/2 hours later WORKING EXAMPLE, AT LAST!

Read only

Former Member
0 Kudos
2,802

Hi,

Generally Once the execution is over, we clear all the selection parameters, ITAB etc using the END OF SELECTION.

You can try using the same.

Regards

Shiva

Read only

0 Kudos
2,801

Generally Once the execution is over, we clear all the selection parameters, ITAB etc using the END OF SELECTION.

In that event block, it doesn't work for selection screen input/output fields. The only right places are either PBO or PAI events (and maybe POV/POH? but it doesn't make sense here).

Sandra

Read only

0 Kudos
2,801

We can achieve the same using the below code which i got in one blog. It may work.

Have a look into this code

end-of-selection.

FIELD-SYMBOLS : <fs> .

ASSIGN ('(RSDBRUNT)MEMKEY-INT_MODE') TO <fs> .

IF sy-subrc = 0 .

<FS> = '01' .

ENDIF.

or you can AT SELECTION SCREEN OUTPUT.

SELECT-OPTIONS : s_kunnr FOR kna1-kunnr.

AT SELECTION-SCREEN OUTPUT.

REFRESH : s_kunnr.

I have executed both the code and worked for me.

Shiva

Read only

Former Member
0 Kudos
2,801

Hi

The selection-screen data are stored in ABAP memory, so it need to clear it .

Now how set ID parameter can depend on SAP release, anyway in ECC 6 this should work:

INITIALIZATION.
  DATA: BEGIN OF MEMKEY,
          REPORT  TYPE SY-REPID VALUE SY-REPID,
          VARIANT TYPE RSVAR-VARIANT,
          INT_MODE(2) TYPE N,
          KIND(1)     TYPE C,
        END OF MEMKEY.

  SYSTEM-CALL INTERNAL MODE INTO MEMKEY-INT_MODE.
  FREE MEMORY ID MEMKEY.

But in this way it'll clea whole selection-screen...do you wnat do it?

Max

Read only

0 Kudos
2,801

Hi

>

> The selection-screen data are stored in ABAP memory, so it need to clear it .

>

> Now how set ID parameter can depend on SAP release, anyway in ECC 6 this should work:

>

>

INITIALIZATION.
>   DATA: BEGIN OF MEMKEY,
>           REPORT  TYPE SY-REPID VALUE SY-REPID,
>           VARIANT TYPE RSVAR-VARIANT,
>           INT_MODE(2) TYPE N,
>           KIND(1)     TYPE C,
>         END OF MEMKEY.
> 
>   SYSTEM-CALL INTERNAL MODE INTO MEMKEY-INT_MODE.
>   FREE MEMORY ID MEMKEY.

>

> But in this way it'll clea whole selection-screen...do you wnat do it?

>

> Max

@Max : The above hack seem to work fine unless you assign a 'DEFAULT' value to the selection fields.

@OP : Here is an other work around, however, this approach needs an additional effort to create

new PF-STATUS('MYLIST') and assign a function code of your choice to the function keys in the standard toolbar and handle them in the 'AT USER-COMMAND' event as shown below. Let us know if you have/find any issues with this.

PARAMETERS:
  p_test TYPE char5 DEFAULT '123'.

AT USER-COMMAND.
  CASE syst-ucomm.
    WHEN 'MBACK'.
      SUBMIT zytest WITH p_test = '' VIA SELECTION-SCREEN.
  ENDCASE.

START-OF-SELECTION.
  SET PF-STATUS 'MYLIST'.

-Rajesh.