View previous topic :: View next topic
|
Author |
Message |
teethu thomas
New User
Joined: 17 May 2007 Posts: 24 Location: India
|
|
|
|
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 |
|
|
rameshfoa
New User
Joined: 05 Apr 2007 Posts: 27 Location: chennai
|
|
|
|
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 |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
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 |
|
|
ramfrom84
New User
Joined: 23 Aug 2006 Posts: 93 Location: chennai
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ramfrom84
New User
Joined: 23 Aug 2006 Posts: 93 Location: chennai
|
|
|
|
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 |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
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 |
|
|
ramfrom84
New User
Joined: 23 Aug 2006 Posts: 93 Location: chennai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|