Former Member

# How to Determine Length of variable up to period (.)

I have a variable called my_var in an ABAP and it is passed many #’s and they may or may not have some text following these #’s --- these #’s can have a Length of up to 13 and will always have 3 Decimal Places. I need to find a way to return the length of the # up to the decimal place.

The # is always first in this variable, it will always have a .000 and it may or may not have text following it. The only way I can think of doing this is to
loop through the my_var one character at a time to find the decimal place and to determine the length. Does anyone have any other ideas?

Examples:

my_var = “22.000 ABC” would return the length of 2

my_var = “0.000 this is more text” would return the length of 1

my_var = “1200000.00” would return the length of 7

my_var = 87098.000” would return a length of 5

my_var = “987.000 this is text again” would return a lenth of 3

Message was edited by: Manish Kumar : Basic programming. Answer can be easily found by searching. Thread locked.

10|10000 characters needed characters exceeded

### Related questions

• Posted on Jul 23, 2014 at 02:08 PM

So you did not find the statement to find a character in a string, look for it again you should find it...

Regards,

Raymond

10|10000 characters needed characters exceeded
• Former Member
Posted on Jul 23, 2014 at 02:06 PM

Hi Janice,

You can use TRUNC function to read the integer part.

Regards,

Ashvin

10|10000 characters needed characters exceeded
• Former Member
Posted on Jul 23, 2014 at 02:11 PM

Hi,

You can use the SPLIT statement at the character - '.'

SPLIT my_var AT '.' INTO lv_var1 lv_var2.

lv_length = strlen (lv_var1).

Regards,

Abhi

10|10000 characters needed characters exceeded
• Jānis B Former Member

That isn't simple - opening ABAP help, finding and then using FIND statement, or from NW 702 or later, the built in find( ) function - is... 😊

cheers

Jānis

• Posted on Jul 23, 2014 at 02:27 PM

Hi ,

try this

data : var1 type char20 value '222.000ABC'.

data : part1 type char10,

part2 type char10.

data : lv_int type i.

split var1 at '.' into part1 part2.

lv_int = strlen( part1 ).

write : 'length of Interger Before decimal',lv_int.

Regards

pavan