‎2010 Dec 31 2:15 AM
HELLO,
In a SDN Blog I have seen the FM 'RS_CONV_EX_2_IN' can be used to convert formatted char value to float.
I am trying this FM to convert some data but the final data format does not belong to an existing structure.
I have tried to define within the code but I keep getting a 15 return code (invalid name)
What is wrong? Does this FM need a predefined structure to work?
Here is a code sample:
TYPES: BEGIN OF OUT_PUT_TYPE_STRUC,
value TYPE F,
END OF OUT_PUT_TYPE_STRUC.
lv_tabfield-tabname = 'OUT_PUT_TYPE_STRUC'.
lv_tabfield-fieldname = 'VALUE'.
PARAMETERS lv_value TYPE crm_imp_cell_value OBLIGATORY. u201CCHAR30
CALL FUNCTION 'RS_CONV_EX_2_IN'
EXPORTING
input_external = lv_value
table_field = lv_tabfield
IMPORTING
output_internal = lv_cell_value
EXCEPTIONS
input_not_numerical = 1
too_many_decimals = 2
more_than_one_sign = 3
ill_thousand_separator_dist = 4
too_many_digits = 5
sign_for_unsigned = 6
too_large = 7
too_small = 8
invalid_date_format = 9
invalid_date = 10
invalid_time_format = 11
invalid_time = 12
invalid_hex_digit = 13
unexpected_error = 14
invalid_fieldname = 15
field_and_descr_incompatible = 16
input_too_long = 17
no_decimals = 18
invalid_float = 19
conversion_exit_error = 20
OTHERS = 21.
Thanks
Paul
‎2010 Dec 31 3:00 AM
Hi Paul,
Please see the documentation.
The parameter OUTPUT_EXTERNAL must have the technical attributes of the ABAP Dictionary field specified in TABLE_FIELD
Functionality
Converts field contents from an external format (INPUT_EXTERNAL) into an internal format (OUTPUT_EXTERNAL). The parameter OUTPUT_EXTERNAL must have the technical attributes of the ABAP Dictionary field specified in TABLE_FIELD. The field INPUT_EXTERNAL must be a character field. It may have any length, but may not be filled to a greater length than that of OUTPUT_INTERNAL (this leads to the exception INPUT_TOO_LONG).If you use a structure, you will get an output but no values will be stored.
Regards,
Jovito.
‎2011 Jan 01 4:07 PM
HI Jovito,
Thanks for your help.
But the out-put variable has the right type.
Here is the complete code that you can try.
I have tried two way for the input param.
Regards,
Paul
DATA lv_cell_value TYPE f.
DATA lv_tabfield TYPE tabfield.
DATA lv_value TYPE char30 value '44,5'.
TYPES: BEGIN OF out_put_type_struc,
value TYPE f,
END OF out_put_type_struc.
lv_tabfield-tabname = 'OUT_PUT_TYPE_STRUC'.
lv_tabfield-fieldname = 'VALUE'.
*PARAMETERS lv_value TYPE Char40 OBLIGATORY.
CALL FUNCTION 'RS_CONV_EX_2_IN'
EXPORTING
input_external = lv_value
table_field = lv_tabfield
IMPORTING
output_internal = lv_cell_value
EXCEPTIONS
input_not_numerical = 1
too_many_decimals = 2
more_than_one_sign = 3
ill_thousand_separator_dist = 4
too_many_digits = 5
sign_for_unsigned = 6
too_large = 7
too_small = 8
invalid_date_format = 9
invalid_date = 10
invalid_time_format = 11
invalid_time = 12
invalid_hex_digit = 13
unexpected_error = 14
invalid_fieldname = 15
field_and_descr_incompatible = 16
input_too_long = 17
no_decimals = 18
invalid_float = 19
conversion_exit_error = 20
OTHERS = 21.
IF sy-subrc = 0 .
WRITE lv_cell_value.
ELSE.
WRITE: / 'error ' , sy-subrc.
ENDIF.
‎2011 Jan 03 2:17 AM
Hi Paul,
What I meant to say was that according to the definition of the FM, the Structure table_field has to have a table / field combination that exists in the ABAP dictionary i.e. SE16.
Since it does not exist, you are getting sy-subrc = 15.
Replace the below code.
lv_tabfield-tabname = 'OUT_PUT_TYPE_STRUC'.
lv_tabfield-fieldname = 'VALUE'.With new code.
lv_tabfield-tabname = 'PGPL'.
lv_tabfield-fieldname = 'ABSAT'.Also, change the value of lv_value from 44,5 to 44.5.
DATA lv_value TYPE char30 VALUE '44.5'.You will see the output.
4.4500000000000000E+01Regards,
Jovito.