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 do I add validation to a system-generated Selection Screen?

Former Member
0 Likes
768

As HR ABAPers know, using the Logical Database approach (I'm using PNPCE) gives you a system-generated Selection Screen. Part of the specs I have for this report involves making sure that the begin and end dates for the period selected are for a two-week period. If not, I should display an error message until the user enters a period such that the period (pn-begda and pn-endda) reflect a two-week period.

The code for the validation is easy enough, and I put it in the AT SELECTION-SCREEN event. But here's the problem -- the code fires every time the user clicks the "Reporting Period" drop-down box, never giving the user a chance to specify a two-week period. It fires because pn-begda and pn-endda are still all zeroes. Even if I select "Other Period" from the drop-down list, the text boxes to allow me to specify the begin and end dates don't appear.

I've been working on this for quite a while, trying all kinds of things, but I'm spinning my wheels now. I just want that check to happen when the user clicks the Execute button on the Selection Screen, not when he/she is still trying to enter criteria. I'm thinking screen field validation for a system-generated Selection Screen has to be a pretty common thing, and there must be a good solution out there.

Any ideas?

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
738

Under the AT SELECTION-SCREEN Event, just before doing your check, add this.

CHECK SY-UCOMM = 'ONLI'.

Regards,

Rich Heilman

As HR ABAPers know, using the Logical Database approach (I'm using PNPCE) gives you a system-generated Selection Screen. Part of the specs I have for this report involves making sure that the begin and end dates for the period selected are for a two-week period. If not, I should display an error message until the user enters a period such that the period (pn-begda and pn-endda) reflect a two-week period.

The code for the validation is easy enough, and I put it in the AT SELECTION-SCREEN event. But here's the problem -- the code fires every time the user clicks the "Reporting Period" drop-down box, never giving the user a chance to specify a two-week period. It fires because pn-begda and pn-endda are still all zeroes. Even if I select "Other Period" from the drop-down list, the text boxes to allow me to specify the begin and end dates don't appear.

I've been working on this for quite a while, trying all kinds of things, but I'm spinning my wheels now. I just want that check to happen when the user clicks the Execute button on the Selection Screen, not when he/she is still trying to enter criteria. I'm thinking screen field validation for a system-generated Selection Screen has to be a pretty common thing, and there must be a good solution out there.

Any ideas?

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
739

Under the AT SELECTION-SCREEN Event, just before doing your check, add this.

CHECK SY-UCOMM = 'ONLI'.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
738

Could you not initialize pn-begda and pn-endda at the INITIALIZATION event to something like today and two weeks from today?

Rob

Read only

0 Likes
738

Rich,

Absolutely beautiful -- that's exactly what I needed to learn. Thank you so much.

Rob, I thought about that. I even proposed to the users that I could default in a two-week range beginning with today, exactly as you suggested, but they didn't want that. They felt that this report would more often than not be run to reflect data from two-week periods not necessarily starting today. Still thought it was a good idea, but that's their call. _

Again, thanks Rich. Points awarded.

Read only

0 Likes
738

Glad to help.

Regards,

RIch Heilman