Application Development 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: 

Selection screen - two values optional mandatory

Former Member
0 Kudos
2,091

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

JozsefSzikszai
Active Contributor
0 Kudos
736

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

Former Member
0 Kudos
736

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.

0 Kudos
736

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!!

0 Kudos
736

for example you can call FM POPUP_DISPLAY_MESSAGE

Former Member
0 Kudos
736

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

Former Member
0 Kudos
736

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

0 Kudos
736

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

Former Member
0 Kudos
736

Anna,

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

-Rajat

Former Member
0 Kudos
736

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.

0 Kudos
736

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

0 Kudos
736

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

0 Kudos
736

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

0 Kudos
736

>

> 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.

0 Kudos
736

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

0 Kudos
736

>

> 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!

0 Kudos
736

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

Thanks

Anne

0 Kudos
736

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.