Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Exec step based on a cond

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Exec step based on a cond
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    Post subject: Re: Exec step based on a cond
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    Post subject:
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: 464

PostPosted: Tue Feb 21, 2006 3:58 pm    Post subject: Re: Exec step based on a cond
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    Post subject:
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: 1452
Location: Chicago, IL

PostPosted: Tue Feb 21, 2006 7:57 pm    Post subject: Re: Exec step based on a cond
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 Moderator


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

PostPosted: Tue Feb 21, 2006 8:25 pm    Post subject:
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":

http://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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Feb 22, 2006 9:42 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us