Greg,
You can actually use ICETOOL operator MODE to skip checking the second
file if the first file is empty
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
//IN2 DD *
//TOOLIN DD *
MODE STOP
COUNT FROM(IN1) EMPTY RC8
COUNT FROM(IN2) EMPTY RC4
//*
If IN1 is empty then the second COUNT operator will not RUN
However I do think OP wanted to check even if the file did not exist. So
if the files to be checked do not exist the above job will end with a JCL
error. With IDCAMS you can pass the filename via sysin cards and they do
not result in JCL error if the files do NOT exist. So here is a JCL that
OP can use
//**********************************************************************
//* RC = 08 IF FILEA AND FILEB ARE EMPTY *
//* RC = 04 IF FILEA HAS ATLEAST 1 RECORD AND FILEB IS EMPTY *
//* RC = 12 IF FILEA NOR FILEB DOES NOT EXIST *
//**********************************************************************
//STEP0100 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT INDATASET('FileA') COUNT (1)
IF LASTCC NE 0 THEN DO
PRINT INDATASET('FileB') COUNT (1)
IF LASTCC NE 0 THEN SET LASTCC=8
ELSE SET LASTCC = 4
END
ELSE
PRINT INDATASET('FileB') COUNT (1)
IF LASTCC NE 0 THEN SET LASTCC=4
END
END
//*
Thanks,
Kolusu
DFSORT Development
IBM Corporation
From: Greg Shirey <[email protected]>
To: [email protected],
Date: 03/06/2014 06:39 AM
Subject: Re: IDCAMS if-else
Sent by: IBM Mainframe Discussion List <[email protected]>
As an alternative, you can use ICETOOL, if you have it, to test for an
empty data set.
The text below is from IBM's Smart DFSORT Tricks:
For example, in the following ICETOOL job, the EMPTY operand of COUNT is
used to stop STEP2 from being
executed if the IN data set is empty. ICETOOL sets RC=8 (because the RC8
operand is specified) if the IN data
set is empty, or RC=0 if the IN data set is not empty. ICETOOL only reads
one record to determine if the data set
is empty or not empty, regardless of how many records there are in the
data set.
//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...
//TOOLIN DD *
* SET RC=8 IF THE 'IN' DATA SET IS EMPTY, OR
* SET RC=0 IF THE 'IN' DATA SET IS NOT EMPTY
COUNT FROM(IN) EMPTY RC8
/*
// IF STEP1.RC = 0 THEN
//*** STEP2 WILL RUN IF 'IN' IS NOT EMPTY
//*** STEP2 WILL NOT RUN IF 'IN' IS EMPTY
//STEP2 EXEC ...
...
// ENDIF
HTH,
Greg Shirey
Ben E. Keith Company
-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On
Behalf Of Micheal Butz
Sent: Wednesday, March 05, 2014 5:22 PM
To: [email protected]
Subject: IDCAMS if-else
I have 2 files and would lime to see
If one or both or none exist
I am using IDCAMS if-else sequence
With a command of print for this
However I am always coming up with a cc of 0 in the jcl for this step
E.G.
Let's say filea is empty so is fileb
Print indataset(filea) count (1)
If lastcc ne 0 then do
Print indataset(fileb) count (1)
If lastcc = 0 then set lastcc = 8
Else
Set lastcc = 0
End
Else do
Print indataset(fileb) count(1)
If lastcc ne 0 then
Set lastcc = 4
End
I always cone up with a 0 for the IDCAMS job step when it should be in the
case of 2 empty file 8 Sent from my iPhone
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN