Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Is ther any possibility of passing arrays to called programs

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
lucky.rohith
Currently Banned

New User


Joined: 06 Aug 2006
Posts: 10

PostPosted: Thu Aug 24, 2006 12:28 am    Post subject: Is ther any possibility of passing arrays to called programs
Reply with quote

Hi,

In C-language ter is a possibility of passing an array to the called program.
But is ther any possibility of passing arrays to called programs in COBOL.
If its is possible then were v hav to read the array either in the called or calling program.
Back to top
View user's profile Send private message

kondakonda

New User


Joined: 20 Mar 2006
Posts: 34

PostPosted: Thu Aug 24, 2006 4:31 pm    Post subject: Re: query reguarding arrays
Reply with quote

in COBOL an array element can only be passed to the subprogram not an array itself.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Aug 25, 2006 2:47 am    Post subject: Re: Is ther any possibility of passing arrays to called prog
Reply with quote

Yes you can pass an array to a called program.

Code:

    01  YOUR-ARRAY.
        02  ARRAY        OCCURS 500 TIMES.
            05 
            05
            :
       

        CALL ?YOURSUB? USING YOUR-ARRAY.


In the called (subroutine) define the array in the LINKAGE SECTION the same as in the main program.

Dave
Back to top
View user's profile Send private message
Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Fri Aug 25, 2006 11:14 am    Post subject: Re: Is ther any possibility of passing arrays to called prog
Reply with quote

Hi
Please see below how an array is passed to a called program(passtab) and return some value to the calling program.

Regards

Aji Cherian
**********************************

01 a.
02 b occurs 2 times.
03 c pic 99.
01 i pic 9 value 0.
01 so pic 99 value 0.
procedure division.
p1.
perform p2 varying i from 1 by 1 until i > 2.
call "passtab" using a so.
cancel "passtab".
display so.
stop run.
p2.
accept c(i).

********see passtab program below

01 i pic 9 value 0.
linkage section.
01 a.
02 b occurs 2 times.
03 c pic 99.
01 tot pic 99 value 0.
procedure division using a tot.
p1.
perform p2 varying i from 1 by 1 until i > 2.
exit program.

p2.
display c(i).
add c(i) to tot.
Back to top
View user's profile Send private message
kondakonda

New User


Joined: 20 Mar 2006
Posts: 34

PostPosted: Fri Aug 25, 2006 2:06 pm    Post subject: Re: Is ther any possibility of passing arrays to called prog
Reply with quote

Yes, we can pass the array. David is right.
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
No new posts Why myself doing Package Bind always ... Susanta DB2 5 Thu Mar 02, 2017 10:47 pm
No new posts How does a called pgm know if its cal... Graeme Westerman COBOL Programming 5 Tue Nov 29, 2016 9:25 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us