Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

What is unpack command

Former Member
0 Likes
2,568

What is unpack command

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,482

Hi,

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.

Thanks,

Naren

4 REPLIES 4
Read only

Former Member
0 Likes
1,483

Hi,

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.

Thanks,

Naren

Read only

Former Member
0 Likes
1,482

Hi,

Unpacks the packed field field1 and places it in the field field2 with leading zeros. If field2 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'

Regards,

Ferry Lianto

Read only

anversha_s
Active Contributor
0 Likes
1,482

hi,

execute this code, u will get the exact idea

REPORT ZTEST_UNPACK.
 
DATA : VAR(5) VALUE '123'.
 
WRITE : / VAR.
 
UNPACK VAR TO VAR.
 
WRITE : / VAR.

Rgds

Anver

Read only

Former Member
0 Likes
1,482

Hi Harika ,

Unpack command is used to add leading zeros .

This is usefull because when using many functions / in select statements the value is required in its full length.

An example of this is the function module 'CO2H_PROD_ORDER_READ' in this if u give the value of a valid production order of length 10 , it will execute and give u the result , but when u do the same from a program it will not give u the result the reasonf being that the FM starts to search for a the PO whose lenght is 10.

Now if you use the unpack command the 2 spaces which are blank are added as zeros in the front.

You can also try the same with material number.

Regards

Arun