2011 Jun 22 8:42 PM
I am working on a piece of code:
we have a custom table ZVEND_DETAILwhich has the following fields:
1. Vend_num1_From
2. Vend_Num1_To
3. Vend_num2_From
4. Vend_num2_TO
5. Zcode
now the user will enter the above fields on the screen and I need to check what user entered is in this table or not, if not then throw an error.
the input fields for user are:
v_vend_num1
v_vend_num2
zcode
Vend_num1_From Vend_num2_TO Vend_num1_From Vend_num2_To
12 20 1 5
10 15 2 2
10 10 1 1
20 25 6 10
so if the user enters any of the above mentioned value, it's a correct value
So basically what I need to see whatever user enters should be validated against this table All the records are unique, I am not able to build this logic, can you please help me on how to start this.
Your help is appreciated.
Rahul
Edited by: goel.rahul2238 on Jun 22, 2011 9:47 PM
Edited by: Rob Burbank on Jun 23, 2011 8:58 AM
2011 Jun 23 9:29 PM
Hi Rahul,
If all your 3 screen fields are mandatory, and you want to select the lines which correspond to the 3 fields (there will be 0 line if the user entries do not correspond), then it would be:
SELECT * FROM zvend_detail INTO TABLE lt_itab
WHERE vend_num1_From <= v_vend_num1
AND vend_num1_to >= v_vend_num1
AND vend_num2_From <= v_vend_num2
AND vend_num2_to >= v_vend_num2
AND zcode = zcode.
BR
Sandra
2011 Jun 23 1:47 AM
2011 Jun 23 6:49 AM
Rahul,
I assume it is not a table Maintenance generator but a selection screen throug which you are trying to have such a kind of check.Then you can use At selection screen on that particular field and then check if the entered data is already availble in the table or not using a select query,check the sy subrc and accordingly give an error message.
If it is a table maintennange generator then you need to handle it using events or by giving the check table ENTRY HELP/CHECK in SE11.
Thanks,
K.Kiran.
2011 Jun 23 9:54 AM
Rahul,
The logic should go like this.
data: lv_succ type c.
select * from ZVEND_DETAIL into table itab.
loop at itab into wa.
if ( v_vend_num1 ge wa-Vend_num1_From and
v_vend_num1 le wa-Vend_num1_to ) AND
( v_vend_num2 ge wa-Vend_num2_From and
v_vend_num2 le wa-Vend_num2_to ) AND
Zcode eq wa-zcode.
lv_succ = 'X'.
exit.
endif.
endloop.
if lv_succ is initial.
raise error
endif.
regards,
Diwakar
2011 Jun 23 4:57 PM
Hi
Use the initialization event to build your range tables for your fiuelds.
INITIALIZATION.
SELECT vendor_num_from INTO TABLE lt_vend_num_fr
FROM zvend_table.
LOOP AT lt_vend_num_fr INTO ls_vend_num_fr.
lwr_vend_num_fr-sign = 'I'.
lwr_vend_num_fr-option = 'EQ'.
lwr_vend_num_fr-low = ls_vend_num_fr-vendor_num_from.
APPEND lwr_vend_num_fr TO gr_vend_num_fr.
ENDLOOP.
then use event AT SELECTION_SCREEN ON to do the validation for your values
AT SELECTION-SCREEN ON p_from.
IF NOT p_from IN gr_vend_num_fr.
*...issue message
ENDIF.
regards
PrinceIsaac
2011 Jun 23 9:29 PM
Hi Rahul,
If all your 3 screen fields are mandatory, and you want to select the lines which correspond to the 3 fields (there will be 0 line if the user entries do not correspond), then it would be:
SELECT * FROM zvend_detail INTO TABLE lt_itab
WHERE vend_num1_From <= v_vend_num1
AND vend_num1_to >= v_vend_num1
AND vend_num2_From <= v_vend_num2
AND vend_num2_to >= v_vend_num2
AND zcode = zcode.
BR
Sandra
2011 Jun 24 11:00 AM
Hi Rahul
suppose you have V1F, V1T, V2F and V2T as your input fields on screen.
Obviously you have declared your screen with this input fields.
then in your program, on the event of AT SELECTION SCREEN
create a perform Validation and write below code.
select Vend_num1_From
from ZVEND_DETAIL
where Vend_num1_From = V1F.
if sy-subrc <> 0.
message
endif.
similarly do the same for all the other fields which you want to validate.
after this validation perform
write your code on the event Start-Of-Selection
I hope this will work for you
Thanks
LG