Page 1 of 1

Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 12:43 pm
by sinmani
Check sum of two fields in same record using JCL

I want to put a check in the JCl such that if the value of the sum of the second and fourth field is greater than 0
only then it should be copied to the output file.

For example Suppose my Input file is :
INPUT FILE
A 001 000 000 ---> Rec1
B 000 000 000 ---> Rec2
C 00-1 000 001 ---> Rec3
D 000 000 001 ---> Rec4

in ---> Rec1 A 001 000 000
001 + 000 = 1 >0 hence it should be copied.

B 000 000 000 ---> Rec2
000 + 000 = 0 hence Skip

C 00-1 000 001 ---> Rec3
00 -1 + 001 = 0 Hence Skip

D 000 000 001 ---> Rec4
000 + 001 = 1 Hence Copy.

Out file
OUTPUT FILE

A 001 000 000
D 000 000 001

Could you please help

Re: Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 12:53 pm
by BillyBoyo
You can do it with INCLUDE or OMIT.

Re: Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 1:07 pm
by sinmani
But how to calculate Sum??
How to compare > 0 ?
What is the Keyword ?
Syntax?
I could not find anything on net

Re: Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 1:23 pm
by enrico-sorichetti
if You had searched the forums You would have found them!

or look at
http://www-01.ibm.com/support/docview.w ... g3T7000094

or start from
www.ibm.com/storage/dfsort

Re: Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 1:50 pm
by BillyBoyo
You have already shown you don't need to do any calculation. If A = B result will be zero. So OMIT when A = B.

Re: Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 1:56 pm
by sinmani
BillyBoyo wrote:You have already shown you don't need to do any calculation. If A = B result will be zero. So OMIT when A = B.


No that is the not the case and this is just an example.

Also -1 is not equal to +1 Still this needs to be excluded.

Re: Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 2:20 pm
by BillyBoyo
Oh, I thought the embedded "-" was a typo :-)

Which Sort product do you use?

What is the RECFM of you input file? And LRECL?

You can calculate the sum and put the result in a temporary "extension" of your record. Where, depends on the RECFM and LRECL answer.

Then with OUTFIL OMIT you can exclude the ones whose sum is zero.

Re: Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 2:32 pm
by sinmani
BillyBoyo wrote:Oh, I thought the embedded "-" was a typo :-)

Which Sort product do you use?

What is the RECFM of you input file? And LRECL?

You can calculate the sum and put the result in a temporary "extension" of your record. Where, depends on the RECFM and LRECL answer.

Then with OUTFIL OMIT you can exclude the ones whose sum is zero.


Thanks Billy. this is exactly how I think this would be done but I don't know how to sum them up and store at the End.

We have both DFSORT and SYNCSORT.
File type = Flat file with fixed record length of 80.

Re: Check sum of two fields in same record using JCL

PostPosted: Wed May 15, 2013 3:26 pm
by BillyBoyo
  INREC OVERLAY=(81:1,3,ADD,7,3,ZD,TO=ZD,LENGTH=3)
  OUTFIL OMIT=(81,3,ZD,EQ,0),
        BUILD=(1,80)


Something along those lines. I don't know if your ZDs are PDs, or SFFs, BIs, but that, and the manual, should get you going.

You can do the TO=ZD,LENGTH=3 with an EDIT as an alternative.

The BUILD is to drop off the temporary extension.