Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

problem detecting uppercase

juanluis_ragel
Participant
0 Likes
982

hi,

I'm beginner.

I have a stupid question :-). Paste my Example:

DATA: lowletters(28) TYPE c VALUE 'abcdefghijklmnñopqrstuvwxyz',

string(100) TYPE c VALUE 'WORDINUPPERCASE'.

IF string CA lowletters.

WRITE 'string is lower-case'.

ELSE.

WRITE 'string is upper-case'.

ENDIF.

Result of report:

string is lower-case

Why??? I don't understand. I read help a lot of time about CA (Contains Any) and it say: "c1 contains at least one character from the string c2. ". In my Example c1 (string) NOT CONTAINS at least one character from the string lowletters. Maybe Im crazy.

Can you help me?

A lot of thanks in advance.

Best regards.

djlu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
949

declare lowletters of length 27(exact length) , its working

REPORT ABC line-size 255.

DATA: lowletters(27) TYPE c VALUE 'abcdefghijklmnñopqrstuvwxyz',
string(100) TYPE c VALUE 'WORDINUPPERCASE'.

IF string CA lowletters.
WRITE 'string is lower-case'.
ELSE.
WRITE 'string is upper-case'.
ENDIF.

8 REPLIES 8
Read only

Former Member
0 Likes
949

hi Juan,

CA is case sensitive...

Contains any (ca)

If ‘SAP’ ca ‘ABAP/4’.
			Write:/ ‘True’.
		Else.
			Write:/ ‘False’.
		Endif.
				True

this code of yours is working in this way ..

DATA: lowletters(28) TYPE c VALUE 'abcdefghijklmnnopqrstuvwxyz',
string(100) TYPE c VALUE 'WORDINUPPERCASE'.
 
IF string CA 'abcdefghijklmnnopqrstuvwxyz'.
WRITE 'string is lower-case'.
ELSE.
WRITE 'string is upper-case'.
ENDIF.

Regards,

Santosh

Read only

Former Member
0 Likes
949

try this

REPORT ABC line-size 255.

DATA: lowletters(28) TYPE c VALUE 'abcdefghijklmnñopqrstuvwxyz',
string(100) TYPE c VALUE 'WORDINUPPERCASE'.

IF string CA 'abcdefghijklmnñopqrstuvwxyz'.
WRITE 'string is lower-case'.
ELSE.
WRITE 'string is upper-case'.
ENDIF.

Read only

Former Member
0 Likes
950

declare lowletters of length 27(exact length) , its working

REPORT ABC line-size 255.

DATA: lowletters(27) TYPE c VALUE 'abcdefghijklmnñopqrstuvwxyz',
string(100) TYPE c VALUE 'WORDINUPPERCASE'.

IF string CA lowletters.
WRITE 'string is lower-case'.
ELSE.
WRITE 'string is upper-case'.
ENDIF.

Read only

0 Likes
949

WOW!

a lot of thanks!!!

exact length problem! Now it's works.

But i think that i'll never understand why.

regards.

djlu2003

Read only

0 Likes
949

May be because if you dont give the exact length , the extra character will be taken as space ,

so both the variables will contain space

so the SY_SUBRC will be 0 as both contain spaces

Read only

0 Likes
949

The reason is due trailing SPACE at the end. Also, you can use CONDENSE statmenet with NO-GAP to delete the trailing spaces in the string.

Regards

Anurag

Read only

0 Likes
949

Hi,

But it doesn't work if we have a variable which is the type c, and we want to get only the num data:

for example, I have :

parameters: pa(10) type c.

if pa CA 'abcdefghijklmnopqrstuvwxyz'.

WRITE / 'pa is the type num'.

endif.

even if the parameters pa has type c, I want to verify the input data in this field and get only the numeric value.

Mll Mat

Edited by: mll mat on Apr 28, 2009 10:50 AM

Read only

Former Member
0 Likes
949

may be in string comparision the checking is case INsensitive.

regards

srikanth

Message was edited by: Srikanth Kidambi