Tuesday, June 24, 2008

SAP Function Module String Numerical

SAP Function Module String Numerical

For converting a string to a numerical value the follwing Function Module can be used.

SAP ABAP function module to convert string to a numerical value.

IF_CA_MAKE_STRING_NUMERICAL

Find the code below.

REPORT ZEX_STRINGTONUMBER .

Parameter: p_string(20).


data: d_value like CAWAO_S_FIELDS-NUM_VAL.


CALL FUNCTION 'IF_CA_MAKE_STRING_NUMERICAL'
  EXPORTING
    INPUT_STRING        = p_string
 IMPORTING
   VALUE               = d_value
 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_value.


No comments:

Post a Comment