Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

JCL to Delete Empty Datasets after DFSORT

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Time2Live

New User


Joined: 27 Apr 2005
Posts: 7

PostPosted: Wed Apr 27, 2005 5:57 am    Post subject: JCL to Delete Empty Datasets after DFSORT
Reply with quote

Hi,

I have a lot of empty datasets after a after running a DFSort. Is there a special technique to delete these dataset in a following JCL step, or a way to not catalog them if they are empty during the sort?

Currently my Sort Sysin looks like this:
//SYSIN DD DATA
SORT FIELDS=(9,4,CH,A,121,4,CH,A,86,10,CH,A,46,4,CH,A)
MERGE FIELDS=COPY
OUTFIL FILES=1,INCLUDE=(9,4,CH,EQ,C'AU ')
OUTFIL FILES=2,INCLUDE=(9,4,CH,EQ,C'SH ')
OUTFIL FILES=3,INCLUDE=(9,4,CH,EQ,C'PW ')
OUTFIL FILES=4,INCLUDE=(9,4,CH,EQ,C'SS ')
OUTFIL FILES=5,INCLUDE=(9,4,CH,EQ,C'AN ')

Thank you in advance.
Time2Live
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Apr 27, 2005 8:07 pm    Post subject:
Reply with quote

I'd be very interested to hear if somebody has an easy way to do this.

It would probably be possible to check each output file to see if it's empty and if so generate the JCL or a control statement (IEHPROGM?) to delete it, but it seems like there really should be a better way. I don't do this kind of thing myself, so I'm not aware of a simple solution.

BTW, MERGE FIELDS=COPY will do a COPY - your SORT statement will be ignored.
Back to top
View user's profile Send private message
ankyhunk

Moderator


Joined: 05 May 2005
Posts: 98
Location: Navi Mumbai, India

PostPosted: Thu May 05, 2005 6:53 pm    Post subject:
Reply with quote

Isnt it possible to delete the datasets using IEFBR14 utility?
e.g -
//STEP001 EXEC PGM=IEFBR14
//DD1 DD DSN=MY.DATA.SET,DISP=(OLD,DELETE)

Also you can check for empty datasets using FILEAID utility -

//CHKEMPTY EXEC PGM=FILEAID
//DD01 DD DSN=G1SG00AT.INFILE,DISP=SHR
//DD01O DD DSN=DUMMY,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA
//SYSOUT DD *
//SYSPRINT DD SYSOUT=*
//SYSLIST DD SYSOUT=*
//SYSTOTAL DD SYSOUT=*
//SYSIN DD DUMMY

If the input file is empty then this step will give RC = '08'. Trapping the return code of this step one can say whether the input file was empty.
Back to top
View user's profile Send private message
infoman123

New User


Joined: 01 Mar 2005
Posts: 10

PostPosted: Thu May 05, 2005 7:39 pm    Post subject:
Reply with quote

use icetool program itself to copy the 1st record of sorted data set into another....if its empty it will give a RC of 8 and delte if its empty.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu May 05, 2005 9:54 pm    Post subject:
Reply with quote

Quote:
use icetool program itself to copy the 1st record of sorted data set into another....if its empty it will give a RC of 8 and delte if its empty.


ICETOOL COPY does NOT set RC=8 if a file is empty and does NOT automatically delete an empty file. ICETOOL COUNT or NULLOUT can be used to force a non-zero return code for an empty data set, but the question still remains of how you "translate" that to the action of deleting the empty file.
Back to top
View user's profile Send private message
ankyhunk

Moderator


Joined: 05 May 2005
Posts: 98
Location: Navi Mumbai, India

PostPosted: Fri May 06, 2005 4:08 pm    Post subject:
Reply with quote

You put an if stmt like - if RC = 8 then execute the delete step.
Also you can compare the files produced with an empty file. If its true then delete the file produced.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri May 06, 2005 9:05 pm    Post subject:
Reply with quote

Quote:
You put an if stmt like - if RC = 8 then execute the delete step.


I think you're missing the point. The DFSORT step produces multiple output data sets. Some of them may be empty and some of them may not be empty. Only the empty data sets are to be deleted. DFSORT's NULLOFL parameter can set a RC=16 if any of the output data sets is empty. But if we use that RC=16 to execute the delete step, it will delete the non-empty data sets as well as the empty data sets. The challenge here is to find a way to delete ONLY the empty data sets without deleting the non-empty data sets.

Of course this could be done by using a step that creates one output data set followed by a step that deletes the output data set if its empty, and repeating for each output data set. But what the poster wants is a way to delete only the empty output data sets after a step that creates multiple output data sets, each of which may or may not be empty.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 239
Location: Cincinnati OH USA

PostPosted: Sat May 07, 2005 1:17 am    Post subject:
Reply with quote

Frank,

I think Ankur's method will work, but it does require two additional steps per output file.

First step is the Fileaid step to set the RC and followed by second step which is executed only upon RC=8 from first step and is and pgm=IEFBR14 with a MOD,DELETE,DELETE for the empty DSN.

Repeat for each output file.

In this case 5 output files from SORT step require additional 10 steps to achieve the desired result.


Dave
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat May 07, 2005 1:23 am    Post subject:
Reply with quote

You don't need FileAid to set the RC. You can use the COUNT operator of DFSORT's ICETOOL to do that. But I really think the whole idea here was to avoid having to do multiple steps for each output file. The original poster said "Is there a special technique to delete these dataset in a following JCL step". "step" here is singular. Or maybe I'm reading too much into it. If any number of steps will do, then it's easy.
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Mon Mar 08, 2010 11:11 pm    Post subject:
Reply with quote

May be you guys already found a easier solution, but if this is of any worth. You can do multiple files in the same step. A RC of 4 implies an empty file.
Code:
//STEP001 EXEC PGM=IDCAMS                             
//SYSPRINT DD SYSOUT=*                               
//SYSIN    DD *                                       
  PRINT INDATASET ('DSS1') COUNT(1)       
  IF LASTCC=4       -                                 
     THEN DELETE DSS1                     
  PRINT INDATASET ('DSS2') COUNT(1)   
  IF LASTCC=4       -                                 
     THEN DELETE DSS2                 
  SET MAXCC=0                                         
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DUMP DATASETS VS TRACE DATASETS! lind sh CICS 4 Tue Dec 06, 2016 11:31 pm
No new posts JCL to delete component in a package sundaram.naveen Compuware & Other Tools 14 Tue Nov 29, 2016 6:21 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts Single COPY CICS TS datasets and when... Kyle Carroll CICS 2 Tue Oct 11, 2016 9:47 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us