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.


SAP Function Module String Scramble

SAP Function Module String Scramble

In ABAP if you wish to scramble a STRING it can be easy done with the help of the following function module.

SAP FUNCTION MODULE TO SCRAMBLE STRING

DP_SCRAMBLE_STRING

The inputted string is scrambled with some numeric characters.

Note: The LOWER CASE option does not work in this Function Module and you may have to do a work around to make it work.

Find the code below.

REPORT ZEX_STRINGSCR.

Parameter: p_pass(100) LOWER CASE.

data: d_passowrd(100).

d_passowrd = p_pass.

CALL FUNCTION 'DP_SCRAMBLE_STRING'
  CHANGING
    PASSWORD       = d_passowrd
          .

 Write:/ d_passowrd.

Related Links:
Creating Valid Password in SAP
Function Module to Create Passwords in SAP