Highlighted
Absent Member.
Absent Member.
1022 views

order of linkage item and entry points

[Migrated content. Thread originally posted on 16 November 2011]

From the doc

1.Each level 01 and 77 data item declared in Linkage should be named in a USING phrase of the Procedure Division header. Data items that are REDEFINES of other data items should not be named, however


I also know that the standard imposes to list the linkage items in the procedure division USING phrase in the exact order in which they are declared in linkage section, otherwise the runtime raises an error.
However i didn't find anything in the doc or in google about the order in which they must be listed in the USING phrase of alternatives entry points.

For example, it follows an extract from one of my program:


       linkage section.
       01  lks-array.
           05 lks-array-ptr   usage pointer value 0.
           05 lks-array-el-sz pic 9(04)  usage is comp-4 value 0.
           05 lks-array-len   pic 9(09)  usage is comp-4 value 0.
           05 lks-array-cap   pic 9(09)  usage is comp-4 value 0.

       01  lks-array-val pic x(01).
       01  lks-array-idx pic 9(09).
                                                     
       01  lks-sort-tipo-var pic x(15).
       01  lks-start-byte    pic 9(09).
       01  lks-bytes-num     pic 9(09).

       procedure division.
       main.
           initialize werr-return-code.
           goback giving werr-return-code.


       array-new-entry.
       entry "array:new" using lks-array.
       ...
       ...
       
       array-get-entry.
       entry "array:get" using lks-array
                               lks-array-val
                               lks-array-idx.
       ...
       ...

       array-sort-entry.
       entry "array:sort" using lks-array,
                                lks-sort-tipo-var,
                                lks-start-byte,
                                lks-bytes-num.
       ...
       ...       

   
       array-binsearch.
       entry "array:binsearch" using lks-array,
                                     lks-array-val,
                                     lks-array-idx
                                     lks-sort-tipo-var,
                                     lks-start-byte,
                                     lks-bytes-num.


Is the linkage used correctly?

Which are the best practices about linkage section and entry points?

If i use a linkage item only to dereference pointers, it also shoud be listed in a USING phrase? From the quoted doc it seems so but from this other extract it seems not:


1.A Linkage Section data item can be referred to in the Procedure Division only if it satisfies one of the following conditions:


a.It is named in the Procedure Division's USING phrase.

a.The address of the data item is assigned to another data item or a pointer. This is accomplished through the SET ADDRESS OF statement. See the Linkage Section in section 5.3 and the SET Statement for additional information.

a.It is subordinate to a parameter named in the USING phrase.

a.It is a data item defined by a REDEFINES or RENAMES clause whose object is named in the USING phrase. Data items subordinate to such items may also be referenced.

a.It is a condition-name or index-name associated with any data item that satisfies any of the previous conditions.
0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: order of linkage item and entry points

Is the linkage used correctly? Yes, your usage seems correct

Which are the best practices about linkage section and entry points? I do not know of one, I look at the Micro Focus knowledge base, but I did not see a best practices.

If i use a linkage item only to dereference pointers, it also shoud be listed in a USING phrase? From the quoted doc it seems so but from this other extract it seems not:
I believe it is prudent to use the USING phrase even when you dereference pointers.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: order of linkage item and entry points

Ok, thank you

Luca
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.