How to store the output of TSO command in REXX



IBM's Command List programming language & Restructured Extended Executor

How to store the output of TSO command in REXX

Postby Dheeraj Sharma » Thu Oct 03, 2013 3:37 pm

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
Dheeraj Sharma
 
Posts: 12
Joined: Mon Sep 30, 2013 1:55 pm
Has thanked: 8 times
Been thanked: 0 time

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

Postby Akatsukami » Thu Oct 03, 2013 3:50 pm

Dheeraj Sharma wrote:Please tell me where i am wrong?

In posting twice.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

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

Postby NicC » Thu Oct 03, 2013 4:06 pm

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
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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

Postby Dheeraj Sharma » Thu Oct 03, 2013 4:29 pm

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
:( :? :? :?
Dheeraj Sharma
 
Posts: 12
Joined: Mon Sep 30, 2013 1:55 pm
Has thanked: 8 times
Been thanked: 0 time

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

Postby Pedro » Thu Oct 03, 2013 5:55 pm

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
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

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

Postby steve-myers » Thu Oct 03, 2013 6:25 pm

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.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

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

Postby Pedro » Sat Oct 05, 2013 2:51 am

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.
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post