View previous topic :: View next topic
|
Author |
Message |
dunkinjonats
New User
Joined: 14 Aug 2008 Posts: 2 Location: Philippines
|
|
|
|
Hello,
I recently encountered a run time error in my CALL statement.
In my calling program i had 3 parameters that are passed but the called program was expecting that i have four parameters to be passed.
I was wondering if this kind of error could be caught during compilation/link phase...? Or is this is just one of those errors that we really need to watch out for since this could not be caught and only seen during run time?
Thanks. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
yes, you have to test.
unlike JAVA and C, where the GUI Dev will flag such things,
Mainframe COBOL does not have that capability.
Could be that PC based development tools for COBOL have that.
Though one could write a REXX Macro
to compare the USING List of the Procedure Division of the CALLed program
to the USING List of the CALL as you EDIT the module.
But then again,
with split-screen,
it is very easy to VIEW the CALLed module in another session,
and determine if the CALL you are coding is correct. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
You could change the parmlist, to include a "mask" (for example, a PIC X(08)), which is initialized to SPACES and then for each passed-parm, you would set the mask-position to a "Y", which indicates to the sub-program that this parm has been passed.
I'm using an 8-Byte mask only as an example, but it may be OK to keep it as it can be used for expansion if the number of parms ever grows in the future.
EG:
Code: |
03 WS-PARM-MASK PIC X(008).
03 WS-PARM-01 PIC X(256).
03 WS-PARM-02 PIC X(256).
03 WS-PARM-03 PIC X(256).
03 WS-PARM-04 PIC X(256).
03 WS-SUB-PGM PIC X(008) VALUE 'MYSUBPGM'.
* ONLY PASSING PARMS 01-03. POSITIONS 04-08 ARE SPACES.
MOVE 'YYY' TO WS-PARM-MASK.
CALL WS-SUB-PGM USING WS-PARM-MASK,
WS-PARM-01,
WS-PARM-02,
WS-PARM-03,
WS-PARM-04.
|
Although all four parms are in the the CALL USING, when the sub-program gains control, it will look at the parm-mask to determine which parms should be addressed.
Your sub-program LINKAGE SECTION, needs to be modified and the 8-Byte mask-parameter must be added. In addition, the parmlist in the PROCEDURE DIVISION USING must be changed to include the mask-parameter first, then followed by the four current parms.
HTH....
Regards, |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
IIRC, at runtime, you could check the address of each of the passed items and if low-values, it ain't there so don't access it. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
CICS Guy,
You rattled my brain and IIRC, you can "OMIT" parameters from a parmlist, either using the keyword "OMIT" or substituting a given parm with a comma.
Then the sub-program can check the ADDRESS OF each defined parm for NULL or NOT NULL.
And I'm sure this is documented somewhere in the applicable COBOL manual....
Regards, |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Back in the "static" call days, I'd update common subroutines and use additional passed fields. To avoid problems with existing code, checking the newest added passed field for addressability, I'd get the routine to run correctly for all programs. |
|
Back to top |
|
|
|