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
 
Combining 2 similar procs in one?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
kbrahma

New User


Joined: 08 Oct 2007
Posts: 38
Location: Delhi

PostPosted: Fri Nov 27, 2009 1:24 pm    Post subject: Combining 2 similar procs in one?
Reply with quote

Good Day Everyone,

I have coded 2 different procedures (with a little help from this forum) for reading and writing in a PDS member. They are both very similar but ofcourse they are two separate procs for a reason. I was wondering if it is possible to combine both of them into one proc, making my code much smaller and easier to understand. I will give a brief intro of what both of my procs do;

This one reads (indd.i) a member in a PDS and searches for a string in the variable filestr.n, when it finds the string it starts reading the contents below it. After reaching a certain keyword (bttmline) inside the file, it writes the content in another PDS member (memname.n). Then it continues reading the member to find a different keyword in the variable filestr.n and write it on a new member in memname.n.

So this basically extracts certain portions of a file by reading sequentially and writes them in different members of a PDS.

Code:
do i = 1 to indd.0             
   if pos(filestr.n,indd.i) > 0 then                 
     do                                                           
       "alloc shr fi(outdd) dataset('"PDS"("memname.n")')"   
        do a = i+1 to indd.0         
           dslist = delstr(indd.a,44)                             
           if pos('bttmline',indd.a) > 0 then leave             
           push dslist                                           
           "execio 1 diskw outdd"                                 
        end                                                       
        "execio 0 diskw outdd (finis"                             
        "ispexec edit dataset('"PDS"("memname.n")')"         
        "free fi(outdd)"                                         
        leave                                                     
     end                                                         
end         

-------------------------------------------------------------------------------------

This one on the other hand reads the member and looks for a certain texts which can be present anywhere in the file. It selects the lines which contains those keywords and prints them in a PDS member (bookmem).

Code:
do i = 1 to indd.0                                                 
   if pos('Txt2find',indd.i) > 0 then   
      do                                                           
        "alloc shr fi(outdd) dataset('"PDS"("bookmem")')"     
        do a = i to indd.0         
           if pos('Txt2find',indd.a) > 0 then                       
              do                                                   
                 books = delstr(indd.a,44)                         
                 push books                                         
                 "execio 1 diskw outdd"                             
              end                                                 
         end                                                       
        "execio 0 diskw outdd (finis"                             
        "ispexec edit dataset('"PDS"("bookmem")')"           
        "free fi(outdd)"                                           
        leave                                                     
      end                                                         
end           


I can combine the variable in bookmem to loop in memname.n but I get very undesirable results when I try to combine the 2 procs.

So firstly, is it possible to combine these 2 bad boys in one? and secondly, if it is possible, can I have a few logical pointers (pseudo code) on how to go about it?

Thanks in advance,
Kushal

P.S. I have come a long way since asking my first question in REXX a couple of weeks ago. But I am still a beginner in REXX and programming in general. icon_redface.gif
Back to top
View user's profile Send private message

suthish

New User


Joined: 27 Apr 2009
Posts: 3
Location: bangalore

PostPosted: Fri Nov 27, 2009 2:01 pm    Post subject:
Reply with quote

Could you please brief shortly what exactly tje requirement is..

Few Queries:

U want to search the two strings in the same PDS and extract it in different PDS.??

In that case u can use or condition in the first loop itself...
Back to top
View user's profile Send private message
kbrahma

New User


Joined: 08 Oct 2007
Posts: 38
Location: Delhi

PostPosted: Fri Nov 27, 2009 2:24 pm    Post subject:
Reply with quote

Hi Suthish,

In short:
I want to combine both of the procs (in my previous post) into a single proc. They are very similar but they read/write into a file differently.

My first proc reads and writes the file sequentially (from top to bottom) and exists when a keyword is found. Then it continues reading (the SAME file) after that keyword till the same keyword is found again and it prints that portion too in a different member. So it reads and writes portions of same file and print it in different members in a PDS.

The second one finds keywords in a file and prints the lines containing those keywords in a member of a PDS.

and to answer your question:
No, it's all happening in only one PDS.

What I want to achieve is a SINGLE proc (instead of 2) which breaks and prints the contents of a SINGLE file into multiple members of a single PDS.

I have achieved what I wanted in 2 procs, I was wondering if I can do it in one or just make the code a little smaller.
Back to top
View user's profile Send private message
suthish

New User


Joined: 27 Apr 2009
Posts: 3
Location: bangalore

PostPosted: Fri Nov 27, 2009 2:28 pm    Post subject:
Reply with quote

U can set aa flag to identify which condition is getting satisfied :

Then check for the Flag and write it accordingly..
Back to top
View user's profile Send private message
kbrahma

New User


Joined: 08 Oct 2007
Posts: 38
Location: Delhi

PostPosted: Fri Nov 27, 2009 4:23 pm    Post subject: Reply to: Combining 2 similar procs in one?
Reply with quote

Hmmm... I have some conceptual confusion, can you please implement what you said in a code (pseudo/practical anything... icon_razz.gif )
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Nov 27, 2009 4:29 pm    Post subject:
Reply with quote

Take a look at the post by Marso in your original thread and then rework the logic for two finds instead of one.
Back to top
View user's profile Send private message
kbrahma

New User


Joined: 08 Oct 2007
Posts: 38
Location: Delhi

PostPosted: Fri Nov 27, 2009 7:43 pm    Post subject: Reply to: Combining 2 similar procs in one?
Reply with quote

Thank you for the pointers... Had to struggle a little but finally got it to work from a single proc!!

Thanks again guys! icon_biggrin.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Fri Nov 27, 2009 8:43 pm    Post subject:
Reply with quote

PROC? what Proc, I did not see anything about PROC's in this discussion
about combining two REXX Scripts.
Back to top
View user's profile Send private message
kbrahma

New User


Joined: 08 Oct 2007
Posts: 38
Location: Delhi

PostPosted: Fri Nov 27, 2009 9:07 pm    Post subject: Reply to: Combining 2 similar procs in one?
Reply with quote

Oops, forgot to mention that I was calling them as procedures in my program to process multiple PDS's. That's why I was calling them procs.

Sorry about the confusion...
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts 24x7 online logs using DSN1LOGP (simi... SRICOBSAS DB2 3 Thu Aug 18, 2016 11:52 am
No new posts Combining contents of 2 files in to s... sprikitik SYNCSORT 1 Fri Jan 22, 2016 2:16 pm
No new posts Symbolic vaiable in procs instream data bhavya_sha JCL & VSAM 3 Fri Jan 16, 2015 4:45 pm
No new posts COND referback in nested PROCS? Claes Norreen JCL & VSAM 11 Thu May 15, 2014 6:34 pm
No new posts Compare results similar to SuperCE wi... ramsri SYNCSORT 17 Tue Apr 15, 2014 4:48 pm

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