JCL - MVS: how to retrieve result from submiting MVS command in Batch

2.6k Views Asked by At

Morning guys,

After submitting a MVS command in Batch, I wonder if it is possible to print the result in a seq file. Thanks for your time.

//S02IEBG  EXEC PGM=IEBGENER                     
//SYSUT2   DD SYSOUT=(A,INTRDR),DCB=BLKSIZE=23440
//SYSIN    DD DUMMY                              
//SYSOUT   DD SYSOUT=*                           
//SYSUDUMP DD SYSOUT=*                           
//SYSUT1   DD *,DLM=$$                           
/*$VS,'$DQ'                                      
$$ 
4

There are 4 best solutions below

2
On

I believe that the following may work. That is assuming that you want to capture the output from the DQ command :-

//SDSF  EXEC PGM=SDSF
//ISFOUT DD SYSOUT=*
//CMDOUT DD DSN=YOUR.DATASET,
//          DISP=(,CATLG,DELETE),
//          DCB=(RECFM=FBA,LRECL=133,BLKSIZE=0),
//          SPACE=(CYL,(1,1)),UNIT=SYSDA
//ISFIN  DD *
  SET CONSOLE BATCH
  SET DELAY 60
  /$ DQ 
  PRINT FILE CMDOUT
  ULOG
  PRINT
  PRINT CLOSE
/*
// 
  • Obviously this may need to be tailored according to your site's requirement.

You may find Issuing MVS or JES commands helpful.

Addition Re Comment :-

I did try the SDSF but I am not authorized to use it, which is why I am looking for another way.

Perhaps then using TSO/E (REXX) as per :-

From TSO/E, you can establish an extended MCS console session using the TSO/E CONSOLE command. After you activate a console session, you can issue MVS™ system and subsystem commands and obtain command responses. This appendix describes the different commands and functions you can use in REXX execs to set up and use a console session.

Writing REXX Execs to perform MVS operator activities

However, authority may be an issue if not immediately perhaps as soon as someone cottons on to you getting around the doors already closed.

This may work (I don't have the facilities to test it) :-

/* REXX */
ADDRESS TSO 'CONSPROF SOLDISPLAY(NO)'
ADDRESS TSO 'CONSOLE ACTIVATE'
ADDRESS CONSOLE '$DQ'
/* retrieve output command */
max_iterations = 100
DO i = 1 to max_iterations
   messages_remaining = GETMSG('line.','SOL',,,10)
   IF messages_remaining = 0 THEN leave
END
/* Done so echo retrieved messages
say 'Messages Retrieved are :-'
DO i = 1 to line.0
   say '*** ' line.i
END
ADDRESS TSO 'CONSOLE DEACTIVATE'
EXIT

You'd need to wrap that into your batch job, so you may find the following helpful


A solution could be speaking to those responsible for denying access to SDSF, This could result in authority being given. There again it may result in the open doors such as being able to issue JES commands being shut.

2
On

Yes it is possible to write the SYSOUT to a sequential file. I have done this before, but I would not recommend it unless you absolutely need to.

Your system should have some SYSLOG management system (like SMR/JMR or similar), where you can browse the SYSOUTs that a job has produced. Don't get me wrong, I realize that this isn't fool proof. There are times when you may need to write the SYSOUT to a file. The reason I needed to was because I looping with a lot of debugging displays and needed to have a lot lines to help me debug.

If you want to make sure that the SYSOUT goes to a file all you need to do is put the file after the SYSOUT:

//S02IEBG  EXEC PGM=IEBGENER                     
//SYSUT2   DD SYSOUT=(A,INTRDR),DCB=BLKSIZE=23440
//SYSIN    DD DUMMY                              
//SYSOUT   DD  DSN=YOUR.SYSOUT.FILE, 
//         DISP=(NEW,CATLG,DELETE), 
//         UNIT=TEST,SPACE=(TRK,(2,1),RLSE), 
//         DCB=(LRECL=080,BLKSIZE=0,RECFM=FB)                           
//SYSUDUMP DD SYSOUT=*                           
//SYSUT1   DD *,DLM=$$    

You can alter the size of the file if you need to by editing the SPACE parameter. If you plan on running this job more than once, you will need to add a delete step before this, or make your SYSOUT file a GDG that can be incremented. Otherwise, the DISP of NEW will not work.

This can be done with any DD name as long as you know what the proper file allocation is.

0
On

It isn't clear from your question, but if you mean "after submitting your job, can you capture output to a dataset", I would suggest you use the XDC line command in SDSF. If you want a specific part of the output, use the ? line command first to show each of the outputs, then XDC on the one you want to save.

0
On

You probably have access to SDSF to view the output.

Next to the job you want to print type xdc this will pop up a panel for dataset allocation(or it can be already existing one). Once done it will print the output and close it.

If You need just a output of a certain step/sysout you can type ? next to the job in SDSF. This will give you the list of the outputs. Same as before type xdc next to the one you picked and allocate a dataset.

This can also be done to your TSO session if you use the commands directly and need to have a history of it. Although this will only work until you close the SDSF ULOG.