‎2021 Oct 30 9:46 AM
function module to check the string can be converted into numeric or not????? clearly explain please
‎2021 Oct 30 10:47 AM
DATA(char) = '123'.
DATA(num) = 0.
num = char.
ASSERT num = 123.
‎2021 Oct 30 12:56 PM
DATA number TYPE i.
DATA is_convertible TYPE abap_bool.
TRY.
number = tested_string.
is_convertible = abap_true.
CATCH cx_sy_conversion_no_number.
is_convertible = abap_false.
ENDTRY.
‎2021 Nov 02 9:05 AM
‎2021 Nov 02 9:16 AM
using Function module is not a best practice, FM is old school
use the the solution of gabmarian, this is how you should use ABAP today
‎2021 Nov 02 9:16 AM
‎2021 Oct 31 1:56 PM
Why a function module at all?
Read this
and this
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abaptry.htm
and combine.
‎2021 Oct 31 6:10 PM
Hi Haya,
you can check if the character variable contains only numeric characters values with CO
if l_char co '0123456789'.
....
endif.