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

currency decimal fix issue

Former Member
0 Likes
1,756

Hi,

I am working on a currency decimal fix issue.Here for the currency HUF,currency has no decimals.The fact that HUF does not have decimals is not considered by the program and is giving error message as 'decimal places not permitted'.So i have made some changes in the code.

DATA: c_HUF(5) TYPE c VALUE 'HUF'.

WRITE v_temp to v_amount CURRENCY c_HUF.

PERFORM FORMAT_DECIMAL using v_amount.

form FORMAT_DECIMAL using p_v_amount.

STATICS : XUSDEF like USDEF OCCURS 0 WITH HEADER LINE.

DATA: v_data TYPE C,

v_data1 TYPE C.

if xUSDEF is initial.

xUSDEF-bname = sy-uname.

append xUSDEF.

CALL FUNCTION 'SUSR_GET_USER_DEFAULTS'

EXPORTING

LANGU = SY-LANGU

TABLES

users = xUSDEF.

endif.

READ TABLE xUSDEF INDEX 1 TRANSPORTING dcpfm.

v_data = ','.

v_data1 = '.'.

case xusdef-DCPFM.

when '.'.

IF p_v_amount NA v_data1.

replace ALL OCCURRENCES OF ',' IN p_v_amount with '.'.

ELSEIF p_v_amount CA v_data1 AND p_v_amount CA v_data.

replace ALL OCCURRENCES OF '.' IN p_v_amount with ' '.

CONDENSE p_v_amount NO-GAPS.

replace ALL OCCURRENCES OF ',' IN p_v_amount with '.'.

ELSE.

replace ALL OCCURRENCES OF ',' IN p_v_amount with '.'.

ENDIF.

when ','.

IF p_v_amount NA v_data.

replace ALL OCCURRENCES OF '.' IN p_v_amount with ','.

ENDIF.

replace ALL OCCURRENCES OF '.' IN p_v_amount with ' '.

endcase.

CONDENSE p_v_amount NO-GAPS.

ENDFORM.

After the write statement the value is getting converted to 2,000,000.

After the perform statement it is getting converted to 2.000.000.

Here the program is giving dump error as '2.000.000 is not expected as a numerical value'.

Can anyone help me solvthis issue?

Hi,

I am working on a currency decimal fix issue.Here for the currency HUF,currency has no decimals.The fact that HUF does not have decimals is not considered by the program and is giving error message as 'decimal places not permitted'.So i have made some changes in the code.

DATA: c_HUF(5) TYPE c VALUE 'HUF'.

WRITE v_temp to v_amount CURRENCY c_HUF.

PERFORM FORMAT_DECIMAL using v_amount.

form FORMAT_DECIMAL using p_v_amount.

STATICS : XUSDEF like USDEF OCCURS 0 WITH HEADER LINE.

DATA: v_data TYPE C,

v_data1 TYPE C.

if xUSDEF is initial.

xUSDEF-bname = sy-uname.

append xUSDEF.

CALL FUNCTION 'SUSR_GET_USER_DEFAULTS'

EXPORTING

LANGU = SY-LANGU

TABLES

users = xUSDEF.

endif.

READ TABLE xUSDEF INDEX 1 TRANSPORTING dcpfm.

v_data = ','.

v_data1 = '.'.

case xusdef-DCPFM.

when '.'.

IF p_v_amount NA v_data1.

replace ALL OCCURRENCES OF ',' IN p_v_amount with '.'.

ELSEIF p_v_amount CA v_data1 AND p_v_amount CA v_data.

replace ALL OCCURRENCES OF '.' IN p_v_amount with ' '.

CONDENSE p_v_amount NO-GAPS.

replace ALL OCCURRENCES OF ',' IN p_v_amount with '.'.

ELSE.

replace ALL OCCURRENCES OF ',' IN p_v_amount with '.'.

ENDIF.

when ','.

IF p_v_amount NA v_data.

replace ALL OCCURRENCES OF '.' IN p_v_amount with ','.

ENDIF.

replace ALL OCCURRENCES OF '.' IN p_v_amount with ' '.

endcase.

CONDENSE p_v_amount NO-GAPS.

ENDFORM.

After the write statement the value is getting converted to 2,000,000.

After the perform statement it is getting converted to 2.000.000.

Here the program is giving dump error as '2.000.000 is not expected as a numerical value'.

Can anyone help me solvthis issue?

4 REPLIES 4
Read only

Former Member
0 Likes
1,253

Hi

Try with the command

SET COUNTRY <country name> .

and see

Before that ensure that the country settings/currency setting in SPRO and the User settings are fine.

Regards

Anji

Read only

0 Likes
1,253

Hi,

Could you please give an example how to use this SET COUNTRY?

Read only

Former Member
0 Likes
1,253

Hi ,

I am not able to properly get your requirement .

However, if you want to convert the amount according to the currency ,

you can use the command, WRITE field TO var CURRENCY c.

Here , make sure that the target variable is char type.

In the program also , i think the dump is coming because the target is not character type. Please use a character type field.

Correct me if I understood your requirement wrongly..

Pls reward if you find it useful..

Regards,

Ratheesh .V

Read only

0 Likes
1,253

Hi,

I have used the target variable(v_amount) as char type only.Here after the write statement the value of v_amount is getting changed to 2,000,000.But hungarian currency HUF doesnot have decimals.So I have used the perform format_decimal to correct it.After the perform statement the v_amount value is getting changed to 2.000.000.Here it is giving a dump error.How can I solve this?