IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Exec step based on a cond


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Tue Feb 21, 2006 12:06 pm
Reply with quote

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
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Tue Feb 21, 2006 12:15 pm
Reply with quote

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
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Tue Feb 21, 2006 12:23 pm
Reply with 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.

Thanks

T & R
Prabs
Back to top
View user's profile Send private message
Rupesh.Kothari

Member of the Month


Joined: 27 Apr 2005
Posts: 463

PostPosted: Tue Feb 21, 2006 3:58 pm
Reply with quote

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
View user's profile Send private message
VENKATA999
Warnings : 2

New User


Joined: 05 Jan 2006
Posts: 44

PostPosted: Tue Feb 21, 2006 7:35 pm
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Feb 21, 2006 7:57 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Tue Feb 21, 2006 8:25 pm
Reply with quote

Note that you can also use DFSORT's ICETOOL to determine if a file is empty as discussed in this "Smart DFSORT Trick":

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmst03.html#t10
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Wed Feb 22, 2006 10:01 am
Reply with quote

Fine...Thanks all of you..got it...

T & R
Prabs
Back to top
View user's profile Send private message
sendil

New User


Joined: 30 Jun 2005
Posts: 27

PostPosted: Wed Feb 22, 2006 2:29 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Feb 22, 2006 9:42 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts JCL EXEC PARM data in C Java & MQSeries 2
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
Search our Forums:

Back to Top