2009 Aug 06 3:20 PM
Hi Everyone,
I am having a problem with a VBRK-NETWR field. There are some currencies that SAP divides them by 100 or 1000 because they are too big to store in DB. When I retrieve those amounts, I have to make some calculations, lets say amount = netwr / exchange rate.
The problem is that I am using the value from the DB (the one that is divided by 100) and I need to use the original one.
Is there a way to retrieve the number, convert it to the original number (not dividing it by 100 or 1000 hardcoding it on the code) and use it for calculations?
I can do so with the WRITE amount CURRENCY cur statement, but this is useless for calculations.
I hope my explanation is clear, if not, I will try to explain it in another way.
Many thanks,
Ernesto Caballero
Hi Everyone,
I am having a problem with a VBRK-NETWR field. There are some currencies that SAP divides them by 100 or 1000 because they are too big to store in DB. When I retrieve those amounts, I have to make some calculations, lets say amount = netwr / exchange rate.
The problem is that I am using the value from the DB (the one that is divided by 100) and I need to use the original one.
Is there a way to retrieve the number, convert it to the original number (not dividing it by 100 or 1000 hardcoding it on the code) and use it for calculations?
I can do so with the WRITE amount CURRENCY cur statement, but this is useless for calculations.
I hope my explanation is clear, if not, I will try to explain it in another way.
Many thanks,
Ernesto Caballero
2009 Aug 06 4:13 PM
hi,
The problem is that u must use write and the currency or if u use a ALV u must pass the currency in the amount value. u must not divide or multiply, that it not how it works. I'm working in Chile and the amounts value, such as netwr are stored in the table as divide by 100, but when i use those values in ALV or smartforms i must use the correct currency to show it.
so, dont worry about calculation, just at the moment to show the value, use the currency.
in alv use sth like this
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'AMOUNT_S'.
ls_fieldcat-just = 'R'.
ls_fieldcat-outputlen = '13'.
ls_fieldcat-emphasize = 'C900'.
ls_fieldcat-cfieldname = 'HWAER'. " this contains the value of CLP
ls_fieldcat-datatype = 'CURR'.
ls_fieldcat-seltext_l = 'Debe'.
ls_fieldcat-seltext_m = text-719.
ls_fieldcat-seltext_s = text-720.
* LS_FIELDCAT-REPTEXT_DDIC = TEXT-440.
ls_fieldcat-col_pos = '9'.
ls_fieldcat-row_pos = '1'.
APPEND ls_fieldcat TO lt_fieldcat.
in smartforms
write wa_tabla-saldo_end to lv_saldo_end currency 'CLP'.
Regards
2009 Aug 07 11:28 AM
Hell Miguel, thanks for your answer, however it is not working that way. Here is an example:
Amount Doc Curr. Exch. Rate Local Curr in Euros Valor that is in DB
100 EUR 1.0 100 100
200 EUR 1.0 200 200
62,745,470 HUF 279.1185 224,799 2247.99
1000 EUR 1.0 1000 1000
-
TOTAL = 226099 3547.99
With the WRITE statement the value 224799 with currency HUF is shown correctly but when I want to calculate the total in Euros, it is using the values of the last column. those values are the ones stored in DB.
I hope it is clear enough.
Thanks
Ernesto Caballero
2009 Aug 06 9:37 PM
Hi,
First let us knowIis SAP dividing the value by 100 or 1000 or any other value in your case?
Than we can put the logic to get the original value by simply multipying DB Value with that number.
Once you get the original value do any further calculation on it.
Regards,
Mayank
Edited by: mayank verdia on Aug 6, 2009 10:37 PM
2009 Aug 07 12:50 PM
Hi Ernesto,
U must be developing a smartform or a ALV report.
For smartform u have to declare the internal table field (NETWR) as a currency field under global definition-->Currency/Quant.Fields. with a refrence field which is a currency field (declared in global definition-->Global Data).
For ALV u have to declare the field as Currency in the field catalog i.e t_fieldcat-datatype = 'CURR'.
Regards,
Akash Rana.
2009 Aug 07 12:55 PM
Hi Akash,
It is not an ALV or Smartform, is a simple report with WRITE statemen which was not working and I received it. Because of what you say, I think the best option is do it again with ALV right? If doing so, you say this issue is going to be solved?
Regards
Ernesto
2009 Aug 07 1:43 PM
Hi Ernesto,
If u r using a classical report or a alv then the value of netwr field will be printed as in the database if u do not perform any calculation, but if u use any currency or quantity field in smartform u have to declare the same as QTY or Currency which ever it belongs or in the output, numberof decimal place shifts 1 or 2 points in right.
For Classical report or ALV the value of Netwr will be printed as it is in the database ( IF No calculation is done).
even in smartform if netwr field is declared as a currency field it will get printed same as in database in u will not declare the same decimal points will shift to right i.e if the value of netwr = 1233.14 it will show like 12331.40.
So finally i will advice you to do the same calculation which u were doing earlier because there is no such way to retrieve any data from database, because its already stored as a currency field in the database ( Refer to table VBRK, Data element NETWR Domain WERTV8 which shows that NETWR field is a currency field in database.
So if u have any kind of such requirement to do some calculations on the Netwr you have to do the same, there is no other way.
So Dont go for an ALV report because u will get the same output as in the classical.
Regards,
Akash Rana
2009 Aug 08 9:38 AM
2009 Aug 10 4:37 PM
Hi Everybody, thanks for all your approaches.
I've found the solution. I used BAPI_CURRENCY_CONV_TO_EXTERNAL and it returns the correct value I need to do the calculations. As I said, I solved the issue with the WRITE statement but I needed this to calculate the total.
Regards
Ernesto
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |