10-28-2011 9:40 AM
I have selection option like the following
data : v_acti type char4
select-options: s_acti for v_acti obligatory.
Here user can enter value from 0000 to 9999
My requirement is to validate this Here user needs to allow values only from 2000 to 9999.
I have find following to do this :-->
(1). I have created a domain and put the value range as 2000 to 9999 and used that data element. ( This is not working and not giving error message if user enter value as 1000 in s_acti-low)
I know it can validated in "at selection screen" event . But the issue is here user can enter values <2000 or >9999 or ne 2000 like that . I find these combinations validations in the "at selection screen" more tedious.
Other possible way i saw is create an internal table with value ranging from 0000 to 1999 and value the selection option
s_acti as
loop at itab.
if itab-acti in s_acti.
message e000(v1) with "Wrong Input"
endif.
endloop.
But don't want above like
Finally my requirement is to make validation in at selection screen event if user values as < 2000 combination i have give an error message.
Moderators : please do not lock this thread i have searched this forum for nearest one answers, but could not find.
a®
10-28-2011 10:11 AM
Hi ,
You can use the following syntax in your program.
AT SELECTION-SCREEN ON S_ACTI.
IF ( s_acti-low not between '2000' and '9999' ) AND ( s_acti-HIGH not between '2000' and '9999' ).
MESSAGE.
ENDIF.
10-28-2011 10:03 AM
10-28-2011 10:11 AM
Hi ,
You can use the following syntax in your program.
AT SELECTION-SCREEN ON S_ACTI.
IF ( s_acti-low not between '2000' and '9999' ) AND ( s_acti-HIGH not between '2000' and '9999' ).
MESSAGE.
ENDIF.
10-28-2011 10:30 AM
Hi,
try this short code with MARA.
TABLES: MARA.
*
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
*
AT SELECTION-SCREEN.
*
SELECT * FROM MARA WHERE MATNR IN S_MATNR.
IF MARA-MATNR LT '000000000000000200'.
MESSAGE E010 WITH 'Range not allowed'.
EXIT.
ENDIF.
ENDSELECT.
*
START-OF-SELECTION.
WRITE: / 'TEST'.
END-OF-SELECTION.
*
Hope it helps.
Regards, Dieter
10-28-2011 10:31 AM
Just only allow the user to enter a low and high range and restrict all other options ( NP,CP,NE,LE etc )using SELECT_OPTIONS_RESTRICT.
Kesav
10-28-2011 10:49 AM
All,
Point #1 Here for s_acti selection there is no table entries ( like mara or makt ) so selecting a value then validating is not possible.
a®
10-28-2011 12:21 PM
Hi,
another way is like this:
DATA: V_ACTI TYPE CHAR4.
*
SELECT-OPTIONS: S_ACTI FOR V_ACTI OBLIGATORY.
*
AT SELECTION-SCREEN.
*
DO 1999 TIMES.
IF SY-INDEX IN S_ACTI.
MESSAGE E010 WITH 'Range not allowed'.
EXIT.
ENDIF.
ENDDO.
START-OF-SELECTION.
WRITE: / 'TEST'.
END-OF-SELECTION.
Regards, Dieter
Edited by: Dieter Gröhn on Oct 28, 2011 1:39 PM
10-28-2011 12:42 PM
Dieter,
You suggestions worked very well. Only thing i have bothered is DO loop.
But i didn't find any other solution to this.
Thanks for reply.
a®
10-28-2011 11:46 AM
tables:vbak,vbap.
types:begin of x_vbak,
vbeln type vbak-vbeln,
end of x_vbak.
data:it_vbeln type standard table of x_vbak,
wa_vbeln type x_vbak,
it_posnr type table of vbap,
rt_vbak type range of vbak-vbeln,
wrt_vbak like line of rt_vbak.
select vbeln
from vbak
into table it_vbeln.
wrt_vbak-low = '0000002000'.
wrt_vbak-sign = 'I'.
wrt_vbak-high = '0000009999'.
wrt_vbak-option = 'BT'.
append wrt_vbak to rt_vbak.
select vbeln
posnr
from vbap
into table it_posnr
where vbeln in rt_vbak.
write:/ 'data'.
try this example and do the same of your requiremnt
i have done this example its working.
10-28-2011 12:29 PM
Hi,
for validating SELECT-OPTIONS.
you need to use the particular data base table inside LOOP..... ENDLOOP
for HIGH, LOW as well as SIGN = 'EQ'..
Check the below code. sure it will help...
LOOP AT S_LIFNR.
CHECK S_LIFNR-OPTION = 'EQ'.
SELECT SINGLE * FROM LFA1
WHERE
MANDT = SY-MANDT AND
LIFNR = S_LIFNR-LOW.
IF SY-SUBRC NE 0.
MESSAGE E101(06) WITH S_LIFNR-LOW.
EXIT.
ENDIF.
ENDLOOP.
LOOP AT S_LIFNR.
CHECK S_LIFNR-OPTION = 'BT'.
SELECT SINGLE * FROM LFA1
WHERE
MANDT = SY-MANDT AND
LIFNR = S_LIFNR-LOW.
IF SY-SUBRC NE 0.
MESSAGE E101(06) WITH S_LIFNR-LOW.
EXIT.
ENDIF.
ENDLOOP.
LOOP AT S_LIFNR.
CHECK S_LIFNR-OPTION = 'BT'.
SELECT SINGLE * FROM LFA1
WHERE
MANDT = SY-MANDT AND
LIFNR = S_LIFNR-HIGH.
IF SY-SUBRC NE 0.
MESSAGE E101(06) WITH S_LIFNR-HIGH.
EXIT.
ENDIF.
ENDLOOP.
10-28-2011 12:29 PM
Hi,
for validating SELECT-OPTIONS.
you need to use the particular data base table inside LOOP..... ENDLOOP
for HIGH, LOW as well as SIGN = 'EQ'..
Check the below code. sure it will help...
LOOP AT S_LIFNR.
CHECK S_LIFNR-OPTION = 'EQ'.
SELECT SINGLE * FROM LFA1
WHERE
MANDT = SY-MANDT AND
LIFNR = S_LIFNR-LOW.
IF SY-SUBRC NE 0.
MESSAGE E101(06) WITH S_LIFNR-LOW.
EXIT.
ENDIF.
ENDLOOP.
LOOP AT S_LIFNR.
CHECK S_LIFNR-OPTION = 'BT'.
SELECT SINGLE * FROM LFA1
WHERE
MANDT = SY-MANDT AND
LIFNR = S_LIFNR-LOW.
IF SY-SUBRC NE 0.
MESSAGE E101(06) WITH S_LIFNR-LOW.
EXIT.
ENDIF.
ENDLOOP.
LOOP AT S_LIFNR.
CHECK S_LIFNR-OPTION = 'BT'.
SELECT SINGLE * FROM LFA1
WHERE
MANDT = SY-MANDT AND
LIFNR = S_LIFNR-HIGH.
IF SY-SUBRC NE 0.
MESSAGE E101(06) WITH S_LIFNR-HIGH.
EXIT.
ENDIF.
ENDLOOP.
Thanks & Regards,
SUJI.
10-28-2011 12:50 PM
I cant really believe that allmighty a®s has a problem with this!
If i understand you right, user can only enter 0000 to 9999.
What i would do is:
Make myself an internal table with values 0000 to 1999.
like following:
data begin of ls_number.
data number type i.
data end of ls_number.
data lt_numbers type table of ls_number.
DO 1999 TIMES.
ls_number-number = sy-index.
append ls_number to lt_numbers.
ENDDO.
"add 0
ls_number-number = 0.
append ls_number to lt_numbers.
"now simulate a select
loop at lt_number into ls_number where number in so_number.
"if you get here you got unallowed entries in your select option
"process error message
exit.
endloop.
If sy-subrc = 4.
"all is fine
endif.
hope you got my drift.
10-28-2011 1:27 PM
Florian,
This day not my day.i am totally drained !!
In my Initial post i am given the same solution, but QM come up with queries related DO loop for 0000 to 1999 itrations
so that it would get some expert opinions regarding that
a®s
Other possible way i saw is create an internal table with value ranging from 0000 to 1999 and value the selection option
s_acti as
loop at itab. if itab-acti in s_acti. message e000(v1) with "Wrong Input" endif. endloop.
a®
10-28-2011 2:27 PM
if s_acti-low <= 1999 .
MESSAGE 'wrong input' TYPE 'E'.
endif.
if s_acti-low >= 2000.
write : 'working fine'.
ENDIF.
Try This
10-28-2011 3:02 PM
@a®s - the issue I have with this is that in your original post, you set out your requirements, stating what you do and do not want; then after a number of people try to solve your problem, you mark as solved an answer which gives a solution that you specifically say you don't want and then assign nothing to the others.
I think it would have been better to assign a yellow star to each answer and close the thread as "closed but unanswered".
Rob
10-28-2011 6:27 PM
Rob,
I think you misunderstood my question in the initial post.
Other possible way i saw is create an internal table with value ranging from 0000 to 1999 and value the selection option s_acti as
loop at itab. if itab-acti in s_acti. message e000(v1) with "Wrong Input" endif. endloop.
But don't want above like
and also i mentioned in my initial post
know it can validated in "at selection screen" event . But the issue is here user can enter values <2000 or >9999 or ne 2000 like that . I find these combinations validations in the "at selection screen" more tedious.
My requirement is to avoid internal table in some manner, and the given the maximum points to user who given the answer close to resolve the issue.
Now i have made question "Closed but answered" and given points to each user who answered.
My explnation here is not to hurt anybody's intensions, who are giving answers.
I really thankful Rob for pointing out
a®
10-28-2011 7:01 PM
I think you misunderstood my question in the initial post.
Well, it certainly wouldn't be the first time
I really didn't mean anything personal - I was more thinking about the point system in general. Moderators see a lot of posts where points are assigned (if at all) to posts that are incorrect or irrelevant (not saying that this is the case here). So this skews a system that is already not helpful in the long run.
Rob
PS Since you did mark this as closed but unanswered, I couldn't respond to it originally. I had to mark it as un answered. You can change it back at your convenience.
10-29-2011 3:23 PM
post deleted by myself... someone had already suggested my solution.
Edited by: Arseni Gallardo on Oct 29, 2011 4:24 PM
10-29-2011 9:57 PM
Hi a®s,
SELECT-OPTIONS defines a complex filter. If you do not apply the filter to data, you have little chance to validate the filter.
The only way, I think ABAP is fast enough, may be to check all distinct values outside the desired range, in your case value^s from 0000 to 1999:
DATA lv_numc4 TYPE NUMC4.
while lv_numc4 < 2000.
IF lv_NUMC IN s_acti.
MESSAGE TYPE 'E' 'Invalid range used - please restrict to 2000 to 9999'.
ENDIF.
ADD 1 TO lv_numc4.
ENDWHILE.
I'm convinced that will take less time than the user is able to notice even if 1999 is in the range.
Regards
Clemens
11-08-2011 12:02 PM
I researched a lot for this issue. SCN members given the closest answer to this issue. So i am closing this thread.
Thanks
a®