Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Convert Character field to Packed field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
kalpana

New User


Joined: 19 Nov 2004
Posts: 24
Location: Banglore

PostPosted: Thu Jul 03, 2008 1:55 pm    Post subject: Convert Character field to Packed field
Reply with quote

COuld any please suggest me code for converting character field to packed field

can i use PACK command
Back to top
View user's profile Send private message

Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 991
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Jul 03, 2008 5:03 pm    Post subject:
Reply with quote

Depends on which language you're using.

For Assembler, use the PACK instruction. For PL/1 have a PIC declare of your CHAR field and assign the PIC to the DECIMAL FIXED field.

e.g.
Code:
 
 DCL        CHAR_FIELD           CHAR(5);
 DCL        PIC_FIELD            PIC'(5)9' BASED(ADDR(CHAR_FIELD));
 DCL        DEC_FIELD            DEC FIXED(5);

   CHAR_FIELD = '12345';
   DEC_FIELD   = PIC_FIELD;

Regards,
Garry
Back to top
View user's profile Send private message
kalpana

New User


Joined: 19 Nov 2004
Posts: 24
Location: Banglore

PostPosted: Thu Jul 03, 2008 5:56 pm    Post subject: Reply to: Convert Character field to Packed field
Reply with quote

Iam using Assembler..

I want code for the conversion
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 991
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Jul 03, 2008 6:02 pm    Post subject:
Reply with quote

Both operands have length fields
Code:


   PACK  DOUBLE,0(4,R8)
   .
   .
   .
   .
   .
DOUBLE   DS   D
will pack a 4-character field at R8 into the doubelword field named DOUBLE.

This could also be coded as
Code:

   PACK  0(8,DOUBLE),0(4,R8)


Regards,
Garry.
Back to top
View user's profile Send private message
kalpana

New User


Joined: 19 Nov 2004
Posts: 24
Location: Banglore

PostPosted: Fri Jul 04, 2008 12:14 pm    Post subject: Reply to: Convert Character field to Packed field
Reply with quote

Actually my requirement F_nomval is a character filed of 16 bytes

i have stored value 4.000000 thru screen

i declard F_nv_pack as double word

PACK F_nv_pack,f_nomval

i checked the value of f_nv_pack by putting delibrate dump

but iam getting value 0 in the F_nv_pack field


could any one help me with query???


Many thanks in advance

Kalpana
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Fri Jul 04, 2008 1:09 pm    Post subject: Reply to: Convert Character field to Packed field
Reply with quote

there is very little that we can do from here

PACK/unpack are two of the most simple and most dumb instructions ...
review its description in the manual

- they will take anything as input an build the output according to the specifications
- they will never program check for data exception
- they are GIGO ( garbage in garbage out ) instruction
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Thu Jul 10, 2008 4:59 pm    Post subject:
Reply with quote

Code:
DCL        CHAR_FIELD           CHAR(5);
 DCL        PIC_FIELD            PIC'(5)9' BASED(ADDR(CHAR_FIELD));
 DCL        DEC_FIELD            DEC FIXED(5);

   CHAR_FIELD = '12345';
   DEC_FIELD   = PIC_FIELD;


What is the need of using based?
can't we directly assign
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Jul 10, 2008 5:24 pm    Post subject: Re: Reply to: Convert Character field to Packed field
Reply with quote

kalpana wrote:
Actually my requirement F_nomval is a character filed of 16 bytes

i have stored value 4.000000 thru screen

i declard F_nv_pack as double word

PACK F_nv_pack,f_nomval

i checked the value of f_nv_pack by putting delibrate dump

but iam getting value 0 in the F_nv_pack field


could any one help me with query???


Many thanks in advance

Kalpana


4.000000 is not 16 bytes and it can not be packed since it is not numeric. In assembler the programmer has to keep track of where the decimal point is suppose to be.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 991
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Jul 10, 2008 5:31 pm    Post subject:
Reply with quote

Hi Murugan,
Quote:
What is the need of using based?

This is for PL/1 only. "BASED" is used to overlay the CHAR field with a PIC field. You could also use DEFINED to achieve the same result, but DEFINE is, IMHO, less flexible.

Quote:
can't we directly assign

No, You can't assign a CHAR field directly into a DECIMAL FIXED field.



Regards,
Garry.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us