04-08-2008 9:57 AM
Hi!
I'm a very beginner in ABAP so please don't hurt me for my question.
On my dynpro I have two fields which the user has to fill out. One for the month (01 - 12) and the second is for the year (4 characters). Now I want to validate both fields in PAI. I also want that the user could enter either e.g. "08" or "2008". If he enters just "08", the system should complete it to "2008".
Is there a easy way to do this?
Thanks for your help,
Alex
04-08-2008 10:01 AM
create the input field as standard field type.. so it'l get validted automatically.. (if validation exists for the standard one)
or do the coding manually
04-08-2008 10:08 AM
Hi and thanks for your very quick answer!
But could you go a bit more in detail? As I wrote above I'm very new in ABAP...
04-08-2008 10:11 AM
Hi,
In Flow logic editor.
PROCESS AFTER INPUT.
MODULE validate_0100.
IN ABAP editor....
DATA : v_len TYPE I.
MODULE validate_0100 INPUT.
If field1 LT 1 OR
field1 GT 12.
Message ......... "Pls. enter valid month."
ENDIF.
v_len = strlen(field2 ) .
IF v_len eq 2.
CONCATENATE '20' field2 INTO field2.
ENDIF.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 8, 2008 11:32 AM
04-08-2008 10:31 AM
Thanks for that!
One last question concerning this. How should I define field1 and field2? Right now I have it field1 as N(2) and field2 as N(4). Is that correct?
04-08-2008 10:37 AM
here is one example :
field2 type ALYEAR
field1 type AFWGO_MONTH
you can search for such more data elements in SE11
04-08-2008 10:57 AM
Hi Alexander,
Just a quick observation from the above comments..
if user enters 08 it hould be 2008
what if he enters 00 .....then it will be 2000
what if he enters 98 ..will be 1998 or 2098?????
If it is 2098..you can do as suggested,but if it is 1998..then you can't provide the user the requirement to enter just 2 of the 4 digits..he has to enter it completely
Hope i have made my point clear...
Regards
Byju
04-08-2008 10:59 AM
Hi Alexander,
Just a quick observation from the above comments..
if user enters 08 it hould be 2008
what if he enters 00 .....then it will be 2000
what if he enters 98 ..will be 1998 or 2098?????
If it is 2098..you can do as suggested,but if it is 1998..then you can't provide the user the requirement to enter just 2 of the 4 digits..he has to enter it completely
Hope i have made my point clear...
Regards
Byju
04-08-2008 10:38 AM
04-08-2008 11:32 AM
Thanks everybody for helping me!!!!
You are right. If the user enters 98 it could be 1998 and also 2098. But I would say 2098 is ok. If he need some old data from 1998 he should enter the whole year and not just 98. But thanks a lot for that!
I will check all these this evening and will let you know if it's work for me!
Regards, Alex
04-08-2008 4:13 PM
I'm nearly there!
The year-field is declared as NUMC (4) on my dynpro. If I enter just 08, the field is filled up with 0. So I have 0008 in there and I the length is surely 4.... where is my mistake?
Alex
04-08-2008 4:24 PM
Go with Sharayu's suggestion, is better to declare the field with an standard data element, because they already have attached the conversion routine
04-08-2008 4:30 PM
I tried it already but I just have a few formats in the dynpro F6 Selection.
In my program it's declared as ALYEAR....
04-08-2008 4:42 PM
You usually use dictionary fields in dynpros.
A good way to do it, since you are using alyear.
Type in the name of the field BSIK-GJAHR when a window asks you to refer to the dictionary, click yes, after that change the name again to the variable you are using in your program and you'll keep the conversion routines of BSIK-GJAHR
04-08-2008 5:00 PM
04-08-2008 5:06 PM
In the screen painter, in the attributes of your year field. Change the name to bski-gjahr so you bring the attributes of the dictonary, after that you can change the name of the field to the variable you are using in your program