Elardus, Here is a JCL which will give you the desired results. I rearrange your INCLUDE conditions in the order of positions and it is easy to read and Understand.
We set up a return code of 4 if the INCLUDE results in an empty input. We then validate that return code and write the reports or leave them as is. If the step0200 results in a empty dataset then you will have return code of 4 and the step0300 will NOT run. //*********************************************************** //* DELETE IF THE REPORT DATASETS EXIST ** //*********************************************************** //STEP0100 EXEC PGM=IEFBR14 //DD01 DD DSN=&SYSUID..DISPLAY.REPORT, // DISP=(MOD,DELETE,DELETE), // SPACE=(TRK,(1,0),RLSE) //* //DD02 DD DSN=&SYSUID..OCCURS.REPORT, // DISP=(MOD,DELETE,DELETE), // SPACE=(TRK,(1,0),RLSE) //* //*********************************************************** //* SET RETURN CODE OF 4 IF THE INCLUDE CONDITIONS RESULT ** //* IN A EMPTY OUTPUT AND HAVE THE EMPTY HEADERS ** //*********************************************************** //STEP0200 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DISP=SHR,DSN=Your Input VB file //SORTOUT DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) //PRINT3R DD DSN=&SYSUID..DISPLAY.REPORT, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(25,25),RLSE) /* //PRINT3T DD DSN=&SYSUID..OCCURS.REPORT, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(25,25),RLSE) /* //SYSIN DD * OPTION VLSCMP,NULLOUT=RC4 INCLUDE COND=(005,04,CH,EQ,C'0200',AND, 054,04,CH,NE,C'YES',AND, (100,08,CH,EQ,C'@GROEP',OR, 100,08,CH,EQ,C'@PREFIX'),AND, 118,10,CH,NE,C' ',AND, (118,10,CH,NE,19,10,CH)) SORT FIELDS=(10,8,CH,A) OUTFIL FNAMES=PRINT3R,REMOVECC, HEADER2=(001:'@PREFIX - @SYSTM: ACTIVE IDS', 037:DATE(4MD/), 055:TIME(24:), 068:PAGE,/,3/, 001:' NR USER ID USER NAME ', 'DFLT GROUP CREATED LAST USED',/, 001:'------ ------- -------------------- ', '---------- ---------- ----------',/, 001:' NO IDS FOUND') OUTFIL FNAMES=PRINT3T,REMOVECC,NODETAIL, HEADER2=(001:'ACTIVE IDS COUNT',/, '---------- ------',/, 001:' NO IDS FOUND') //* //*********************************************************** //* IF THE ABOVE STEP ISSUES A RETURN CODE OF ZERO THEN WE ** //* HAVE DATA AND GENERATE THE REPORT USING THE REPORT DSN ** //*********************************************************** //STEP0300 EXEC PGM=ICETOOL,COND=(0,NE,STEP0200) //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //INDD DD DISP=SHR,DSN=&&T1 //PRINT3R DD DISP=SHR,DSN=&SYSUID..DISPLAY.REPORT //PRINT3T DD DISP=SHR,DSN=&SYSUID..OCCURS.REPORT //TOOLIN DD * DISPLAY FROM(INDD) LIST(PRINT3R) - NOCC - WIDTH(500) - BETWEEN(2) - TITLE('@PREFIX - @SYSTM: ACTIVE IDS') - DATE(4MD/) - TIME(24:) - PAGE - BLANK - ON(NUM,N05) HEADER('NR') - ON(10,8,CH) HEADER('USER ID') - ON(79,20,CH) HEADER('USER NAME') - ON(100,8,CH) HEADER('DFLT GROUP') - ON(19,10,CH) HEADER('CREATED') - ON(118,10,CH) HEADER('LAST USED') OCCUR FROM(INDD) LIST(PRINT3T) - NOCC - WIDTH(500) - ON(79,1,CH) HEADER('ACTIVE IDS') - ON(VALCNT,N05) HEADER('COUNT') /* Further if you have any questions please let me know Thanks, Kolusu DFSORT Development IBM Corporation From: Elardus Engelbrecht <elardus.engelbre...@sita.co.za> To: IBM-MAIN@LISTSERV.UA.EDU Date: 05/31/2017 04:56 AM Subject: Re: DFSORT with empty outputs Sent by: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> Sri h Kolusu wrote: >>>Is there a DFSORT or ICETOOL statement where the output contains headers plus a line saying 'No selected records found' if nothing selected is found? >It can be done , however I need a few more details. First thing first, many thanks for offering help. >1. How are you selecting the data? (using INCLUDE/OMIT COND or OUTFIL INCLUDE/OMIT ?) I am mostly using ICETOOL with both these two sets of statements or only with one, like this example with INCLUDE COND: (PS - fields with @ are replaced by actual contents) SORT FROM(INDD) TO(TEMP0003) USING(REST) DISPLAY FROM(TEMP0003) LIST(PRINT3R) - NOCC - WIDTH(500) - BETWEEN(2) - TITLE('@PREFIX - @SYSTM: Active Ids') - DATE(4MD/) - TIME(24:) - PAGE - BLANK - ON(NUM,N05) HEADER('NR') - ON(10,8,CH) HEADER('User id') - ON(79,20,CH) HEADER('User Name') - ON(100,8,CH) HEADER('Dflt Group') - ON(19,10,CH) HEADER('Created') - ON(118,10,CH) HEADER('Last Used') OCCUR FROM(TEMP0003) LIST(PRINT3T) - NOCC - WIDTH(500) - ON(78,1,CH) HEADER('Active Ids') - ON(VALCNT,N05) HEADER('Count') //RESTCNTL DD * SORT FIELDS=(10,8,CH,A) INCLUDE COND=(5,4,CH,EQ,C'0200',AND, 54,4,CH,NE,C'YES ',AND, 118,10,CH,NE,C' ',AND, 118,10,CH,NE,19,10,CH,AND, 100,8,CH,EQ,C'@GROEP',AND, 10,3,CH,EQ,C'@PREFIX') With these ICETOOL statements, when there is nothing I get this lame output: ********************************* Top of Data ***************** XYZ - SYSTEM: Active Ids 2017/05/31 13:37:55 NR User id User Name Dflt Group Created ------ -------- -------------------- ---------- ---------- Active Ids Count ---------- ------ ******************************** Bottom of Data *************** ... resulting in unneeded queries from reviewers of these reports. >2. What is the LRECL and RECFM of the dataset? It should not matter, but output is generally LRECL=500 and RECFM=FB (see NOCC in above example) Input for this specific example is a RACF Unloaded DB. RECFM=VB, LRECL=4096. I am also using SMF unloaded dataset from IRRADU00 (LRECL=12288, RECFM=VB) as well other SMF data and other datasets. >3. Does the header already exist in the input file and is it the first 2 records in the file? or can this be generated? No. I prefer raw data without headers as input, so I can add headers at a later stage like this ICETOOL example above or simply omit headers for sending over as a CSV file. Many thanks again! Groete / Greetings Elardus Engelbrecht ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN