2008 Nov 19 7:12 AM
Hi.... all
please help me....
My requirement is this....
If i use the first statement i am getting True statement.
1) IF 'EXAMPLE' CO SY-ABCDE. WRITE 'TRUE'. ELSE. WRITE 'FALSE'. ENDIF.
in second case am getting.....am getting false statement.....
2) PARAMETERS: FNAME TYPE PAD_VORNA.
START-OF-SELECTION.
example FNAME value is 'RAJA NARAYANAN' all CAPS letters.
IF FNAME CO SY-ABCDE. WRITE 'TRUE'. ELSE. WRITE 'FALSE'. ENDIF.
Please help me out...
i need to get if i enter small letters i should get false satement.
and cap means true statement... i should not change the type for fname....becaz that is my requirement.
Thanks in advance
Regards
Raja...
2008 Nov 19 8:23 AM
Hi....all
Thanks for your replies.....
i should not go for do loop for my scenario....i tried with do loop before itself and i got the answer.... but my client requirement is i have to use CO or CN like this string operators in IF..ENDIF. statements... and not in loop..
DATA STR TYPE STRING.
PARAMETERS: FNAME TYPE PAD_VORNA lower case.
str = fname.
IF STR CA 'SY-ABCDE'.
WRITE 'TRUE'.
ELSE.
WRITE 'FALSE'.
ENDIF.
i also tried with this statement... but... still i need some help....
if i enter in FNAME like this 'abc123#9'. i should get errors....
the FNAME should only accept character with only CAPS and not in small letters and also without any special charaters....
Please help.....me
Regards
Raja
2008 Nov 19 7:22 AM
2008 Nov 19 7:23 AM
Hi,
instead of
PARAMETERS: FNAME TYPE PAD_VORNA,
use
PARAMETERS: FNAME TYPE PAD_VORNA lower case
Because, by default, whatever you will put in parameter input it is initialy converted into UPPERCASE. So internaly it is always compairing with to UPPERCASE STRINGs and you got 'TRUE ' as output.
Check your code now
PARAMETERS: FNAME TYPE PAD_VORNA lower case.
IF FNAME CA 'SY-ABCDE'.
WRITE 'TRUE'.
ELSE.
WRITE 'FALSE'.
ENDIF.
Regards,
Anirban
2008 Nov 19 7:23 AM
Hi Raja,
Here is a simple example
data :loc_var type string value 'abcdefghijklmnopqrstuvwxyz'.
data :loc_test1 type string value 'MY NAME IS Raja'.
data :loc_test2 type string value 'MY NAME IS RAJA'.
if loc_test1 CA loc_var.
Message 'Small letters found' type 'I'..
endif.
if loc_test2 CA loc_var.
else.
Message 'Small letters not found' type 'I'.
endif.
Solution:
so the loc_var defines all variables in lower case and if any of the lowercase is found then we have the statement "if loc_test1 CA loc_var." as successful
Hope it helps
Regards
Byju
2008 Nov 19 7:25 AM
Hi
2 things
(1) There should not be space between words, if you pass 'RAJA NARAYANAN' to first statement also it will fail
(2) when you are passing thru parameter, write the parameter to different varaible and than check.
try this code
data : string type string.
PARAMETERS: FNAME TYPE PAD_VORNA.
START-OF-SELECTION.
translate fname to upper case.
string = fname.
*example FNAME value is 'RAJA NARAYANAN' all CAPS letters.
IF string CO SY-ABCDE. WRITE 'TRUE'. ELSE. WRITE 'FALSE'. ENDIF.
Regards
Madhan D
Edited by: Madhan Doraikannan on Nov 19, 2008 8:26 AM
2008 Nov 19 7:29 AM
>
> Hi.... all
>
> please help me....
> My requirement is this....
>
> If i use the first statement i am getting True statement.
>
> 1) IF 'EXAMPLE' CO SY-ABCDE. WRITE 'TRUE'. ELSE. WRITE 'FALSE'. ENDIF.
>
> in second case am getting.....am getting false statement.....
>
> 2) PARAMETERS: FNAME TYPE PAD_VORNA.
> START-OF-SELECTION.
> * example FNAME value is 'RAJA NARAYANAN' all CAPS letters.
> IF FNAME CO SY-ABCDE. WRITE 'TRUE'. ELSE. WRITE 'FALSE'. ENDIF.
>
>
>
> Please help me out...
> i need to get if i enter small letters i should get false satement.
> and cap means true statement... i should not change the type for fname....becaz that is my requirement.
>
> Thanks in advance
> Regards
> Raja...
Hi,
I think FALSE is coming in second case due to a sapce in between the name.
Thanks
NItesh
2008 Nov 19 7:53 AM
hi
the 'CO' operand can not work! it is sensible bewteen capitalization and lower.
you can try this
DATA:l_letter,
position TYPE i,
length TYPE i,
upper_counts TYPE i,
lower_counts TYPE i.
length = STRLEN( fname ).
DO length TIMES.
l_letter = fname+position(1).
IF l_letter >= 'A' AND
l_letter <= 'Z'.
upper_counts = upper_counts + 1.
ELSEIF l_letter >= 'a' AND
l_letter <= 'z'.
lower_counts = lower_counts + 1.
ENDIF.
position = position + 1.
ENDDO.
IF upper_counts = length.
WRITE 'TRUE'.
ELSEIF lower_counts = length.
WRITE 'FALSE'.
ENDIF.
2008 Nov 19 8:23 AM
Hi....all
Thanks for your replies.....
i should not go for do loop for my scenario....i tried with do loop before itself and i got the answer.... but my client requirement is i have to use CO or CN like this string operators in IF..ENDIF. statements... and not in loop..
DATA STR TYPE STRING.
PARAMETERS: FNAME TYPE PAD_VORNA lower case.
str = fname.
IF STR CA 'SY-ABCDE'.
WRITE 'TRUE'.
ELSE.
WRITE 'FALSE'.
ENDIF.
i also tried with this statement... but... still i need some help....
if i enter in FNAME like this 'abc123#9'. i should get errors....
the FNAME should only accept character with only CAPS and not in small letters and also without any special charaters....
Please help.....me
Regards
Raja
2008 Nov 19 8:40 AM
Why r u making the code complecated
try
REPORT ZTEST002.
PARAMETERS: FNAME TYPE PAD_VORNA lower case.
IF FNAME CA SY-ABCDE.
WRITE 'TRUE'.
ELSE.
WRITE 'FALSE'.
ENDIF.
Regards,
Anirban
2008 Nov 19 8:45 AM
HI...Anirban Bhattacharjee
Read my question and then reply for that
2008 Nov 19 8:46 AM
i also tried with this statement... but... still i need some help....
if i enter in FNAME like this 'abc123#9'. i should get errors....
the FNAME should only accept character with only CAPS and not in small letters and also without any special charaters....
2008 Nov 19 8:47 AM
REPORT ZSRK_068 .
PARAMETERS: FNAME TYPE PAD_VORNA.
DATA AL(27) VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '.
START-OF-SELECTION.
IF FNAME CO AL.
WRITE 'TRUE'.
ELSE.
WRITE 'FALSE'.
ENDIF.
2008 Nov 19 8:49 AM
Check the code properly....... there will be no ' ' with SY-ABCDE and follow the RULE OF ENGAGEMENT regarding use of words in forum. I have read it and worked it out in my system.
2008 Nov 19 9:00 AM