Application Development and Automation 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: 
Read only

Number format in script

Former Member
0 Likes
1,977

Hello,

May be this is a common question on number format.

I have researched for suitable answer thoroughly before posting here.

Here is my requirement.

I have a script, in which the total invoice amount is displaying like this, 11.593.296.372

But the requirement is to print "11.593.296,372"

I have checked SU3, OY01....all set to "1.234.567,89", but still getting the same output with "." separator.

Please help to find the correct solution, for the above problem.

Thanks in advance,

Rgs,

Priya

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,834

Hi Priya Sha,

  ***Please refer attachment there you can see the screenshots

**** Change XX.txt has XX.doc to read it in word document.

  Go to SU01 transaction -> in defaults tab

First I set Decimal Notation are as follows,

The result of my code is,

Second I have changed my user profile decimal notation are as follows,

Now the result I got is,

My Coding are as below,

DATA : v_rate(10) TYPE p DECIMALS 5,
g_curr_amt22
(25) type c,
g_curr_jpy
(25) type c.

v_rate
= '115104028.76'.
g_curr_amt22
= v_rate.
WRITE g_curr_amt22 TO g_curr_jpy.

WRITE : 'String',g_curr_jpy.
WRITE : 'Actual',v_rate.

Now the problem is many users can use this script we can not ask users to change the profile data instead we need to use set country command please press F1 in that keyword you can get the full details.

Code Using SET COUNTRY command,

DATA : v_rate(10) TYPE p DECIMALS 5,
g_curr_amt22
(25) type c,
g_curr_jpy
(25) type c.

v_rate
= '115104028.76'.
g_curr_amt22
= v_rate.
WRITE g_curr_amt22 TO g_curr_jpy.

WRITE : 'String',g_curr_jpy.
WRITE : 'Actual',v_rate.
SET COUNTRY 'IN'.
WRITE : 'String',g_curr_jpy.
WRITE : 'Actual',v_rate.

IN T005X table for Country India it is maintained has X please press F4 there you can see the possibilities of usage in decimal notations.

Now my user profile setting is

But see my output of actual,

Use g_curr_jpy(C) in script to condense the values.

*Note: If you are not having access to user profile transaction go to se37, uses this function module ALINK_CALL_TRANSACTION execute it and type transaction SU01 execute it.

Hope it is useful.

Regards,

Ravi Shankar L

14 REPLIES 14
Read only

eduardo_hinojosa
Active Contributor
0 Likes
1,834

Hi

I don't know what is the report calling this list or form, but look for a sentence in ABAP as this link explains: http://help.sap.com/abapdocu_70/en/ABAPSET_COUNTRY.htm

Regards

Eduardo

Read only

Former Member
0 Likes
1,834

Have you looked at the data in debug to verify that there is actually a decimal portion to the number?  Could you show us a code snippet where the variable is defined, Where it is filled, where it is output?

Neal

Read only

venkateswaran_k
Active Contributor
0 Likes
1,834

Hi Priya,

Before printing the Amount,

Use the SET COUNTRY statement  .. 

Regards,

Venkat

Read only

Former Member
0 Likes
1,834

Hi,

Check in T005X table what all are the types and possibilities that user maintaining handle all the types

has venkateswaran said please use SET COUNTRY statement.Hope it is useful for you.

*Sometime individual country uses three types of notations you need to handle it in program.

Regards,

Ravi Shankar L

Read only

0 Likes
1,834

Hello All,

I tried all the options, none of them working.( T005x table is having space, which means N.NNN,NN format, the same which I want to display)

Find the code below:

Data:

v_rate(10) TYPE p DECIMALS 5,

g_curr_amt22(25) type c,

g_curr_jpy(25) type c.

g_curr_amt22 =  v_rate * zsapscript-zkwert22  .

write g_curr_amt22 to g_curr_jpy.

g_curr_jpy is the variable which is printing the value.

Code in script:

/:   IF &VBDKR-WAERK& = 'JPY'

/:   SET COUNTRY 'JP'

VA   ,,,,,,&ZSAPSCRIPT-ZKWERT3(C)&

VA   ,,,,,,&ZSAPSCRIPT-ZDISCOUNT(C)&

VA   ,,,,,,&zsapscript-zkwert34(C)&

VA   ,,,,,,&ZSAPSCRIPT-ZKWERT22(C)&,,&g_curr_jpy&

VA   ,,,,,,&vbdkr-mwsbk(C)&,,&g_curr_amtbkn(C)&

/*   ,,,,,,&vbdkr-mwsbk(C)&,,&g_curr_amtbk(C)&

/:   ENDIF

Currently It is printing the value as 115104028.76,,,, I want it in 115.104.028,76 format.

Anyhelp would be highly appreciated.

Rgs,

Priya

Read only

0 Likes
1,834

Hi,

Please check the decimal precision of the currency JPY in T-Code OY04. Usually here is no decimals in JPY currency hence you do not get the comma and the decimal part.

Cheers,

Arindam

Read only

0 Likes
1,834

Priya,

Did Arindam suggestion change your understanding of the problem?

Neal

Read only

0 Likes
1,834

Hi,

Option 1:

Use write g_curr_amt22 to g_curr_jpy currency 'JPY'.

If the above doesn't work.

Option 2:

Just copy the value into a char type variable and format.

Call FM CLSE_SELECT_USER01.

This shall return the DECIMAL_SIGN and SEPARATOR.

If both are as expected

NO ACTION.

else.

Replace All occurances of '.' with ','.

Replace all occurances of ',' with '.'.

endif.

Read only

0 Likes
1,834

Hi Priya

In your code  -- 

      g_curr_amt22 =  v_rate * zsapscript-zkwert22  .

      write g_curr_amt22 to g_curr_jpy.

Before the Write statement,  write the SET COUNTRY 'JP'.

that is,

      g_curr_amt22 =  v_rate * zsapscript-zkwert22  .

      SET COUNTRY 'JP'.

      write g_curr_amt22 to g_curr_jpy.

Regards,

Venkat

Read only

Former Member
0 Likes
1,834

Are you using a CURR type or another?

Read only

Former Member
0 Likes
1,835

Hi Priya Sha,

  ***Please refer attachment there you can see the screenshots

**** Change XX.txt has XX.doc to read it in word document.

  Go to SU01 transaction -> in defaults tab

First I set Decimal Notation are as follows,

The result of my code is,

Second I have changed my user profile decimal notation are as follows,

Now the result I got is,

My Coding are as below,

DATA : v_rate(10) TYPE p DECIMALS 5,
g_curr_amt22
(25) type c,
g_curr_jpy
(25) type c.

v_rate
= '115104028.76'.
g_curr_amt22
= v_rate.
WRITE g_curr_amt22 TO g_curr_jpy.

WRITE : 'String',g_curr_jpy.
WRITE : 'Actual',v_rate.

Now the problem is many users can use this script we can not ask users to change the profile data instead we need to use set country command please press F1 in that keyword you can get the full details.

Code Using SET COUNTRY command,

DATA : v_rate(10) TYPE p DECIMALS 5,
g_curr_amt22
(25) type c,
g_curr_jpy
(25) type c.

v_rate
= '115104028.76'.
g_curr_amt22
= v_rate.
WRITE g_curr_amt22 TO g_curr_jpy.

WRITE : 'String',g_curr_jpy.
WRITE : 'Actual',v_rate.
SET COUNTRY 'IN'.
WRITE : 'String',g_curr_jpy.
WRITE : 'Actual',v_rate.

IN T005X table for Country India it is maintained has X please press F4 there you can see the possibilities of usage in decimal notations.

Now my user profile setting is

But see my output of actual,

Use g_curr_jpy(C) in script to condense the values.

*Note: If you are not having access to user profile transaction go to se37, uses this function module ALINK_CALL_TRANSACTION execute it and type transaction SU01 execute it.

Hope it is useful.

Regards,

Ravi Shankar L

Read only

0 Likes
1,834

Hi Priya,

Have you tried this solution?

Regards,

Ravi Shankar L

Read only

Former Member
0 Likes
1,834

Hi,

Thanks all for inputs.

It worked out. I have changed the data type of output variable, from CHAR to type P decimal 2.

The output is displaying as desired.

Rgs,

Priya

Read only

Former Member
0 Likes
1,834

Hi Priya,

in SAP script.

Just add the following before you are adding currency or Qty fields.

/: Set Country 'US'.  or /:set Country <LAND1 field>.

Hope this will solve your problem.

If not you can achieve this using perform and form statement in Script.

Warm Regards,

John.