Iam running a SELECT QUERY in JCL program using DSNTEP2. The output comes in the SPOOL in SYSPRINT. But, what i want is ?, i want the output to come in the dataset, which i specify.
Code:
//HXSULLXX JOB (T,TEST),'QUERY EXEC',MSGCLASS=X,CLASS=L,NOTIFY=&SYSUID
//DSNTEP2 EXEC PGM=IKJEFT01,COND=(4,LT),DYNAMNBR=20
//SYSTSIN DD *
DSN SYSTEM(DB2D)
RUN PROGRAM(DSNTEP2) PLAN(DSNTEP2) -
LIB('DB2.POPR.PROD.RUNLIB.LOAD')
END
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD DSN=HXSULL.QUERYRES,
// DISP=(MOD,,DELETE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=2400),
// UNIT=SYSDA,SPACE=(TRK,(1,1))
//SYSIN DD *
SELECT ' DEFINE ALIAS (NAME('
||LEFT(A.DSNAME,LENGTH(RTRIM(A.DSNAME))-9)
||'.D'
||' RELATE ('
||RTRIM(A.DSNAME)
||'))'
FROM SYSIBM.SYSCOPY A
WHERE A.ICTYPE = 'F'
AND A.TIMESTAMP >= CURRENT TIMESTAMP - 4 HOURS
AND A.JOBNAME LIKE 'PDBC500I'
AND A.TIMESTAMP = (SELECT MAX(B.TIMESTAMP)
FROM SYSIBM.SYSCOPY B
WHERE B.DBNAME = A.DBNAME
AND B.TSNAME = A.TSNAME
AND B.DSNUM = A.DSNUM
AND B.JOBNAME = A.JOBNAME
AND B.ICTYPE ='F');
All the output, which i get in the SYSPRINT i want it in the SYSOUT.
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
Hi,
Dick has already suggested a way to do what you want, actually it's same as you route the SYSOUT to some DSN in the shown JCL. But my question is - you are running a "Batch query", aren't you interested in the results of that query instead of contents of SYSPRINT ? I don't see any DD statement for the results of the query executed..
Anuj : Not a batch query. Yes, iam interested in the result. But, i want the result in the file as well as the SPOOL.
i.e., When i run this JCL, in SPOOL in SYSPRINT i get the records(results).
All the data present in the SYSPRINT(spool), i want it in a FILE. "HXSULL.QUERYRES"
This file should like the copy of SYSPRINT.