View previous topic :: View next topic
|
Author |
Message |
mushreyas
New User
Joined: 18 Jul 2008 Posts: 59 Location: Bangalore
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
mushreyas
New User
Joined: 18 Jul 2008 Posts: 59 Location: Bangalore
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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....
Mr. Bill |
|
Back to top |
|
|
|