‎2007 Jun 14 10:29 AM
Hi,
I have a problem in rounding the value, it is something like this,
In my program i am passing the value 26.560 but when it stores in the sap database "KOMV-KBETR" it is storing as 265.60. So, I divided the value in my program by 10 and passed the value 2.656 but now it is storing the value as 26.6 instead of 26.56.
Hope I am clear with the issue and expecting the solution from your desk.
Regards,
Suman
‎2007 Jun 14 11:05 AM
Hi,
Please note SAP will always store the value as 10*actual value.Let that be as it is.In your pgm whenever you get kbetr divide it by 10 & use it.Do not do division by 10 in order to get the so called 'correct value' in database.Internally whenever SAP in using kbetr it will take care of it automatically i.e. it will divide it by 10 & use it as the actual kbetr.
I hope this helps,
Regards
Raju Chitale
‎2007 Jun 14 10:43 AM
hey suman,
KOMV-KBETR is a currency field.. so it has only 2 decimal place.
please provide the code if possible...
check the declaration of the variable .
may be it is one decimal.. round off usaully happens when u declare the destination variable different from source... plz check that...
why dont u pass the value as 2 decimal place...
i hope thgs are clear now...
reward points if helpful
thanks
‎2007 Jun 14 10:55 AM
HI,
do like this :
declare a temporary variable of type KBETR,
move value to temporary field as follows and then to table:
data: V_temp type KOMV-KBETR.
write <b>FIELD</b> to V_temp decimals 2.
move V_temp to table instead.
Regards,
Sooness
‎2007 Jun 14 11:05 AM
Hi,
Please note SAP will always store the value as 10*actual value.Let that be as it is.In your pgm whenever you get kbetr divide it by 10 & use it.Do not do division by 10 in order to get the so called 'correct value' in database.Internally whenever SAP in using kbetr it will take care of it automatically i.e. it will divide it by 10 & use it as the actual kbetr.
I hope this helps,
Regards
Raju Chitale
‎2007 Jun 14 11:56 AM
below is the code for you i did it ...
REPORT zround2.
PARAMETER: p_value type p decimals 3 default '26.560'.
DATA: d_value type p decimals 2,
d_int1 TYPE i,
d_int2 TYPE i,
d_number(20) TYPE c,
d_num_result(20) TYPE c,
d_decimal(2) TYPE c.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
d_number = p_value.
SHIFT d_number LEFT UP TO '.'.
SHIFT d_number LEFT.
d_decimal = d_number+0(2).
d_decimal = d_decimal + 1.
Clear: d_number.
d_number = p_value.
SHIFT d_number RIGHT DELETING TRAILING '123456789 '.
SHIFT d_number LEFT DELETING LEADING ' '.
CONCATENATE d_number d_decimal INTO d_num_result.
d_value = d_num_result.
write:/ 'Value rounded up to 2 decimal places is ', d_value.reward points if it is usefull ....
Girish
‎2007 Jun 14 12:34 PM
Hi,
My problem is exactly like this,
MOVE gs_so_item_raw-kwmeng TO gs_so_item_conv-kwmeng.
REPLACE ALL OCCURRENCES OF ',' IN gs_so_item_raw-netpr WITH '.' .
MOVE gs_so_item_raw-netpr TO gs_so_item_conv-netpr.
For ex, we have value '2.65' in gs_so_item_conv-netpr and the same value is passed to the internal table and used in the Bapi "BAPI_SALESDOCU_CREATEFROMDATA". But the problem when the sales order is created the price is stored as '26.5" when i check the conditions tab.
So, somewhere the value is multiplyed by 10 and storing in the database. Could you please let me know how to avoid this and store the exact passing value in the sales order creation.
Urgent !!!
Thanks in advance...
Regards,
Suman
‎2007 Jun 14 12:39 PM