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: 

Remove initial 0 values and find the first number

Former Member
0 Kudos

Hi ,

I have different numbers in my records, they vary from 1 digit to 9 digit . I also have some letters in these records . Relevant field is 10 character length and if it fills initial free spaces with '0' to make record 10 digit. I want to find first digit after '0' values.

For example I have records like :

000123456S I want to find '1'

0000000081 I want to find '8'

Thanks for your helps

Erkan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi ,

I forgot one additional requirement . I also want to check if the letter I found is a letter or a number .

8 REPLIES 8

Former Member
0 Kudos

Hi ,

I forgot one additional requirement . I also want to check if the letter I found is a letter or a number .

0 Kudos

U can either use this function module also

CONVERSION_EXIT_ALPHA_OUTPUT

or

SHIFT <yourField> LEFT DELETING LEADING '0'

or

try NO-ZERO option of WRITE statement

or

Another way is to create another variable of type I and assign the value into it

example:

DATA: L_NUMC(08) TYPE N.

DATA: L_INT TYPE I.

L_NUMC = '00000018'.

L_INT = L_NUMC.

Result will be = 18.

Hope this helps

Former Member
0 Kudos

Hi Erkan,

try it to ur first post.

data: text(10) value '000123456S',

cont(2).

while text+cont(1) = '0'.

cont = cont + 1.

endwhile.

write: / text+cont(1).

Regards,

Allan Cristian

Former Member
0 Kudos

Try:

DATA: f1(10) VALUE '0001234567'.

IF f1 CN '0'.
  WRITE: /001 f1+3(1).
ENDIF.

Rob

former_member387317
Active Contributor
0 Kudos

SHIFT varibale LEFT DELETING LEADING '0'.

then

tempvar = variable(1)

then check the value of tempvar

use the below logic to check for numerical or char filed...

test(5) type c.

test = '12345'.

if test co '0123456789 ' and test NE ' '.

write : 'only numericals'.

ELSEif test = SPACE.

write : 'SPACE'.

elseIF NOT TEST = SPACE.

write : 'ALPHA numericals'.

else.

write : 'Other'.

endif.

ENDIF.

<b>Reward Points if it is helpful.</b>

Thanks & Regards

ilesh 24x7

former_member387317
Active Contributor
0 Kudos

I think this will be the complete solution ...

SHIFT varibale LEFT DELETING LEADING '0'.

then

tempvar = variable(1)

then check the value of tempvar

====================

if tempvar co '0123456789'.

write : 'Numericals'.

else.

write : 'ALPHA numericals'.

endif.

====================

Reward Points if it is helpful.

Thanks & Regards

ilesh 24x7

Former Member
0 Kudos

Hi Erkan,

here the full code.

I found a error when the value is '0000000000', its solved here:

data: text(10) value '0000A00000',

cont(2),

num_lett.

while text+cont(1) = '0' <b>and cont < 9.</b>

cont = cont + 1.

endwhile.

write: / text+cont(1).

num_lett = 'A'.

case text+cont(1).

when '0' or '1' or '2' or '3' or '4' or

'5' or '6' or '7' or '8' or '9'.

num_lett = 'N'.

endcase.

if num_lett = 'A'.

write: / 'ALPHA numeric'.

else.

write: / 'numeric'.

endif.

Regards

Allan Cristian

Former Member
0 Kudos

Thanks for all answers