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

Selection screen - two values optional mandatory

Former Member
0 Likes
4,728

Hello,

is there a way to make two data fields obligatory in a selection-screen that the user only has to enter either one OR the other value, meaning at least one of these two data fields have to be entered?

Thanks

Anne

17 REPLIES 17
Read only

JozsefSzikszai
Active Contributor
0 Likes
3,373

hi,

simple:

AT SELECTION SCREEN.
IF ... IS INITIAL AND
... IS INITIAL.
==> issue error message that at least one of the above has to be filled
ENDIF.

hope this helps

ec

Read only

Former Member
0 Likes
3,373

Hi,

Suppose there are two parameters in selection screen.

Parameters:para1 type matnr,

para2 type kunnr.

Do validation for that Functioanlity------

AT SELECTION-SCREEN.

if para1 is initial and para2 is inital.

Message 'Enter at least one value' type 'E'.

endif.

Error message is displayed only if both the fields are blank.

Read only

0 Likes
3,373

Thanks for your answers, that sounds good to me!

But how can I issue an error message that comes up as a pop-up in case both fields are empty? What is the code for that?

Thanks!!

Read only

0 Likes
3,373

for example you can call FM POPUP_DISPLAY_MESSAGE

Read only

Former Member
0 Likes
3,373

Hi,

Check this sample code


REPORT z_sdn.


PARAMETERS:
  p_fld1(10) TYPE c,
  p_fld2(10) TYPE c.

AT SELECTION-SCREEN.
  IF p_fld1 IS INITIAL AND p_fld2 IS INITIAL.
    MESSAGE 'FILL EITHER OF TWO FIELDS' TYPE 'E'.
  ELSE.
    MESSAGE 'GOTO SELECTION SCREEN' TYPE 'I'.
  ENDIF.


START-OF-SELECTION.
  WRITE: 'TEST'.

Regards

Abhijeet

Read only

Former Member
0 Likes
3,373

Hi anne,

As you want the message as a pop-up,use type 'I' message

Try this code;-

PARAMETERS:
p_1(20) TYPE c,
p_2(20) TYPE c.

AT SELECTION-SCREEN.
IF p_1 IS INITIAL AND p_2 IS INITIAL.

CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
  EXPORTING
*   TITEL              = ' '
    textline1          = 'Enter data'.
*   TEXTLINE2          = ' '
*   START_COLUMN       = 25
*   START_ROW          = 6ENDIF.

endif.

-Bhumika

Read only

0 Likes
3,373

Hi Bhumika,

I've used your code and it works good. The popup comes up, but it comes up in a new session and when I press "continue", it is loading forever.

Is there a way, that the pop-up comes up in the same session?

I just would like to press continue, but stay on the same screen?

THANKS

Anne

Read only

Former Member
0 Likes
3,373

Anna,

You can put such a validation in the event at selection screen.

-Rajat

Read only

Former Member
0 Likes
3,373

try it like this:

Parameters:
  w_char1,
  w_char2.

At selection-screen.

  if  w_char1 is initial and w_char2 is initial.
    message 'enter a value' type 'E'.
  endif.

Wth luck,

Pritam.

Read only

0 Likes
3,373

Hey,

now it stays in the same screen, but there is only the message showing and there is no way to get back to the original screen.

Thanks

Anne

Read only

0 Likes
3,373

hi Anne,

if I understand right the problem is not solved yet. Pls. have a look at the following sample and let me know if it is suitable or not:

PARAMETERS : p1 TYPE bkpf-bukrs,
             p2 TYPE bkpf-gjahr.

AT SELECTION-SCREEN.
  IF p1 IS INITIAL AND
     p2 IS INITIAL.
    MESSAGE i396(00) DISPLAY LIKE 'I'.
  ENDIF.

Message will be displayed in popup and after hitting Enter will go back to the selection screen.

hope this helps

ec

Read only

0 Likes
3,373

Eric,

thanks for your answer.

I've used your code. When executing my program, a new screen opens and following message comes up:

No authorization for analyzing session

I've checked Su53, but there is no authorization missing, I have SAP_all and SAP_new.

Also, when I click on the green checkmark, nothing happens, it is loading forever and does not go back to the original screen....

Thanks

Anne

Read only

0 Likes
3,373

>

> I've used your code. When executing my program, a new screen opens and following message comes up:

> No authorization for analyzing session

it is just an error message I used as an example, you have to replace it with your own one (in the line MESSAGE...)

>

> Also, when I click on the green checkmark, nothing happens, it is loading forever and does not go back to the original screen....

that is very strange... by me, when I hit Enter (that should be equivalent with clicking on the green checkmark), it goes back to the selection screen.

Read only

0 Likes
3,373

Hm, there is nothing else I have to do but add this line of code?

Then I don't know what it is with my system, I just will not take me back to the original screen

Thanks

Anne

Read only

0 Likes
3,373

>

> Hm, there is nothing else I have to do but add this line of code?

>

> Then I don't know what it is with my system, I just will not take me back to the original screen

>

> Thanks

> Anne

just replace the message with a more suitable one (you can create an own one and that one)

about the navigation problem: I guess this also could be a SAPGUI problem. Pls. check internally if your SAPGUI version is OK!

Read only

0 Likes
3,373

I am using sapgui 710, patch 8, so I think, we're pretty up to date with that...

Thanks

Anne

Read only

0 Likes
3,373

Try this...

START-OF-SELECTION.
* Selection data is mandatory
IF s_act_id[] IS INITIAL
AND s_commdt[] IS INITIAL.
MESSAGE TEXT-e01 TYPE 'I'.
LEAVE LIST-PROCESSING.
ELSE.