Omit USING phrase in PROCEDURE DIVISION



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Omit USING phrase in PROCEDURE DIVISION

Postby tivrfoa » Tue Sep 27, 2016 10:21 pm

Hi,

Normally subroutines use the USING phrase, like:
PROCEDURE DIVISION USING DFHCOMMAREA.


I saw a subroutine that does not use USING phrase, but it receives parameters through LINKAGE section.
*------------------------------------------
 LINKAGE                         SECTION.  
*------------------------------------------
 01  DFHCOMMAREA.                          
...


I didn't find anything telling that you can omit the USING phrase:
https://www.ibm.com/support/knowledgece ... pdsusi.htm
http://www.ibm.com/support/knowledgecen ... pdsusi.htm
References to items in the linkage section

Data items defined in the linkage section of the called program or invoked method can be referenced within the procedure division of that program if and only if they satisfy one of the following conditions:

They are operands of the USING phrase of the procedure division header or the ENTRY statement.
They are operands of SET ADDRESS OF, CALL ... BY REFERENCE ADDRESS OF, or INVOKE ... BY REFERENCE ADDRESS OF.
They are defined with a REDEFINES or RENAMES clause, the object of which satisfies the above conditions.
They are items subordinate to any item that satisfies the condition in the rules above.
They are condition-names or index-names associated with data items that satisfy any of the above conditions.


So I am wondering why this works. Maybe it's because it's using DFHCOMMAREA as a name?
I will try a different name and see if it works.
tivrfoa
 
Posts: 77
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 56 times
Been thanked: 0 time

Re: Omit USING phrase in PROCEDURE DIVISION

 

Re: Omit USING phrase in PROCEDURE DIVISION

Postby tivrfoa » Tue Sep 27, 2016 10:47 pm

tivrfoa wrote:So I am wondering why this works. Maybe it's because it's using DFHCOMMAREA as a name?
I will try a different name and see if it works.

That's the reason.
http://www.ibm.com/support/knowledgecen ... hp37u.html
In a receiving COBOL program, you must give the data area the name DFHCOMMAREA.

I got the error below when I tried a different name:
NAT0954 Abnormal termination S0C7 during program execution.
tivrfoa
 
Posts: 77
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 56 times
Been thanked: 0 time

Re: Omit USING phrase in PROCEDURE DIVISION

Postby BillyBoyo » Wed Sep 28, 2016 12:07 am

For CICS programs, the pre-processor/co-processor gives you two LINKAGE SECTION items automatically. These will be the first two items on the USING on the PROCEDURE DIVISION.

These users thanked the author BillyBoyo for the post:
tivrfoa (Wed Sep 28, 2016 1:43 am)
BillyBoyo
Global moderator
 
Posts: 3759
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 256 times

Re: Omit USING phrase in PROCEDURE DIVISION

Postby Robert Sample » Wed Sep 28, 2016 2:05 am

If you omit the USING in a batch program, the subprogram will not be able to address the parameters passed from the calling program. In some cases this is fine; in other cases this will cause problems. In general, the calling program and subprogram should be in agreement as to number and length of data going between the programs. While mismatches are sort of allowed -- see the use of OMITTED in the Programming Guide manual -- it becomes much easier to get system ABENDS such as S0C4 when doing so.

These users thanked the author Robert Sample for the post:
tivrfoa (Wed Sep 28, 2016 2:17 am)
Robert Sample
Global moderator
 
Posts: 3121
Joined: Sat Dec 19, 2009 8:32 pm
Location: Bellevue, Iowa
Has thanked: 1 time
Been thanked: 182 times

Re: Omit USING phrase in PROCEDURE DIVISION

Postby tivrfoa » Wed Sep 28, 2016 2:23 am

Thanks a lot Billy and Robert.

BillyBoyo wrote:For CICS programs, the pre-processor/co-processor gives you two LINKAGE SECTION items automatically. These will be the first two items on the USING on the PROCEDURE DIVISION.

By two you mean one is DFHCOMMAREA? What is the other? DFHEIBLK?
tivrfoa
 
Posts: 77
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 56 times
Been thanked: 0 time

Re: Omit USING phrase in PROCEDURE DIVISION

Postby tivrfoa » Wed Sep 28, 2016 2:36 am

tivrfoa wrote:By two you mean one is DFHCOMMAREA? What is the other? DFHEIBLK?

That's ok. I think I got it.
DFHEIBLK is useful, for example to test EIBCALEN. Interesting. =)
https://www.ibm.com/support/knowledgece ... env03b.htm
http://ibmmainframes.com/about5154.html
https://www.ibm.com/support/knowledgece ... EIBKK.html
EIB EXEC interface block

CONTROL BLOCK NAME = DFHEIBLK
DESCRIPTIVE NAME = CICS EXEC Interface Block.
@BANNER_START 02
DFHEIBLK
Licensed Materials - Property of IBM
"Restricted Materials of IBM"
5655-S97
@BANNER_END
FUNCTION = EXEC Interface Block.
The exec interface block contains information on the
transaction identifier, the time and date, and the cursor
position on a display device. Some of the other fields are
set indicating the next action that a program should take
in certain circumstances.
DFHEIBLK also contains information that will be helpful
when a dump is being used to debug a program.
This control block is included automatically by an
application program using the command-level interface.
EISEIBA in the EIS addresses the EIB.
NOTES :
DEPENDENCIES = S/370
MODULE TYPE = Control block definition
--------------------------------------------------------------------
EXEC INTERFACE BLOCK
tivrfoa
 
Posts: 77
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 56 times
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post