View previous topic :: View next topic
|
Author |
Message |
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
t_ctaram
New User
Joined: 15 May 2007 Posts: 20 Location: mumbai
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
uday bhaskar
New User
Joined: 18 Mar 2007 Posts: 15 Location: Columbus
|
|
|
|
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 |
|
|
|