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: 

mandatory field (without obligatory) - multiple selection

former_member750977
Discoverer

Hello all,

I have a little problem. I have declared a mandatory field (without obligatory).

However, then the multiple selection does not work without having already inserted a material.

My code looks like this right now:

at selection-screen on s_matnr.
if s_matnr[] is initial.

MESSAGE 'The material number must be filled' type 'E'.

leave LIST-PROCESSING.
endif.

Is there any way to work around this so that the multiple selection works when no material is filled?

Thank you.

17 REPLIES 17

moshenaveh
Community Manager
Community Manager
0 Kudos
Welcome and thanks for visiting SAP Community to get answers to your questions. While you're waiting for help, check out our tutorial to get started in SAP Community: https://developers.sap.com/tutorials/community-qa.html, as it provides tips for preparing questions that draw responses from our members.
For example, you can:
- outline what steps you took to find answers (and why they weren't helpful)
- share screenshots of what you've seen/done
- make sure you've applied the appropriate tags
The more details you provide, the more likely it is that members will be able to help you. Should you wish, you can revise your question by selecting Actions, then Edit.
By adding a picture to your profile you encourage readers to respond to your question. Learn more about your profile here: https://developers.sap.com/tutorials/community-profile.html

FredericGirod
Active Contributor

You put the control on the bad event.

AT SELECTION-SCREEN ON ... occurs when you do something on ... so obviously you check if the SELECT OPTIONS is not empty each time you do something on it ...

Maybe what you want to control is, before calling the report, control the SELECT OPTIONS is not empty.

You could do it with AT USER-COMMAND or after START-OF-SELECTION

0 Kudos

moisy98 When the optional "ON field" addition is used, only the field is transported from the screen to the global variable (of same name). I guess you want to transport the value of the other field, so the easiest solution is to not use "ON field" (only AT SELECTION-SCREEN) so that all screen fields are transported to the global variables and the check can be done on the fields you want (IF field1 ... AND field2 ...).

VXLozano
Active Contributor

Just curious... if you want a mandatory field... why do not use the OBLIGATORY clause?

DoanManhQuynh
Active Contributor
0 Kudos

If I understand correctly maybe you shouldnt use message type E, use message type S or W display like E

raymond_giuseppi
Active Contributor

You could try to perform the check only when user triggers the execution:

" ...
TABLES: sscrfields.
" ...
AT SELECTION-SCREEN ON s_matnr.
  CASE sscrfields-ucomm.
    WHEN 'PRIN' OR 'ONLI'.
      IF s_matnr[] IS INITIAL.
	     MESSAGE 'The material number must be filled'(001) TYPE 'E'.
      ENDIF.
  ENDCASE.

This way the check is still executed in the selection screen and the user can enter his selection of material code.

0 Kudos

raymond.giuseppi it is working even if he doesn't do any action on the SELECT OPTIONS ?

0 Kudos

I create a short program and the check was executed. (Seems the generated dynpro statements CHAIN and FIELD don't contain additions such as ON INPUT or ON REQUEST)

Also

  • the multiple selection is available even with no value input
  • the s_matnr area is ready for input after raising the error.

0 Kudos

Strange, when you catch an action on a field, and even if there is no action, it is triggered ...

0 Kudos

Hello Giuseppi,

thank you for your help, but the code doesn't work in my case.

The multiple selection does not work when the material number is not filled already.

Thank you

0 Kudos

Post your code, as it should work.

0 Kudos

i have done it like you told me.

AT SELECTION-SCREEN on s_matnr.
CASE sscrfields-ucomm.
WHEN 'PRIN' OR 'ONLI'.
IF s_matnr[] IS INITIAL.
MESSAGE 'Die Materialnummer muss gefüllt werden' TYPE 'E'.
ENDIF.
ENDCASE.

same situation as before. The multiple selection does not work

0 Kudos

Try to debug the execution (value of UCOMM is not 'ONLI' or 'PRIN' when click on multiple selection icon) error should come from of another code or from any not removed OBLIGATORY option in the SELECT-OPTIONS statement. (Post declaration of S_MATNR)

Sandra_Rossi
Active Contributor
0 Kudos

For information, the statement(s) after MESSAGE ... TYPE 'E' (without INTO) are never executed -> remove this dead code.

former_member750977
Discoverer
0 Kudos

Thank you for your help. But this doesn't help anyway.

The multiple selection doesn't work anyway when the material number isn't already filled....

Does anyone have a other solution?

0 Kudos

Dont answer an answer with an answer, use comment so others may know who you are answering...

(read the 'Before answering' text below)

raymond_giuseppi
Active Contributor
0 Kudos

Why did you add a 'leave LIST-PROCESSING' statement, IMHO not suitable to handle a selection-screen logic (Hopefully these instructions are dead code, never executed, did you perform some text with a warning message?)