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

execute subroutine only when selection parameter changes

Former Member
0 Likes
591

Hi ABAP workers,

I have a block of selection parameters, and I created the event AT SELECTION SCREEN ON BLOCK bl1 with a subroutine. I want that subroutine to be executed only when a parameter in the selection block is changed by the user. But the behaviour right now is that it executes every time I press Enter, even if no parameter changes.

Is there any way to chieve this (like in the module pool case, with the extension "ON REQUEST")?

Thank you very much

Ivson

Code involved:

SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.

PARAMETERS: p_bukrs LIKE csks-bukrs MEMORY ID buk OBLIGATORY,

p_ryear LIKE glpct-ryear OBLIGATORY.

SELECT-OPTIONS: s_poper FOR glpct-rpmax,

s_racct FOR glpct-racct,

s_kunnr FOR glpca-kunnr,

s_lifnr FOR glpca-lifnr,

s_sprctr FOR glpct-sprctr.

SELECTION-SCREEN END OF BLOCK bl1.

AT SELECTION-SCREEN ON BLOCK bl1.

PERFORM preselect.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
523

Hi,

U can use

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_meth1(Screen field).

it'll solve ur problm

4 REPLIES 4
Read only

Former Member
0 Likes
523

Hi,

Pressing Enter is triggering the PAI which is executing AT SELECTION-SCREEN regardless of any condition.

Please include another perform like CHECK_VALUES_ENTERED and if values are not initial, call the PERFORM preselect in AT SELECTION-SCREEN.

Regards,

Prosenjit.

Read only

Former Member
0 Likes
524

Hi,

U can use

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_meth1(Screen field).

it'll solve ur problm

Read only

0 Likes
523

Hi,

i think you should use an additional variable like this:


data : curr_value like <your_parameter_type>.
..
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <your_parameter>.
if <your_parameter> ne curr_value.
 curr_value = <your_parameter>.
 perform <your_form> using .....
endif.

This should works

Bye

Andrea

Read only

Former Member
0 Likes
523

Hi,

You could try this.

Use the FM "DYNP_VALUES_READ" to get the contents of that screen parameter and then check for the parameter value inside the subroutine using a IF statement.

PNAME is a paramter name here.

a dynpfields-fieldname = 'PNAME'.

append dynpfields.

repid = sy-repid.

call function 'DYNP_VALUES_READ'

exporting

dyname = repid

dynumb = sy-dynnr

tables

dynpfields = dynpfields

exceptions

others.

read table dynpfields index 1.

pname = dynpfields-fieldvalue.

Process the subroutine if needed based on the check condition.

Hope this helps you.

Regards,

Subbu