Application Development 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: 

How to interchange the dot to comma sap abap

Former Member
0 Kudos

Hi Experts,

I have simple doubt ... in database the value is showing as "1.667,000" so during debug mode i am getting "1667.000" so how to convert to this value as

1.667.

Thanks in advance

16 REPLIES 16

matt
Active Contributor
0 Kudos

What you mean is the tool you are using to see the value in the database is showing 1.666,000. Probably there is something that is converting the raw data (which is what you see in debug) into a nicely formatted display.

The question is: what is your program actually doing?

Former Member
0 Kudos

hi,

From menu bar follow following steps

System--->User Profile ----> Own Data

Then go to Defaults Tab. There u can change the format of currency

Former Member
0 Kudos

Hi Jatin,

As far as i understood your requirement is to change the format of the decimal value notations.

If this is what you require then go to System->user profile ->own data and then go to the defaults tab.

There you have the options to change the decimal notations.

Former Member
0 Kudos

Hi Jatin,

Please try below mentioned code.

Find out the variable value l_xdezp from USR01 table for corresponding user.

px_in is character variable

* If comma is used for decimal separator "e.g. 1.500.010,009

if l_xdezp eq space.

TRANSLATE px_in-value USING '. '.

TRANSLATE px_in-value USING ',.'.

* If dot is used for decimal separator "e.g. 1,500,010.009

elseif l_xdezp eq 'X'.

TRANSLATE px_in-value USING ', '.

endif.

regards

Tejas

former_member458055
Participant
0 Kudos

Hi,

Go to SU01. Enter the user id. Go to "Defaults" tab. Set the decimal notation. Log out of the system after saving the changes. And login again and check.

Thanks-

Makarand

p244500
Active Contributor
0 Kudos

hi

go to t-code OY01 and change the comma and dot separate under the country code

or

user wise

t-code SU01

Goto System->User Profile->Own data

Defaults tab..Maintain the desired one in field Decimal Notation

or

use bellow code

REPLACE ALL OCCURRENCES OF ',' IN: LV_NUM  WITH '.'.

Regard,

Nawa

0 Kudos

Hi Dear,

Sorry, but could you please tell me is it right to suggest to use OY01, since it will change the setting for entire country?

Thanks -

Makarand

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi Jatin,

1. You can use SAP standard option from System - > User Profile - > Own Data.

2. You can use Translate statement (Check F1 help) Tejas also suggested some methods using this.

3. You can also use, Search and Replace.

For Search and Replace Syntax is as the below mentioned

  Constants : C_DQUOTATION(2)  Value ''',

  Search L_PRESTRING For C_DQUOTATION.

  Replace All occurances of C_DOT with C_DQUOTATION.

F1 help will give you more information. hope this helps.

arindam_m
Active Contributor
0 Kudos

Hi,

Just curious why you want it as 1.667.That's a strange format to work with for any purpose DB or program. Any specific need?

Cheers,

Arindam

Former Member
0 Kudos

Hi Jatin,

As I understood, you want to convert 1667.000 number to 1.667....

Try assigning this value to an Integer variable. I think it will remove ending 000.....

Sample code -

DATA:

   val   TYPE  P DECIMALS 3   VALUE '1667000',

   val1  TYPE  I.

BREAK-POINT.

val1 = val.

WRITE: val1.

To replace dot with comma use following syntax

REPLACE '.' WITH ',' IN lv_string.

former_member767623
Participant
0 Kudos

Dear Jatin,

Solution  1 ) U may use standard procedure menu-->system-->user profile---->own data.

Solution 2 )  In programatically  write this logic and debug, easily understand this logic

parameters radha type matnr.

DATA: NEW(18) TYPE C,

       LENN TYPE I,

       NEWW(18) TYPE C,

       CH TYPE CHAR18,

        POS TYPE CHAR4,

       COUNT TYPE I,

       P TYPE I,

       KP(18) TYPE C,

       tp(18) type c,

       price(18) type C,

       l_prodh(5) type c.

*PRICE = WA_VBRP1-PRODH.

price =   RADHA.

SHIFT PRICE LEFT DELETING LEADING SPACE.

SPLIT PRICE AT '.' INTO NEW NEWW.

CLEAR : PRICE.

LENN = STRLEN( NEW ).

POS = LENN.

POS = POS - 1.

COUNT = 0.

DO LENN TIMES.

   P = SY-INDEX.

   COUNT = COUNT + 1.

IF P = 3 .

IF LENN = P.

   CH = NEW+POS(1).

   CONCATENATE  CH KP INTO KP.

ELSE.

   CH = NEW+POS(p).

concatenate '.' ch into kp.

   endif.

else.

  IF P = 1 OR P = 2 OR P = 3 OR P = 4 OR P = 5 OR P = 6 OR P = 8 OR P = 9 OR P = 11 OR P = 12.

*  if not p = 7.

     CH = NEW+POS(1).

     concatenate ch kp into kp.

    else.

       CH = NEW+POS(1).

       concatenate CH '.' INTO CH.

       CONCATENATE CH KP INTO KP.

   endif.

  endif.

  POS = POS - 1.

ENDDO.

IF KP <> ' ' AND NEWW <> ' '.

CONCATENATE kp neww into tp separated by ','.

CLEAR: L_PRODH.

L_PRODH = TP.

ENDIF.

CLEAR: TP,KP.

Regards,

Radhakrishna.Ette

Former Member
0 Kudos

Hi Jatin,

Use  REPLACE '.' WITH '--' IN Variable name.

        REPLACE ',' WITH '.' IN  Variable name ,

        REPLACE '--' WITH ',' IN Variable name.

Many thanks

venkat

mayur_priyan
Active Participant
0 Kudos

Hi,

You are seeing the format difference in the value due to the User profile settings maintained in your system.

Go to Menu System -- User Profile -- Own Data -- Default Tab.

Here You can see the Decimal notation maintained.

Former Member
0 Kudos

Hi,

use this code

*      Converting Amount field formats
     SELECT SINGLE dcpfm INTO l_dcpfm
                         FROM usr01
                        WHERE bname EQ sy-uname.

IF l_dcpfm IS INITIAL.                            "134,50
*
           CONDENSE : it_output-kbetr,
                      it_output-kpein.

*         Converting amounts as per User's decimal settings
           REPLACE ALL OCCURRENCES OF '.' IN it_output-kbetr
                                 WITH ' '.
           REPLACE ALL OCCURRENCES OF '.' IN it_output-kpein
                                 WITH ' '.

           REPLACE ALL OCCURRENCES OF ',' IN it_output-kbetr
                                 WITH '.'.
           REPLACE ALL OCCURRENCES OF ',' IN it_output-kpein
                                 WITH '.'.

           CONDENSE : it_output-kbetr,
                      it_output-kpein.


         ELSEIF l_dcpfm EQ c_x.                            "134.50


*         Converting amounts as per User's decimal settings
           REPLACE ALL OCCURRENCES OF ',' IN it_output-kbetr
                                 WITH ' '.
           REPLACE ALL OCCURRENCES OF ',' IN it_output-kpein
                                 WITH ' '.

           CONDENSE : it_output-kbetr,
                      it_output-kpein.

         ENDIF" IF gd_dcpfm IS INITIAL.

         CONDENSE : it_output-kbetr,
                    it_output-kpein.

Former Member
0 Kudos

As per my understanding the user settings maintained for your profile is dot(.) and comma(,) separator.So for this setting the database will always store the values as 1.667,000. But when you read it in your program from the database table you will always get in SAP internal format as with only dot separator,example 1667.000.

If you want to change the value then you need to use the currency key and change the format using the below syntax:

lv_data = '1667.000'.

WRITE lv_data to lv_final_data CURRENCY 'USD'.

WRITE: lv_final_data.

The currency key "USD" used above is just an example. You have to take the currency key based on your requirement.

Thanks

Akankshi

former_member198834
Participant
0 Kudos

Hi Kumar,

First check u r Own data settings. it's not working

then simply divide the value by 1000 and append to internal table

suresh.