Application Development 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: 

Check Numaric or not

Former Member
0 Kudos

Hi,

i have one field which contains 10 chars.

first 5 chars should be any char. last 5 chars must be numeric only.

if last 5 chars contains any char then it should throw error.

thanks in advance.

regards,

Balu

Moderator message - Please search before asking basic questions - post locked

Edited by: Rob Burbank on Jun 18, 2009 9:48 AM

5 REPLIES 5

SuhaSaha
Advisor
Advisor
0 Kudos

Hello,

You have to use offset functions for this purpose:

DATA:
V_CHAR TYPE CHAR10,
V_CHECK TYPE CHAR5.

V_CHECK = V_CHAR+5.

IF V_CHECK CN '0123456789'.
" Throw error message
ENDIF.

BR,

Suhas

Former Member
0 Kudos

Hello

you can try like this:



IF VAR+5 CO '0123456789'
YOUR ERROR....
ENDIF.

Bye

Gabriel P.-

Pawan_Kesari
Active Contributor
0 Kudos
DATA : lv_char1 TYPE char10 VALUE 'ABCDE12' ,
       lv_int   TYPE i                         .

TRY .
    lv_int = lv_char1+5(5).
  CATCH cx_sy_conversion_no_number .
    WRITE 'No Number' .
ENDTRY.

Former Member
0 Kudos

Hi,

Use Contains ANY:

sample code:



c_text = c_text+5
 IF c_wild CA lv_c. <------- The 26 english alphabets
          Throw error
endif

.

former_member188829
Active Contributor
0 Kudos

Hi,

Try this.

DATA :char(10) TYPE c.

char = 'abcde1234q'.

IF char+5(5) CN '0123456789'.
  WRITE:/ 'Error Message'.
  ELSE.
  WRITE:/ 'Correct'.
ENDIF..