Discussion:
Sorting a REXX STEM variable
Add Reply
John Gateley
2017-06-12 14:29:41 UTC
Reply
Permalink
Raw Message
Hi

Last weeks discussion on sorting a REXX stem inspired me to write a program to do it.

example call to sort ascending
"ISPEXEC LIBDEF ISPLLIB DATASET ID ('my_loadlib') STACK"
"ALLOC FI(SORTPRT) DUMMY"
r_c = SORTSTEM(my_stem_name,'A')
"FREE FILE(SORTPRT)"
"ISPEXEC LIBDEF ISPLLIB "

SORTSTEM gets the variable count from my_stem_name.0 and then looks at every variable in the stem to get the maximum length.

Then it getmains some storage big enough for the maximum record plus 4 bytes for the length of the variable

It then calls the system SORT passing E15 and E35 exits

SORT FIELDS=(1,max_len,BI,A),FILSZ=stem_count
OPTION MSGDDN=SORTPRT
RECORD TYPE=F,LENGTH=(max_len+4)

On each call to the E15 exit the next stem variable is read, padded with spaces and the length put on the end

On each call to the E35 exit the variable is put back into the stem, starting at 1, using the original length


It will be on File#953 of the CBT Tape soon, but it anyone wants a preview then the code is in IEBUPDTE format here
http://www.spurtle.biz/STEMASM.txt
and supporting macros here
http://www.spurtle.biz/STEMMAC.txt
You will need to assemble the six modules then link
INCLUDE SYSLIB(STEMSORT)
ENTRY STEMSORT

Regards
John

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Robert Prins
2017-06-12 17:58:53 UTC
Reply
Permalink
Raw Message
Post by John Gateley
Hi
Last weeks discussion on sorting a REXX stem inspired me to write a program to do it.
example call to sort ascending
"ISPEXEC LIBDEF ISPLLIB DATASET ID ('my_loadlib') STACK"
"ALLOC FI(SORTPRT) DUMMY"
r_c = SORTSTEM(my_stem_name,'A')
"FREE FILE(SORTPRT)"
"ISPEXEC LIBDEF ISPLLIB "
SORTSTEM gets the variable count from my_stem_name.0 and then looks at every variable in the stem to get the maximum length.
Then it getmains some storage big enough for the maximum record plus 4 bytes for the length of the variable
It then calls the system SORT passing E15 and E35 exits
SORT FIELDS=(1,max_len,BI,A),FILSZ=stem_count
OPTION MSGDDN=SORTPRT
RECORD TYPE=F,LENGTH=(max_len+4)
On each call to the E15 exit the next stem variable is read, padded with spaces and the length put on the end
On each call to the E35 exit the variable is put back into the stem, starting at 1, using the original length
It will be on File#953 of the CBT Tape soon, but it anyone wants a preview then the code is in IEBUPDTE format here
http://www.spurtle.biz/STEMASM.txt
and supporting macros here
http://www.spurtle.biz/STEMMAC.txt
You will need to assemble the six modules then link
INCLUDE SYSLIB(STEMSORT)
ENTRY STEMSORT
Will your code handle non-numerical "indices"?

tom = 'dick'
my_stem.tom = 'Harry'

Robert
--
Robert AH Prins
robert.ah.prins(a)gmail.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Paul Gilmartin
2017-06-12 19:16:18 UTC
Reply
Permalink
Raw Message
Post by Robert Prins
Post by John Gateley
...
r_c = SORTSTEM(my_stem_name,'A')
...
It will be on File#953 of the CBT Tape soon, but it anyone wants a preview then the code is in IEBUPDTE format here
http://www.spurtle.biz/STEMASM.txt
and supporting macros here
http://www.spurtle.biz/STEMMAC.txt
... where I see a lot of assembler code and little Rexx.
Post by Robert Prins
Will your code handle non-numerical "indices"?
The key definition, not merely 'A', ought to be an argument to SORTSTEM.

But I fell into this discussion using SORT as an example, and replies took
that as the goal. What I mean to ask is, how can I invoke an arbitrary
utility or load module (not just SORT) associating all its files with Rexx
stems, not just data sets. SORT allows this because of the I/O exits; many
utilities (other than HLASM) have no similar facility.

BPXWUNIX supports this, but only for for UNIX utilities and three customary
files.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Tony Harminc
2017-06-12 20:10:54 UTC
Reply
Permalink
Raw Message
On 12 June 2017 at 15:17, Paul Gilmartin <
Post by Paul Gilmartin
What I mean to ask is, how can I invoke an arbitrary
utility or load module (not just SORT) associating all its files with Rexx
stems, not just data sets. SORT allows this because of the I/O exits; many
utilities (other than HLASM) have no similar facility.
I'm thinking Howard Gilbert's GPSAM is the approach for this.

Tony H.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Jesse 1 Robinson
2017-06-12 20:19:21 UTC
Reply
Permalink
Raw Message
I have a number of applications that sort a REXX array. My solution is to load it into an ISPF table. Not only is a table easily sorted, but you can do an instant search with single ISPF command. And so much more.

Yes, you need to run in a TSO environment, but I've never found much use for a REXX that does not otherwise need some TSO service anyway.

.
.
J.O.Skip Robinson
Southern California Edison Company
Electric Dragon Team Paddler
SHARE MVS Program Co-Manager
323-715-0595 Mobile
626-543-6132 Office ⇐=== NEW
***@sce.com


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-***@LISTSERV.UA.EDU] On Behalf Of Tony Harminc
Sent: Monday, June 12, 2017 1:12 PM
To: IBM-***@LISTSERV.UA.EDU
Subject: (External):Re: Sorting a REXX STEM variable
What I mean to ask is, how can I invoke an arbitrary utility or load
module (not just SORT) associating all its files with Rexx stems, not
just data sets. SORT allows this because of the I/O exits; many
utilities (other than HLASM) have no similar facility.
I'm thinking Howard Gilbert's GPSAM is the approach for this.

Tony H.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Paul Gilmartin
2017-06-12 23:14:08 UTC
Reply
Permalink
Raw Message
Post by Jesse 1 Robinson
I have a number of applications that sort a REXX array. My solution is to load it into an ISPF table. Not only is a table easily sorted, but you can do an instant search with single ISPF command. And so much more.
Rexx compound symbols do search, but only for match, not lower/upper bound.
Post by Jesse 1 Robinson
Yes, you need to run in a TSO environment, but I've never found much use for a REXX that does not otherwise need some TSO service anyway.
Which? What I've missed, beyond ISPF itself, are TRANSMIT and RECEIVE.
And TSO provides shortcuts to many IDCAMS functions.

But I have a Rexx that extracts all the spool files for a job.
Runs fine under OMVS, TSO, or IRXJCL.

And it's irritating that a job can't extract its own ID without
either an ISPF function or chasing control blocks.
Post by Jesse 1 Robinson
-----Original Message-----
From: Tony Harminc
Sent: Monday, June 12, 2017 1:12 PM
What I mean to ask is, how can I invoke an arbitrary utility or load
module (not just SORT) associating all its files with Rexx stems, not
just data sets. SORT allows this because of the I/O exits; many
utilities (other than HLASM) have no similar facility.
I'm thinking Howard Gilbert's GPSAM is the approach for this.
Google tells me CBTTAPE 290, with high praise for the author.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Albert Ferguson
2017-06-13 14:04:19 UTC
Reply
Permalink
Raw Message
Under zOS REXX does have a STEM Sort (via BPXWUNIX). If you have an OMVS Segment on your USERID (and as of zOS 2.1+ you should), try this:

/*
Do a Binary Sort (use -tn for Text)
Using 2nd Word in each StemIn. Record as primary sort key
Using 1st Word in each StemIn. Record as secondary sort key
More doc on Unix Sort at http://publibz.boulder.ibm.com/epubs/pdf/bpx1cd10.pdf
*/
x = BPXWUNIX("/bin/sort -bn -k2,2 -k1,1","StemIn.","StemOut.")

Also available via the USS side of zOS is Regex support:

/*
Get the JESMSGLG output from a JOB, e.g. via SDSF or (E)JES and put in the STEM JesMsgLg.
Use the USS grep in, Extended mode, to search for all STEPS with an RC=12, 16, or 20
Return only those steps to the BadSteps. STEM variable ...

Add a step using this at the very END of a JOB to determine if something did not go as expected, and then
possibly correct it!
*/
x = BPXWUNIX("/bin/grep -E -e'¬.{30}(.{10} (12|16|20)'", "JesMsgLg.","BadSteps.")

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Nims,Alva John , Al
2017-06-13 16:38:27 UTC
Reply
Permalink
Raw Message
BPXWUNIX is available to z/OS 1.13 too, so this should work under z/OS 1.13. I am using BPXWUNIX to invoke USS dig command get info from the DNS server.

Al Nims
Systems Admin/Programmer 3
UFIT
University of Florida
(352) 273-1298

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-***@LISTSERV.UA.EDU] On Behalf Of Albert Ferguson
Sent: Tuesday, June 13, 2017 9:55 AM
To: IBM-***@LISTSERV.UA.EDU
Subject: Re: Sorting a REXX STEM variable

Under zOS REXX does have a STEM Sort (via BPXWUNIX). If you have an OMVS Segment on your USERID (and as of zOS 2.1+ you should), try this:
z
/*
Do a Binary Sort (use -tn for Text)
Using 2nd Word in each StemIn. Record as primary sort key
Using 1st Word in each StemIn. Record as secondary sort key
More doc on Unix Sort at http://publibz.boulder.ibm.com/epubs/pdf/bpx1cd10.pdf
*/
x = BPXWUNIX("/bin/sort -bn -k2,2 -k1,1","StemIn.","StemOut.")

Also available via the USS side of zOS is Regex support:

/*
Get the JESMSGLG output from a JOB, e.g. via SDSF or (E)JES and put in the STEM JesMsgLg.
Use the USS grep in, Extended mode, to search for all STEPS with an RC=12, 16, or 20
Return only those steps to the BadSteps. STEM variable ...

Add a step using this at the very END of a JOB to determine if something did not go as expected, and then
possibly correct it!
*/
x = BPXWUNIX("/bin/grep -E -e'¬.{30}(.{10} (12|16|20)'", "JesMsgLg.","BadSteps.")

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Loading...