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: 

Checking for chars or numbers in i string

Former Member
0 Kudos

Hi,

I need to convert a varibale of type char10 to integer. Exampple: ZCHAR: '0000144210' to ZINT: 144210; for instance with following statement: ZINT=ZCHAR

However, if ZCHAR contains a character like 'a'=> '000014a4210' the program shortdumps at the assignment.

My question is then if there is a function or such to check number of characters in a variable or anything to ensure that the short dump wont occur.

Best Regards

/Daniel

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Dan,

Try this:

IF ZCHAR CO '0123456789 '.

ZINT = ZCHAR.

ELSE.

  • Error

ENDIF.

Regards,

Arjan

4 REPLIES 4

Former Member
0 Kudos

Hi Dan,

Try this:

IF ZCHAR CO '0123456789 '.

ZINT = ZCHAR.

ELSE.

  • Error

ENDIF.

Regards,

Arjan

Former Member
0 Kudos

Hi Dan,

you can use this:

if variable cn '0123456789'.

regards

Siggi

0 Kudos

Here is another option.......



data: c(10) type c,
      i     type i.

c = '01234a6789'.

catch system-exceptions convt_no_number = 1.
  i = c.
endcatch.

if sy-subrc  = 1.
  write:/ 'error'.
endif.

Regards,

Rich Heilman

0 Kudos

Thanks guys!!!

Best Regards

/Daniel