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 convert a string ( p.e.: 25,56) into a quan (13,3) field?

Former Member
0 Kudos

I read data from an excel using function ALSM_EXCEL_TO_INTERNAL_TABLE. This data contains decimal numbers, for example 25,56.

DATA:li_intern TYPE TABLE OF alsmex_tabline WITH HEADER LINE.

lv_filename = pi_fich.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = lv_filename

i_begin_col = lv_start_col

i_begin_row = lv_start_row

i_end_col = lv_end_col

i_end_row = lv_end_row

TABLES

intern = li_intern

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

li_intern-value field is a char50 field. I would like to convert this value in a field which type is quan 13 3.

Which function should I use?

Thanks in advance.

1 ACCEPTED SOLUTION

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

or you can directly move the data to one variable to other

data :p1 type string,

p2 type p decimals 3.

p1 = '10.11'.

*p2 = '22.

p2 = p1.

write: p2.

move p1 to p2.

write: / p2.

4 REPLIES 4

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

you can do it by creating a dynamic table.

use Fm CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' to get the fieldcat.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lt_fcat

IMPORTING

ep_table = lt_dy_table.

lt_fcat can be filled like this...

LOOP AT lt_struc_fld INTO ls_struc_fld.

ls_fcat-dd_outlen = ls_struc_fld-intlen.

ls_fcat-decimals = ls_struc_fld-decimals.

ls_fcat-datatype = ls_struc_fld-datatype.

ls_fcat-fieldname = ls_struc_fld-fieldname.

APPEND ls_fcat TO lt_fcat.

ENDLOOP.

and then you can move lt_excel_tab to your dyn_tab

Edited by: ssm on Jul 27, 2011 5:03 PM

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

or you can directly move the data to one variable to other

data :p1 type string,

p2 type p decimals 3.

p1 = '10.11'.

*p2 = '22.

p2 = p1.

write: p2.

move p1 to p2.

write: / p2.

Former Member
0 Kudos

Thanks for your help. Instead of 25,56 I have written 25.56 and now it´s enough asigninf the value read to the numeric variable.

Clemenss
Active Contributor
0 Kudos

Hi,

just an addition. For this and similar purposes the task is to convert the external representation to internal storage type. Sometimes you even have 1000 separator as in 123.456,78. Then you can always us FUNCTION 'RS_CONV_EX_2_IN', see the sample mentioned in this thread [About Date validation|;.

Regards

Clemens