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
 
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 pointers on using USS and C programs. Pedro All Other Mainframe Topics 0 Wed Oct 04, 2017 4:38 am
No new posts LIBDEF not working in called proc packerm CLIST & REXX 0 Fri Sep 15, 2017 7:22 pm
No new posts PLI - printing from multiple programs Pedro PL/I & Assembler 8 Fri Sep 08, 2017 6:36 am
No new posts Passing data from REXX to C programme... chong.zhou CLIST & REXX 3 Wed Jul 26, 2017 9:11 pm
No new posts Could we identify the called modules ... elixir1986 COBOL Programming 5 Fri Jul 14, 2017 1:53 am

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