07-10-2007 3:54 AM
hai guru's....
can u send me some material on unpack command ...and also can send me the definition and where we actulally use it...
Thnaks
PAvan
07-10-2007 3:58 AM
hi pavan,
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.
Exceptions
Catchable Exceptions
CX_SY_ASSIGN_OUT_OF_RANGE
Cause: Overflow during conversion (type P)
Runtime Error: BCD_FIELD_OVERFLOW (catchable)
CX_SY_CODEPAGE_CONVERTER_INIT
Cause: Source field cannot be interpreted as a number
Runtime Error: CONVT_NO_NUMBER (catchable)
CX_SY_CONVERSION_NO_NUMBER
Cause: Overflow during conversion (all types except type P)
Runtime Error: CONVT_OVERFLOW (catchable)
CX_SY_CONVERSION_OVERFLOW
Cause: Overflow during conversion (type P)
Runtime Error: BCD_OVERFLOW (catchable)
Non-Catchable Exceptions
Cause: Source field (type P) does not contain a valid BCD format
Runtime Error: BCD_BADDATA
07-10-2007 3:58 AM
hi pavan,
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.
Exceptions
Catchable Exceptions
CX_SY_ASSIGN_OUT_OF_RANGE
Cause: Overflow during conversion (type P)
Runtime Error: BCD_FIELD_OVERFLOW (catchable)
CX_SY_CODEPAGE_CONVERTER_INIT
Cause: Source field cannot be interpreted as a number
Runtime Error: CONVT_NO_NUMBER (catchable)
CX_SY_CONVERSION_NO_NUMBER
Cause: Overflow during conversion (all types except type P)
Runtime Error: CONVT_OVERFLOW (catchable)
CX_SY_CONVERSION_OVERFLOW
Cause: Overflow during conversion (type P)
Runtime Error: BCD_OVERFLOW (catchable)
Non-Catchable Exceptions
Cause: Source field (type P) does not contain a valid BCD format
Runtime Error: BCD_BADDATA
07-10-2007 4:05 AM
Pavan,
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.
WRITE: / C_FIELD.
Don't forget to reward if useful...
07-10-2007 4:06 AM
07-10-2007 4:14 AM
Syntax
<b>UNPACK source TO destination.</b>
<b>This statement converts the content of the data object source according to a specific rule and assigns the converted content to data object destination. For source, the data type p of length 16 without decimal places is expected. The data type of destination must be character-type and flat.</b>
<b>
The conversion is performed according to the following rules:</b>
If the data type of source is not of the type p with length 16 and without decimal places, then the content of source is converted to this data type. Contrary to the rules described in conversion rules for elementary data types, any decimal separator in source is completely ignored.
The digits of the interim result are assigned to data object destination right-aligned and without +/- sign. Any additional places in destination are filled with leading zeros. If the length of destination is not sufficient, the assigned variable is truncated from the left.
DATA: pack TYPE p LENGTH 8 DECIMALS 3 VALUE '123.456',
char1 TYPE c LENGTH 10,
char2 TYPE c LENGTH 10.
MOVE pack TO char1.
UNPACK pack TO char2.
<b>output will be :
char1 -> "123.456"
char2 -> "0000123456</b>
reward points if it is usefull ....
Girish