Page 1 of 2

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

Posted: Wed Jan 23, 2013 12:50 am
by venky
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.

Posted: Wed Jan 23, 2013 1:16 am
by MrSpock
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=*
...

Posted: Sat Jan 26, 2013 1:18 am
by venky
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

Posted: Sun Jan 27, 2013 10:06 am
by DikDude
I suspect you can use the same process . . . :?

Posted: Sun Jan 27, 2013 2:31 pm
by venky
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.

Posted: Mon Jan 28, 2013 2:41 am
by NicC
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

Posted: Mon Jan 28, 2013 4:01 pm
by Anuj Dhawan
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?

Posted: Wed Jan 30, 2013 5:12 pm
by venky
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.

Posted: Wed Jan 30, 2013 8:47 pm
by William Collins
Show some sample input and expected output please.

Posted: Thu Jan 31, 2013 2:34 pm
by venky
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.

Posted: Thu Jan 31, 2013 4:24 pm
by William Collins
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?

Posted: Thu Jan 31, 2013 5:22 pm
by venky
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.

Posted: Mon Feb 04, 2013 11:32 am
by venky
Hi,

Please anyone help me for the above post. Thanks

Regards,
Venky.

Posted: Mon Feb 04, 2013 12:50 pm
by William Collins
Show some sample input, which covers all situations, and expected output.

Posted: Mon Feb 04, 2013 3:52 pm
by venky
William,

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

Regards,
Venky.