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

Data conversion

Former Member
0 Likes
1,590

Hi all,

I am using Spell_amount, in which i am getting the value as 356,586.00.

I need to convert it as 356586.00

Expecting ur reply.

ravi.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,547

Hello Ravi,

Consider this code. Just copy and execute it.


REPORT abc.

DATA : spell_amt(15).

spell_amt = '356,586.00'.


WRITE : 'Before Conversion :' ,spell_amt.


TRANSLATE spell_amt USING ', '.
CONDENSE spell_amt NO-GAPS.

WRITE : 'After Conversion :' ,spell_amt.

Regards,

Arun S.

15 REPLIES 15
Read only

Former Member
0 Likes
1,547

Hi Ravi,

Take a characrer variable and replace , with space.

Try as follows.

DATA V_AMOUNT(18).

V_AMOUNT = '356,586.00'.

REPLACE ',' WITH SPACE IN V_AMOUNT.

CONDENSE V_AMOUNT.

Thanks,

Vinay

Read only

0 Likes
1,547

if u want to display it in sap script (form)

than in from write this way..

<b>ex....

&EKPO-MENGE& -


>1,234.560

&EKPO-MENGE(T)& -


>1234.560</b>

andSPELL_AMOUNT is used to convert amounts in words

Read only

dani_mn
Active Contributor
0 Likes
1,547

Hi,

SPELL_AMOUNT is used to convert amounts in words, not for omiting commas.

Regards,

Wasim Ahmed

Read only

Former Member
0 Likes
1,547

Hi,

1. REPLACE ',' WITH SPACE IN <LV_AMT>

2. CONDENSE <LV_AMT>.

Regs,

Venkat Ramanan

Read only

0 Likes
1,547

My field is komk-fkwrt.

In which i need to send the value like 12323.56, without coma to spell_amount.

Read only

0 Likes
1,547

Hi Ravi,

First take a character field of length 18 and move komk-fkwrt value into character field and then replace comma with space and do condense and reassign

Try with this code.

DATA V_AMOUNT(18).

DATA V_FKWRT TYPE KOMK-FKWRT.

V_AMOUNT = KOMK-FKWRT.

REPLACE ',' WITH SPACE IN V_AMOUNT.

CONDENSE V_AMOUNT.

CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 4

OTHERS = 8.

V_FKWRT = V_AMOUNT.

ENDCATCH.

Thanks,

Vinay

Read only

0 Likes
1,547

Hi vinay

Thanks for ur response.

Bur WITH SPACE is showing syntax error.

Read only

0 Likes
1,547

Hi Ravi,

Then try as follows.

REPLACE ',' WITH <b>''</b> IN V_AMOUNT. -->Dont give any space between single quotes.

*CONDENSE V_AMOUNT. --> Comment this statement.

Note: Plz award points to all helpful answers and Close the thread if it is solved.

Thanks,

Vinay

Read only

0 Likes
1,547

REPLACE ',' with SPACE in V_AMOUNT.

Condense V_AMOUNT no-gaps.

Read only

0 Likes
1,547

Ex. Input is 123,232.56

if i convert into type N of 10 , it becoms 0012323256.

how to suppress leading zeros.

Read only

0 Likes
1,547

Hi ravi,

check it its working perfect.

REPORT ZTEST.

DATA: ALPHABET(15) VALUE '0000EFGHIJ'.

SHIFT ALPHABET LEFT DELETING LEADING '0'.

write : alphabet.

Read only

0 Likes
1,547

Hi,

Use FM CONVERSION_EXIT_ALPHA_OUTPUT to remove the leading zero

e.g.

CONVERSION_EXIT_ALPHA_OUTPUT

import

input = 00123

export

output = lv_without_zero.

result lv_without_zero = 123.

Regards,

Sameena

Read only

Former Member
0 Likes
1,547

Function module SPELL_AMOUNT converts an amount or number into words. It can be used as follows:

1. Convert a number into words

To do this, the transfer parameters LANGUAGE and AMOUNT have to be entered.

2. Convert an amount into words

To do this, the fields LANGUAGE, CURRENCY, and AMOUNT have to be entered.

3. Set the number of places before and after the decimal point for an amount

To do this, the parameters CURRENCY and AMOUNT have to be entered. The LANGUAGE field must be transferred with the value SPACE! This option optimizes the runtime of the function module.

The structure SPELL transfers the converted amounts. The FB enters the number of places before and after the decimal point in the NUMBER and DECIMAL fields, the amount in words in the WORD and DECWORD fields, and the figure in words in the DIGnn fields. The numbers converted into words can be protected by a star or some other FILLER.

Read only

Former Member
0 Likes
1,548

Hello Ravi,

Consider this code. Just copy and execute it.


REPORT abc.

DATA : spell_amt(15).

spell_amt = '356,586.00'.


WRITE : 'Before Conversion :' ,spell_amt.


TRANSLATE spell_amt USING ', '.
CONDENSE spell_amt NO-GAPS.

WRITE : 'After Conversion :' ,spell_amt.

Regards,

Arun S.

Read only

Former Member
0 Likes
1,547

Hi Ravi,

Consider this code.


REPORT abc.

DATA : spell_amt(10) TYPE  n.

spell_amt = '123,232.56'.


WRITE : 'Before Conversion :' ,spell_amt.


TRANSLATE spell_amt USING ', '.

WRITE spell_amt NO-ZERO NO-GAP TO spell_amt.


WRITE : 'After Conversion :' ,spell_amt.

Regards,

Arun S.