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

Type conversion problem

Former Member
0 Likes
1,784

I am doing a upload from excel file using FM 'ALSM_EXCEL_TO_INTERNAL_TABLE'. In this there are several currency fields. i am populating the values of excel into an itab of char type.

when i am trying to convert the char type to currency type it is going to dump.

i had declared my currency field of domain WERTV8.

while debugging i observed that amount '9,000.00' is not converted to amount type.

in dump i got a message saying: " unable to interpret '9,000.00' as number.

i had used 'move' stmt for conversion of c type to amount.

hope my problem is clear to you.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,166

Hi Ateeq,

You should use conversion exit insted of moving directly.

for converting use this FM HRCM_STRING_TO_AMOUNT_CONVERT

pass your currency, decimal separator asa '.' and thousand separator as ',' it will give you the correct(converted) value.

regards

vijay

Message was edited by: Vijay Babu Dudla

6 REPLIES 6
Read only

Former Member
0 Likes
1,166

Hi,

I suggest you to use FM 'GUI_UPLOAD' instead of 'ALSM_EXCEL_TO_INTERNAL_TABLE'.

Or use the following Bapi's for conversion

BAPI_CURRENCY_CONV_TO_EXTERNAL

BAPI_CURRENCY_CONV_TO_EXTERN_9

BAPI_CURRENCY_CONV_TO_INTERNAL

BAPI_CURRENCY_CONV_TO_INTERN_9

Hope it helps...

Lokesh.

Pls. reward appropriate points

Read only

Former Member
0 Likes
1,166

Hi

You have to delete the , from your char number, it has always this format: '9000.00'

So

CHAR_NUMBER = '9,000.00'.

REPLACE ',' WITH SAPCE INTO CHAR_NUMBER.

CONDENSE CHAR_NUMBER.

MOVE CHAR_NUMBER TO WERTV8.

Max

Read only

Former Member
0 Likes
1,167

Hi Ateeq,

You should use conversion exit insted of moving directly.

for converting use this FM HRCM_STRING_TO_AMOUNT_CONVERT

pass your currency, decimal separator asa '.' and thousand separator as ',' it will give you the correct(converted) value.

regards

vijay

Message was edited by: Vijay Babu Dudla

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,166

Hi,

Try using 'KCD_EXCEL_OLE_TO_INT_CONVERT'.Kindly reward points by clicking the star on the left of reply,if it helps.

DATA : lt_intern TYPE STANDARD TABLE OF kcde_cells WITH HEADER LINE.

CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

EXPORTING

filename = p_file

i_begin_col = p_scol

i_begin_row = p_srow

i_end_col = p_ecol

i_end_row = p_erow

TABLES

intern = lt_intern

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

FORMAT COLOR COL_BACKGROUND INTENSIFIED.

WRITE:/ text-004."Error Uploading file or Path Not Found.

EXIT.

ENDIF.

Read only

Former Member
0 Likes
1,166

Hi Ateeq,

1. As already suggested,

we can REPLACE comma with ''

(Because COMMA is creating the main problem,

the string having comma cannot be

converted to number )

2. try this code (just copy paste)

Try with/without commenting REPLACE statement.

REPORT abc.

DATA : cr TYPE wertv8.

DATA : s(20) TYPE c.

s = '9,000.00'.

*----


If we don't use replace, error

REPLACE ',' IN s WITH ''.

cr = s.

WRITE : s , cr.

Regards,

Amit M.

Read only

Former Member
0 Likes
1,166

Hi take one local vairable whose type is of any currency field.

then use the write to statement and

write value to local_variable.

then use this local_variable in ur program.

satish