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

Finding digits in variable

Former Member
0 Likes
710


Hello, I have a question. I have one variable called lv_tst. i have declared it like this:

 

lv_tst(3) TYPE C,

Now, sometimes this variable may have only one digit like 1 through 9 and other times it may have 10. What I am looking to do is when

lv_tst has a single digit then i want to

Concatenate '00' to lv_tst into another variable.

but when lv_tst has 2 digits such as 10 or 11 or anything uptil 99 then:

Concatenate '0' to lv_tst into another variable.

but i don't know what is the syntax to find our how many digits have occupied in lv_tst.

Please help.

Thanks.

1 ACCEPTED SOLUTION
Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
646

Hello Venkat,

Please use the FM CONVERSION_EXIT_ALPHA_INPUT to add leading zeros.


data : lv_tst(3).

lv_tst = '2'.


CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
   EXPORTING
     INPUT         = lv_tst
  IMPORTING
    OUTPUT        = lv_tst


Write lv_tst.


O/P : 002.

Thanks

3 REPLIES 3
Read only

Former Member
0 Likes
646

Hi Venkat,

try this:

l_i = strlen( lv_tst ).

regards,

Edgar

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
647

Hello Venkat,

Please use the FM CONVERSION_EXIT_ALPHA_INPUT to add leading zeros.


data : lv_tst(3).

lv_tst = '2'.


CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
   EXPORTING
     INPUT         = lv_tst
  IMPORTING
    OUTPUT        = lv_tst


Write lv_tst.


O/P : 002.

Thanks

Read only

sivaganesh_krishnan
Contributor
0 Likes
646

hi venkat,

There are Function module for your scnerio

data: lv_t TYPE char3.

lv_t = 1.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

   EXPORTING

     input         = lv_t

  IMPORTING

    OUTPUT        = lv_t

           .

WRITE lv_t.

lv_t = 13.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

   EXPORTING

     input         = lv_t

  IMPORTING

    OUTPUT        = lv_t

           .

WRITE lv_t.



Regards,

Sivaganesh