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

Use of COMP SYNC clause in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sghosh

New User


Joined: 13 May 2008
Posts: 2
Location: Kolkata

PostPosted: Wed May 14, 2008 1:46 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed May 14, 2008 1:57 pm
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: 218
Location: India

PostPosted: Wed May 14, 2008 2:04 pm
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 : 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: 355
Location: New York

PostPosted: Wed May 14, 2008 2:53 pm
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
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: 2
Location: Kolkata

PostPosted: Wed May 14, 2008 5:22 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top