cancel
Showing results for 
Search instead for 
Did you mean: 

Select Option Validation

Former Member
0 Kudos

Hi,

I have a selection screen ..select option : Company Code.

I need to do this validation for the range . If the user enters values on the screen and also using the puchbutton, I need to check against this table for all the ranges entered in the selection table. However this code is not working for this. What else i need to add to make sure that it checks all the ranges entered.?

when i debug the value for the S_c_code changes and fetches the next range in the table but it doesnt change the value for sy-subrc , even if the range is invalid !!

SELECT SINGLE * FROM ZMAXCODE INTO ZMAXCODE

WHERE MX_COMP_CODE IN S_C_CODE.

IF SY-SUBRC <> 0.

MESSAGE E008.

ENDIF.

Thanks

Accepted Solutions (0)

Answers (7)

Answers (7)

former_member181962
Active Contributor
0 Kudos

Hi ABAP..:P,

Validating a select option is meaningless to say the least. Because even if both the values on LOW and HIGH are invalid, there might be valid values in between them.

For example 0 may be an invalid comp code, 1000 may be an in valid comp code, but there may be 100 valid companies in betwen the range you have mentioned.

If you have single values to be validated, one value may be valid, and the other invalid, the select will be succesful no matter 9 out of 10 single values are invalid.

Hence convince your Lead that its a waste of time to validate a select option.

Regards,

Ravi

Former Member
0 Kudos

Hi,

i dont know what exartly the requriement is

you can do one thing in the selection screen for S_C_CODE remove the extension button then user can only enter the ranges then u only have the option of LOW & HIGH of that particular field.Then u can loop and u can validate for each and every value.

Thanks

Vikranth Khimavath

Former Member
0 Kudos

Hi,

I think this will not work.

For example if user enters 1 to 10 range.if all the condition fails then you will not get any output.if any of the above condition is valid then u will get the report output.

or loop the select-option table.

Thanks

Vikranth Khimavath

ferry_lianto
Active Contributor
0 Kudos

Hi,

Have you looked this FM <b>SELECT_OPTIONS_RESTRICT</b>?

Please check the function module documentation.

Hope it will help.

Regards,

Ferry Lianto

Former Member
0 Kudos

You could loop at the select options table and for each entry:

refresh a range table.

put the single entry of the select option into the range table.

use the range table in the validation.

Rob

former_member188685
Active Contributor
0 Kudos

Hi,

in that case you need to loop the select-option table and fill the range table , pass it in selection condition.,

Regards

vijay

Former Member
0 Kudos

<b>Did we not discuss this and the futility of validating every entered value/range for a select-option?</b>

Message was edited by: Srinivas Adavi

Former Member
0 Kudos

Yes - if you want to validate a number of lines that contain exclusion or patterns, the select won't be able to use an index. If you're validating a large select-option against a large table, performance may be a show stopper.

Rob

Former Member
0 Kudos

As ferry suggested, you could use FM SELECT_OPTIONS_RESTRICT to force the users only to enter simple restrictions (EQ and ranges).

You could then validate each line as I suggested before. It would still be awkward, but it might be the best way to achieve what you want.

Rob

Former Member
0 Kudos

Again that is exactly what we discussed in the previous post that I gave in the above link. There this function module was also suggested.

Former Member
0 Kudos

Hi,

Try this way...

SELECT * up tp 1 rows FROM ZMAXCODE INTO ZMAXCODE

WHERE MX_COMP_CODE IN S_C_CODE.

endselect.

IF SY-SUBRC <> 0.

MESSAGE E008.

ENDIF.

Former Member
0 Kudos

I tried the suggestions but it doesnt work.

what i m looking for is : to check the ranges entered in the pushbutton on selection screen (multiple ranges for a select option ).

former_member188685
Active Contributor
0 Kudos
SELECT SINGLE * FROM ZMAXCODE INTO ZMAXCODE
WHERE MX_COMP_CODE IN S_C_CODE.
IF SY-SUBRC <> 0.
MESSAGE E008.
ENDIF

generally it will check the conditions which you give in selection screen. check any data that falls in that mentioned Range that might be the reason it is giving sy-subrc = 0.

Regards

vijay