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

Error while Char to Number

Former Member
0 Likes
1,477

Hi Experts,

In my code below, i getting a short dump as unable to interpret 1,000 .00 as a number

lv_atwrt has to be type c & lv_qty1 has to be type n.

data : lv_cval(10) type n,

lv_qty1(10) type n,

lv_qty2 type dzmeng,

lv_atwrt(10) type c,

lv_qty3 type p.

lv_atwrt = '1,000.00'.

lv_qty1 = 10000.

write : lv_atwrt to lv_cval.

shift lv_qty1 left deleting leading '0'.

*lv_cval = lv_atwrt.

lv_qty2 = lv_qty1 / lv_cval. --> short dump

write lv_qty2.

i am getting a short dump if change lv_cval to type P.

pls tell me where am i wrong?

Thanks

Dan

15 REPLIES 15
Read only

Former Member
0 Likes
1,378
lv_atwrt = '1000.00'.

change this code.

Read only

0 Likes
1,378

Hi,

Comma (,) is unavoidable in lv_atwrt = '1000.00' as this is a value returned by an FM.

Any other suggestions plss.

Thanks

Dan

Read only

0 Likes
1,378

Which FM are you talking about? The output variable of the FM will not have the Comma during code execution, its only when it displays the output in the GUI it gets the user preferences and displays the comma.

Read only

0 Likes
1,378

Hi,

I am yaking abt FM: VC_I_GET_CONFIGURATION. the field lv_atwrt resembles the ATWRT field in the structure CONF_OUT.

Pls suggest.

Read only

0 Likes
1,378

Hi,

I am yaking abt FM: VC_I_GET_CONFIGURATION. the field lv_atwrt resembles the ATWRT field in the structure CONF_OUT.

Pls suggest.

Read only

0 Likes
1,378

Hi,

I am yaking abt FM: VC_I_GET_CONFIGURATION. the field lv_atwrt resembles the ATWRT field in the structure CONF_OUT.

Pls suggest.

Read only

Former Member
0 Likes
1,378

data : lv_cval(10) type n,

lv_qty1(10) type n,

lv_qty2 type dzmeng,

lv_atwrt(10) type c,

lv_qty3 type p.

lv_atwrt = '1,000.00'.

lv_qty1 = 10000.

write : lv_atwrt to lv_cval.

shift lv_qty1 left deleting leading '0'.

*lv_cval = lv_atwrt.

  • Begin of Change

translate lv_cval using ', '.

condense lv_cval no-gaps.

  • End of Change

lv_qty2 = lv_qty1 / lv_cval. "--> No short dump

write lv_qty2.

Execute the above code you will not get dump .

Your issue is solved !!!!

Result : 10.000

Thanks,

Karthik

Read only

Former Member
0 Likes
1,378

Hope the result of the program and you award points will be same .

Read only

Former Member
0 Likes
1,378

ATWRT is of type char and size 30 so whats the problem still my code will work !!!!

data : lv_cval(10) type n,

lv_qty1(10) type n,

lv_qty2 type dzmeng,

lv_atwrt like conf_out-atwrt, ( I have referenced to the same type as you mentioned )

lv_qty3 type p.

lv_atwrt = '10,999,80,000.00'. ( Since its size is 30 i m adding few more comma's run the program and see you will not get any dump )

lv_qty1 = 10000.

write : lv_atwrt to lv_cval.

shift lv_qty1 left deleting leading '0'.

*lv_cval = lv_atwrt.

translate lv_cval using ', '.

condense lv_cval no-gaps.

lv_qty2 = lv_qty1 / lv_cval. "--> short dump

write lv_qty2.

Note : output will be 0.009 ( Less because we are using higher value in the denominator )

Thanks,

Karthik

Read only

0 Likes
1,378

Hi karthik,

It helped me to some extent.

when i use

*write : lv_atwrt to lv_cval. commented and used as below

lv_cval = lv_atwrt.

the result is different.

when lv_atwrt = 1,000.00

lv_cval will hold 1000000.00

why is this so?

code :

data : lv_cval(10) type n,

lv_qty1(10) type n,

lv_qty2 type dzmeng,

lv_atwrt(10) type c,

lv_qty3 type p.

lv_atwrt = '1,000.00'.

lv_qty1 = 10000.

*write : lv_atwrt to lv_cval.

lv_cval = lv_atwrt.

shift lv_qty1 left deleting leading '0'.

*lv_cval = lv_atwrt.

translate lv_cval using ', '.

condense lv_cval no-gaps.

lv_qty2 = lv_qty1 / lv_cval. "--> No short dump

write lv_qty2.

Read only

0 Likes
1,378

When you move the data using the WRITE, system writes the data to the target variable in the FORMATTED way, same as you would use the WRITE statement to write the contents on the screen. So, system gives you the vlaue in the target field with the Comma.

If you use MOVE or VAR1 = VAR2, system moves the data without formatting.

Regards,

Naimesh Patel

Read only

0 Likes
1,378

i m not getting the value what you say ...

the result is different.

when lv_atwrt = 1,000.00

lv_cval will hold 1000000.00

data : lv_cval(10) type n,

lv_qty1(10) type n,

lv_qty2 type dzmeng,

lv_atwrt like conf_out-atwrt,

lv_qty3 type p.

lv_atwrt = '1,000.00'.

lv_qty1 = 10000.

*write : lv_atwrt to lv_cval.

lv_cval = lv_atwrt.

write lv_atwrt.

skip.

write lv_cval.

result :

1,000.00

0000100000

Pls check with the above code .

Read only

0 Likes
1,378

Karthik -

data : lv_cval(10) type n,

lv_qty1(10) type n.

i mean to say that when assigning like this : lv_cval = lv_atwrt.

lv_cval will hold 0000100000 instead of 1000.00 (while in debugging) can be seen in debugging.

Can you pls tell me why is this so?

Read only

0 Likes
1,378

How can a number data type will hold a decimal value , that's why.

Thanks,

Karthik

Read only

Former Member
0 Likes
1,378

thanks