want to check a file is empty or not in a JCL

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

venky
Active Member
Posts: 50
Joined: Sat May 12, 2012 10:13 pm

want to check a file is empty or not in a JCL

Post by venky » Wed Jan 23, 2013 12:50 am

Hi all ,

I want to check a file is empty or not in a JCL in first step

and in secod step:

If its not emty
I will take some action
else
I will take some other action.

can u pls tel me the how to do this in Jcl. Thanks.

Regards,
Venky.

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Wed Jan 23, 2013 1:16 am

In our shop we use SYNCSORT with a NULLOUT parameter, i.e.:

Code: Select all

//STEP EXEC PGM=SORT,PARM='NULLOUT=RC4'  
//SORTIN DD DSN=DSN to check
//SORTOUT DD SYSOUT=*
...

venky
Active Member
Posts: 50
Joined: Sat May 12, 2012 10:13 pm

Post by venky » Sat Jan 26, 2013 1:18 am

Thank you it is working,

Now I want to check if the file as records, then I need to get some return code.

Please help me.

Regards,
Venkatesh

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Sun Jan 27, 2013 10:06 am

I suspect you can use the same process . . . :?
Have a good one

venky
Active Member
Posts: 50
Joined: Sat May 12, 2012 10:13 pm

Post by venky » Sun Jan 27, 2013 2:31 pm

Dikdude, thank you for the reply, If the file contains records I am getting maxcc=0.

Is there is any possibility to get other than maxcc=0?

Please help me.

Regards,
Venky.

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Mon Jan 28, 2013 2:41 am

Why on earth would you need something else - you can only have 2 possibilities - you have records or you don't have records - rc = 0 or rc = 4
Regards
Nic

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Mon Jan 28, 2013 4:01 pm

venky wrote:Now I want to check if the file as records, then I need to get some return code.
Did you mean to checking some specific condition, at some location, in input records?
Regards,
Anuj

venky
Active Member
Posts: 50
Joined: Sat May 12, 2012 10:13 pm

Post by venky » Wed Jan 30, 2013 5:12 pm

Hi Anuj,

ok if I have records in particular position(say 4th position with length 9) then I need to get return code other than maxcc=0?

Please help me if it is possible. Thank you.

Regards,
Venky.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Jan 30, 2013 8:47 pm

Show some sample input and expected output please.

venky
Active Member
Posts: 50
Joined: Sat May 12, 2012 10:13 pm

Post by venky » Thu Jan 31, 2013 2:34 pm

William,

suppose In the input file I have the below records in 4th position with length 9.


123456789
302645877
012456478
124567247

Now if I have records in this position(4th position) then I need to get return code other than maxcc=0.

If this is possible please help me. Thank you.

Regards,
Venky.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Jan 31, 2013 4:24 pm

So if any of those four (static?) values appear in your data at the 4th position, you want to have a non-zero return code?

Which Sort product do you have? Can you show the full sysout from a Sort step?

You've seen that an RC can be set when an output file contains no data. So they key is to not write data to a (dummy) output file if one of those keys (at least) exists. Do you have a "trailer" on your file?

venky
Active Member
Posts: 50
Joined: Sat May 12, 2012 10:13 pm

Post by venky » Thu Jan 31, 2013 5:22 pm

William,

Yes, If it contains data in 4th position which are not static then I need to get non-zero return code, but the data will be always from 0 to 9 in 4th position with length 1( the data will be 0 or 1 or 2 or 3 or 4 or 5 and so on upto 9 in 4th position).

I am using the Sort utility. Please see the below JCL.

JCL for empty input file: I am getting return code is maxcc=4

//Job card
//Step01 exec pgm=sort,parm='nullout=RC4'
//sysprint dd sysout=*
//sysout dd sysout=*
//Sortin dd dsn='input file',disp=shr
//sortout dd sysout=*
//sysin dd dummy

JCL for input file having records: for the below JCL I need to get non-zero return code?

//Job card
//Step01 exec pgm=sort
//sysprint dd sysout=*
//sysout dd sysout=*
//Sortin dd dsn='input file',disp=shr
//sortout dd sysout=*
//sysin dd dummy

I am not having "trailer" in the file. I have number of records in the file which look like below and in 4th position it can 0 or 1 or 2 upto 9 which are static.

012345678
112345678
212345678
312345678
412345678
512345678
612345678
712345678
812345678
912345678

Regards,
Venky.

venky
Active Member
Posts: 50
Joined: Sat May 12, 2012 10:13 pm

Post by venky » Mon Feb 04, 2013 11:32 am

Hi,

Please anyone help me for the above post. Thanks

Regards,
Venky.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Mon Feb 04, 2013 12:50 pm

Show some sample input, which covers all situations, and expected output.

venky
Active Member
Posts: 50
Joined: Sat May 12, 2012 10:13 pm

Post by venky » Mon Feb 04, 2013 3:52 pm

William,

I have mentioned everything in my post. Please look into it once again. Thanks.

Regards,
Venky.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others