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

Is ther any possibility of passing arrays to called programs


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Passing Parameters to Programs Invoke... PL/I & Assembler 5
No new posts Passing SYSPRINT to Invoked Program PL/I & Assembler 9
No new posts Finding Assembler programs PL/I & Assembler 5
No new posts step by step trace 4 ISPF dialog call... TSO/ISPF 17
Search our Forums:

Back to Top