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

Converting charecter to quantity.

Former Member
0 Likes
1,091

Following is the issue, I want to write l_char to l_quan, The following code is throwing a dump error.

Write and Move are not working.

Please solve this for me.

data : l_char(18),l_quan type kwmeng.

l_char = '123,456.000'.

l_quan = l_char.

write : l_quan.

<REMOVED BY MODERATOR>

-Veeru.

Edited by: Alvaro Tejada Galindo on Feb 21, 2008 3:28 PM

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
698

Try this -

in this case, WRITE TO will not work, as you are sending CHAR value to a numeric field.

here is the logic i followed to overcome the (user settings of comma(,) and DOT(.))

DATA : V_WEIGHT TYPE LTAP-BRGEW,

V_WT_CHAR(21) TYPE C.

assume you have weight value in a CHAR field.

v_WT_CHAR = '21,987.258'.

here your requirement is to push this value to a weight field.for that follow this,

REPLACE ALL OCCURRENCES OF ',' IN V_WT_CHAR WITH ''.

REPLACE ALL OCCURRENCES OF '.' IN V_WT_CHAR WITH ''.

CONDENSE V_WT_CHAR.

MOVE V_WT_CHAR TO V_WEIGHT.

V_WEIGHT = V_WEIGHT / 1000.

now your V_WEIGHT will have value '21987.258' (as it stores in INTERNAL format)

~ As found in forum.

Regards,

Amit

Try this -

in this case, WRITE TO will not work, as you are sending CHAR value to a numeric field.

here is the logic i followed to overcome the (user settings of comma(,) and DOT(.))

DATA : V_WEIGHT TYPE LTAP-BRGEW,

V_WT_CHAR(21) TYPE C.

assume you have weight value in a CHAR field.

v_WT_CHAR = '21,987.258'.

here your requirement is to push this value to a weight field.for that follow this,

REPLACE ALL OCCURRENCES OF ',' IN V_WT_CHAR WITH ''.

REPLACE ALL OCCURRENCES OF '.' IN V_WT_CHAR WITH ''.

CONDENSE V_WT_CHAR.

MOVE V_WT_CHAR TO V_WEIGHT.

V_WEIGHT = V_WEIGHT / 1000.

now your V_WEIGHT will have value '21987.258' (as it stores in INTERNAL format)

~ As found in forum.

Regards,

Amit

4 REPLIES 4
Read only

0 Likes
698

Hello Veerendranath,

SAP is throwing dump because you are tring to assign a value containing ',' and '.' to a quantitiy field. Please remove the ',' and '.' and try it should work.

Regards

Farzan

Read only

amit_khare
Active Contributor
0 Likes
699

Try this -

in this case, WRITE TO will not work, as you are sending CHAR value to a numeric field.

here is the logic i followed to overcome the (user settings of comma(,) and DOT(.))

DATA : V_WEIGHT TYPE LTAP-BRGEW,

V_WT_CHAR(21) TYPE C.

assume you have weight value in a CHAR field.

v_WT_CHAR = '21,987.258'.

here your requirement is to push this value to a weight field.for that follow this,

REPLACE ALL OCCURRENCES OF ',' IN V_WT_CHAR WITH ''.

REPLACE ALL OCCURRENCES OF '.' IN V_WT_CHAR WITH ''.

CONDENSE V_WT_CHAR.

MOVE V_WT_CHAR TO V_WEIGHT.

V_WEIGHT = V_WEIGHT / 1000.

now your V_WEIGHT will have value '21987.258' (as it stores in INTERNAL format)

~ As found in forum.

Regards,

Amit

Read only

Former Member
0 Likes
698

Don't pass ',' or '.' into the quan field ..

Pass like this ...

l_char = '123456000'.

l_quan = l_char.

l_quan = l_quan / 1000.

Read only

Former Member
0 Likes
698

hi

good

data : qty type p decimals 2,

ch(10) type c value '10'.

move ch to qty.

may be this will be helpful to u.

or try the FM

CALL FUNCTION 'CHECK_AND_CONVERT_NUMERICS'

EXPORTING

dmzei = ','

dtype = 'CURR'

efeld = input

IMPORTING

error = error

ifeld = output

messg = messg

msgln = msgln.

<REMOVED BY MODERATOR>

thanks

mrutyun^

Edited by: Alvaro Tejada Galindo on Feb 21, 2008 3:28 PM