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

Combining 2 similar procs in one?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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
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
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
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
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: 8797
Location: Welsh Wales

PostPosted: Fri Nov 27, 2009 4:29 pm
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
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: 6966
Location: porcelain throne

PostPosted: Fri Nov 27, 2009 8:43 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Combining Multiple Row Values into Si... DB2 3
No new posts Combining more 4 files with sorted or... DFSORT/ICETOOL 3
No new posts 24x7 online logs using DSN1LOGP (simi... DB2 3
No new posts Combining contents of 2 files in to s... SYNCSORT 1
No new posts Symbolic vaiable in procs instream data JCL & VSAM 3
Search our Forums:

Back to Top