cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a character to number

Former Member
0 Kudos
78,425

hi,

i want to convert a character to number in abap which function can i use? and how to use this function?

View Entire Topic
Former Member

Sample code below:

DATA: lv_chr(4) type c,
      lv_num    type p.

CALL FUNCTION 'MOVE_CHAR_TO_NUM'
  EXPORTING
    CHR             = lv_chr
  IMPORTING
    NUM             = lv_num
  EXCEPTIONS
    CONVT_NO_NUMBER = 1
    CONVT_OVERFLOW  = 2
    OTHERS          = 3.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

former_member624107
Contributor
0 Kudos

PACK f TO g.

Places the character field f in packed format in the field g. Reverse of the UNPACK statement.

Example

DATA C_FIELD(4) TYPE C VALUE '0103',

P_FIELD(2) TYPE P.

PACK C_FIELD TO P_FIELD.

C_FIELD: C'0103' --> P_FIELD: P'103C'

Note

The field f can contain up to 16 characters.

a142367
Explorer
0 Kudos
Function module MOVE_CHAR_TO_NUM does not exist Message no. FL110 Diagnosis You attempted to display, change, rename or delete a function module that does not exist. Procedure Check your input. If you do not know the exact name, choose Utilities -> Find to search for the function module in the Function Builder.