Convert string to integer
I need to convert a string (it is a packed number stored in a string variable) into an integer. I tried just saying integer = string but it throws a run-time error. Then I tried to use fm convert_string_to_integer but that FM isn't at all what it sounds like (it doesn't' accept a string of numbers). How can I do this?
Rich Heilman replied
what's the problem?
data: str type string value '123456'. data: i type i. i = str. write:/ i.
what is the value in your string? Does it contain something other than numbers? If so you would need to get rid of those. For example, say that your string contained a number with a thousand separator like ','.
data: str type string value '123,456'. data: i type i. translate str using ', '. "< get rid of the comma condense str no-gaps. i = str. write:/ i.