Page 1 of 2

Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 3:32 pm
by durgam4
How to write records to a new page in REXX.

Re: Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 3:55 pm
by prino
Clarify "a new page".

z/OS has no concept of pages, unless you mean print files, in which case your file should be defined FBA, FBM, VBA or VBM, and you should read the manuals!

Re: Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 4:00 pm
by durgam4
I need to print every 30 records in a new page. is there any command to do this?

Re: Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 5:50 pm
by steve-myers
I do not think you read and understood prino's post.

Rexx, as a language, is not well suited to prepare highly formatted reports.

In the TSO environment there is no concept of report pages; for the most part TSO programs write their output to a TSO terminal, which in the current world usually means a 3270 type "glass teletype." In 1970 or so when TSO was first used, TSO terminals usually meant something like an IBM 2741 printer/keyboard using fan folded paper usually intended for 1403 printers. While this paper had "pages," TSO was ignorant of page boundaries; programs running in the TSO environment literally had to count lines if they were going to write "pages" on a 2741 printer/keyboard, and the printer/keyboard operator had to manually position the paper before starting a program that was going to write "pages" on this paper.

The term "glass teletype" was often used in the 1970s and 1980s when CRT terminals were replacing printer/keyboard terminals in nearly all online environments, not just TSO. By the 1990s, the term "glass teletype" was obsolete since CRT terminals had completely replaced printer/keyboards. Only gray beards like me even remember the term.

To extend prino's remarks: if it is your intent to use Rexx to produce output that is going to be printed, you are going to write the printed report to a data set that uses carriage control characters, and then "print" the data set in some fashion appropriate to your environment.

I need to print every 30 records in a new page. is there any command to do this?
Basically, no. If you are thinking in terms of the ASCII "form feed" concept and the \f character as used in the standard C library printf function formats, it really does not exist in Rexx or the z/OS mainframe except as carriage control characters used in printed reports. Technically the EBCDIC character set does have a form feed character comparable to the ASCII form feed character, but the only time it was widely used was for now obsolete 3270 type printers.

Re: Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 8:29 pm
by durgam4
Got it .. Thank you Steve and Prino for your replies

Re: Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 9:31 pm
by Pedro
30 records seems odd to me. Are you 'writing' a page to the screen?

Re: Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 10:59 pm
by steve-myers
Pedro is right. Sadly, there is no formally defined way for Rexx to clear a screen and start writing from the top. Many shops have a TSO command to clear a screen, perhaps known as clrscrn or something similar. I use a command I stole from my last employer for this purpose, that I renamed to CLS. I vaguely recall a topic about how to write a command to clear a screen in this forum a couple of years ago.

There is a formal method for Rexx to obtain screen dimensions. See sysvar in "TSO/E REXX Reference" for your z/OS release.

Re: Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 11:22 pm
by Pedro
Writing line mode messages to the screen is not user friendly. You should consolidate all of your messages then display in a file.

Here is an example of capturing the line mode messages:
/* rexx */                                                           
parse arg parms                                                       
x = outtrap('output.')                                               
Address TSO parms                                                     
x = outtrap('OFF')                                                   
if output.0 = 0 then                                                 
 Do                                                                   
  say '===> No information trapped from' parms                       
  EXIT                                                               
 End                                                                 
trapdd = 'TRAP'|| right('0000'||random(9999),4)                       
Address TSO "ALLOC FILE("TRAPDD") BLKSIZE(0) LRECL(133) NEW REU",     
            " SPACE(50,50) CYL RECFM(F,B) "                           
Address TSO 'EXECIO ' output.0 ' DISKW 'TRAPDD' ( FINIS  STEM OUTPUT.'
Address ISPEXEC                                                       
"LMINIT DATAID(DATAID) DDNAME("TRAPDD")"                             
"VIEW DATAID(&DATAID)"                                               
"LMFREE DATAID(&DATAID)"                                             
Address TSO "FREE F("TRAPDD")"                                       

If you normally invoke your rexx program like this:
TSO %myrexx
you can invoke it from the trap exec:
TSO %TRAP %myrexx

Though, ideally, your rexx program should write to a file itself and also invoke the VIEW service.

Re: Insert a Page break in REXX

PostPosted: Fri Jul 18, 2014 11:49 pm
by steve-myers
Again Pedro is right. I usually write print output to a data set and then browse the data set. The data set is often too wide to work well that way, but it's usually better than writing it to the screen!

Re: Insert a Page break in REXX

PostPosted: Wed Jul 23, 2014 9:18 pm
by Pedro
The data set is often too wide to work well that way

You should format the output based on the screen width.