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

REXX program to retrieve the case numbers from a Module


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Tue Sep 11, 2007 5:57 pm
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
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

Global Moderator


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

PostPosted: Tue Sep 11, 2007 8:02 pm
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
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

Global Moderator


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

PostPosted: Wed Sep 12, 2007 12:29 pm
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
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

Global Moderator


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

PostPosted: Wed Sep 12, 2007 8:02 pm
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
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

Global Moderator


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

PostPosted: Thu Sep 13, 2007 12:14 am
Reply with quote

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

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

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

ibmmainframes.com/viewtopic.php?t=4296
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:

ibmmainframes.com/viewtopic.php?t=24091
ibmmainframes.com/viewtopic.php?t=23520
ibmmainframes.com/viewtopic.php?t=7356
ibmmainframes.com/viewtopic.php?t=6192
ibmmainframes.com/viewtopic.php?t=5667
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:

ibmmainframes.com/viewtopic.php?t=23894
ibmmainframes.com/viewtopic.php?t=5501
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

Global Moderator


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

PostPosted: Thu Sep 13, 2007 12:24 am
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Using API Gateway from CICS program CICS 0
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top