Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number of parameters in Linkage

Status
Not open for further replies.

pardizzi

Technical User
Apr 30, 2007
3
CH
Does anyone know if there is a way of knowing how many parameters have been sent by a calling program though a "call using ..." statement?
The goal is to extend the parameter list of a called program without impacting on calling programs.
For example, let's say there is a program that receives three parameters and I add a fourth one. Existing calling programs keep on passing three parameters and new ones pass four parameters.
The called program checks how many parameters have been passed and references the fourth one only in case four parameters have been passed (to avoid 0C4).
Environment is mainframe Z/OS.
Thanks for helping.
Pier
 
Can't you use a syntax like this ?
IF ADDRESS OF Parm4 = NULL

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried checking the address for NULL and it won't work in all cases. Seemed that once you called with 4 addresses, it was never null again during that execution.

I had to do just what you're doing a few years ago and got help from this site.

The last parameter sent is marked with a binary '1' in the leftmost bit of the address, therefore it is a negative number. You pass the addresses in and receive them as binary numbers and check to see which one is negative to determine how many parameters you have.

Ex.
LINKAGE SECTION.
01 L-ADDR-1 BINARY PIC S9(09).
01 L-ADDR-1-POINTER REDEFINES L-ADDR-1 POINTER.

01 L-ADDR-2 BINARY PIC S9(09).
01 L-ADDR-2-POINTER REDEFINES L-ADDR-2 POINTER.

01 L-PARM-1 PIC X(25).
01 L-PARM-2 PIC X(10).
PROCEDURE DIVISION USING BY VALUE L-ADDR-1 L-ADDR-2.
SET ADDRESS OF L-PARM-1 TO L-ADDR-1-POINTER.
IF L-ADDR-1 > +0
SET ADDRESS OF L-PARM-2 TO L-ADDR-2-POINTER
END-IF

You'll have to figure out from there what to do if you do not have the second address.

 
This method works only for IBM Maiframes. Other os's and compilers will have different methods or none at all. Give us your OS and compiler info.
 
Thanks everyone for contributing.

Mainframe is IBM, Z/OS is 1.4 and Cobol is V2R2M0.

Anyway I feel that, in general, what I'm trying to achieve is a bit "borderline", and therefore too risky.

The approach I'll probably follow is the following:
- create a new called program exposing all the needed params
- transform the current called program into a program that simply adds the new params and calls the new called programs (for compatibility with current calling programs)
- new calling programs will address directly the new called program

Thanks again
Pier
 
To PHV: unfortunately address of "non sent" params is never null (this was my first attempt to solve the issue).
 
Z/OS is a successor to OS/370, etc, I am told. This being the case, what the program actually gets is a pointer (In Reg 13) of the parameter list. In normal COBOL, this list is hidden from the COBOL code and the addresses of the passed variables are resolved at entry time. You might try the poorly documented non-standard IBM extension SERVICE RELOAD. I am not sure of the syntax. This causes the addresses of passed variables to be reevaluated. It may force the addresses of non-passed variables to become NULL.

Another posibility is to look at compiling the program as though it were a CICS COBOL program. When this is done, the COBOL code gains addressibililty to the parameter address list. I don't know what other repercusions doing this might have, though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top