Reputation: 162
I'm a little bit confused about getting converted data in ABAP because I'm still new to the ABAP world.
I have a table with data as shown here:
As you can see in the screenshot, there are two columns for Value Unconverted
and Value
(which is converted).
When I do a SELECT
query, I always get the unconverted value, and what I need is the converted value, because there's a big difference between (6.070) and (6,070).
I did some research but still nothing helps.
Here's is my code:
SELECT tknum
tplst
erdat
vsart
exti1
exti2
FROM vttk
INTO CORRESPONDING FIELDS OF TABLE gt_vttk
FOR ALL ENTRIES IN lt_vttp
WHERE tplst EQ p_tplst
AND tknum EQ lt_vttp-tknum
AND erdat IN s_erdat.
IF gt_vttk IS NOT INITIAL. // if return of above query is not empty
// below is the query for fetching value that I'm talking about
SELECT vsart
volum
FROM YMSNVT003
INTO CORRESPONDING FIELDS OF TABLE it_mtiga
FOR ALL ENTRIES IN gt_vttk
WHERE vsart EQ gt_vttk-vsart.
ENDIF.
and u can see the return of it in debug mode :
So what I'm confused about is:
Select
query in ABAP? If no, then how to deal with unconverted value to make it converted ? (from 6.070 to be 6,070)Please let me know if my question is not clear so I can edit it and make it clear for you so I can get helps from you guys :)
Upvotes: 0
Views: 1682
Reputation: 111
As @Kisbandi said, you see the unconverted value when you are in Debug mode.
The value format in the blue circle is displayed based on the user's settings. According to the image, this user's decimal places configuration is a comma separator. You can confirm this in transaction SU01 in the Defaults tab.
Values will be displayed based on this configuration, you can change this accordingly.
Upvotes: 2
Reputation: 69663
AFAIK you can't do the format conversion on the database layer. But you can use string templates in order to format a decimal number as a text string in the preferred number format of the user:
DATA(number_type_string_var) = |{ number_type_p_var NUMBER = USER }|.
The format option NUMBER = USER
will use the preferred number format in the settings of the current user. There is also NUMBER = ENVIRONMENT
in combination with SET COUNTRY
which can be used to force the number format of a specific locale independent from the user settings. This can be important if the resulting value needs to be formatted in a specific way for a technical purpose and not just for presentation to the end-user.
Upvotes: 1
Reputation: 313
Does the format that debug uses affect the logic? I think debug always displays the uncoverted value and then the converted value is displayed to the user.
I checked how to change the format for currency and found these function modules: BAPI_CURRENCY_CONV_TO_EXTERNAL
, BAPI_CURRENCY_CONV_TO_INTERNAL
. You can change the display format, but the debug shows dot for both. The conversion can be done for other units, but the problem will be the same.
CONVERSION_FACTOR_GET
. There are 2 parameters where you can set the unit of measurement. You can find all all unit of measurement in the table T006
.Upvotes: 1
Reputation: 21
For the first part with the converted value: I dont think you can select the converted value, but you can convert it manually by replacing , with . and . with , .
For unit conversion you can use Fuba UNIT_CONVERSION_SIMPLE
Upvotes: 1