The structure of the Linkage Section is identical to the Working-Storage Section. That is, it consists of a section header, followed by data description entries for noncontiguous data items, record description entries, or both.
A data-name defined at the 01 or 77 level in the Linkage Section must be unique only if there is a reference to it elsewhere in the program.Subordinate data-names need not be unique if they can be made unique by qualification or if there are no references to them elsewhere in the program.
Record description entries and 77-level-description-entries in the Linkage Section describe record layouts for formal arguments of a program and for based linkage records. Linkage Section data items are not allocated storage during compilation, but rather during the execution of the run unit.
The formal arguments of a program are named in the USING and GIVING phrases of the Procedure Division header and must be names defined as level 01 or level 77 entries in the Linkage Section.Formal arguments receive their base address from the actual arguments passed by a calling program.Formal arguments may also be treated as based linkage records; this can be convenient to establish a default argument when the calling program does not pass the corresponding actual argument.
Based linkage data records are any record-description-entries or 77-level-description- entries in the Linkage Section that receive their base address by use of Formats 5 or 6 of the SET statement in which the receiving item is an ADDRESS OF data-name-1.Based linkage records may include formal arguments of a program.For example,it may be convenient to set the base address of a formal argument when the corresponding actual argument is omitted.
When a program is placed into its initial state (either on its first CALL in the run unit or on its first CALL since it has been canceled), the base addresses of all based linkage records are set equal to NULL.A Format 5 SET statement must be executed to change the base address to a value other than NULL.Once set,the base address of a based linkage record remains set until changed by the execution of a Format 5 or Format 6 SET statement or the program that describes the based linkage item is canceled. If the program refers to a data item with a NULL base address, other than in an ADDRESS OF special register or in the USING or GIVING phrases of a CALL statement, a runtime Linkage Section data reference error will terminate the run unit.The ADDRESS OF special register may be used to test for a base address that is equal to NULL.
If a based linkage item is also a formal argument, the actual argument base address in a subsequent CALL statement in the calling program overrides any base address set or modified by a Format 5 or Format 6 SET statement in the called program.The override occurs each time that the program is called, unless the actual argument base address is equal to NULL.When the actual argument base address is equal to NULL, the last set base address is used instead.If there has been no Format 5 SET executed to set the base address, the NULL address from the initial state of the program will be used for a reference and a data reference error will occur except as described in the preceding paragraph.An actual argument has a NULL base address in the following cases:
The ENTRY-LINKAGE-SETTINGS keyword of the COMPILER-OPTIONS configuration record may be used to control certain details of how base addresses for linkage records are interpreted at runtime for a program compiled with a particular setting of this keyword. The option controls what happens on each entry to a called program, including how the correspondence of actual arguments to formal arguments and previous executions of Format 5 and 6 SET statements affect the base address used for a reference to a Linkage Section data item during that invocation of the called program.
A Format 1 (data item initialization) VALUE clause specified in the Linkage Section is ignored except in the execution of the INITIALIZE statement.If the runtime element containing the Linkage Section is activated by a COBOL runtime element, the initial value of a data item in the Linkage Section is determined by the value of the corresponding formal parameter in the activating runtime element, as described in the paragraphs above and the general rules of the Procedure Division. If the runtime element containing the Linkage Section is activated by the operating system.
The compiler handles as a special case the specification of a Linkage Section record-name as an actual argument in a CALL statement or in a reference modified identifier.In these two cases, the record-name is resolved according to the description of the actual data item on which the record-name is based rather than using the Linkage Section description of the record-name.The record-name is based on an actual argument if it represents a formal argument, that is, is named in the Procedure Division header USING or GIVING argument list, or may be based on some other data item through use of Formats 5 and 6 of the SET statement.Other than when used as an actual argument or in a reference modified identifier, a Linkage Section record-name is resolved according to its data description entry in the Linkage Section of the program in which it is declared.
This special case means that a program that is just an intermediary between two programs need not have a Linkage Section data description entry that accurately describes the size of the actual argument being passed through it.For example, calling C$CARG with a formal argument, which is described as longer than the corresponding actual argument, will no longer result in a data reference error.Instead, C$CARG will return the correct length of the actual argument, and because of the reference modification change described here, this length may be successfully used to reference modify the formal argument in order to access the entire contents of the actual argument. This also means that a program can call the supplied subprogram C$CARG with an argument that the calling program omitted without getting a data reference error.In this case, the call to C$CARG will succeed and return an argument descriptor that includes a type of OMITTED and a length of zero.
In the case of reference modification, an omitted actual argument would cause a data reference error, but for an argument that is not omitted, the reference modification can use any offset and length combination that is consistent with the actual argument. Previous to this enhancement, reference modification that used variables implied a reference to the item as described in the Linkage Section for the formal argument data item and this implied reference, if larger than the corresponding actual argument, would cause a data reference error before the reference modification was applied.
This special case also means that when the supplied subprogram, C$MemoryAllocate, is used to allocate an area of memory and then the SET statement is used to base a Linkage Section record on this allocated memory, the entire allocated memory area is passed as an actual argument when the record-name is used in the USING or GIVING phrases of the CALL statement.Also, the entire allocated memory area may be accessed by using reference modification of the record-name.
COBOL Related Interview Questions
|VSAM Interview Questions||IBM - VSAM Interview Questions|
|IBM-CICS Interview Questions||JCL Interview Questions|
|IBM DB2 Interview Questions||IBM-JCL Interview Questions|
|DB2 Using SQL Interview Questions||IBM-JCL&VSAM Interview Questions|
|IBM Mainframe Interview Questions||COBOL, CICS, JCL, VSAM, DB2 Interview Questions|
|DB2 SQL Programming Interview Questions||IMS/DB Interview Questions|
|Mainframe DB2 Interview Questions|
Procedure Division Statements
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.