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

How to Pass Array to subroutines.


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Tue Feb 05, 2008 11:29 pm
Reply with quote

I have a array called SYM.0 in the main program and I need to pass the array variable to another subroutine.

How can i do this.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 05, 2008 11:48 pm
Reply with quote

the subroutine must be in the same source file,
snippet...

subroutine:procedure expose sym.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Wed Feb 06, 2008 1:12 am
Reply with quote

Yes they are in the same source file.'

This is how I have passed.

Code:
ADDRESS ISPEXEC "VPUT (DSNSTMT SYM) PROFILE"
CALL DSNPROCS                               


This is how i am getting it.

Code:
ADDRESS ISPEXEC "VGET (DSNSTMT SYM) PROFILE"


I am not clear with the one you have said earlier.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Feb 06, 2008 1:58 am
Reply with quote

maybe Your request was not very clear to me
I inferred that in the main flow You had an array ...
improper term for a stemmed variable
and You wanted to use the same in a subroutine

Code:
....
sym.0 = 2
sym.1 = "one"
sym.2 = "two" 

do i = 1 to sym.0
   say "mainprog  " i sym.i
end

say "calling mysub"
call mysub

exit

mysub:procedure expose sym.
do i = 1 to sym.0
   say "mysub    " i sym.i
end
return


but from Your second post i see that You are passing by using ispf vput service
a simple variable called SYM, not ann array or a stem...

please clarify
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Wed Feb 06, 2008 4:59 am
Reply with quote

You are correct I have passed just the SYM as if I was passing the SYM.0 it was throwing me an error using the ISPEXEC.

So I was trying different option.

I tried your way of using the procedure.

First program TEST

Code:
/**REXX*/                                         
DSNAME.1='&HLQV.SECU.ABCP.DRIVER'                 
DSNAME.2='&HLQ.&SYS..&JOB..NOTPSTED.REPORT'       
DSNAME.3='&HLQV&VER&SYS..POST20.TEMP.LTRQ.CLUSTER'
DSNAME.4='&HLQ.&LSCID..&RCVR.&SNDR.VERI.RESPONSE'
DSNAME.0 = 4                                     
                                                 
  CALL TEST1                 
EXIT(0)
 


The TEST1 Program

Code:
/* REXX */                     
 TEST1:PROCEDURE EXPOSE DSNAME.
                               
 DO I = 1 TO DSNAME.0         
    SAY 'DSNAME' DSNAME.I     
 END                             
RETURN
 



When i run the TEST program its showing me Error as

2 +++ PROCEDURE EXPOSE DSNAME.
IRX0017I Error running TEST1, line 2: Unexpected PROCEDURE
8 +++ CALL TEST1



I am not sure If I was clear with my question I am sorry.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Wed Feb 06, 2008 12:04 pm
Reply with quote

Krishna -

As Enrico already said, "the subroutine must be in the same source file", that is - your main routine and your called subroutine should be in the same member in order to use the PROCEDURE instruction (as clearly noted in the fine manual).

If you want to pass arrays to external subroutine, you need to compose your own logic. For this, you can
- Use the QUEUE
- Write to dataset (probably temporary)
- Use VPUT/VGET with INTERPRET
- Concatenate the values into one string with delimiter in between
- Use the variable access routine IKJCT441
etc...

O.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Wed Feb 06, 2008 7:33 pm
Reply with quote

As I already mentioned both the TEST and TEST1 member are in the same PDS.

or the main routine and the subroutine are in the same source.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Feb 07, 2008 6:20 pm
Reply with quote

what we meant was that ...

main and subroutines ( for expose to work ) must be in the same source member

not... different members of the same source PDS
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Feb 07, 2008 10:35 pm
Reply with quote

If You need to pass stems across rexx scripts, search the net with
"STEMPUSH" and/or "STEMPULL"
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Feb 07, 2008 10:41 pm
Reply with quote

You know, this is the second post by this O/P on this same topic. All of these answers were given the first time too.

I really don't get what the big deal is with just writing the data to a temp (VIO) dataset from one exec, and reading it from a different exec or clist. They can go back-and-forth all day long like this.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Feb 07, 2008 10:58 pm
Reply with quote

the other time He was asking about simple variables,
and the VPUT/VGET approach was viable

not the same thing for stem, if the subroutine is getting called
let' s say, for each record read, then the performance would be horrible..
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Thu Feb 07, 2008 11:01 pm
Reply with quote

Quote:
not the same thing for stem, if the subroutine is getting called
let' s say, for each record read, then the performance would be horrible..

That's a good reason to use an internal subroutine, or to use COBOL with IKJCT441 ....

O.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Fri Feb 08, 2008 2:20 am
Reply with quote

I dont think I have raised the this question in another post of mine. If I misunderdtood I am sorry.

The code that I have showed in here is just a example actually I need to know how to pass the stem variable which will be used in my code which is too big to post here.

thanks for the input I will search for STEMPUSH and PULL
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Feb 08, 2008 7:58 am
Reply with quote

Hello,

Quote:
I need to know how to pass the stem variable which will be used in my code which is too big to post here.
You might consider making a much smaller bit of code to test passing the variable. Once the test works, incorporate the method that works for you into the main code.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Fri Feb 08, 2008 9:51 am
Reply with quote

Yes I will do that way, but I am not sure how to pass the stem variable across program.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Feb 08, 2008 8:11 pm
Reply with quote

Hello,

If you build the 2 "test" sets of code (using the suggestions above) and have questins/problems, you could post the small test code and someone would probably have suggestions.

Until you post what you have and what error(s) are presented - or what does not work as you want, it will be difficult for someone to offer specifics.
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts Dynamically pass table name to a sele... DB2 2
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts pass data as symbolic parameter from ... CLIST & REXX 2
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
Search our Forums:

Back to Top