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

SYNC variables value same as group?


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

New User


Joined: 18 Jul 2008
Posts: 59
Location: Bangalore

PostPosted: Tue Feb 14, 2012 5:36 pm
Reply with quote

Will the length of 01 level group variable having SYNC variables be same as that of a group without SYNC definition. Below scenario will be helpful.

01 WS-SYNC-GROUP.
05 WS-NUM-DATA PIC S9(9) COMP-5 SYNC.
05 WS-TEXT PIC X(16).

01 WS-NON-SYNC-GROUP.
05 WNS-NUM-DATA PIC S9(9) COMP-5.
05 WNS-TEXT PIC X(16).

Is LENGTH OF WS-SYNC-GROUP = LENGTH OF WS-NON-SYNC-GROUP ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Feb 14, 2012 5:47 pm
Reply with quote

Don't post your question at the end of a thread inactive for almost 4 years. I've split it into a new topic.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Feb 14, 2012 5:50 pm
Reply with quote

The answer to your question is that it depends upon the data. Data definitions:
Code:
      WORKING-STORAGE SECTION.
      01  WS-SYNC-GROUP.
          05  WS-X                    PIC X(01).
          05  WS-NUM-DATA             PIC S9(9) COMP-5 SYNC.
          05  WS-TEXT                 PIC X(16).

      01  WS-SYNC-GROUP-2             SYNC.
          05  WS-X                    PIC X(01).
          05  WS-NUM-DATA             PIC S9(9) COMP-5 SYNC.
          05  WS-TEXT                 PIC X(16).

      01  WS-NON-SYNC-GROUP.
          05  WS-X                    PIC X(01).
          05  WNS-NUM-DATA            PIC S9(9) COMP-5.
          05  WNS-TEXT                PIC X(16).

      01  WS-SYNC-GROUP-3.
          05  WS-X                    PIC X(01).
          05  WS-NUM-DATA             PIC S9(9) COMP-5 SYNC.
          05  WS-TEXT                 PIC X(16).

      01  WS-SYNC-GROUP-4             SYNC.
          05  WS-X                    PIC X(01).
          05  WS-NUM-DATA             PIC S9(9) COMP-5 SYNC.
          05  WS-TEXT                 PIC X(16).

      01  WS-NON-SYNC-GROUP-2.
          05  WNS-X                   PIC X(01).
          05  WNS-NUM-DATA            PIC S9(9) COMP-5.
          05  WNS-TEXT                PIC X(16).
generates compiler output of
Code:
SYNC-GROUP . . . . . . . . . . . . . . . . BLW=00000  000               DS 0CL24
S-X. . . . . . . . . . . . . . . . . . . . BLW=00000  000   0 000 000   DS 1C
S-NUM-DATA . . . . . . . . . . . . . . . . BLW=00000  004   0 000 004   DS 1F
S-TEXT . . . . . . . . . . . . . . . . . . BLW=00000  008   0 000 008   DS 16C
SYNC-GROUP-2 . . . . . . . . . . . . . . . BLW=00000  018               DS 0CL24
S-X. . . . . . . . . . . . . . . . . . . . BLW=00000  018   0 000 000   DS 1C
S-NUM-DATA . . . . . . . . . . . . . . . . BLW=00000  01C   0 000 004   DS 1F
S-TEXT . . . . . . . . . . . . . . . . . . BLW=00000  020   0 000 008   DS 16C
NON-SYNC-GROUP . . . . . . . . . . . . . . BLW=00000  030               DS 0CL21
S-X. . . . . . . . . . . . . . . . . . . . BLW=00000  030   0 000 000   DS 1C
NS-NUM-DATA. . . . . . . . . . . . . . . . BLW=00000  031   0 000 001   DS 4C
NS-TEXT. . . . . . . . . . . . . . . . . . BLW=00000  035   0 000 005   DS 16C
SYNC-GROUP-3 . . . . . . . . . . . . . . . BLW=00000  048               DS 0CL24
S-X. . . . . . . . . . . . . . . . . . . . BLW=00000  048   0 000 000   DS 1C
S-NUM-DATA . . . . . . . . . . . . . . . . BLW=00000  04C   0 000 004   DS 1F
S-TEXT . . . . . . . . . . . . . . . . . . BLW=00000  050   0 000 008   DS 16C
SYNC-GROUP-4 . . . . . . . . . . . . . . . BLW=00000  060               DS 0CL24
S-X. . . . . . . . . . . . . . . . . . . . BLW=00000  060   0 000 000   DS 1C
S-NUM-DATA . . . . . . . . . . . . . . . . BLW=00000  064   0 000 004   DS 1F
S-TEXT . . . . . . . . . . . . . . . . . . BLW=00000  068   0 000 008   DS 16C
NON-SYNC-GROUP-2 . . . . . . . . . . . . . BLW=00000  078               DS 0CL21
NS-X . . . . . . . . . . . . . . . . . . . BLW=00000  078   0 000 000   DS 1C
NS-NUM-DATA. . . . . . . . . . . . . . . . BLW=00000  079   0 000 001   DS 4C
NS-TEXT. . . . . . . . . . . . . . . . . . BLW=00000  07D   0 000 005   DS 16C
Note that some of the groups have length 24 and some have length 21. If you don't understand why, click on the Manuals link at the top of the page and read the COBOL Language Reference manual on what SYNC does.
Back to top
View user's profile Send private message
mushreyas

New User


Joined: 18 Jul 2008
Posts: 59
Location: Bangalore

PostPosted: Tue Feb 14, 2012 8:04 pm
Reply with quote

Thanks Bob for the quick and detailed response. I thought the slack bytes will be allocated internally and doesn't actually alter the length visible to user.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Feb 14, 2012 8:08 pm
Reply with quote

Can affect not only the length of a group item, including the 01, but, obviously, the location of fields following the "synchronisation".
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Feb 14, 2012 8:18 pm
Reply with quote

Slack bytes are allocated internally -- but they count as part of the group data and hence must be considered by the programmer. This will be be especially critical if you're putting slack bytes in an FD 01, where they will actually increase the LRECL of the file.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Feb 16, 2012 5:44 am
Reply with quote

mushreyas,

To answer your original ques: yes

If your proposed 01 group is already at a doubleword boundary, no slack bytes are added by the compiler and SYNC does nothing; if it is not positioned at the dw boundary the compiler adds the slack bytes before the 01 and again SYNC does nothing.

So the real issue here is that the compiler aligns 01 levels on a doubleword boundary, therefor the SYNC clause is unnecessary in your example.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 16, 2012 6:45 am
Reply with quote

I've found that defining elementary binary-fields with SYNC is to ensure proper mapping/alignment in a parmlist targeted for Assembler sub-programs, who have H, F and D aligned definitions in a DSECT.

Otherwise, I generally don't use them because they're more of a nuisance, especially for newbies during maintenance.

Years ago, using OS/VS COBOL, they were used as optimized subscripts, but because of builtin compiler optimization nowadays, they've fallen out of favor.

Just my two cents.... icon_wink.gif

Mr. Bill
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 Compare latest 2 rows of a table usin... DB2 1
No new posts JCL with variables JCL & VSAM 1
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Splitting group records based on deta... DFSORT/ICETOOL 8
No new posts JCL Variables JCL & VSAM 1
Search our Forums:

Back to Top