Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Select Options

I have declared a select option on the Selection screen . The user may enter value on the screen and can also enter multiple ranges with the help of pushbutton on screen . All the values have to be validated from a ztable ( any value entered shuld be present in the Ztable) .

*Now , to check each and every value i loop at the select table , check if option = 'EQ'/"BT' and accordingly check the calue in the ztable.

*The problem is :

  • when I enter a valid value on the screen , I am allowed to go ahead and enter the ranges in the push button option . Now , if there is an

*invalid value in that range , the error message is displayed after i press f8 . I want the error message to be displayed before coming

*out of pushbutton screen . Also, in my present code, the value from the current select table loop gets copied to the selection screen values,

*thus overwriting any value entered on screen .

I have written all my validations in "At selection screen"

The code goes like this :

LOOP AT S_C_CODE.

----


*If the Select Table contains only a Single value (Only for low not for high) , then check its presence in Table <>

----


IF S_C_CODE-OPTION = 'EQ'.

SELECT SINGLE * FROM ZMAXCODE INTO ZMAXCODE WHERE MX_COMP_CODE EQ S_C_CODE-LOW.

IF SY-SUBRC <> 0.

MESSAGE E001 with v_low.

ENDIF.

ENDIF.

----


*If the Select Table contains a range , then check for presence in Table <> for each value in the range.

----


IF S_C_CODE-OPTION = 'BT'.

V_LOW = S_C_CODE-LOW.

V_HIGH = S_C_CODE-HIGH.

WHILE V_LOW <= V_HIGH.

SELECT SINGLE * FROM ZMAXCODE WHERE MX_COMP_CODE EQ V_LOW.

IF SY-SUBRC <> 0.

MESSAGE E001 with v_low.

ENDIF.

V_LOW = V_LOW + 1.

UNPACK V_LOW TO V_LOW.

ENDWHILE.

CLEAR V_LOW.

CLEAR V_HIGH.

ENDIF.

ENDLOOP.

*I would appreciate if anyone can help me with their experiences?

Tags:
Former Member
replied

A compromise could be that you provide the user with only LOW option to fill in and remove the ranges and exclude conditions. That way user will be forced to enter single values and you can validate each of them by looping at the select option.

I think your customer will understand the reason. Let the customer know that it is possible to say either you found values or didn't find values, but not the way they want it. Explain it to them with several examples to showcase how many variations there can be and how difficult it will be to validate each of those variations. Tell them SELECT-OPTIONS gives them the flexibility of entering ranges, excluding ranges, single values etc. Such a powerful flexibility comes with a small price of not being able to validate each and every value.

If they still insist, then you have to restrict their ability to enter 'EXCLUSIONS', and may be even ranges. Look at the function module 'SELECT_OPTIONS_RESTRICT'. There is very good documentation associated with it.

Here is an example using this function module where I restrict the users to just multiple single values for a select option called S_EXWRK which is for plant.

  TYPE-POOLS sscr.
  DATA: ls_restrict TYPE sscr_restrict,
        ls_opt_list TYPE sscr_opt_list,
        ls_ass      TYPE sscr_ass.

  CLEAR ls_opt_list.
  MOVE 'EQ'  TO ls_opt_list-name.
  ls_opt_list-options-eq = 'X'.
  APPEND ls_opt_list TO ls_restrict-opt_list_tab.
  ls_ass-kind    = 'S'.
  ls_ass-name    = 'S_EXWRK'.
  ls_ass-sg_main = 'I'.
  ls_ass-sg_addy = ' '.
  ls_ass-op_main = 'EQ'.
  ls_ass-op_addy = 'EQ'.
  APPEND ls_ass TO ls_restrict-ass_tab.
  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
      restriction = ls_restrict
    EXCEPTIONS
      OTHERS      = 1.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question