When it is present, the Procedure Division is identified by and must begin with the following header:
The USING phrase of the Procedure Division header identifies the names used by the program for any parameters passed to it by a calling program or from the RM/COBOL Runtime Command.It is required only in one of the following circumstances:
In the first case, the parameters passed to the called program are identified in the USING phrase of the calling program’s CALL statement.The correspondence between the two lists of names is established on a positional basis.That is, the first data-name-1 in the USING list of the CALL statement in the calling program corresponds to the first data-name-1 in the USING list of the Procedure Division header in the called program, the second data-name-1 in the USING list of the CALL statement in the calling program corresponds to the second data-name-1 in the USING list of the Procedure Division header in the called program, and so forth.The two lists need not have the same number of operands, but operands for which there is no corresponding operand in the other list may not be referred to, nor may any of their subordinate data items, condition-names or index-names be referred to in the called program.
In the second case, there is only a single parameter, and it must be defined in the Linkage Section with entries similar to the following:
02 PARAMETER-LENGTH PIC S9(4) BINARY (2).
03 PARAMETER-CHAR PIC X OCCURS 0 TO 100 TIMES
DEPENDING ON PARAMETER-LENGTH.
The Procedure Division header should have the following form:
PROCEDURE DIVISION USING MAIN-PARAMETER.
Subscripted references to PARAMETER-CHAR can then be used to access the characters within the invocation line.There is further information in the describing the technique for passing a character-string to the first program in a run unit.
In either case, each data-name-1 and data-name-2 must be defined as a level 01 entry or a level 77 entry in the Linkage Section of the Data Division.A particular user-defined word may not appear more than once as data-name-1 or data-name-2.The data description entry for data-name-1 or data-name-2 must not contain a REDEFINES clause.However, data-name-1 or data-name-2 may be the object of a REDEFINES clause elsewhere in the Linkage Section.
If the reference to the corresponding data item in the CALL statement declares the parameter to be passed by content, the value of the item is moved when the CALL statement is executed and placed into a system-defined storage item possessing the attributes declared in the Linkage Section for data-name-1.
The data description of each parameter in the BY CONTENT phrase of the CALL statement must be congruent to the data description of the corresponding parameter in the USING phrase of the Procedure Division header.Two data descriptions are congruent if they specify the same size and, for numeric items, the same usage, scale and sign convention.For binary data items, congruency also depends on both items being allocated with the same number of bytes, which depends on specification of the same binary allocation override in the USAGE clause or matching configuration of the compiler with the BINARY-ALLOCATION and BINARY-ALLOCATION-SIGNED keywords of the COMPILER-OPTIONS configuration record when compiling each of the possibly separately compiled programs.
If the reference to the corresponding data item in the CALL statement declares the parameter to be passed by reference, the object program operates as if the data item in the called program occupies the same storage area as the corresponding data item in the calling program.If data-name-1 or any of its subordinate elements is referred to in the Procedure Division, it must not be defined as being longer than its corresponding data item in the calling program.
RETURNING is a synonym for GIVING.
The GIVING phrase identifies the name used by the program for a result value.It is required only when the calling program specifies a GIVING phrase in the CALL statement and the design of that calling program depends on a result being placed in its GIVING argument.That is, it is not an error if the calling program specifies a GIVING operand and the called program does not; in this case, the called program ignores and cannot affect the GIVING operand in the calling program.However, it is a data reference error to refer to data-name-2, or any of its subordinate data-names or condition-names, redefined data-names, or renamed data-names if the calling program does not have a GIVING phrase, except in certain contexts.When the calling program does not have a GIVING phrase, the contexts where an error will not occur are:
Each reference to data-name-1 or data-name-2 in the called program is resolved in accordance with the description of data-name-1 or data-name-2 as given in the Linkage Section of the called program, except when they name a level 01 or level 77 entry and they are specified in the USING or GIVING phrase of a CALL statement, or when they are reference modified.In these two exception cases, the reference to data-name-1 or data-name-2 is resolved according to the description in the calling program.
A data item defined in the Linkage Section of the called program may be referred to within the Procedure Division of that program only if it satisfies one of the following conditions:
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|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.