Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

REXX program to retrieve the case numbers from a Module

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

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Tue Sep 11, 2007 12:20 pm    Post subject: REXX program to retrieve the case numbers from a Module
Reply with quote

i need a REXX program for which the input will be a PDS.

i need to retrive all the CASE numbers which were coded in the first 6 positions in a program.

The output should be the module name along with all the case numbers present in that module. I am attaching the screen shot to give an idea of the case numbers. In the attachment 024505 and 18795 are the sample case numbers. i need to retrive all the case numbers present in the entire program and should send those case numbers to an output PDS please help me in writing this program.
Back to top
View user's profile Send private message

superk

Moderator Team Head


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

PostPosted: Tue Sep 11, 2007 5:57 pm    Post subject: Re: REXX program to retrieve the case numbers from a Module
Reply with quote

uday bhaskar wrote:
please help me in writing this program.


The requirements seem deceptively simple so far. You're going to have to provide more details as to where in your code you're running into a problem.
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Tue Sep 11, 2007 7:40 pm    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

I need the logic to retrive the 1st six characters from each line in a program, so that I can retrive all the case numbers which were coded in the module. Actually I'm new to REXX programming, so I want to know how to retrive the first six characters from 80 character length record.

According to my requirement in the program the input should be a PDS given by me(which consists of several members)

and the output should be : Member name followed by all the case numbers present in it.
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Tue Sep 11, 2007 8:02 pm    Post subject: Re: Reply to: REXX program to retrieve the case numbers from
Reply with quote

uday bhaskar wrote:
I'm new to REXX programming, so I want to know how to retrive the first six characters from 80 character length record.


For the record, this site is NOT a classroom or to be used as a substitute for proper training. You're supposed to posess the basic knowledge before posting here, or at least know how to find information in a manual.

That being said, you can use either the SUBSTR function or the LEFT function.

Personally, I'd use the LEFT function:

var = LEFT(string,6)

In addition, you may want to use the DATATYPE function to verify that the variable contains only numeric data.
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Wed Sep 12, 2007 10:13 am    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

Hi Kevin,

I am Extremely Thankful for your guidance.Now i got an idea how to begin with to meet my requirement.I went through all the key words which you suggested for reading a record like SUBSTR and LEFT.Now i will start coding the program using those key words.

i will search in the forum for the REXX userguide.

Actually i am a COBOL programmer,so i never come across the logic to read the first few characters.Thats why i posted in our site.Now I will start coding and need your help if i struck in the middle.Thanks a lot Kevin.
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Wed Sep 12, 2007 12:29 pm    Post subject: Re: Reply to: REXX program to retrieve the case numbers from
Reply with quote

uday bhaskar wrote:
Actually i am a COBOL programmer


Is there a particular reason why you want to switch to REXX? I always believe that it's usually easier to code in what you already know.
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Wed Sep 12, 2007 7:40 pm    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

Hi Kevin,

No Special Reason.i just want to learn REXX as i want to develop some tools so that i can automate some part of the work which we frequently do in our poject.

Kevin,i am going through the REXX manual which i got from our site,its really interesting to learn REXX.i have a doubt in EXECIO command.

In the entire manual they are using the EXECIO command for reading the sequential datasets only and in the syntax also they are asking for number of lines to be read in the dataset.

But in my requirement as i mentioned in my earlier posts i need to read all the members present in the PARTIONED DATA SET. how to read all the members present in the dataset.can i use the same EXECIO command, if so please let me know the systax for that.
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Wed Sep 12, 2007 8:02 pm    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

How would you do it today, in COBOL perhaps, without REXX? The methodologies are the same regardless of what you're using.

For what it's worth, the topic of reading individual members of a PDS is discussed almost daily in these forums. Search around and you'll find your answers.
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Wed Sep 12, 2007 9:26 pm    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

hi,

Hope this code will be useful.This REXX is coded for a single member in a PDS. Please do some ground work on this for different members of PDS.

Code:
 /* REXX */                                             
                                                       
 Say 'Provide the Input PDS'                           
 parse pull input                                       
 say 'Provide the Member name which you need case nums'
 parse pull pgm                                         
      infile = input || "(" || pgm || ")"               
      output = my.casenums.output.file                 
      SAY 'INFILE  IS : ' INFILE                       
      "alloc fi(infile) da('"infile"') shr reuse"       
      "alloc fi(outfile) da('"output"') shr reuse"     
      "execio * diskr infile (stem inputarr. finis"     
      say 'no of lines' inputarr.0                     
      do lineno = 1 to inputarr.0                       
       upper inputarr.lineno                           
       casenums =substr(inputarr.lineno,1,6)           
            push casenums                               
            "execio 1 diskw outfile"                   
      end                                               
      queue ''                                         
      "execio * diskw outfile(finis"                   
      "free fi(infile,outfile)"                         
 exit                                                   


allocate the output PS file my.casenums.output.file before running this rexx.

thanks
Ctaram
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Thu Sep 13, 2007 12:14 am    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

These previous topics deal with how to use the IEBPTPCH utility to offload a PDS into a seqential dataset:

http://ibmmainframes.com/viewtopic.php?t=4284
http://ibmmainframes.com/viewtopic.php?t=5863

These previous topics deal with how to use the TSO PRINTDS command to do the same task:

http://ibmmainframes.com/viewtopic.php?t=4296
http://ibmmainframes.com/viewtopic.php?t=2252

These previous topics deal with how to use the TSO LISTDS command to display a list of members, and how to trap and use the results:

http://ibmmainframes.com/viewtopic.php?t=24091
http://ibmmainframes.com/viewtopic.php?t=23520
http://ibmmainframes.com/viewtopic.php?t=7356
http://ibmmainframes.com/viewtopic.php?t=6192
http://ibmmainframes.com/viewtopic.php?t=5667
http://ibmmainframes.com/viewtopic.php?t=235

These previous topics deal with how to use the ISPF Library Management (LM) LMMLIST to display and/or loop through PDS members:

http://ibmmainframes.com/viewtopic.php?t=23894
http://ibmmainframes.com/viewtopic.php?t=5501
http://ibmmainframes.com/viewtopic.php?t=2079

IEBPTPCH Utility.

TSO PRINTDS Command.

TSO LISTDS Command.

ISPF LMMLIST Service.

REXX OUTTRAP Function.
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Thu Sep 13, 2007 12:24 am    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

And, there's always this old code that lets you read a PDS directory list blocks directly:

Code:

/* REXX */                                                           
ARG dsn                                                             
"ALLOC F(pds) DA("dsn") SHR REUSE",                                 
"RECFM(F) DSORG(PS) LRECL(256) BLKSIZE(256)"                         
"EXECIO * DISKR pds (STEM dir. FINIS"  /* read pds directory */     
Do blk = 1 to dir.0                                                 
  usedbytes = C2D(Substr(dir.blk,1,2))                               
  index = 3                            /* skip past used bytes */   
  Do While index < usedbytes                                         
    If Substr(dir.blk,index,8) = 'FFFFFFFFFFFFFFFF'X Then           
        Signal DIREOF                                               
    pds2name = Substr(dir.blk,index,8) /* member name */             
    Say pds2name                                                     
    index = index + 11                 /* skip past name and ttr */ 
    pds2indc = Substr(dir.blk,index,1)                               
    len = Bitand(pds2indc,'1F'X)       /* isolate user data length */
    userdata = C2D(len) * 2            /* halfwords to bytes */     
    index = index + userdata + 1       /* skip past user data */     
  End                                                               
End                                                                 
DIREOF:   
Exit 0   
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Thu Sep 13, 2007 2:25 pm    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

Hi Kevin and Ctaram,

First i need to thank both of you for your concern on my query.
Thanks a lot for both of you.

i ran the code which ctaram has provided with slight modification to remove the blank lines from the program.it work fine.but i am not able to remove duplicate values from the output file.

In the code we are sending the first 7 characters of the line in to an stack.
rather than passing into the stack can we pass into an array so that we can filter the duplicate values and i need to filter the character string also.Is there any keyword which will filter (like IS NUMERIC in COBOL) to check whether the string is a character or a numeric.i am providing the screen shot for this also.

Kevin,i ran the code which you provided to me for listing all the members in the PDS.for the first time it worked fine but from the second time onwards it is giving the error which i showed in the screen shot.can you please suggest me the reason for that error.
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Thu Sep 13, 2007 2:47 pm    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

Hi Kevin,

I am able to rectify the error which i am getting to retrieve the members from a PDS.The reason was i was trying the list the members of the PDS where the REXX code was saved.I Hope that is the reason for that error. am i right ??..
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Fri Sep 14, 2007 8:42 am    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

Hi ,

How to remove duplicate values and the alphabetic characters ( i need only distinct case numbers) from the screenshot2.jpg ??

i am using

IF DATATYPE('STRING','N') = 1 THEN
WRITE TO OUTPUT
ELSE
NOP

BUT THAT CODE IS NOT WORKING.

and to remove duplicate values to be written to the output i am using array but i am not able to get the result.

from the above screen shot Ctaram was using STACK as a buffer before writing to the output file,so i am unable to remove duplicate values,thats why i want to use array so that i can search for that element before placing in the array.

can you please provide me the logic for that?
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Fri Sep 14, 2007 12:10 pm    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

Hi Kevin/Ctaram

i wrote a code to remove the duplicate values from the retrived case numbers by using an array.But in the output i am getting only first casenumber

i am providing the code which i am using in the attached txt file.
please let me know where my code went wrong in removing duplicate values.i have provided the necessary comments in the code to tell you what i am doing with that piece of code.

Please look into the attached code and help in rectifying the error.

Code:

/* REXX */
Say 'PROVIDE THE INPUT PDS'                                           
parse pull input                                                       
say 'PROVIDE THE MEMBER NAME FOR WHICH YOU NEED CASE NUMBERS'         
parse pull pgm                                                         
                                                                       
     infile = input || "(" || pgm || ")"                               
     output = ind1943.rexx.caseretv                                   
                                                                       
     SAY 'INFILE  IS : ' INFILE                                       
                                                                       
     "alloc fi(infile) da('"infile"') shr reuse"                       
     "alloc fi(outfile) da('"output"') shr reuse"                     
                                                                       
     "execio * diskr infile (stem inputarr. finis"
     say 'NO OF LINES OF CODE IN THE GIVEN MEMBER' inputarr.0   
                                                           
i=0;k=0;cnt=0                                               
                                                           
do lineno = 1 to inputarr.0                                 
     casenums =substr(inputarr.lineno,1,7)                 
     c=substr(inputarr.lineno,1,6)

/* to remove the lines having spaces or Non Numreric from writting to the output file */                         
     if (SUBSTR(casenums,1,1)=''| DATATYPE(c,'N')=0) then   
        nop                                                 
     else 


/*  to remove the duplicate values being written to the output file.for that i am passing */
/*  all the elements which i read from the above loop into an array.           */
/*  before writing a new element into an array i am checking whether the new element is   */ /*  already present or not.if it is present the CNT variable will be incremented to 1 and */
/*  at the same time i am incrementing the array index to one and writing the new element */
                                               
       do                                                   
         do i=1 to k                                       
           if casenums=array.k then                         
           cnt=cnt+1                                       
         end                                               
          if cnt=0 then                                     
            do                                             
               k=k+1                                       
               array.k=casenums
                     cnt=0                                     
                     push casenums                             
                     "execio 1 diskw outfile"                   
                  end                                           
             end                                               
      end                                                       
                                                               
      queue ''                                                 
                                                               
      "execio * diskw outfile(finis"                           
      "free fi(infile,outfile)"                                 
      Say 'SUCCESSFULLY WRITTEN THE CASE NUMBERS TO THE OUTPUT'
exit
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Fri Sep 14, 2007 12:20 pm    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

Hi

The text file i have provided is not opening properly so i am providing the entire program in scrren shots.

the below mentioned is the code explanation

/* to remove the duplicate values being written to the output file.for that i am passing */
/* all the elements which i read from the above loop into an array. */
/* before writing a new element into an array i am checking whether the new element is */ /* already present or not.if it is present the CNT variable will be incremented to 1 and */
/* at the same time i am incrementing the array index to one and writing the new element */
Back to top
View user's profile Send private message
uday bhaskar

New User


Joined: 18 Mar 2007
Posts: 15
Location: Columbus

PostPosted: Tue Sep 18, 2007 9:54 am    Post subject: Reply to: REXX program to retrieve the case numbers from a M
Reply with quote

Hi,

Thanks for you all...especially kevin and ctaram for your extreme guidance till end...now i am able to succesfully execute my code according to my requirement. The mistake was i placed cnt=0 in wrong place.In trial and error method i have corrected that.

Once again thanks for you all and for the forum
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 IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us