Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Variable call list in COBOL CICS program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vabond

New User


Joined: 15 Oct 2008
Posts: 3
Location: Oregon

PostPosted: Fri Oct 17, 2008 3:17 am    Post subject: Variable call list in COBOL CICS program
Reply with quote

Hello folks,
I have an Assembler CICS program that is called by multiple COBOL programs. I am trying to rewrite it in COBOL. The problem is that the various programs that call it pass a variable number of parms in the call.
I need to figure out how many parms were used to call this program.
I tried the ADDRESS OF with a comparison to nulls but it did not work.
Any suggestions?
Thanks in advance,
Victor
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 17, 2008 3:20 am    Post subject:
Reply with quote

Hello Victor and welcome to the forum,

How does the assembler code detect the number of parms?
Back to top
View user's profile Send private message
vabond

New User


Joined: 15 Oct 2008
Posts: 3
Location: Oregon

PostPosted: Fri Oct 17, 2008 3:31 am    Post subject: Reply to: Variable call list in COBOL CICS program
Reply with quote

The assembler program just counts the parms in the parm list until it finds the x'80' in the high order byte of the address.
Thanks
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Oct 17, 2008 3:45 am    Post subject: Re: Variable call list in COBOL CICS program
Reply with quote

Victor,

You could set a WS POINTER to the ADDRESS OF each parm, redefining the POINTER as PIC X(04) and then test the high-order byte of the redefined POINTER for a value not less than X'80'.

I never tried this so this is a SWAG on my part....

Bill
Back to top
View user's profile Send private message
vabond

New User


Joined: 15 Oct 2008
Posts: 3
Location: Oregon

PostPosted: Fri Oct 17, 2008 4:34 am    Post subject: Reply to: Variable call list in COBOL CICS program
Reply with quote

Bill,
Tried your suggestion. No go. In fact, I displayed the addresses for each and they all appeared to have addresses. Not sure what COBOL is doing. Here is what it looks like:

Program A:
CALL PROGRAM-C USING PARM-1, PARM-2, PARM-3.

Program B:
CALL PROGRAM-C USING PARM-1, PARM-2, PARM-3, PARM-4.

Program C:
PROCEDURE DIVISION USING PARM-1, PARM-2, PARM-3, PARM-4.

Program C needs to be able to determine if it was called with 3 or 4 parms.
Thanks again.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 17, 2008 7:12 am    Post subject:
Reply with quote

Hello,

Maybe this would be a stop-gap until a better solution presents itself.

Write a new little "filter" in assembler that always calls the cobol replacement module with 4 parameters. Keep the current logic to check for "last parm" and when this filter calls the replacement code, it would place a constant value in the unused parm(s) (i.e. "NONE", or x'FF', or whatever).

This would allow the cobol replacement of the business functionality quickly.

FWIW. . .
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7999
Location: Bellevue, IA

PostPosted: Fri Oct 17, 2008 5:45 pm    Post subject:
Reply with quote

The COBOL Application Programming Guide says this:
Quote:
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
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 17, 2008 7:09 pm    Post subject:
Reply with quote

1. Program-C can not be a CICS module
(i.e. a module that invokes CICS APIs),
since Program-C is invoked via a COBOL CALL.

2. The COBOL compiler generates the necessary register population (the CALL)
and the code to provide addressability for linkage section entries (USING ).

3. Program-C's compiler generated code will always provide addressability to all four parms.

4. Program-C's address for parm-4 will be radically different for that of parm-3,
depending on if Program-C is CALLed from Program-A (3 parm CALL) or Program-B (4 parm CALL).

5. I don't think the OP wants to modify any Program-As or Program-Bs, so the OMIT is not to helpful.

don't have access to a mainframe until Monday, so I can not check anything out,
but, I believe what Bill suggested to do should have worked,
had his suggestion been implemented properly.

May not be the hex80,
as I can not remember if it is a simple 'move address'
or set register, move address that is generated by the compiler for the USING phrase.

But there should be an easy way to determine number of parms passed.
====================
If there are 3 or 4 parms, is there no code in parm-1,2,or 3 to indicate what is going on?

what actually does Program-C do?

I don't think the OP has a lot of experience.
OP mentioned that he had no idea what the COBOL code did for addressability.
That's not to tough since one only has to look at the object generated.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7999
Location: Bellevue, IA

PostPosted: Fri Oct 17, 2008 7:44 pm    Post subject:
Reply with quote

The last part of the manual I quoted said
Quote:
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
I have tested this using a batch program and a COBOL program can distinguish between being passed 3 and 4 parameters by testing the address of the 4th parameter to be NULL. I haven't done a lot of testing so I'm not sure if there are conditions that could affect the results, but the called program displayed different messages based on getting 3 or 4 parameters.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Fri Oct 17, 2008 7:53 pm    Post subject: Reply to: Variable call list in COBOL CICS program
Reply with quote

the fastest approach would be to have an assembler stub
to analyze the number of parameters passed
and call the cobol subroutine ( which has to be written yet , if I understand correctly)
with an augmented parameter list where the first parm is the number of the parms that follow
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts Asynchronous CICS Processing Question moezbud CICS 0 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us