View previous topic :: View next topic
|
Author |
Message |
roy_robi
New User
Joined: 25 Dec 2006 Posts: 4 Location: chicago
|
|
|
|
Hi,
What is the difference between these two types of statement in GroupLevel 01. Everything is same except SYNC.
Any help is appreciated.
Code: |
01 INEXIT01-IOAREA SYNC.
05 ACCEPT-CODE PIC X VALUE 'Y'.
88 RECORD-ACCEPTED VALUE 'Y'.
88 RECORD-DELETED VALUE 'N'.
88 RECORD-INSERTED VALUE 'I'.
05 EXIT-ID PIC X(8) VALUE 'INEXIT01'.
05 INSERTED-RECORD-INFO.
10 MAX-INSERTED-REC-LENGTH PIC S9(4) COMP SYNC VALUE +0.
10 INSERTED-REC-LENGTH PIC S9(4) COMP SYNC VALUE +0.
|
$$$$$$$$$$$$$AND$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Code: |
01 INEXIT01-IOAREA.
05 ACCEPT-CODE PIC X VALUE 'Y'.
88 RECORD-ACCEPTED VALUE 'Y'.
88 RECORD-DELETED VALUE 'N'.
88 RECORD-INSERTED VALUE 'I'.
05 EXIT-ID PIC X(8) VALUE 'INEXIT01'.
05 INSERTED-RECORD-INFO.
10 MAX-INSERTED-REC-LENGTH PIC S9(4) COMP SYNC VALUE +0.
10 INSERTED-REC-LENGTH PIC S9(4) COMP SYNC VALUE +0.
|
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
There is no reason to specify SYNC on an 01 level - it is automatically aligned by the compiler. |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
|
|
Quote: |
There is no reason to specify SYNC on an 01 level - it is automatically aligned by the compiler. |
Can you please clarify this?
I still hope, the compiler assumes SYNC only for 01 level elementary items, not for group items.
If you specfiy the SYNC clause for 01 level group item, its applied to all the elements of the group, except DISPLAY and COMP-3 items. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
As been said, SYNC at an "01" is unnecessary. However, if your group-level needs to match that of a Assembler DSECT, which contains fields defined using the "D", "F" and/or "H" aligned directives (Doubleword, Fullword, Halfword) or you need to match an existing COBOL layout which contains SYNC items, then you must define SYNC elementary items where needed.
Otherwise, SYNC can be more of a maintenance headache than anything and for the most part, is basically obsolete unless you need to use it based upon the above or similar criteria.
HTH....
Regards,
Bill |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I still hope, the compiler assumes SYNC only for 01 level elementary items, not for group items. |
ALL level 01 entries (group or elementary) are SYNCronized. And from Enterprise COBOL via the "Manuals" link above:
Quote: |
In the working-storage section, the compiler aligns all level-01 entries on a doubleword boundary |
Quote: |
If you specfiy the SYNC clause for 01 level group item, its applied to all the elements of the group, except DISPLAY and COMP-3 items.
|
Unless i misunderstand, this is incorret. The 01 is automatically aligned by the compiler, but there is no aligment for elementary fields contained beneath the 01.
As Bill mentioned, there may be other code (typically assembler) that requires some particular boundary alignment (SYNC). |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
|
|
Quote: |
ALL level 01 entries (group or elementary) are SYNCronized. And from Enterprise COBOL via the "Manuals" link above: |
Yes, you are perfectly right. If its a group item, only the first elemantary item starts from a double word boundary.
Quote: |
Unless i misunderstand, this is incorret. The 01 is automatically aligned by the compiler, but there is no aligment for elementary fields contained beneath the 01. |
No I disagree. As per ANSI 2002 standard, all the elementary items of a group are SYNCed, if SYNC clause is specified for the group.
And the recent version of VS COBOL II manual also says:
Quote: |
The SYNCHRONIZED clause be specified for level-01 group items, in which
case every elementary item within the level-01 group item is synchronized. |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
No I disagree. As per ANSI 2002 standard, all the elementary items of a group are SYNCed, if SYNC clause is specified for the group.
And the recent version of VS COBOL II manual also says:
Quote: |
The SYNCHRONIZED clause be specified for level-01 group items, in which
case every elementary item within the level-01 group item is synchronized. |
|
That "quote" does not look like it was taken directly from the IBM manual.
It is usually not a good idea to disagree with the manual published by the vendor
This code:
Code: |
01 WS-DDD SYNC.
05 WS-DDDA PIC X(5).
05 WS-DDDB PIC 9(5).
05 WS-DDDC PIC 9(5) VALUE 10000. |
ONLY aligns WS-DDD (and thus WS-DDDA). The other 2 fields are NOT sync'ed (as per the quoted manual).
These are the corresponding displacements generated by the compiler:
Code: |
BLW=00000+0E0 0CL15
BLW=00000+0E0,0000000 5C
BLW=00000+0E5,0000005 5C
BLW=00000+0EA,000000A 5C |
Note the "B" and "C" fields are not re-aligned. They are contiguous.
If i've left anything unclear, please advise. |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Interesting,
The IBM manuals typically use better grammar. . . .
But that quote not withstanding, this:
Quote: |
This code:
Code: |
01 WS-DDD SYNC.
05 WS-DDDA PIC X(5).
05 WS-DDDB PIC 9(5).
05 WS-DDDC PIC 9(5) VALUE 10000. |
ONLY aligns WS-DDD (and thus WS-DDDA). The other 2 fields are NOT sync'ed (as per the quoted manual).
These are the corresponding displacements generated by the compiler:
Code: |
BLW=00000+0E0 0CL15
BLW=00000+0E0,0000000 5C
BLW=00000+0E5,0000005 5C
BLW=00000+0EA,000000A 5C |
Note the "B" and "C" fields are not re-aligned. They are contiguous. |
is what happens when an 01 group is specified with sync and the elemenatry fields are not re-aligned. |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
|
|
Yes, its synchronized actually.
As you didnt specify any USAGE clause, the default is DISPLAY which has no effect on SYNC Clause.
Quote: |
If you specfiy the SYNC clause for 01 level group item, its applied to all the elements of the group, except DISPLAY and COMP-3 items. |
Try to declare as:
Code: |
01 WS-DDD SYNC.
05 WS-DDDA PIC X(5).
05 WS-DDDB PIC 9(5) COMP.
05 WS-DDDC PIC 9(5) VALUE 10000. |
And you will get:
Code: |
BLW=00000+0E0 0CL15
BLW=00000+0E0,0000000 5C
BLW=00000+0E8,0000008 5C
BLW=00000+0EC,000000C 5C |
|
|
Back to top |
|
|
|