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

How to create PROC in CLIST?


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

New User


Joined: 21 Feb 2009
Posts: 11
Location: India

PostPosted: Mon Jan 24, 2011 11:29 am
Reply with quote

Hi,

I have a CLIST code which will search the given member in a list of libraries given by the user. For example in the code given I have 5 libraries. If the member found in any of the librarie or all the libraries, it will list all the library names. If not it will say "MEMNAME NOT FOUND IN ANY LIBRARY LISTED ABOVE".

CLIST code for this:
==============

The CLIST code is around 75 lines. So I have attached here for your reference.
-----------------------------------------------------------------------------------
In the code starting from the line 27 to 71, the lines were repeated (means it will check in the Library 1 and so on till the end, if member found "SET FOUND = YES" switch will be enabled, else it is NO).

My requirement/need:
=====================
If a user wants to give 100 Library means, it is very difficult for them to edit all the repeated lines mentioned above. Am not aware of the PROC concept in CLIST. So can somebody please help me in writing a PROC for this?

Thanks in advance...

Regards,
Raje1002
Back to top
View user's profile Send private message
Raje1002

New User


Joined: 21 Feb 2009
Posts: 11
Location: India

PostPosted: Mon Jan 24, 2011 12:09 pm
Reply with quote

For easier reference I'll post the code here!!!

PROC 1 MEMNAME
/* CONTROL LIST MSG CONLIST */
/*********************************************************************/
/*** CLIST: FINDMEM ***/
/*** DESC: FIND MEMBER(S) LISTED IN DATASETS BELOW. ***/
/*** PANEL: NONE ***/
/*** HELP: NONE ***/
/*** NOTE(S): - THE NUMBER OF 'SET LIBNN' MUST EQUAL 'DO WHILE' ***/
/*** - EXAMPLE ON TSO COMMAND LINE: TSO FINDMEM MEMBNAME ***/
/*********************************************************************/
/*--- LOAD LIBRARIES ---*/
SET LIB1 = LIB.DATASET.#01
/*--- JOB/JCL LIBRARIES ---*/
SET LIB2 = LIB.DATASET.#02
/*--- COPY BOOK LIBRARIES ---*/
SET LIB3 = LIB.DATASET.#03
/*--- COBOL SOURCE LIBRARIES ---*/
SET LIB4 = LIB.DATASET.#04
/* CONTROL CARD LIBRARIES ---*/
SET LIB5 = LIB.DATASET.#05
SET CN=0
WRITE *** SEARCHING PDS DATASETS FOR MEMBER &MEMNAME ***
DO WHILE &CN < 5 /*CHANGE TO LAST LIB NUMBER FROM LIB## ABOVE */
SET &CN = &CN + 1
SET &VAR = &&LIB&CN
SET &STATUS = &SYSDSN('&VAR(&MEMNAME)')
IF &CN = 1 THEN DO
IF &STATUS = OK THEN DO
WRITE ===> &MEMNAME FOUND IN &VAR <===
SET FOUND = YES
END
ELSE DO
RETURN
END
END
IF &CN = 2 THEN DO
IF &STATUS = OK THEN DO
WRITE ===> &MEMNAME FOUND IN &VAR <===
SET FOUND = YES
END
ELSE DO
RETURN
END
END
IF &CN = 3 THEN DO
IF &STATUS = OK THEN DO
WRITE ===> &MEMNAME FOUND IN &VAR <===
SET FOUND = YES
END
ELSE DO
RETURN
END
END
IF &CN = 4 THEN DO
IF &STATUS = OK THEN DO
WRITE ===> &MEMNAME FOUND IN &VAR <===
SET FOUND = YES
END
ELSE DO
RETURN
END
END
IF &CN = 5 THEN DO
IF &STATUS = OK THEN DO
WRITE ===> &MEMNAME FOUND IN &VAR <===
SET FOUND = YES
END
ELSE DO
RETURN
END
END
IF &FOUND NE YES THEN DO
WRITE ***> &MEMNAME NOT FOUND IN ANY LIBRARY LISTED ABOVE.<***
END

Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Mon Jan 24, 2011 3:34 pm
Reply with quote

AD 2011 you write REXX, not CLIST.

Read about REXX and more specifically about STEMs.
Back to top
View user's profile Send private message
pmvino

New User


Joined: 22 Aug 2008
Posts: 20
Location: india

PostPosted: Mon Jan 24, 2011 4:01 pm
Reply with quote

Have u written the code or copied from net.... The code is REXX.. search more in net and find ur ans... it is so simple....
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Jan 24, 2011 4:04 pm
Reply with quote

pmvino wrote:
Have u written the code or copied from net.... The code is REXX.. search more in net and find ur ans... it is so simple....

What are you on about.
The code ahown is CLIST
Back to top
View user's profile Send private message
Raje1002

New User


Joined: 21 Feb 2009
Posts: 11
Location: India

PostPosted: Mon Jan 24, 2011 4:39 pm
Reply with quote

Yeah Its CLIST and I want to know how to write a PROC (Procedure) to make the below lines standard.

"IF &CN = 1 THEN DO
IF &STATUS = OK THEN DO
WRITE ===> &MEMNAME FOUND IN &VAR <===
SET FOUND = YES
END
ELSE DO
RETURN
END
END"

For the next time it will go to the &CN = 2 and wil do the search. Like wise it will go for the "N" number of datasets we have given.

For instance if we have 100 datasets means, I need to repeat the above 9 lines 100 times. I want to pass the CN value thru PROC so that we can minimize the code. Can you please help on this...
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Mon Jan 24, 2011 5:03 pm
Reply with quote

Raje1002 wrote:
Yeah Its CLIST
.
.
.
.
Can you please help on this...


Yes, we told you what to do!

Now go away, rewrite your routine in REXX and only come back if you need help with that!
Back to top
View user's profile Send private message
Raje1002

New User


Joined: 21 Feb 2009
Posts: 11
Location: India

PostPosted: Thu Jan 27, 2011 11:34 am
Reply with quote

I got the desired code with the help of my Project lead..

Here is the simplified code:

SET CN=0
SET MAX = 100
WRITE *** SEARCHING PDS DATASETS FOR MEMBER &MEMNAME ***
DO CN = 1 TO &MAX BY 1
SET &VAR = &&LIB&CN
SET &STATUS = &SYSDSN('&VAR(&MEMNAME)')
IF &STATUS = OK THEN DO
WRITE ===> &MEMNAME FOUND IN &VAR <===
SET FOUND = YES
END
END
/*
IF &FOUND NE YES THEN DO
WRITE ***> &MEMNAME NOT FOUND IN ANY LIBRARY LISTED ABOVE.<***
END
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: Thu Jan 27, 2011 1:48 pm
Reply with quote

Good to hear this is working - Thank you for sharing your solution icon_smile.gif

d
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 CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts How to create a list of SAR jobs with... CA Products 3
No new posts create rexx edit Macro that edits the... CLIST & REXX 3
No new posts COBOL - create and write to output fi... COBOL Programming 0
No new posts Best way to create an automated line ... TSO/ISPF 3
Search our Forums:

Back to Top