UNPACK ( SAP ABAP Keyword)

UNPACK is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details.

 UNPACK

Basic form
UNPACK f TO g.

Effect
Unpacks the packed field f and places it in the field g with leading zeros. If g is too short, it is truncated on the left.

Example

DATA: P_FIELD(2) TYPE P VALUE 103,
C_FIELD(4) TYPE C.
UNPACK P_FIELD TO C_FIELD.

P_FIELD: P’103C’ –> C_FIELD: C’0103′

Notes
If f is not type P , it is converted to type P (see MOVE ).
g should always be type C . Otherwise, unwanted side effects may occur.
The sign in the packed number is ignored.