Joined: 14 Aug 2008 Posts: 2 Location: Philippines
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?
Joined: 14 Jan 2008 Posts: 2504 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.
* ONLY PASSING PARMS 01-03. POSITIONS 04-08 ARE SPACES.
MOVE 'YYY' TO WS-PARM-MASK.
CALL WS-SUB-PGM USING WS-PARM-MASK,
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.
Joined: 18 Jul 2007 Posts: 2150 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.