Page 1 of 1

Question: Sortof-statement and file allocations

PostPosted: Thu Oct 04, 2012 6:40 pm
by Johan Vermeulen
Hallo,

I have a question regarding the use of SORTOF-statement.

A SORTIN input file is splitted in several files thru a SORTOF-statement. A total of 140 files
are created that maybe will contain data. Afterwards I added an extra step to control the newly
created SORTOF files, and delete them if empty.
Not with the SPEMPTY statement, but with IDCAMS combined with PRINT statement.
I found no other method that I could use in one step...
(USE SYNCSORT 1.3.2.R)

My question:
When executing the job, we noticed an important increase in ELAPSED Time and CPU Time because of the
extra delete statement.

-> Is there a way to make use of the SORTOF-statement without allocating all the mentioned files?
In other words: Can I use the SORTOF-statement in a way that files, that are not written to, automatically
will be deleted?


Example of as-is:

//S0030 EXEC SPSORT
//* ==== INPUT FILES
//SORTIN DD DSN=sortinfile_1,
// DISP=SHR
//$ORTPARM DD *
VLTEST=0
//SORTOF01 DD DISP=(,CATLG,DELETE),LRECL=12280,RECFM=VB,EXPDT=&EXP05WD,
// DSN=sortoffile_1
//SORTOF02 DD DISP=(,CATLG,DELETE),LRECL=12280,RECFM=VB,EXPDT=&EXP05WD,
// DSN=sortoffile_2
//SORTOF03 DD DISP=(,CATLG,DELETE),LRECL=12280,RECFM=VB,EXPDT=&EXP05WD,
// DSN=sortoffile_3
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=01,
INCLUDE=(211,12,CH,EQ,X'004400320050005A005A0031'),
OUTREC=(1,90,491)
OUTFIL FILES=02,
INCLUDE=(211,12,CH,EQ,X'004400320050005A005A0032'),
OUTREC=(1,90,491)
OUTFIL FILES=03,
INCLUDE=(211,12,CH,EQ,X'004400320050005A005A0033'),
OUTREC=(1,90,491)
//*
//S0035 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT INDATASET ('sortoffile_1') COUNT(1)
IF LASTCC=4 -
THEN DELETE sortoffile_1 PURGE
PRINT INDATASET ('sortoffile_2') COUNT(1)
IF LASTCC=4 -
THEN DELETE sortoffile_2 PURGE
PRINT INDATASET ('sortoffile_3') COUNT(1)
IF LASTCC=4 -
THEN DELETE sortoffile_3 PURGE
SET MAXCC=0
//*

Any suggestions?
Many thanks in advance!

Re: Question: Sortof-statement and file allocations

PostPosted: Thu Oct 04, 2012 7:03 pm
by BillyBoyo
In general, I think the answer is "no".

Why do you need to delete the files?

I suspect there is a better way than 140 PRINT/IF/DELETE statements in IDCAMS if you can describe what you are trying to achieve by deleting the files.

Re: Question: Sortof-statement and file allocations

PostPosted: Thu Oct 04, 2012 7:34 pm
by Johan Vermeulen
These jobs run every hour. In a later process, but same run, these 140 files are being ZIPPED and sent via C:D to servers.
Because we prefer to clean up the datasets that are not used, I tried to delete these datasets in the same JCL.

The IDCAMS statement was the only solution I found. I haven't found a parameter for the SORTOF-statement
that didn't allocate the datasets that are not used... :(

I know 140 PRINT/IF/DELETE statements in IDCAMS is not ideal, but at the moment this is the only alternative.
Ohterwise I wouldn't be posting my question on this forum ;)

Re: Question: Sortof-statement and file allocations

PostPosted: Thu Oct 04, 2012 8:48 pm
by dick scherrer
Hello and welcome to the forum,

I know 140 PRINT/IF/DELETE statements in IDCAMS is not ideal, but at the moment this is the only alternative.
No, this is Not the only alternative - if i understand the issue.

If you only create the files with data, there would be nothing to delete due to the file being empty. . .

Yes, it would take a bit more work, but would reduce the overhead of creating all of these files only to deleete them.

Re: Question: Sortof-statement and file allocations

PostPosted: Thu Oct 04, 2012 9:08 pm
by NicC
If you only create the files with data
which is what TS is trying to determine - if there is a way of sort doing this. However, you still have to specify all 140 datasets in the JCL so they have to exist. There is no JCL parameter that says 'delete if not written to' - unfortunately.

Re: Question: Sortof-statement and file allocations

PostPosted: Thu Oct 04, 2012 9:37 pm
by dick scherrer
Hello,

But there are ways to generate only the DD statements and SortControl for the files that will be used. . .

As i mentioned, it would be a bit more work, but it is quite do-able. It is just not an automagic "do it with sort" thingy.

FWIW - several places i've worked with had this kind of requirement but with far more files to be inbound/outbound. One such received "stuff" multiple times a day from about 450 manufacturing, distribution, and sales sites and each night new data was sent to these remote sites - when there was data to send.

Re: Question: Sortof-statement and file allocations

PostPosted: Sat Oct 06, 2012 5:25 am
by BillyBoyo
Perhaps deleting with ADRDSSU would be quicker.

If you arrange a single-record file with the total output count on, you'd know how many files were used.

Possible to then parse the JCL, extracting the last "n" which you'd know are not used, and create the delete statement for all of those at once.

Or, going with Dick, count the records first, then generate only the JCL and Sort cards needed.

You'd have to mock-up the possibilities and see which gives you the most manageable way of getting the result you want.