Thursday, August 28, 2014

ABAP TIP Check case sensitive

ABAP Check case sensitive

Let’s learn how to check upper/lower case in data variable.
After creating program, create 2 variables. First variable has only one lowercase character, Second variable has all lowercase alphabet. And if you compare with ‘CA’, the program check if the variable has a lowercase or not.
Starting the position of lowercase is saved to SY-FDPOS.


REPORT  zcase_test.

DATA : gv_v1 TYPE string VALUE 'AbCD',
       gv_v2 TYPE string VALUE 'abcdefghijklmnopqrstuvwxyz'.

IF gv_v1 CA gv_v2.
  MESSAGE 'There is lower case in variable.' TYPE 'I'.
ELSE.
  MESSAGE ' There is lower case in variable..' TYPE 'I'.
ENDIF.



In contrast, you can also check upper case with the string consisted of upper case.

DATA : gv_v2 TYPE string VALUE 'ABCDEFGHIZKLMNOPQRSTUVWXYZ'.

Or system variable SY-ABCDE is replaced with 'ABCDEFGHIZKLMNOPQRSTUVWXYZ'.
.
IF gv_v1 CA SY-ABCDE.


No comments:

Post a Comment