‎2007 Apr 16 8:38 AM
Hi,
How do we convert a 18 byte char field(Which contains all numerics) in to a 8 byte field ?
Regards,
Hari
‎2007 Apr 16 10:34 AM
Hi..
you can not do it with 8 bytes...1 char is missing in conversion if we do so. So, take type P(10) which will solves ur problem..in efficient way..
data w_char(18) type c value '200710311140000001'.
data w_p(10) type p.
<b> PACK W_CHAR TO W_P.</b>
WRITE: W_P.
CLEAR W_CHAR.
<b> UNPACK W_P TO W_CHAR.</b> WRITE:/ W_CHAR.
‎2007 Apr 16 8:41 AM
Hi.,,
what is your actual requirement ??
if u want to move a character variable which contains all numerics into a P type field u can directly move it !!
<b>data w_char(18) type c value '1234567'.
data w_p type p decimals 2.
move w_char to w_p.
write w_p.</b>
<u>If you want to hold large numbers then increase the size of P type variable..</u>
<u>data w_p<b>(10)</b> type p decimals 2.</u>
reward if it helps u..
sai ramesh.
‎2007 Apr 16 10:20 AM
Hi Ramesh,
My requirement is: The Char field(18) contains a value like '200710311140000001'. We have to move this to a packed no which packs it to a 8 byte field. If we unpack this field, we should get again 18 byte fields.
Regards,
Hari
‎2007 Apr 16 10:26 AM
Hi,
Check the syntax of PACK :
PACK f TO g.
<b>The field f can contain up to 16 characters.</b>
Places the character field f in packed format in the field g
You can only store maximum 16 characters.
Regards
L Appana
‎2007 Apr 16 10:29 AM
Hari,
hi ,
chk this.
Converting type c to type n
DATA: SCN(4) VALUE '12x4',
T1CN(2) TYPE N,
T2CN(6) TYPE N.
MOVE: SCN TO T1CN,
SCN TO T2CN.
Converting type n to type p
DATA: SNP(6) TYPE N VALUE '012345',
T1NP(10) TYPE P,
T2NP(2) TYPE P.
MOVE SNP TO T1NP.
Don't forget to reward if useful....
‎2007 Apr 16 10:34 AM
Hi..
you can not do it with 8 bytes...1 char is missing in conversion if we do so. So, take type P(10) which will solves ur problem..in efficient way..
data w_char(18) type c value '200710311140000001'.
data w_p(10) type p.
<b> PACK W_CHAR TO W_P.</b>
WRITE: W_P.
CLEAR W_CHAR.
<b> UNPACK W_P TO W_CHAR.</b> WRITE:/ W_CHAR.
‎2007 Apr 16 11:21 AM
Hi Rammohan,
Thanks, But the output file format given by the client has space to store only 8 bytes. We have to convert 18 char into 8 bytes and output to the file.
Regards,
Hari