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

Linkage section problem


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

New User


Joined: 12 Mar 2010
Posts: 64
Location: India

PostPosted: Wed Jul 28, 2010 5:45 pm
Reply with quote

Program 1, Program 2 and Program 3 are calling a program say Program 4.

Program 1 is passing parameters A, B, C to Program 4
Program 2 is passing parameters B, C to Program 4.
Program 3 is passing parameters A, B to Program 4.


Program 1:

Code:
01 A  PIC X(10).
01 B  PIC X(9).
01 C  PIC X(8).

Call 'Program4' using A,B,C.


Program 2.

Code:
01 B  PIC X(9).
01 C  PIC X(8).

Call 'Program4' using B,C.


Program 3.

Code:
01 A  PIC X(10).
01 B  PIC X(9).

Call 'Program4' using B,C.



How do I code the Linkage section in Program 4 to handle this condition?

I declared linkage section in program 4 as follows:
Code:
01 A  PIC X(10).
01 B  PIC X(9).
01 C  PIC X(8).


and I was able to handle program 1 and program 3

using "If address of C = NULL."

But I am not able to handle program 2?
Can you please suggest me a way to do this?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Jul 28, 2010 5:51 pm
Reply with quote

your examples are inconsistent with your narrative.
hopefully your code is better.

if the following works:
if address of c = null

why not use it for all?

if address of a = null then...
if address of b = null then...
if address of c = null then...

??????

what is your problem?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jul 28, 2010 5:54 pm
Reply with quote

Code:
CALL 'PROGRAM4' USING OMITTED, B, C
and test in PROGRAM4:
Code:
IF  ADDRESS OF A = NULL
...
Back to top
View user's profile Send private message
Amb

New User


Joined: 12 Mar 2010
Posts: 64
Location: India

PostPosted: Wed Jul 28, 2010 7:06 pm
Reply with quote

@dbzTHEdinosauer
Program 2 passes B, C to program 4
and in Program 4 all the 3 variables A, B, C are defined

as parameter passing is done positionally so
B from program 2 will get collected in A of program 4
C from program 2 will get collected in B of program 4

also as the datatypes of A, B, C are different so data collected in program 4 will be incorrect

so I cannot check "if address of A = NULL"....

@Robert Sample
I think "ommit" in calling program should work but I need to make changes to the called program (ie. program 4) because I have around 100 calling programs which are calling this program 4.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Jul 28, 2010 7:32 pm
Reply with quote

AMBy,

poor design based on inadequate knowledge leads you to the only solution,
which you have mentioned in your note to Robert.
Back to top
View user's profile Send private message
ChowHan

New User


Joined: 16 Oct 2009
Posts: 15
Location: India

PostPosted: Thu Jul 29, 2010 12:00 am
Reply with quote

I wonder what would be the performance overhead of keeping the size of linkage area variable as (10 + 9 + 8)?

10 for A
9 for B
and 8 for C

and moving spaces to A before calling from program 2 which will use only parameters B and C and spaces in the first 10 characters.

Or you could consider passing name of the calling module along with the data, if there are more modules and larger number of combinations .
You could pass some sort of op-code (f1 for fetching customer data, f2 for fetching contract data etc.....) that would identify what needs to be done with the data passed to the subroutine.

Just a thought... I have seen it some old code...
In any case, how was this handled earlier, since you are talking of 100 modules already calling this module? Is program-1 a new program that requires some new functionality from the subroutine?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Jul 29, 2010 12:01 am
Reply with quote

Hello,

As you are still fairly early in the testing suggest you change the 100 programs to be consistent. . .

Hopefully the variables always contain the same type of info (i.e. A is a 3-byte alphanumeric, B is an 8-digit zoned-decimal, etc. . .)
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
Search our Forums:

Back to Top