View previous topic :: View next topic
|
Author |
Message |
prabs2006
Active User
Joined: 12 Jan 2006 Posts: 103
|
|
|
|
Hi all,
I have a JCL step where a file being FTPd. Assume the file being created in any of the prev steps. Now I would like to execute the last step only if the file is non-empty. How can it be done.
T & R
Prabs |
|
Back to top |
|
|
nuthan
Active User
Joined: 26 Sep 2005 Posts: 146 Location: Bangalore
|
|
|
|
Hi,
After creating that file check wether its empty or not in a separate step. Depending on the return code of this step use IF COND to procede further to execute the last step. |
|
Back to top |
|
|
prabs2006
Active User
Joined: 12 Jan 2006 Posts: 103
|
|
|
|
Hi,
Somehow it can be done with COND. how? (this was an interview Q)
But again h can we know a file is empty or non-empty or is there any other alternate soln.
Thanks
T & R
Prabs |
|
Back to top |
|
|
Rupesh.Kothari
Member of the Month
Joined: 27 Apr 2005 Posts: 463
|
|
|
|
Hi,
Quote: |
Hi,
Somehow it can be done with COND. how? (this was an interview Q)
But again h can we know a file is empty or non-empty or is there any other alternate soln. |
You need to check first that if File contain data or not by
Code: |
//STEP01C EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INDD5 DD DSN=File name
//SYSIN DD *
PRINT INFILE(INDD5) COUNT(1) |
Then use if --end if
Hope it is clear now.
Regards
Rupesh |
|
Back to top |
|
|
VENKATA999 Warnings : 2 New User
Joined: 05 Jan 2006 Posts: 44
|
|
|
|
Hi,
This also can be done through the listcat command of idcams .
if dataset exist it will give 0 ruturn code other wise some non-zero . In the second step check the cond like cond=(4,ne,stepnamewhere u are checking listcat command )
Thank you, |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
As Rupesh already provided above IDCAMS code to check empty file.
I'll just add something to that.
Code: |
//S010 FILE CREATION
//::
//::
//S020 EXEC PGM=IDCAMS
//IN DD DSN=HLQ.INPUT.FILE,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD DATA
PRINT INFILE(IN) COUNT(1)
/*
//IFSTEP# IF (S020.RC^=4) THEN
//S030 FTP STEP
//::
//ENDSTEP# ENDIF |
This IDCAMS code will return RC=4 in case of file is empty. And If cond provided will check for RC of S020. Then based on RC FTP step will be executed.
COND PARAMETER :
Code: |
//S010 FILE CREATION
//::
//::
//S020 EXEC PGM=IDCAMS
//IN DD DSN=HLQ.INPUT.FILE,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD DATA
PRINT INFILE(IN) COUNT(1)
/*
//S030 FTP STEP,COND=(4,EQ,S020)
//::
|
Regards,
Priyesh. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
Back to top |
|
|
prabs2006
Active User
Joined: 12 Jan 2006 Posts: 103
|
|
|
|
Fine...Thanks all of you..got it...
T & R
Prabs |
|
Back to top |
|
|
sendil
New User
Joined: 30 Jun 2005 Posts: 27
|
|
|
|
Empty file check,
//*********************************************************************
//* SETS RC=0000 IF DATASET HAS RECORDS *
//* SETS RC=0004 IF DATASET IS EMPTY *
//* You will need syncsort 3.7 with TPF2A or higher to work *
//*********************************************************************
//STEP0100 EXEC PGM=SORT,PARM='NULLOUT=RC4'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=YOUR FILE IN QUESTION,
// DISP=SHR
//SORTOUT DD DUMMY
//SYSIN DD *
SORT FIELDS=COPY
/* |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Note that you need z/OS DFSORT V1R5 to use the NULLOUT parameter. It is not available with DFSORT R14. On the other hand, COUNT with EMPTY is available for both releases. |
|
Back to top |
|
|
|