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

Number of parameters in Linkage


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

New User


Joined: 16 Mar 2006
Posts: 21

PostPosted: Wed Jan 27, 2016 5:13 pm
Reply with quote

hello all,

i need to know wich parameter is last given, when the subprogram is called.

Program a
call 'subpgm' using a, b, c

Program b
call 'subpgm' using a, b

Program c
call 'subpgm' using a

subpgm
linkage
01 a PIC x(10).
01 b PIC x(07).
01 c PIC x(05).
procedure division using a, b, c.
.
.
.
goback

how can i know how much paramters has the
mainprogram given to the subprogram?

regards
kai
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 27, 2016 5:36 pm
Reply with quote

Why do you want to know that?

The traditional way if there is a valid reason for a program to receive different numbers of parameters is to have something in the first item which indicates that. An IO-subroutine that knows from O(pen) and C(lose) that there is no record-area required, for instance.
Back to top
View user's profile Send private message
kregen

New User


Joined: 16 Mar 2006
Posts: 21

PostPosted: Wed Jan 27, 2016 5:53 pm
Reply with quote

hi Bill,
i want to check that the mainprogram has given the parameters that the subprogramm needed.

example
function open no other parameter needed
function close no other parameter needed
function insert one other parateer is needed
function update two other parameter are needed

when the parameter wasn't give then the modul crash. i don't like it.
i want to give the result 'Parameter is Missing'.

In REXX have i no Problem to do this.

regards
Kai
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Jan 27, 2016 6:13 pm
Reply with quote

Are you saying that the sub-program actions the first parameter without first checking that any required subsequent parameter has been passed? If so, then do the proper thing and edit your parameters first BEFORE actioning. If necessary then have the calling program pass a parameter coiunt as the first parameter and move the other parameters down one (p1 becomes p2 etc).
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 27, 2016 6:21 pm
Reply with quote

Well, COBOL isn't rexx.

It crashes or otherwise goes badly in testing. It gets fixed. Once it is fixed, there is nothing to worry about.

Once you are up-and-running, say that your subroutine is CALLed 100m times a day/week/month. You want to check each time that the correct number of parameters are used, even though it is only when there is a new use of the subroutine that could get the number of parameters wrong?

Whether you like it or not, matching the order and number of parameters on a CALL to the PROCEDURE DIVISION USING (or ENTRY USING) is down to the programmer.
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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top