Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with column specific output using Rexx

2,245 views
Skip to first unread message

Trimble, John

unread,
Apr 26, 2013, 2:03:29 PM4/26/13
to
I am working on converting an assembler program to Rexx so it can be supported by programmers that are not familiar with IBM assembler. The assembler program takes a variable input file and turns it into a fixed format file with additional spacing in the record for processing later by other programs. I am familiar with parsing fixed data input using columns, but not with producing fixed columnar data output. Does anyone have suggestions and or samples of how to accomplish that?


John Trimble, CISSP
Information Security Technical Architect
Corporate Security
Fishers, IN
317-806-0269
john.t...@salliemae.com

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

Dave Salt

unread,
Apr 26, 2013, 2:20:53 PM4/26/13
to
I usually use LEFT and RIGHT to ensure fields are padded to a consistent length.

HTH,

Dave Salt

SimpList(tm) - try it; you'll get it!

http://www.mackinney.com/products/program-development/simplist.html


> Date: Fri, 26 Apr 2013 14:03:08 -0400
> From: john.t...@SALLIEMAE.COM
> Subject: Help with column specific output using Rexx
> To: TSO-...@VM.MARIST.EDU

Trimble, John

unread,
Apr 26, 2013, 2:26:29 PM4/26/13
to
So how do I make the output fields a consistent length?




John Trimble, CISSP
Information Security Technical Architect
Corporate Security
Fishers, IN
317-806-0269
john.t...@salliemae.com


This E-Mail has been scanned for viruses.

Jeff Byrum

unread,
Apr 26, 2013, 2:32:15 PM4/26/13
to
You can just use the REXX SAY command with a list of variables, and use built-in functions to format each column.

Left-aligned column 8 characters wide: LEFT(var1,8)
Right-aligned column 6 characters wide: RIGHT(var2,6)
Right-aligned numeric field 5 characters wide with leading blanks: FORMAT(var3,5)

See doc for the FORMAT function for many more options.

If you wanted 4 spaces between each column described above, you could do this:

SEP = ' '
Say LEFT(var1,8) SEP,
RIGHT(var2,6) SEP,
FORMAT(var3,5)

Note that since I am not using the concatenation symbol, ||, REXX will insert a space between each operand, so I defined "SEP" as only 2 spaces.

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Trimble, John
Sent: Friday, April 26, 2013 2:03 PM
To: TSO-...@VM.MARIST.EDU
Subject: Help with column specific output using Rexx

Walter Pachl

unread,
Apr 26, 2013, 2:34:32 PM4/26/13
to
pls post a short sample Input and the desired Output
Do you want to separate fields
aaa bbb ccc
aaaa b cccc
->
aaa bbb ccc
aaaa b cccc
?
or just produce an Output with RECFM FB
In the latter case 'EXECIO' l.0 'DISKW OUT(STEM L. FINIS' will do what you want
if OUT is allocated appropriately)
Walter Pachl

Trimble, John

unread,
Apr 26, 2013, 2:36:11 PM4/26/13
to
Thanks, that's what I needed.




John Trimble, CISSP
Information Security Technical Architect
Corporate Security
Fishers, IN
317-806-0269
john.t...@salliemae.com


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@vm.marist.edu] On Behalf Of Jeff Byrum
Sent: Friday, April 26, 2013 2:32 PM
To: TSO-...@vm.marist.edu
This E-Mail has been scanned for viruses.

Dave Salt

unread,
Apr 26, 2013, 2:42:45 PM4/26/13
to
I'm just heading out the door, but here's an example of how I create a variable called LOGREC. This record contains the number of SimpList functions that were performed for a particular user (where for example vs#b is a variable containing the number of Browse functions that were performed and is right justified for a length of 7). As each record is written the columns all line up underneath each other, and some extra columns are written at the end for future use:

logrec = left(syspref,8),
|| left(memname,8), /* userid */
|| right(invoke,7), /* total tool usage this month*/
|| right(vs#b,7), /* total Browse this month*/
|| right(vs#c,7), /* total Copy this month*/
|| right(vs#e,7), /* total Edit this month*/
|| right(vs#h,7), /* total HSM this month*/
|| right(vs#i,7), /* total Info this month*/
|| right(vs#l,7), /* total List this month*/
|| right(vs#p,7), /* total Print this month*/
|| right(vs#u,7), /* total Util this month*/
|| right(vs#v,7), /* total View this month*/
|| right(vs#rtz,7), /* total func R/T/Z this month*/
|| right(vs#123,7), /* total func 1/2/3 this month*/
|| right(vs#chg,7), /* total CHGALL this month*/
|| right(vs#sek,7), /* total HIDE/SEEK this month*/
|| right(vs#d,7), /* total mems delet this month*/
|| right(vs#j,7), /* total mems submt this month*/
|| right(vs#r,7), /* total mems renam this month*/
|| right(vs#a,7), /* total mems stat this month*/
|| right(vs#amb,7), /* total AMBLIST this month*/
|| right(vs#o,7), /* total macrO this month*/
|| right(vs#t,7), /* total TSO/ISPF this month*/
|| right(vs#x,7), /* total exclude this month*/
|| right(vs#n,7), /* total xfer this month*/
|| right(vs#lbl,7), /* total labels this month*/
|| right(vs#see,7), /* total SEE cmd this month*/
|| right(vs#sym,7), /* total symbolics this month*/
|| right(vs#wkst,7), /* total workstationthis month*/
|| right(vs#link,7), /* total AML linK this month*/
|| right(vs#look,7), /* total AML looK this month*/
|| " 0 0 0 0 0"


Dave Salt

SimpList(tm) - try it; you'll get it!

http://www.mackinney.com/products/program-development/simplist.html


> Date: Fri, 26 Apr 2013 14:26:03 -0400
> From: john.t...@SALLIEMAE.COM
> Subject: Re: Help with column specific output using Rexx

Walter Pachl

unread,
Apr 26, 2013, 2:46:06 PM4/26/13
to
Say should be EXECIO ?!? (or lineout on the PC)
Untested:
"ALLOC FI(IN) DA('...') SHR REUSE"
"ALLOC FI(OUT) DA('...') SHR REUSE"
'EXECIO * DISKR IN (STEM L. FINIS'
sep=' '
Do i=1 To l.0
Parse Var l.i var1 var2 var3
o.i=LEFT(var1,8) SEP RIGHT(var2,6) SEP FORMAT(var3,5)
End
'EXECIO' l.0 'DISKW OUT (STEM O. FINIS'
Walter Pachl

EXT-Schwarz, Barry

unread,
Apr 26, 2013, 5:23:32 PM4/26/13
to
You decide how long each field should be as part of your design. You can probably determine these values from the assembler code that you are converting from.

Then you process the fields sequentially. For the first, you simply assign to your string. For each subsequent field, you append to the previous result. Something like
string = left(value1,len1)
string = string || left(value2,len2)

> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-...@vm.marist.edu] On
> Behalf Of Trimble, John
> Sent: Friday, April 26, 2013 11:26 AM
> To: TSO-...@vm.marist.edu
> Subject: Re: Help with column specific output using Rexx
>
> So how do I make the output fields a consistent length?

Steve Comstock

unread,
Apr 26, 2013, 5:27:49 PM4/26/13
to
On 4/26/2013 12:35 PM, EXT-Schwarz, Barry wrote:
> You decide how long each field should be as part of your design. You can probably determine these values from the assembler code that you are converting from.
>
> Then you process the fields sequentially. For the first, you simply assign to your string. For each subsequent field, you append to the previous result. Something like
> string = left(value1,len1)
> string = string || left(value2,len2)

Except, as some posters have shown, you may need to
append spaces and then truncate to the field size
you want.


>
>> -----Original Message-----
>> From: TSO REXX Discussion List [mailto:TSO-...@vm.marist.edu] On
>> Behalf Of Trimble, John
>> Sent: Friday, April 26, 2013 11:26 AM
>> To: TSO-...@vm.marist.edu
>> Subject: Re: Help with column specific output using Rexx
>>
>> So how do I make the output fields a consistent length?

--

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-355-2752
http://www.trainersfriend.com

* To get a good Return on your Investment, first make an investment!
+ Training your people is an excellent investment

* Try our tool for calculating your Return On Investment
for training dollars at
http://www.trainersfriend.com/ROI/roi.html

Jeff Byrum

unread,
Apr 26, 2013, 5:39:03 PM4/26/13
to
Well, most people wouldn't want to *truncate* data. The purpose of using LEFT and RIGHT in this context is to make sure each value is *padded* with enough blanks (on the right or left) to make the report appear in regular columns. So you want the second operand (the number) to be the *largest* width that you anticipate for each field.

Steve Comstock

unread,
Apr 26, 2013, 6:10:26 PM4/26/13
to
On 4/26/2013 3:38 PM, Jeff Byrum wrote:
> Well, most people wouldn't want to *truncate* data. The purpose of using
> LEFTand RIGHT in this context is to make sure each value is *padded* with enough
blanks (on the right or left) to make the report appear in regular columns. So
you want the second operand (the number) to be the *largest* width that you
anticipate for each field.

Well, just a different perspective: I first pad with a fixed number
of spaces then truncate the resulting string to the desired length.
That's what I meant when I said 'append spaces'; maybe that's not clear.

Jeff Byrum

unread,
Apr 26, 2013, 6:17:43 PM4/26/13
to
Not sure I understand why you would append spaces and then truncate when you can do it all with one function: LEFT.

Let's say I have a column that consists of TSO userids. I know the maximum length of a value (at our site) is 8. So I code:

LEFT(TSO_UID,8)

All the userid's will have as many blanks appended to the end as required to make the value 8 characters wide, anywhere from 0 to 7 blanks. That's it -- only one operation.

Glenn Knickerbocker

unread,
Apr 26, 2013, 11:28:25 PM4/26/13
to
On 4/26/2013 2:03 PM, Trimble, John wrote:
> I am familiar with parsing fixed data input using columns, but not
> with producing fixed columnar data output.

If you want to specify the columns by position rather than width,
analogous to parsing by absolute patterns like so:

Parse Var line 1 field1 12 field2 17 field3

then OVERLAY() can be a convenient way to build your output:

line = Overlay(field2, field1, 12)
line = Overlay(field3, line, 17)

You can use that in combination with formatting using RIGHT() and
FORMAT() to align the fields, of course.

line = Overlay(field2, Right(field1, 10))
line = Overlay(Format(field3, 6, 2), line, 17)

ŹR

Glenn Knickerbocker

unread,
Apr 27, 2013, 4:34:56 PM4/27/13
to
On 4/26/2013 2:03 PM, Trimble, John wrote:
> I am familiar with parsing fixed data input using columns, but not
> with producing fixed columnar data output.

If you want to specify the columns by position rather than width,
analogous to parsing by absolute patterns like so:

Parse Var line 1 field1 12 field2 17 field3

then OVERLAY() can be a convenient way to build your output:

line = Overlay(field2, field1, 12)
line = Overlay(field3, line, 17)

You can use that in combination with formatting using RIGHT() and
FORMAT() to align the fields, of course.

line = Overlay(field2, Right(field1, 10))
line = Overlay(Format(field3, 6, 2), line, 17)

�R

Adrian Stern

unread,
Apr 28, 2013, 6:01:50 AM4/28/13
to
The best way to produce formatted output is with the overlay function:
Eg lineOut = overlay(var1, var2, var3, var4, var5)
Where:
var1 is the data to be inserted
var2 is the variable it's to be inserted into
var3 is the start position of the field
var4 is the length of the field
var5 is the padding character (if required)

check it out
Adrian

Andreas Fischer

unread,
Apr 29, 2013, 3:48:02 AM4/29/13
to
well you got a lot of useful answers, but why using an assembler or rexx
program for that task and not pgm sort? i guess it will do the job, and it
will do it extremly fast.

regards,
andi


TSO REXX Discussion List <TSO-...@VM.MARIST.EDU> schrieb am 26.04.2013
20:03:08:
0 new messages