‎2009 Apr 16 7:22 AM
hi.
please help me for follwing requirement...
PARAMETER : PVAR(6) TYPE C.
the value in above field should be in this format 99AZ99
Means , first two and last two character should be NUMBER only
Third and forth character shold be ALPHABATIC CHARACTER only
while inputing to this field , it shold no allowed me to enter ALPHABATE in first two and last two position.
same for number also.
I WANT THIS WHILE INPUT ONLY. not after pressing ENTER.
‎2009 Apr 16 7:44 AM
Hi Jignesh,
Since I guess you are not alloweing for validations of the input AT SELECTION-SCREEN - then you can try this approach:
Create three parameters as shown below:
selection-screen: begin of line.
parameters: pvar1(2) type n,
pvar2(2) type c,
pvar3(2) type n.
selection-screen: end of line.Then AT SELECTION-SCREEN event you can concatenate them into PVAR.
Now the only hitch is (other than if your end user would be happy with the way the screen looks) the first and third fields would meet you requirement since they would allow only entry of numbers, but the second field would allow numbers or even special characters. Hence you would have to validate that field AT SELECTION-SCREEN.
Just in case you have not thought off it ... it's quite easy to perform your validation with little code as shown below AT SELECTION-SCREEN
IF pvar(2) CN '0123456789' OR pvar+4(2) CN '0123456789' .
.... Raise error.
ELSEIF pvar+2(2) CN 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
.... Raise error.
ENDIF.
Cheers,
Aditya
‎2009 Apr 16 7:49 AM
Thanks aditya,
but that was not the answer what i expect.
This would be heppen in only ONE input field. (not three different)
the way u told to validate it in AT SELECTION SCREEN, also i dont want, since it will validate when i press ENTER or any othere button.
I just dont want to allow certain KEY PRESS on certain position.
‎2009 Apr 16 7:51 AM
Hi,
Try this
AT SELECTION-SCREEN ON PVAR.
IF PVAR(2) CN '0123456789'.
" Message Enter number in first two digits
ENDIF.
IF PVAR+2(2) CN SY-abcde.
" Message Enter char in second two digits
ENDIF.
IF PVAR+4(2) CN '0123456789'.
" Message Enter number in last two digits
ENDIF.
‎2009 Apr 16 8:14 AM
I'm afraid you cannot do such validation on a single field.
I thought the below code would work , but intesting thing is that it still allows to enter alphabets in the first 2 and the last 2 places.
REPORT z_paramter_tst .
TYPES : BEGIN OF ty_par,
p1(2) TYPE n,
p2(2) TYPE c,
p3(2) TYPE n,
END OF ty_par.
PARAMETER p_1 TYPE ty_par.
start-of-selection.
write p_1.
So the only way would be to split the field into 3 fields or validate on PAI ( AT SELECTION-SCREEN) by copying the field into a data type of ty_par and validate each component separately.
AT SELECTION-SCREEN ON p_1.
par_split = p_1.
if par_split-p1 CN '0123456789'
"Error message
endif.
if par_split-p2 CN sy-abcde.
endif.
endif
if par_split-p3 CN '0123456789'
" Error Message
endif.
The reason being that we do not have the control on the frontend and only when some action is performed on the frontend (User command ) the PAI is triggered and the control is back to program.
regards,
Advait