IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Problem during a CALL statement.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dunkinjonats

New User


Joined: 14 Aug 2008
Posts: 2
Location: Philippines

PostPosted: Wed Apr 22, 2009 6:04 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Apr 22, 2009 6:14 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Apr 22, 2009 6:29 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Apr 22, 2009 6:30 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Apr 22, 2009 7:16 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Apr 22, 2009 7:33 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Call program, directly from panel CLIST & REXX 9
No new posts Batch call online program, EXCI task ... CICS 3
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
Search our Forums:

Back to Top