Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How CALL statement works in Cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
teethu thomas

New User


Joined: 17 May 2007
Posts: 24
Location: India

PostPosted: Fri May 18, 2007 10:14 am    Post subject: How CALL statement works in Cobol
Reply with quote

Hi,
Can somebody help me with Call statement in Cobol.

I want to know when we pass more than one group variables in the CALL statemnt ( while calling a subroutine ) how the data with in the variables get moved to the called program. Is it getting moved as a byte stream or is it gets moved variable vise.

Just see this example

Call 'abc' using xyz
yxz
zxy.


Suppose this xyz is a group variable of size 50
yxz is a group variable of size 75
zxy is a group variable of size 75

In the called program it is like

Procedure Division USING xyz
cde
ght.


Xyz size 50
cde size 150
ght size 75.

Will the data coming from the zxy go into cde or will it come into ght as we want it.
Back to top
View user's profile Send private message

rameshfoa

New User


Joined: 05 Apr 2007
Posts: 27
Location: chennai

PostPosted: Fri May 18, 2007 12:03 pm    Post subject:
Reply with quote

I believe they are moved variable wise....so zxy would come into ght...also....if a variable in called program has less size than that of calling program...then it will not ovrwrite in next variable instead truncated...

ex,

calling pgm,

xyz is 50
yxz is 75
zxy is 75

called pgm,
xyz is 50
cde is 50
ght is 75


then...part of yxz will not overwrite in ght...instead truncated...
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Fri May 18, 2007 1:26 pm    Post subject:
Reply with quote

Quote:
Is it getting moved as a byte stream or is it gets moved variable vise.

What did your book say about call?
If you haven't read the book yet then read it first. You will find about CALL BY REFERENCE AND CALL BY VALUE, then you may understand 'call' and 'your own question'.
Back to top
View user's profile Send private message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Fri May 18, 2007 5:53 pm    Post subject:
Reply with quote

CALL in cobol will work as mention below example :

In Variable mention in CALL USING of Main program should be same order as in the linkage section of Sub program , If u interchange the variable in CALL USING corresponding changes to made in the Linkage section OF SUB PROGRAM ,If not then S0C7 abend occurs due to mismatch move occurs

Example :

Main Program :

Code:


WORKING STORAGE SECTION :

 01  CALL-VARIABLE1      PIC X(100)
 01  CALL-VARIABLE2      PIC X(200)
 COPY COPBOOK-NAME

PROCDURE DIVISION:
 
 CALL SUB-PROGRAM NAME USING CALL-VARIABLE1,
                                                    CALL-VARIABLE2,
                                                    COPYBOOK-NAME.



In Sub Program :
Example:

Code:
         
LINKAGE SECTION:
 01  CALL-VARIABLE1      PIC X(100)
 01  CALL-VARIABLE2      PIC X(200)
 COPY COPBOOK-NAME

PROCEDURE DIVSION.
U can use the variable
MOVE CALL-VARIABLE1  TO WS-VARIABLE-NAME.

....


When ABEND Occurs :

Code:
         
LINKAGE SECTION:
  01  CALL-VARIABLE2      PIC X(200)
  01  CALL-VARIABLE1      PIC X(100)
  COPY COPBOOK-NAME

PROCEDURE DIVSION.
U can use the variable
MOVE CALL-VARIABLE1  TO WS-VARIABLE-NAME.

....


Because CALL-VARIABLE1 of 100 bytes moved to 200 bytes of CALL-VARIABLE2 and vicevesa ...

I think u can understand about the CALL
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri May 18, 2007 7:18 pm    Post subject:
Reply with quote

ramfrom84 wrote:
In Variable mention in CALL USING of Main program should be same order as in the linkage section of Sub program , If u interchange the variable in CALL USING corresponding changes to made in the Linkage section OF SUB PROGRAM ,If not then S0C7 abend occurs due to mismatch move occurs
No, they must be in the same order listed on the procedure division line (which you failed to list), but in the linkage section, any order is fine..
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri May 18, 2007 11:56 pm    Post subject:
Reply with quote

Hello,

For this
Quote:
Is it getting moved as a byte stream or is it gets moved variable vise.


Most of the time the data is not moved at all. The called program linkage/using establishes addressability back to the data in the calling program.

Said differently, there is usually only one copy of those data fields.

As was suggested previously, you may want to read more in the manual (which you can link to from this site).
Back to top
View user's profile Send private message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Mon May 21, 2007 3:07 pm    Post subject: Re: How CALL statement works in Cobol
Reply with quote

Sorry.. some code was missing,

Some of member said above , The Call using structure and procedure division using should be same since i have tested. It can't be different .
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Mon May 21, 2007 6:00 pm    Post subject:
Reply with quote

Quote:
Some of member said above , The Call using structure and procedure division using should be same since i have tested.

what did you test? Please paste the code so that we can understand your point and can give suggestions if needed...
Back to top
View user's profile Send private message
ramfrom84

New User


Joined: 23 Aug 2006
Posts: 93
Location: chennai

PostPosted: Tue May 22, 2007 8:20 pm    Post subject:
Reply with quote

Hi ,
when i code the program , i want to add new linkage section , i got this abend,, See teh sample code below


In the call i mention as below

Code:

CALL SUB-PROGRAM NAME USING CALL-VARIABLE1,
                                                    CALL-VARIABLE2,
                                                    CALL-VARIABLE3,
                                                    COPYBOOK-NAME.


Similar i mention the procdure division as below
Code:

PROCEDURE DIVSION USING       CALL-VARIABLE1,
                                                    CALL-VARIABLE2,
                                                    COPYBOOK-NAME
                                                    CALL-VARIABLE3.

 


S0C7 Abend occurs due to mismatch in data , When i look into the program i find CALL-VARIABLE3 is moved to COPYBOOK_NAME.Then i correct and run it..

so the order given in the call and Procedure must be same.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed May 23, 2007 12:07 am    Post subject:
Reply with quote

Hello,

Quote:
so the order given in the call and Procedure must be same.

Yes.

Keep in mind that when the CALL is executed the parm list not being passed based on names - what is passed is a list of addresses. The compiler needs the names to resolve lengths and displaces, but the run-time does not use names. You must ensure the calling and called modules are in sync.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm
No new posts ON 2 AND EVERY 1 - Statement ??? UmeySan COBOL Programming 2 Tue Jul 25, 2017 1:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us