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

Checking for chars or numbers in i string

Former Member
0 Likes
826

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
Read only

Former Member
0 Likes
657

Hi Dan,

Try this:

IF ZCHAR CO '0123456789 '.

ZINT = ZCHAR.

ELSE.

  • Error

ENDIF.

Regards,

Arjan

4 REPLIES 4
Read only

Former Member
0 Likes
658

Hi Dan,

Try this:

IF ZCHAR CO '0123456789 '.

ZINT = ZCHAR.

ELSE.

  • Error

ENDIF.

Regards,

Arjan

Read only

Former Member
0 Likes
657

Hi Dan,

you can use this:

if variable cn '0123456789'.

regards

Siggi

Read only

0 Likes
657

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

Read only

0 Likes
657

Thanks guys!!!

Best Regards

/Daniel