Page 1 of 1

How to store the output of TSO command in REXX

PostPosted: Thu Oct 03, 2013 3:37 pm
by Dheeraj Sharma
Hi All,
Below is the code for rexx...actually i want to store the output produce by applying the tso whois command on the data read from input file. Please tell me where i am wrong?



/* REXX */                                                             
"ALLOC SHR REU F(INPUT) DA('T030.WORK.DHEERAJ.REXX1.INPUT')"           
"ALLOC SHR REU F(OUT) DA('T030.WORK.DHEERAJ.REXX1.OUTFIL')"             
"EXECIO * DISKR INPUT (FINIS STEM INPUT."                               
"FREE F(INPUT)"                                                         
DO LOOP = 1 TO INPUT.0                                                 
  QUEUE INPUT.LOOP                                                     
 X = OUTTRAP('TRAP.')                                                   
 ADDRESS TSO "WHOIS QUEUE"                                             
  X = OUTTRAP('OFF')                                                   
END                                                                     
"EXECIO "TRAP.0" DISKW OUT (FINIS STEM TRAP."                           
"FREE F(OUT)"                                                           
EXIT

Re: How to store the output of TSO command in REXX

PostPosted: Thu Oct 03, 2013 3:50 pm
by Akatsukami
Dheeraj Sharma wrote:Please tell me where i am wrong?

In posting twice.

Re: How to store the output of TSO command in REXX

PostPosted: Thu Oct 03, 2013 4:06 pm
by NicC
1 - by not using code tags to make your program (slightly) more readable
2 - by not writing the output after each invocation of the command - suspect it resets the stem for each invocation but you can test that by putting in a few debugging statements.
3 - you do not actually say WHAT is wrong
4 - you have not provided a trace

Re: How to store the output of TSO command in REXX

PostPosted: Thu Oct 03, 2013 4:29 pm
by Dheeraj Sharma
NicC wrote:1 - by not using code tags to make your program (slightly) more readable
2 - by not writing the output after each invocation of the command - suspect it resets the stem for each invocation but you can test that by putting in a few debugging statements.
3 - you do not actually say WHAT is wrong
4 - you have not provided a trace



It is simply not storing the output which i should get after applying TSO WHOIS command in output file.
If i run this REXX without OUTTRAP and WHOIS commands it is writing the data from input data set to output data set, however what i actually want is to store the output after applying whois command. I hope i am clear about what i actually want
:( :? :? :?

Re: How to store the output of TSO command in REXX

PostPosted: Thu Oct 03, 2013 5:55 pm
by Pedro
without OUTTRAP and WHOIS commands it is writing the data from input data set to output data set

Doubtful.

You should have the EXECIO inside of the loop. Without the FINIS

And outside of the loop, you should have the EXECIO with 0 records and with the FINIS

Re: How to store the output of TSO command in REXX

PostPosted: Thu Oct 03, 2013 6:25 pm
by steve-myers
Dheeraj Sharma wrote:It is simply not storing the output which i should get after applying TSO WHOIS command in output file.
If i run this REXX without OUTTRAP and WHOIS commands it is writing the data from input data set to output data set, however what i actually want is to store the output after applying whois command. I hope i am clear about what i actually want
:( :? :? :?
The other problem is the mechanism used by this WHOIS command to write its output. In order for TSO to "trap" the output the command must use the TSO PUTLINE service or use IKJEFF02 with the MTPUTL flag set. Since I'm sure you don't have a clue as to what I'm saying, try these experiments:
  1. Run this WHOIS command outside of SPF.
  2. If you get good output, run this WHOIS command in TSO in batch using a job like this.
    //        EXEC PGM=IKJEFT01
    //SYSTSPRT DD  SYSOUT=*
      ... Any other DD statements required to run WHOIS
    //SYSTSIN  DD  *
     WHOIS ...
    /*
If it runs in TSO in batch and you got good output you can probably "trap" the output. Otherwise, you cannot "trap" the output. Period. End of story.

Re: How to store the output of TSO command in REXX

PostPosted: Sat Oct 05, 2013 2:51 am
by Pedro
I changed my mind about the execio inside of the loop... use the CONCAT operand of outtrap:
Address TSO                     
x = outtrap('trap.',,'concat')   
Do loop = 1 to input.0           
  "%WHOIS" input.loop           
End                             
x = outtrap('OFF')               


Then follow that with a single EXECIO.

btw, your use of QUEUE INPUT.LOOP and "WHOIS QUEUE" is suspicious to me. I do not think anyone would write a WHOIS command to work like that. Likely, WHOIS has a single required parameter and reads from the queue if not provided. But it is more straightforward to just provide the parameter like my example.