Converting String To Numeric Function Module SAP

Today I want to show you how to convert a string value into a numerical value using ‘IF_CA_MAKE_STRING_NUMERICAL’ function module. The result of this function will be a numeric value with the thousands and hundreds separators.
Here’s the Abap sample code.
REPORT Z_STRING_NUMERIC.
Parameter: p_string(100).
data: d_numeric like CAWAO_S_FIELDS-NUM_VAL.
CALL FUNCTION ‘IF_CA_MAKE_STRING_NUMERICAL’
EXPORTING
INPUT_STRING = p_string
IMPORTING
VALUE = d_numeric
EXCEPTIONS
NOT_NUMERICAL = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write:/ d_numeric.
When you execute the program, you will see the numeric display like below.
30082010-ston

Subscribe in a reader

Comments

0 Responses to "Converting String To Numeric Function Module SAP"

Post a Comment

Stay Updated