Application Development 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: 

Char to Quantity conversion

Former Member
0 Kudos

Hello All,

I am getting the shortdump when I am trying to pass the value from char field to quantity .

Example:

Data : lv_comp_qty like STPO_API02-COMP_QTY.

Data: lv_stpo_qty like STPO_MENGE.

I am getting dump when I am trying to pass 4,123 ( value of lv_comp_qty ) to lv_stpo_qty .

lv_stpo_qty = lv_comp_qty .

I've tried all the possibilities and also FM CHECK_AND_CONVERT_NUMERICS but no luck.

Please give ur input.

Thanks in Advance,

Vinay.

Edited by: Vinay parakala on Jun 8, 2011 6:29 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I used the same code.

Just changed declaration from like to type.

Data : lv_comp_qty like STPO_API02-COMP_QTY.

Data: lv_stpo_qty type kmpmg. " (STPO-MENGE)

"I am getting dump when I am trying to pass 4,123 ( value of lv_comp_qty ) to lv_stpo_qty .

lv_stpo_qty = lv_comp_qty .

Not getting any dump.

Please check teh dump description to confirm why you are getting it.

7 REPLIES 7

Former Member
0 Kudos

Hi,

I used the same code.

Just changed declaration from like to type.

Data : lv_comp_qty like STPO_API02-COMP_QTY.

Data: lv_stpo_qty type kmpmg. " (STPO-MENGE)

"I am getting dump when I am trying to pass 4,123 ( value of lv_comp_qty ) to lv_stpo_qty .

lv_stpo_qty = lv_comp_qty .

Not getting any dump.

Please check teh dump description to confirm why you are getting it.

0 Kudos

Hi,

below code is working at my end, please check

Data : lv_comp_qty like STPO_API02-COMP_QTY VALUE 4123.
Data: lv_stpo_qty like STPO-MENGE.


lv_stpo_qty = lv_comp_qty .
WRITE : / lv_stpo_qty.

while you are passing the characters there has to be only numbers and no special characters such as , in your case where I think you are passing 4,123 but you should pass 4123 only.

Regards,

Umang mehta

0 Kudos

Thanks all for your inputs .....

This is dump analysis ....

Error analysis

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_SY_CONVERSION_NO_NUMBER', was not

caught in

procedure "CHECK_AND_CONVERT_NUMERICS" "(FUNCTION)", nor was it propagated by a

RAISING clause.

Since the caller of the procedure could not have anticipated that the

exception would occur, the current program is terminated.

The reason for the exception is:

The program attempted to interpret the value " 4,123 " as a number, but

since the value contravenes the rules for correct number formats,

this was not possible.

0 Kudos

Hi Vinay,

When you are passing the value to the FM "CHECK_AND_CONVERT_NUMERICS" make sure you take out the ',' comma, from the character field.

I guess others weren't getting any errors as they were passing proper integer values into the char variable.

So,


Data : lv_comp_qty like STPO_API02-COMP_QTY VALUE 4123.
Data: lv_stpo_qty like STPO-MENGE.

lv_stpo_qty = lv_comp_qty .
WRITE : / lv_stpo_qty.

Will not throw an error, but if they tried the same with a small change like below, they too will get a short dump


Data : lv_comp_qty like STPO_API02-COMP_QTY VALUE '4,123'.
Data: lv_stpo_qty like STPO-MENGE.

lv_stpo_qty = lv_comp_qty .
WRITE : / lv_stpo_qty.

Umang has already mentioned this, My Bad didnt go through the complete thread.

Regards,

Chen

Edited by: Chen K V on Jun 8, 2011 4:00 PM

Edited by: Chen K V on Jun 8, 2011 4:02 PM

gaurav_sharan
Explorer
0 Kudos

Hi Vinay,

You can try WRITE statement also. Sometimes it works well. If still it dumps then please provide details of dump.

Thanks & Regards,

Gaurav.

Former Member
0 Kudos

hi,

You are passing the value as '4,123', that's why the dump. Please pass the value as 4123.

0 Kudos

Hello Mr. Chen and Mr Harikrishna,

Same analysis has already been given, why you guys are giving same analysis with adding somthing extra?

Regards,

Umang Mehta