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
 

 

Find the size of the COBOL Group

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 128
Location: kerala,india

PostPosted: Tue Aug 22, 2006 5:44 pm    Post subject: Find the size of the COBOL Group
Reply with quote

01 TAB.
02 A PIC S9(11) USAGE IS COMP
02 B PIC S9(11) USAGE IS COMP SYNC
02 C USAGE IS INDEX
02 D USAGE IS POINTER
02 E PIC 9(11) USAGE IS COMP-3

PLEASE TELL THE SIZE OF TAB
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Aug 22, 2006 5:55 pm    Post subject: Re: SIZE OF GROUP
Reply with quote

Quote:

01 TAB.
02 A PIC S9(11) USAGE IS COMP
02 B PIC S9(11) USAGE IS COMP SYNC
02 C USAGE IS INDEX
02 D USAGE IS POINTER
02 E PIC 9(11) USAGE IS COMP-3

PLEASE TELL THE SIZE OF TAB


The length of TAB is 30.

A = 8
B = 8
C = 4
D = 4
E = 6

Total = 30

Dave
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 128
Location: kerala,india

PostPosted: Tue Aug 22, 2006 11:21 pm    Post subject:
Reply with quote

david can u please explain it for me
Back to top
View user's profile Send private message
Archana_MF

New User


Joined: 21 Jul 2006
Posts: 49
Location: California

PostPosted: Wed Aug 23, 2006 3:44 am    Post subject: Re: What's the size of the Group
Reply with quote

Below is a brief Desc of each Usage.

02 A PIC S9(11) USAGE IS COMP : This is Binary and the memory is defined as 2's complement numbers (2x) i.e 2, 4, 8, 16 etc etc
So for PIC 1-4 : 2 bytes
PIC 5-9 : 4 Bytes
PIC 10-18: 8 Bytes
and this is byte aligned. For Ur Ex it is 8 Bytes

02 B PIC S9(11) USAGE IS COMP SYNC : Similar to COMP but is synchronized to Word Boundaries. 8-Bytes

02 C USAGE IS INDEX : This is a 4-byte data-item to which the Index value is stored for refrences like table occurances and it need not be a part of the table. the Index data-item can be directly ref by SERACH/SET/COND.

02 D USAGE IS POINTER : This is a 4-Byte field to store address of any data-item or field. when u use this field in ur program ur actually using the address in it which in turn points to actual data.


02 E PIC 9(11) USAGE IS COMP-3
<== It uses a notation called BCD(Binary Coded Decimal) i.e two digits are stored in 1 byte (8 bits ) or u can say 1 digit in 4 bits(nybble). To calculate the storage add 1 to the number of PIC bytes and divide by 2. here it is (11+1)/2 i.e 6 bytes
for Ex a number 12345678901(11 digits) is stored as 12 34 56 78 90 1C , C is sign stored in the last Nybble.

Hope this helps
Back to top
View user's profile Send private message
MKP

New User


Joined: 23 Aug 2006
Posts: 12
Location: Chennai

PostPosted: Wed Aug 23, 2006 8:00 am    Post subject: Re: What's the size of the Group
Reply with quote

Hi Archana,
If a group size is 12 , Now i am using comp-3 as an usage clause. will it take 6.5 bytes or 7 bytes.
Back to top
View user's profile Send private message
Archana_MF

New User


Joined: 21 Jul 2006
Posts: 49
Location: California

PostPosted: Wed Aug 23, 2006 9:29 am    Post subject: Re: What's the size of the Group
Reply with quote

It will be rounded to 7 Bytes for PIC (12) Comp-3 and the upper 4 bits will be ignored and can be zeroes .
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Aug 23, 2006 9:31 am    Post subject:
Reply with quote

Hi MKP,
For declaration

02 E PIC 9(12) USAGE IS COMP-3

It will take 6 Bytes

02 E PIC S9(12) USAGE IS COMP-3
It will take 7 bytes.
Back to top
View user's profile Send private message
Archana_MF

New User


Joined: 21 Jul 2006
Posts: 49
Location: California

PostPosted: Wed Aug 23, 2006 9:38 am    Post subject: Re: What's the size of the Group
Reply with quote

Correct me If I am wrong,

I thought COMP-3 will reserve a Nibble for sign irrespective of
Signed S9(12) / Unsigned 9(12) values, making it always 7 bytes for this ex.
Back to top
View user's profile Send private message
MKP

New User


Joined: 23 Aug 2006
Posts: 12
Location: Chennai

PostPosted: Wed Aug 23, 2006 9:39 am    Post subject: Re: What's the size of the Group
Reply with quote

Hi Guptae,

Ru sure that if i wont specify s9(12) instead of 9(12) it iwll take only 6 bytes.
Back to top
View user's profile Send private message
kondakonda

New User


Joined: 20 Mar 2006
Posts: 34

PostPosted: Wed Aug 23, 2006 10:19 am    Post subject: Re: What's the size of the Group
Reply with quote

Hi,

I am sure it will occupy 7 bytes irrespective of 9(12) or s9(12)


Thanks.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Aug 23, 2006 11:43 am    Post subject:
Reply with quote

02 E PIC 9(11) USAGE IS COMP-3

It will take 6 Bytes

02 E PIC S9(11) USAGE IS COMP-3
It will take 6 Bytes

02 E PIC 9(12) USAGE IS COMP-3
It will take 7 Bytes

02 E PIC S9(12) USAGE IS COMP-3
yeap it will occupie seven byte
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 128
Location: kerala,india

PostPosted: Wed Aug 23, 2006 11:53 am    Post subject: Re: What's the size of the Group
Reply with quote

In case i have given a sync clause in a group item is that clause applicable to all the members of the group or only for that item
Back to top
View user's profile Send private message
jose.jeyan

New User


Joined: 28 Jul 2006
Posts: 60
Location: Mumbai

PostPosted: Wed Aug 23, 2006 2:09 pm    Post subject:
Reply with quote

for 02 E PIC 9(12) USAGE IS COMP-3

it will take 6 bytes as sign is not specified

for 02 E PIC s9(12) USAGE IS COMP-3

it will take 7 bytes as the genral formula is int((n/2)+1),sign is stored as hex value in the last nibble.
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 128
Location: kerala,india

PostPosted: Wed Aug 23, 2006 5:02 pm    Post subject: Re: What's the size of the Group
Reply with quote

Please tell me What is the default word boundary in minframe
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1218
Location: Israel

PostPosted: Wed Aug 23, 2006 5:56 pm    Post subject:
Reply with quote

jose.jeyan,

Quote:
for 02 E PIC 9(12) USAGE IS COMP-3
it will take 6 bytes as sign is not specified

Wrong!
Each number occupies half a byte. The rightmost half-byte contains the sign:
C if it's positive,
D if it's negative,
F if it's unsigned.
If you specify an even number (multiple of 2), the leftmost half-byte will contain 0 and will be "wasted".
That's why it is of good practice to specify an odd number (not multiple of 2) for the size of COMP-3 fields, as the fine book says.
Back to top
View user's profile Send private message
jose.jeyan

New User


Joined: 28 Jul 2006
Posts: 60
Location: Mumbai

PostPosted: Wed Aug 23, 2006 6:14 pm    Post subject:
Reply with quote

thanks marso
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Aug 24, 2006 3:30 am    Post subject:
Reply with quote

Let's change cobolunni's ques.

Reverse all the 02 level variables in 01 TAB (i.e. E D C B A, instead of A B C D E).

Now, what will the size of TAB be?
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Aug 24, 2006 4:09 am    Post subject: Re: What's the size of the Group
Reply with quote

Tab starts on a word boundary (Multiple of 4 bytes)

Code:

Offset
from
?TAB?  Variable Length         
0      E        6
6      D        4
10     C        4
14     slack    2 (added to word align B)
16     B (sync) 8
24     A        8

Total Length 32


Dave
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 128
Location: kerala,india

PostPosted: Thu Aug 24, 2006 9:16 am    Post subject: Re: What's the size of the Group
Reply with quote

In the group (in my first question ) There is a SYNC in the data name B .B is in the group called tab . B has a size of 8 bytes SYNC will create a word boundary of 8 .Is this word boundary is applicable to all of the members in the group .Is that the condition then the answer of my first question will be 40 instead of 30 . Please tell me if SYNC clause is apllicable to all of the members in the group or not
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am


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