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

conversion overflow: quan and string

Former Member
0 Likes
1,492

Hi,

I have a method with an exporting parameter of type QUAN, lenghth 9. How do i store the value of a local variable of type STRING into the export parameter?

Regards,

Rachita.

7 REPLIES 7
Read only

Former Member
0 Likes
992

use the PACK command.

PACK lstr to lquant.

Regards

Anurag

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
992

You can just move it. But there must only be numeric values in the string. What is the value in the string when you are moving to the other field when you are getting the error.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
992

Hi Rich,

The value in the local variable of type string is 2151521545.33333333333333.

Regards,

Rachita.

Read only

0 Likes
992

Hi

the value given by you is a 10 digit numeric & morethan 10 as decimals. if you move this to a 9digit numeric, definitely values will be trucated.

so try to redefine your export parameter length.

you can use CEIL or FLOOR command, to round off the variable.

Regards

Srikanth

Read only

0 Likes
992

You have to decide what value you want to end up in the quantity field. How many decimals places, if any. Then we can look for a way to handle it.

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
992

For example, if you want just the whole number with no decimals, the your quantity field must be at least a length of 6 TYPE P field.




report zrich_0001.

data: q(6) type p.
data: str type string.

str = '2151521545.33333333333333'.

clear q.
q =  str .

write:/ q.

The output here is ...

2151521545

Regards,

Rich Heilman

Read only

Former Member
0 Likes
992

Hi,

Since my exp variable is of type QUAN of length 9 only, I want max first 9 difits to be populated from the local variable of string type.

I did the following:

data: q(6) type p,

ex type <data_element QUAN (9)>.

data: str type string.

str = '2151521545.33333333333333'.

clear q.

q = str(9).

ex = q.

However, this raises an exception RANGE OUT OF BOUNDS if the value in str is 0. How do I just pick up the first 9 digits whatever be the length or any no of decimal places?

Regards,

Rachita.