Joined: 30 Nov 2013 Posts: 822 Location: The Universe
Yes, there is an OUTTRAP idea in CLIST to spool command output in storage. It works much the same as in Rexx; you specify you want it done; run your command, and then you can retrieve the lines.
Regardless of Rexx or CLIST, OUTTRAP only works when the output is coming directly from the command using standard TSO services. LISTCAT works well because it's a TSO command writing output to the terminal using TSO services rather than lower level services.
Look in z/OS TSO/E CLISTs for your z/OS release. Try this link.
For example -
00100 PROC 0
00200 CONTROL LIST
00300 SET &SYSOUTTRAP = 500
00400 LISTC LE(XXX.ZJ)
00500 SET SYSOUTTRAP = 0
00600 SET J = &SYSOUTLINE
00700 WRITE J = &J
00800 IF &J > 0 THEN +
00900 DO &I = 1 TO &J BY 1
01000 SET Z = &STR(&&SYSOUTLINE&I)
01100 WRITE &STR(&Z)
Rexx - not that I'm a big fan of Rexx - is usually better than CLIST for this type of stuff. It took me far too long to create the example by cribbing from the example in the manual. The SET Z = &STR(&&SYSOUTLINE&I) line is far from intuitive!