View previous topic :: View next topic
|
Author |
Message |
knobi
New User
Joined: 16 Aug 2005 Posts: 54
|
|
|
|
hello!!
I have a requirement to build a pds file based on a ps (lrecl 400) file .
The input file has the <tags> indicating the begin and the end of each member.
what would be the best approach in this case to create the pds, 1) a rexx code, or 2) is there any other IBM z/os native utility? |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
- How many records does the PS data set contain?
- How many members will be created?
- What do the delimiters look like?
- What sort product does your shop have?
|
|
Back to top |
|
|
knobi
New User
Joined: 16 Aug 2005 Posts: 54
|
|
|
|
around 5000 records...
around 400 members should be created
delimiters are <start> <end>
only IBM z/OS native utilities |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
is the (tobe pds) member name contained in any record?
if not, is there any naming scheme to be followed? |
|
Back to top |
|
|
knobi
New User
Joined: 16 Aug 2005 Posts: 54
|
|
|
|
no member name convention.
it could be mem000, mem001... |
|
Back to top |
|
|
knobi
New User
Joined: 16 Aug 2005 Posts: 54
|
|
|
|
guys, nevermind... i took the rexx approach and it worked fine, thought there was another way to do ...like the IEBUPDTE but unfortunatelly limited to 72 positions for input... |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
It'd be nice if you can post the solution (pseudo code) which worked for you, possibly might help someone later. |
|
Back to top |
|
|
knobi
New User
Joined: 16 Aug 2005 Posts: 54
|
|
|
|
this is basically what was done.
probably there are a way to do it more efficiently
anyway, it did the job...
if anyone has any suggestion of change or any other way to do it, pls share..
Code: |
- allocate and read input file
k=1
do i=1 to dat1.0
text.k=dat1.i /* start getting records */
k = k + 1 /* for 1st member */
if index(dat1.i,'4') = 1 then /* Get member name or repl */
do /* by mem### generator */
memb=strip(substr(dat1.i,54,8))
end
if index(dat1.i,'<end>') = 1 then /* find end tag, create the*/
do /* member, clean variables */
"alloc da('pds_file("memb")') f(out) old reuse"
"execio * diskw out (stem text."
"execio 0 diskr out (finis"
"free f(out)"
memb=" "
k=1
drop text.
end
end
exit 0 |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Why use k at all? i always has the same value when k is used.
What's with the index for '4'? Just an example, or your data can't otherwise contain '4' at that position? If the positions of 4/<end> are fixed, why not substr instead of index?
You use dat.i multiple times.
You don't validate memb.
You are "light" on error checking. If your PDS fills, are you going to notice?
Your comments are generally not correct or those that are say nothing.
You don't deal with either a missing start or end.
For your file size, "efficiency" probably doesn't matter (and how many times are you doing this?). Is the PS in member-name order? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Maintain text.0 then you can use that to control the DISKW instead of * which can terminate DISKW early if the data to be written contains an EOF marker. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
other than very lite on rc checking,
i found the REXX Script rather well written. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
what is an an EOF marker? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Not correct terminology but something that makes EXECIO think it has no more data to read. I believe the manual mentions null as one of these things. It also mentions EOF. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
not to be tooooo picky,
but we were discussing writing with execio in this thread,
and i did not think EOF had a proper place when
discussing when execio reaches a point of nothing else to write.
yes, a NULL length stem variable is one
and, an uninitialized stem variable is another
(i.e. value of mystem.3 = 'MYSTEM.3')
actually, all i was getting at was for an EXECIO with an arbitrary number of writes - DISKW *
the value contained in the stem variable 0
(i.e. mystem.0)
has no effect.
and knobi used an uninitialized stem variable as the terminator
for his EXECIO DISKW * statement.
but in the event that one of the input records in knobi's file contained a 0-length record (or null),
then yes,
EXECIO DISKW k
would have been the better way to write the statement.
so, you are correct, i was wrong. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
I just hope that knobi is still following the thread and is learning. One thing you learn is that you never stop learning. Rights and Wrongs yes but even that manual link you PMed me, Dick, is confusing because it did mention stem.0 being ignored but I am not sure how they were proposing the usage of it. Like any command being sent to another address space, stuff not quoted gets substituted. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
the DISKW does not use the value of stem.0.
when the EXECIO is based on a stem variable DISKW terminates when either - a stem variable contains a zero length value - NULL
- a stem variable is in initialized state - value of stem.x = 'STEM.X'.
DISKR populates stem.0 with the record count when a stem variable (as apposed to the stack) is used as the file record repository.
I admittedly thought that stem.0 have a purpose for DISKW for many years
(never bothered to read the detail in the documentation)
but a simple experiment would proved the point.
populate the first 3 stem variables (1,2, and 3)
drop stem.4 or populate stem.4 with "" (zero length value)
populate stem.0 with 0,1,2 or 4 >4 (does not matter)
DISKW * (stem. finis
it will output 3 records.
Knobi drops the output stem (text.)after each DISKW,
thus all unpopulated stem variables for text. are in INITIAL state. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
From the manual TSO/E REXX Commands example 12
Code: |
"EXECIO" newvar.0 "DISKW MYOUTDD (STEM NEWVAR." /* Write
exactly the number of records read */ |
I think what the manual means when it says EXECIO ignores stem.0 is that it ignore stem.0 as a value to be written. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Sigh,
TSO REXX COMMANDS Operands for Writing to a Data Set: wrote: |
When EXECIO writes an arbitrary number of lines from a list of compound variables, it stops when it reaches a null value or an uninitialized variable (one that displays its own name).
The 0th variable has no effect on controlling the number of lines written from variables. |
In your example, newvar.0 (as you said) resolves to a specific number,
thus your example is not an arbitrary number of lines,
which is indicated as an asterisk (*)
and please try the experiment that I suggested a few posts ago. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
and yes you are correct.
regardless of the format of reading into (DISKR/DISKRU) or writing from (DISKW)
a stem
the 0th variable is not used for record storage or as a record source. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
At 3am I was NOT going to experiment but, if I am still alive after today's (physical) exertions, I will try an experiment or two this evening. Suffice to say for the moment that this debate started because people, not only in this topic, have stated that STEM.0 cannot be used in place of * in DISKW. OF course it can if done right i.e. variable substitution is allowed before the command is passed to TSO. We are now exploring the limits. And I will continue this evening. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Anuj Dhawan wrote: |
It'd be nice if you can post the solution (pseudo code) which worked for you, possibly might help someone later. |
Will Jesus forgive me of my sins? See, what I've done! |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
dbzTHEdinosauer wrote: |
other than very lite on rc checking,
i found the REXX Script rather well written. |
Mmmmm....
Code: |
/* start getting records */
/* for 1st member */ |
The records have already been "got". Presumably, unless we have been shown the code just for processing the first member, this is not for only the first member.
Code: |
/* Get member name or repl */
/* by mem### generator */ |
What's all the "repl" stuff? Don't seem to be no code for it.
Code: |
/* find end tag, create the*/
/* member, clean variables */ |
Just says what the lines of code say, and won't be changed when the lines of code are changed.
I'm not going to go into it all again. It is probably a "one-off", so why bother? Well, "one-offs" have a habit of being copied for other "one-offs". So, knowing that I'm likely to copy it at some time, I try to do it like a "real" program. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
since everyone else is continually justifying their comments,
i will do the same:
the script at times has misleading or useless comments.
the script is very lite on rc checking and could lead to errors
i.e. directory or data full.
substr would have been better than index
k is incremented throughout the population of stem text.
and then reset to 1 after every new member is written.
are pds directorys maintained in sorted order. don't think so.
as a result, the sorted or unsorted member names has no effect.
the value of the 0th variable has no effect when DISKW * format is used.
when the 0th variable is used as the LINES parm
DISKW stem.0
it is treated just like any other variable.
again i say,
sort of the error checking and comments
the script was rather well written.
add appropriate comments and error checking
it would have been an excellent script. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
oh, something that is poor programming:
this:
Code: |
"execio * diskw out (stem text."
"execio 0 diskr out (finis" |
would have been better coded as:
Code: |
"execio * diskw out (stem text. finis" |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Anuj,
Quote: |
Will Jesus forgive me of my sins? See, what I've done! |
I suspect He will, but there are others around here . . . .
d |
|
Back to top |
|
|
|