CALL using OMITTED



So we now have a small z/OS system, in addition to our z/VSE system, so I've
been trying out some features in Enterprise COBOL for z/OS that are missing
in COBOL for VSE/ESA. One feature I've always thought might be useful is
CALL with the OMITTED argument. So I wrote the following:

ID DIVISION.
PROGRAM-ID. COB1.

PROCEDURE DIVISION.
DISPLAY 'NEW TEST' UPON CONSOLE
DISPLAY 'TEST!' UPON CONSOLE
DISPLAY 'TEST2'
DISPLAY 'WHEEEE!!!' UPON CONSOLE
DISPLAY 'YET ANOTHER TEST' UPON CONSOLE
CALL 'COBX' USING BY CONTENT 'AAAA'
OMITTED
'CCCC'
OMITTED

STOP RUN.

ID DIVISION.
PROGRAM-ID. COBX.

DATA DIVISION.
LINKAGE SECTION.
77 A PIC X(4).
77 B PIC X(4).
77 C PIC X(4).
77 D PIC X(4).

PROCEDURE DIVISION USING A B C D.
IF ADDRESS OF A = NULL
DISPLAY 'A IS OMITTED'
ELSE
DISPLAY A
END-IF
IF ADDRESS OF B = NULL
DISPLAY 'B IS OMITTED'
ELSE
DISPLAY B
END-IF
IF ADDRESS OF C = NULL
DISPLAY 'C IS OMITTED'
ELSE
DISPLAY C
END-IF
IF ADDRESS OF D = NULL
DISPLAY 'D IS OMITTED'
ELSE
DISPLAY D
END-IF
EXIT PROGRAM.

END PROGRAM COBX.

END PROGRAM COB1.


This works. However, I also tried:
CALL 'COBX' USING BY CONTENT 'AAAA'
OMITTED
'CCCC'

Where I, umm, omitted the OMITTED keyword as the fourth parameter.
According to the Cobol 2002 standard, I believe this would work:

From 14.8.4.3 General rules:
"11) If an OMITTED phrase is specified or a trailing argument is omitted,
the omitted-argument condition for that
parameter evaluates to true in the called program. (8.8.4.1.7,
Omitted-argument condition.)"

This does not appear to work in Enterprise Cobol. I would have expected to
see 'D IS OMITTED'. But I did not. It printed the value of D, which was
spaces (I guess; or something not readable).

I can't find anything in the IBM docs that say what should be expected in
this situation. All I could find was this:
----------------
4.2.1.3 Testing for OMITTED arguments

You can specify that one or more BY REFERENCE arguments are not to be passed
to a called program by coding the OMITTED keyword in place of those
arguments in the CALL statement.

For example, to omit the second argument when calling program sub1, code
this statement:

Call 'sub1' Using PARM1, OMITTED, PARM3

The arguments in the USING phrase of the CALL statement must match the
parameters of the called program in number and position.
In a called program, you can test whether an argument was passed as OMITTED
by comparing the address of the corresponding parameter to NULL. For
example:

Program-ID. sub1.
. . .
Procedure Division Using RPARM1, RPARM2, RPARM3.
If Address Of RPARM2 = Null Then
Display 'No 2nd argument was passed this time'
Else
Perform Process-Parm-2
End-If
----------------

Well, I guess maybe this statement says it in some ways:
"The arguments in the USING phrase of the CALL statement must match the
parameters of the called program in number and position."
Since the number of arguments does not match I guess the result is
undefined. Annoying! I wonder if they would consider following the
standard... Seems to me this would be a very simple change. The IBM
calling convention sets the high-order byte in the address of the last
parameter. So its easy to know which parameter was last, and then assume
parameters after that are omitted.

The main reason I would like this is that sometimes a subroutine needs to be
extended to allow for more parameters. When a new parameter is added then
all programs calling it need to be changed to pass the additional parameter,
even if they don't actually have a use for it. My hope was that with
omitted trailing arguments the subroutine could just check for them being
omitted, and not use them. The way that it stands I find very little use
for it.

So close and yet so far! Argh!

They should also allow the test to be "IF data-name IS OMITTED", which is
also in the standard (rather than checking for an address of NULL).

Oh well...

Frank

.



Relevant Pages

  • Re: CALL using OMITTED
    ... in COBOL for VSE/ESA. ... DISPLAY 'NEW TEST' UPON CONSOLE ... PROCEDURE DIVISION USING A B C D. IF ADDRESS OF A = NULL ... Omitted-argument condition.)" ...
    (comp.lang.cobol)
  • Re: CALL using OMITTED
    ... Thinking a little more about this, I do NOT think IBM will/should "easily" ... DISPLAY 'NEW TEST' UPON CONSOLE ... "11) If an OMITTED phrase is specified or a trailing argument is omitted, ... Omitted-argument condition.)" ...
    (comp.lang.cobol)
  • Re: CALL using OMITTED
    ... the '02 Standard level. ... DISPLAY 'NEW TEST' UPON CONSOLE ... PROCEDURE DIVISION USING A B C D. ... Omitted-argument condition.)" ...
    (comp.lang.cobol)