2013 Jun 11 9:48 AM
Hi every one,
AT SELECTION-SCREEN on s_lifnr .
if not s_lifnr is INITIAL.
SELECT SINGLE lifnr
INTO v_lifnr
FROM LFA1
WHERE LIFNR IN S_LIFNR.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
ENDIF.
\mine is not validating......wrong ans also executing
2013 Jun 11 10:27 AM
Try putting,
AT SELECTION-SCREEN on s_lifnr .
perform validate_vendor.
form validate_vendor.
if not s_lifnr is INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = s_lifnr
IMPORTING
OUTPUT =s_lifnr
.
SELECT SINGLE lifnr
INTO v_lifnr
FROM LFA1
WHERE LIFNR IN S_LIFNR.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
ENDIF.
endform.
BR,
Ankit.
2013 Jun 11 11:03 AM
Hi,
Following code is working fine for me throws error,
data : lv_lifnr type lifnr.
select-options : s_lifnr for lv_lifnr.
at selection-screen on s_lifnr .
if not s_lifnr is initial.
select single lifnr
into lv_lifnr
from lfa1
where lifnr in s_lifnr.
if sy-subrc <> 0.
message 'INVALID ACCOUNT NUMBER' type 'E'.
endif.
endif.
Regards,
Ravi Shankar L
2013 Jun 12 7:17 AM
HI ANKIT,
it is validating the 1st vale in the selection screen not the other range of values.
2013 Jun 11 10:41 AM
Hi Meenakshi.
1. At Selection screen on we use for single fields in general like for S_LIFNR-LOW / S_LIFNR-HIGH.
2. If you need to validate the entire select opt try like this.
SELECTION-SCREEN BEGIN OF BLOCK BL0.
SELECT-OPTIONS SEL1 FOR SY-TVAR1.
SELECTION-SCREEN END OF BLOCK BL0.
At selection-screen on block b0.
IF s-lifnr[] is not initial.
SELECT SINGLE lifnr
INTO v_lifnr
FROM LFA1
WHERE LIFNR IN S_LIFNR.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
Endif.
OR if you want single fields
The write.
At selection-screen on S_LIFNR-HIGH.
IF s_lifnr-high is not initial.
SELECT SINGLE lifnr
INTO v_lifnr
FROM LFA1
WHERE LIFNR eq S_LIFNR-high.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
Endif.
Similarly for low
Hope it helps
BR
2013 Jun 11 10:56 AM
Hi Meenakshi,
I executed the piece of code that you have written and it worked fine for me. The reason that select query fails maybe because the variable v_lifnr is of different type compared to the field lifnr in lfa1 table. Do check the variable declaration and see if data type is same as the table field value you are fetching.
Hope this helps,
~Athreya
2013 Jun 11 10:57 AM
Hi,
Do you want to provide error message if none of the LIFNR is available? If so, the below should be fine. Because it checks the range what you had provided. If you want to check each and every LIFNR in the range, you need to have loop between s_lifnr-low and s_lifnr-high.
AT SELECTION-SCREEN on s_lifnr .
if s_lifnr[] is not INITIAL.
SELECT SINGLE lifnr
INTO v_lifnr
FROM LFA1
WHERE LIFNR IN S_LIFNR.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
ENDIF.
2013 Jun 11 10:58 AM
Check documentation (F1) AT SELECTION-SCREEN ON selcrit will only be triggered for a line of selection, to get whole selection internal table use ON END OF selcritif user use the dialog box for select-options, so you may be require to put your check in a simple AT SELECTION-SCREEN..
Sample to check :
TABLES: lfa1.
SELECT-OPTIONS s_lifnr FOR lfa1-lifnr.
AT SELECTION-SCREEN ON END OF s_lifnr .
IF NOT s_lifnr[] IS INITIAL.
SELECT COUNT(*)
FROM lfa1
WHERE lifnr IN s_lifnr.
IF sy-subrc <> 0.
MESSAGE 'AT END OF selcrit' TYPE 'S'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON s_lifnr .
IF NOT s_lifnr IS INITIAL.
SELECT COUNT(*)
FROM lfa1
WHERE lifnr IN s_lifnr.
IF sy-subrc <> 0.
MESSAGE 'AT selcrit' TYPE 'S'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN.
IF NOT s_lifnr IS INITIAL.
SELECT COUNT(*)
FROM lfa1
WHERE lifnr IN s_lifnr.
IF sy-subrc <> 0.
MESSAGE 'AT nothing' TYPE 'S'.
ENDIF.
ENDIF.Regards,
Raymond
2013 Jun 11 11:23 AM
Hi Meenakshi,
The code which you had done to validate the vendor is perfect. Please check it properly.
Thanks & Regards.
Pavan.N
2013 Jun 12 6:41 AM
Hi Pavan,
The code is validating ok but wat means wen i give range of values say 45 to 50 where 47 is not available instead to it s taking in to account. I need help in this area.
Regards,
Meenakshi.
2013 Jun 12 7:45 AM
Hi Meenakshi,
For select options, it checks for the range not for individual account numbers.
Select option is the table with header line with the following structure .
So if you give a range the option would be BT.
if you give a single value, or multiple values (using this button ), the option would be EQ. Each account number will be appended to the table.
For Between option, you need to manually check for all the values.
data : msg type string, c_lifnr(10) type c.
at selection-screen on s_lifnr.
if not s_lifnr is INITIAL.
case s_lifnr-option.
when 'BT'.
lv_lifnr1 = s_lifnr-low.
do.
if lv_lifnr1 GT s_lifnr-high.
exit.
endif.
select single lifnr into v_lifnr from lfa1 where lifnr = lv_lifnr1.
if sy-subrc ne 0.
c_lifnr = lv_lifnr1.
concatenate 'Invalid Account No' c_ lifnr into msg.
MESSAGE msg type 'E'.
endif.
lv_lifnr1 = lv_lifnr1 + 1.
enddo.
when 'EQ'.
loop at s_lifnr.
select single lifnr into v_lifnr from lfa1 where lifnr = s_lifnr-low.
if sy-subrc ne 0.
c_lifnr = s_lifnr-low.
concatenate 'Invalid Account No' c_lifnr into msg.
MESSAGE msg type 'E'.
endif.
endloop.
endcase.
Or another option is just allow one account number at a time.
parameters : p_lifnr like lfa1-lifnr.
at selection-screen on p_lifnr.
select single lifnr into v_lifnr from lfa1 where lifnr = p_lifnr.
if sy-subrc ne 0.
MESSAGE 'Invalid Account No' type 'E'.
endif.
2013 Jun 13 11:44 AM
Hi,
I tried ur code. The problem iam facing is ....
say for eg from 42 to 50 the range of value iam giving.....here 44 and 50 values are not there(invalid). But how the output is is showing means 42 is invalid, 43 is invalid........
2013 Jun 13 12:16 PM
Hi meenakshi,
Did you try the code which i gave you below in this discussion?
Link (Direct Link)
Regards,
Madhumahesh,
2013 Jun 11 11:36 AM
Your code seems to be fine.
Another option is, Instead of selection screen on s_lifnr.
Just give
At Selection-screen.
AT SELECTION-SCREEN.
if not s_lifnr is INITIAL.
select single lifnr into v_lifnr from lfa1 where lifnr in s_lifnr.
if sy-subrc ne 0.
MESSAGE 'Invalid Account No' type 'E'.
endif.
endif.
The event block sequence should be correct.
Selection Screen Declarations
at selection screen output
at selection screen
at selection screen on <field>
start of selection. 
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm
2013 Jun 11 12:05 PM
Hi Meena,
As per my knowledge,
You are define select option in your selection screen it is nothing but an one internal table then how can you use single select statement. And also if user does not enter any value in the select option it will get the all vendor details.
If suppose your vendor selection is parameter then it will work fine.
For your understanding go through the following code,
TYPES: BEGIN OF ll,
lv_lifnr type lifnr,
END OF ll.
DATA: lv_lifnr type lifnr,
lt_lifnr TYPE TABLE OF ll.
SELECT-OPTIONS s_lifnr for lv_lifnr.
AT SELECTION-SCREEN on s_lifnr .
perform validate_vendor.
form validate_vendor.
if not s_lifnr is INITIAL.
"IF SUPPOSE USER SELECT THE VENDOR NUMBER FROM SH IT IS NOT REQUIRED
*CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
*
* EXPORTING
*
* input = s_lifnr
*
*IMPORTING
*
* OUTPUT = s_lifnr
SELECT lifnr INTO TABLE lt_lifnr FROM LFA1 WHERE LIFNR IN S_LIFNR.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
ELSE.
MESSAGE 'PLEASE ENTER VENDOR NUMBER' TYPE 'E'.
ENDIF.
endform.
Warm Regards,
John.
2013 Jun 11 12:47 PM
Hi Meenakshi,
I suppose I got your point.... and there is some confusion...
A Select Option is a RANGE so if I put "A" To "Z".
Though the Table contains only B,C, D & E it will return all 4 as they fall in range.
So your select will not validate B , C , D or E individually.
If you want that you have to use the No interval that will force the user to enter single values and you can validate each of them
BR
2013 Jun 12 8:09 AM
hi Mohanmed,
But in input the range of values to be entered mand......
2013 Jun 11 12:48 PM
Hi Meenakshi,
I suppose I got your point.... and there is some confusion...
A Select Option is a RANGE so if I put "A" To "Z".
Though the Table contains only B,C, D & E it will return all 4 as they fall in range.
So your select will not validate B , C , D or E individually.
If you want that you have to use the No interval that will force the user to enter single values and you can validate each of them
BR
2013 Jun 12 7:53 AM
Hi,
You can either restrict the intervals by no intervals or you can check as below which will help you to check if atleast one provided in the interval is valid. If you want to check everything in the interval, then you need to take everything in another internal table by looping s_lifnr from low and high.
select-options : s_lifnr for lv_lifnr.
at selection-screen on s_lifnr .
if s_lifnr[] is not initial.
select single lifnr into lv_lifnr
from lfa1 where lifnr in s_lifnr.
if sy-subrc ne 0.
message ...
endif.
endif.
2013 Jun 12 8:12 AM
2013 Jun 12 8:53 AM
Hi Meenakshi,
check the coding given by Susmitha. It is the correct way to validate present inside the range.
Let me know if any clarifications needed.
Thanks
Pavan.N
2013 Jun 12 8:53 AM
Hi Meenakshi,
check the coding given by Susmitha. It is the correct way to validate present inside the range.
Let me know if any clarifications needed.
Thanks
Pavan.N
2013 Jun 12 9:02 AM
Where are the moderators.....
Please close this thread....
Too much discussion on a FRESHER TOPIC.
Please READ SAP HELP
2013 Jun 12 9:21 AM
Use "Report Abuse" button if you want moderators to notice the discussion.
2013 Jun 14 3:11 PM
Noticed. I also noticed the answer marked as "correct" was wrong. So I've marked the whole discussion as pointless.
2013 Jun 12 9:49 AM
Hi Meenakshi
Pls try the below code
AT SELECTION-SCREEN on s_lifnr-low .
SELECT SINGLE lifnr
INTO v_lifnr
FROM LFA1
WHERE LIFNR IN S_LIFNR-LOW.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN on s_lifnr-high .
SELECT SINGLE lifnr
INTO v_lifnr
FROM LFA1
WHERE LIFNR IN S_LIFNR-HIGH.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
ENDIF.
Regards
Suganya
2013 Jun 12 10:28 AM
Hi Every ,
Got the ans......this is my code
FORM VALIDATE_VENDOR .
IF s_lifnr-low is NOT INITIAL.
LOOP AT s_lifnr.
SELECT SINGLE lifnr
from lfa1
into v_lifnr
where lifnr = s_lifnr-low.
IF sy-subrc <> 0.
MESSAGE 'Invalid vendor number' TYPE 'E'.
ENDIF.
CLEAR v_lifnr.
IF s_lifnr-high is NOT INITIAL.
SELECT SINGLE lifnr
from lfa1
INTO v_lifnr
where lifnr = s_lifnr-high.
IF sy-subrc <> 0.
MESSAGE 'Vendor number 2 is not valid' TYPE 'E'.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " VAL
useful for future refrence.
Thank You.
2013 Jun 12 11:09 AM
That is not going to work for all cases dear.
When you give the range as you had mentioned before from 45 to 50, it is just going to check for 45 and 50 and 47 will still not be validated.
Please check my code again. Use the entire thing if you want complete validation.
2013 Jun 12 11:13 AM
Hi,
I want to clarify my doubt,
1. How it will work fine. If suppose user enter multiple range of value then, what will happen?
ok if suppose you are using no extension then it will fine.
2. If suppose user enter both s_lifnr-low and s_lifnr-high mean time what will happen?
Warm Regards,
John.
2013 Jun 12 11:53 AM
Hi meenakshi,
This would be the better solution for your requirement.
data: v_lifnr type lifnr.
select-options: s_lifnr for lfa1-lifnr.
at selection-screen on s_lifnr.
select lifnr into s_lifnr-low from lfa1 where lifnr in s_lifnr.
s_lifnr-sign = 'I'.
s_lifnr-option = 'EQ'.
append s_lifnr.
clear s_lifnr.
endselect.
sort s_lifnr by low.
delete adjacent duplicates from s_lifnr comparing low.
"""Here you can use your logic.
loop at s_lifnr.
select single lifnr
from lfa1
into v_lifnr
where lifnr = s_lifnr-low.
if sy-subrc <> 0.
message 'Invalid vendor number' type 'E'.
endif.
clear v_lifnr.
endloop.
Regards,
Madhumahesh.
2013 Jun 14 9:55 AM
Hi Madhu,
The select single inside the loop statement makes the performance issue. First i used ur code i submitted also but my tl suggested me not to use select single inside the loop.
2013 Jun 14 1:29 PM
Hi meenakshi,
Check the below code once.
""in selection-screen enter vendors from 1-3 and check it. But i want to know, actually what is your requirement?
tables: lfa1.
data: v_lifnr type lifnr.
types: begin of ty_lifnr,
lifnr type lifnr,
end of ty_lifnr.
data: it_tab type table of ty_lifnr,
wa_tab type ty_lifnr.
select-options: s_lifnr for lfa1-lifnr.
at selection-screen on s_lifnr.
* select lifnr from lfa1 into table it_lifnr where lifnr in s_lifnr.
wa_tab-lifnr = 1.
append wa_tab to it_tab.
clear wa_tab.
wa_tab-lifnr = 3.
append wa_tab to it_tab.
clear wa_tab.
loop at it_tab into wa_tab.
if wa_tab-lifnr in s_lifnr.
else.
message 'Invalid vendor number' type 'E'.
endif.
clear: wa_tab.
endloop.
Regards,
Madhumahesh.
2013 Jun 14 3:11 PM
2013 Jun 13 12:14 PM
HI meenakshi ,,
EPORT ZLIFNR.
tables:lfa1.
select-options s_lifnr for lfa1-lifnr.
Data: v_lifnr type lifnr.
AT SELECTION-SCREEN on s_lifnr .
if not s_lifnr is INITIAL.
* loop at S_LIFNR.
SELECT lifnr
INTO v_lifnr
FROM LFA1
WHERE LIFNR IN S_LIFNR.
endselect.
* endloop.
IF SY-SUBRC <> 0.
MESSAGE 'INVALID ACCOUNT NUMBER' TYPE 'E'.
ENDIF.
ENDIF.
2013 Jun 14 11:51 AM
Hi Meena,
Please remove the Answered tick mark,
Go through the following code, i hope this will meet your requirement,
TYPES: BEGIN OF ty_lifnr,
lifnr TYPE lifnr,
END OF ty_lifnr.
DATA : lv_lifnr TYPE lifnr,
it_lifnr TYPE TABLE OF ty_lifnr,
wa_lifnr TYPE ty_lifnr,
str TYPE string.
SELECT-OPTIONS : s_lifnr FOR lv_lifnr.
AT SELECTION-SCREEN ON s_lifnr .
SELECT lifnr INTO TABLE it_lifnr FROM lfa1 WHERE lifnr IN s_lifnr.
IF s_lifnr-low IS NOT INITIAL.
READ TABLE it_lifnr INTO wa_lifnr WITH KEY lifnr = s_lifnr-low.
IF sy-subrc <> 0.
CONCATENATE 'Your enter vendor number' s_lifnr-low ' is wrong' INTO str.
MESSAGE str TYPE 'E'.
ENDIF.
ENDIF.
IF s_lifnr-high IS NOT INITIAL.
READ TABLE it_lifnr INTO wa_lifnr WITH KEY lifnr = s_lifnr-high.
IF sy-subrc <> 0.
CONCATENATE 'Your enter vendor number' s_lifnr-high 'is wrong' INTO str.
MESSAGE str TYPE 'E'.
ENDIF.
ENDIF.
Warm Regards,
John.
2013 Jun 14 12:20 PM
Hi John,
But this code not working for single value ranges. that is from 40 to 50 ....iam giving in the range as 41, 42, 44, 45, 49....but here 44 is not available.....but also executing
2013 Jun 14 2:06 PM
Hi Meena,
See in my system it is working fine. Kindly check your coding,
And also go through my previous post.
In my table have the 1 and 2 vendor id but my system can not have vendor id 3.
See also it is working for multiple selection range,
Warm Regards,
John.