Skip to main content

order of linkage item and entry points

  • November 16, 2011
  • 2 replies
  • 0 views

[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.

2 replies

Stephen Hjerpe
  • Participating Frequently
  • 1100 replies
  • November 16, 2011

[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.
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.

  • Author
  • Rocketeer
  • 19312 replies
  • November 16, 2011

[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.
Ok, thank you

Luca