IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How we write pic class for 7890 in comp 3 & COMP Var


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
reena_preethi

New User


Joined: 14 Jun 2006
Posts: 14

PostPosted: Sun Jul 09, 2006 12:11 pm
Reply with quote

hello friends
i having i doubt regarding comp variables.
suppose if i store 7890 in comp3 var how it stores?
how it stores in comp var?
how we write pic class for 7890 in comp 3 & COMP var?

thanks in advance
preethi
Back to top
View user's profile Send private message
janamott

New User


Joined: 22 Dec 2005
Posts: 4
Location: Edison, NJ

PostPosted: Wed Jul 12, 2006 1:09 am
Reply with quote

A packed or comp-3 field occupies a number of spaces equal to (pic-clause-length / 2) + 1.

Drop any remainder when you divide the pic clause length by 2.

A field defined as PIC 9(4) COMP-3 will occupy only 3 bytes in storage ((4 / 2) + 1 ) = 3.

However, don't define your pic clause as only 3 bytes. It should be long enough for all your unpacked data.

In your example, your pic clause will be

01 WS-FIELDS.
05 TEST-COMP3-SIGNED PIC S9(4) COMP-3.

And your packed data will appear this way

080
79C

If you don't want a sign (c=positive, d=negative), your pic clause will be

05 TEST-COMP3-UNSIGNED PIC 9(4) COMP-3.

And your data will look like this

080
79F


A comp field also needs to have a pic clause long enough for all the field's unpacked data.

In your example, your pic clause can be either of the following

05 TEST-COMP-SIGNED PIC S9(4) COMP.
05 TEST-COMP PIC 9(4) COMP.

And your data will be stored like this

1D
E2
Back to top
View user's profile Send private message
reena_preethi

New User


Joined: 14 Jun 2006
Posts: 14

PostPosted: Thu Jul 13, 2006 11:47 am
Reply with quote

thanks a lot janamott

regards
preethi
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts building java class with zip4j.jar on... Java & MQSeries 0
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
No new posts Compare two files with a key and writ... SYNCSORT 3
Search our Forums:

Back to Top