IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
HI all,
I have a question HOW TO IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY.
I have a question HOW TO IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY.
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
What I want exactly if the file is empty I want to run the second step like this
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
DFSORT only really likes sequential datasets, so using it do do this check on a VSAM file isn't doable (unless something has changed recently). What you need is an IDCAMS "PRINT" command:
This will try to print the first record in the dataset. If there's nothing in there, it'll drop a return code 160 from the VSAM open which will cause IDCAMS to return CC 12. If there's a matching record, you'll get CC 0.
Code: Select all
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//DD1 DD DSN=your.vsam.dataset,DISP=SHR
//SYSIN DD *
PRINT INFILE(DD1) COUNT(1)
- Anuj Dhawan
- Founder
- Posts: 2812
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
Along with that, SORT products can also work with VSAM:
This produces RC as 4, if the input VSAM dataset is empty.
Another variation:
Code: Select all
//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input-vsam-dataset
//TOOLIN DD *
COUNT FROM(IN) EMPTY RC4
/*
Another variation:
Code: Select all
/STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... VSAM data set
//TOOLIN DD *
* SET RC=12 IF THE 'IN' DATA SET IS EMPTY, OR
* SET RC=0 IF THE 'IN' DATA SET IS NOT EMPTY
COUNT FROM(IN) EMPTY USING(CTL1)
/*
//CTL1CNTL DD *
OPTION VSAMEMT
/*
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
I stand corrected... DFSORT can read VSAM. I'll admit that it's been a very long time since I last tried (and failed) to use it with anything other than a sequential file!
-
- Registered Member
- Posts: 22
- Joined: Thu Mar 17, 2016 9:54 pm
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
So we can use VSAM as input to a SORT step, that's good.
- Anuj Dhawan
- Founder
- Posts: 2812
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
Yes, you can.
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
Thank you, this is working for me.zum13 wrote: ↑Tue Aug 15, 2023 12:14 am DFSORT only really likes sequential datasets, so using it do do this check on a VSAM file isn't doable (unless something has changed recently). What you need is an IDCAMS "PRINT" command:
This will try to print the first record in the dataset. If there's nothing in there, it'll drop a return code 160 from the VSAM open which will cause IDCAMS to return CC 12. If there's a matching record, you'll get CC 0.Code: Select all
//STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //DD1 DD DSN=your.vsam.dataset,DISP=SHR //SYSIN DD * PRINT INFILE(DD1) COUNT(1)
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
Thank you Anuj, this also works.Anuj Dhawan wrote: ↑Wed Aug 16, 2023 12:08 am Along with that, SORT products can also work with VSAM:
This produces RC as 4, if the input VSAM dataset is empty.Code: Select all
//STEP1 EXEC PGM=ICETOOL //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN DD DSN=... input-vsam-dataset //TOOLIN DD * COUNT FROM(IN) EMPTY RC4 /*
Another variation:Code: Select all
/STEP1 EXEC PGM=ICETOOL //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN DD DSN=... VSAM data set //TOOLIN DD * * SET RC=12 IF THE 'IN' DATA SET IS EMPTY, OR * SET RC=0 IF THE 'IN' DATA SET IS NOT EMPTY COUNT FROM(IN) EMPTY USING(CTL1) /* //CTL1CNTL DD * OPTION VSAMEMT /*
-
- Registered Member
- Posts: 22
- Joined: Thu Mar 17, 2016 9:54 pm
Re: IDENTIFY WEATHER THE KSDS EMPTY OR NOT USING SORT UTILITY
Thanks, this is a useful thread. Thanks for sharing all the info.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute