Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Use of COMP SYNC clause in COBOL

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

New User


Joined: 13 May 2008
Posts: 3
Location: Kolkata

PostPosted: Wed May 14, 2008 1:46 pm    Post subject: Use of COMP SYNC clause in COBOL
Reply with quote

Hi,

Before posting this message I searched this site for similar posts but did not find any.

How and when do I use the COMP SYNC clause while declaring vairables?

Would be great if someone can tell me if this was dealt with in this forum before and let me know the link to that post.

Regards
Ghosh
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10308
Location: italy

PostPosted: Wed May 14, 2008 1:57 pm    Post subject: Reply to: Use of COMP SYNC clause in COBOL
Reply with quote

the SYNC attribute is related to the way storage for variables is allocated,

the alignment boundaries are

BYTE for strings and equivalent data ( packed and pic things )
HALFWORD for 2 bytes binary numbers
FULLWORD for 4 bytes binary numbers
DOUBLEWORD for 8 bytes things

search the net for "COBOL ALIGNMENT RULES IBM" an You will find lots of links

or more simply click on the manuals link at top of the page and scroll to the cobol section

just a bit of history

one upon a time the operand boundaries were strictly enforced by hardware
an You would get a specification exception trying to use operands with the wrong alignment
- everything was done to save addressing cycles

now everything has been relaxed and alignment is not usually needed any longer

somebody will tell You when to use the SYNC attribute
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 215
Location: India

PostPosted: Wed May 14, 2008 2:04 pm    Post subject: Re: Use of COMP SYNC clause in COBOL
Reply with quote

sghosh wrote:
Hi,

Before posting this message I searched this site for similar posts but did not find any.

How and when do I use the COMP SYNC clause while declaring vairables?

Would be great if someone can tell me if this was dealt with in this forum before and let me know the link to that post.

Regards
Ghosh


Refer this : http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/IGYL1101/2.7.11?DT=19930312093006
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Wed May 14, 2008 2:53 pm    Post subject:
Reply with quote

Hi,

The SYNCHRONIZED clause explicitly aligns COMP and INDEX data items along their natural WORD boundaries.

If there is no SYNCHRONIZED clause the data items are aligned on byte boundaries.

This clause is used to optimise speed of processing - but it does so at the expense of storage.


COMP SYNC (1 TO 4 Digits) = 2 Byte boundary
COMP SYNC (5 TO 9 Digits) = 4 Byte boundary
COMP SYNC (10 TO 18 Digits) = 8 Byte boundary
INDEX = 4 Byte boundary

KSK
Back to top
View user's profile Send private message
mytags

New User


Joined: 28 Apr 2008
Posts: 63
Location: US

PostPosted: Wed May 14, 2008 4:09 pm    Post subject:
Reply with quote

HI
By mentioning Sync clause along with declarion we can make sure that the variable got stored in system from the starting position of the storage.
Like 2 byte or 4 bytes boundaries.We only need to menton as SYNC along with the declaration of the variable in working storage.
But usage of sync clause is actually a wastage in case of storage.
Hari.
Back to top
View user's profile Send private message
sghosh

New User


Joined: 13 May 2008
Posts: 3
Location: Kolkata

PostPosted: Wed May 14, 2008 5:22 pm    Post subject:
Reply with quote

Thanks a lot everyone for all the information. :)
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed May 14, 2008 5:47 pm    Post subject:
Reply with quote

Just 1 note of caution: if you specify SYNC in variables in a non 01 level group item, then move it to another group, those fields may not be SYNCed properly.

May be a good idea to SYNC both groups.
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
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us