2010 Aug 26 6:36 AM
Now I want to get total weight of the material as weight * quantity. When I doing this process the program short dump.
If my user setting in su01 is 1,234,567.89 it will work normally, but if I changed my user setting to 1.234.567,89 it will get weight like 6,55 which cause short dump in total weight get. Please help me for solution that no mater user setting is dot or comma it will work successfully. thanks.
2010 Aug 26 6:56 AM
Hi ,
select single * from USR01 where uname eq sy-uname.
here there will be a field called DCPFM
Build a condition like
if DCPFM eq ' '
translate itab-field using ',.'
elseif DCPFM eq 'X' .
translate itab-field using '.,'
Endif.
So irrespecive of ur user settings the values are adjusted to the setting .
BR,
Vijay.
Now I want to get total weight of the material as weight * quantity. When I doing this process the program short dump.
If my user setting in su01 is 1,234,567.89 it will work normally, but if I changed my user setting to 1.234.567,89 it will get weight like 6,55 which cause short dump in total weight get. Please help me for solution that no mater user setting is dot or comma it will work successfully. thanks.
2010 Aug 26 6:56 AM
Hi ,
select single * from USR01 where uname eq sy-uname.
here there will be a field called DCPFM
Build a condition like
if DCPFM eq ' '
translate itab-field using ',.'
elseif DCPFM eq 'X' .
translate itab-field using '.,'
Endif.
So irrespecive of ur user settings the values are adjusted to the setting .
BR,
Vijay.
2010 Aug 26 7:16 AM
Sorry I am not quite understand.
My current condition is if my user setting is 1.234,56, I get the value from database will be 1.234,56, but when I use this value to get total weight, ex 1.234,56*3 program will short dump. if I replace comma to dot it wll like 1.234.56 this still not correct I think.
2010 Aug 26 7:18 AM
hi ,
//if I replace comma to dot it wll like 1.234.56 this still not correct I think
Dont think keep it in code ..;) just wrire a temp program and check ..
BR,
Vijay.
Edited by: sniper on Aug 26, 2010 11:48 AM
2010 Aug 26 7:30 AM
I think the problem lies in fact that you are treating this variable as character one (of type c or string ) . This is not correct. You should use only packed numbers (of type p ) for calculation.
The user settings has nothing to do with the calculation. These are purely for displaying data, not for calculating them. So what you need is something like
data: weight type p decimals 2 value '1234567.89',
quantity type i value 3,
result(10) type p decimals 2.
result = weight * quantity. "the value stored in variable has form 3703703.67
"only when you display your data it will receive the format of user settings
write: weight, "displayed as 1,234,567.89 or 1.234.567,89 -> depending on the settings
result. "displayed as 3,703,703.67 or 3.703.703,67 -> depending on the settings
Regards
Marcin
2010 Aug 26 7:40 AM
thank you for your detail answer.
In fact this value get from material classfication view and it should be something like 6,55 gms, in order to get the value first I need to use split to get value 6,55, but split can't split into variable type p. so that is why I face current issue.
SPLIT ls_clobjdat-ausp1 AT space INTO lw_qnt1 lw_text.
lw_qnt2 = lw_qnt1 * ls_it_gen-return_qty.
2010 Aug 26 9:01 AM
If its from the material classification, check the definition of the characteristic. It may be that the value is stored as a floating point in table AUSP. If thats the case, then you can use AUSP-ATFLV.
And to add: there are functions to transform the AUSP values to the external format, eg. 6.55 mm
Edited by: Maen Anachronos on Aug 26, 2010 10:02 AM