06-22-2010 1:49 PM
Hello Experts,
I have a value of Type string. e.g. 2.3
I want to check if this value can be of type p in ABAP.
My idea is to move 2.3 to type p and catch an exception if 2.3 or any other value cannot be converted to p.
Can someone please give me an insight how to implement this?
Thanks,
Nitish.
06-22-2010 2:22 PM
Check this code snippet:
PARAMETERS: p_string TYPE string.
DATA: v_pack TYPE p DECIMALS 2.
DATA: error_ref TYPE REF TO cx_sy_conversion_no_number,
err_text TYPE string.
TRY .
MOVE p_string TO v_pack.
WRITE v_pack.
CATCH cx_sy_conversion_no_number INTO error_ref.
err_text = error_ref->get_text( ).
WRITE err_text.
ENDTRY.
BR,
Suhas
06-22-2010 2:22 PM
Check this code snippet:
PARAMETERS: p_string TYPE string.
DATA: v_pack TYPE p DECIMALS 2.
DATA: error_ref TYPE REF TO cx_sy_conversion_no_number,
err_text TYPE string.
TRY .
MOVE p_string TO v_pack.
WRITE v_pack.
CATCH cx_sy_conversion_no_number INTO error_ref.
err_text = error_ref->get_text( ).
WRITE err_text.
ENDTRY.
BR,
Suhas