Check sum of two fields in same record using JCL



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Check sum of two fields in same record using JCL

Postby sinmani » Wed May 15, 2013 12:43 pm

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
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well
sinmani
 
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Has thanked: 14 times
Been thanked: 0 time

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

Postby BillyBoyo » Wed May 15, 2013 12:53 pm

You can do it with INCLUDE or OMIT.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

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

Postby sinmani » Wed May 15, 2013 1:07 pm

But how to calculate Sum??
How to compare > 0 ?
What is the Keyword ?
Syntax?
I could not find anything on net
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well
sinmani
 
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Has thanked: 14 times
Been thanked: 0 time

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

Postby enrico-sorichetti » Wed May 15, 2013 1:23 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

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

Postby BillyBoyo » Wed May 15, 2013 1:50 pm

You have already shown you don't need to do any calculation. If A = B result will be zero. So OMIT when A = B.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

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

Postby sinmani » Wed May 15, 2013 1:56 pm

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.
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well
sinmani
 
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Has thanked: 14 times
Been thanked: 0 time

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

Postby BillyBoyo » Wed May 15, 2013 2:20 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

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

Postby sinmani » Wed May 15, 2013 2:32 pm

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.
-----------------------------------------
As long as you think you are a student, you are doing well.
The day you consider yourself as the master of the game..........well
sinmani
 
Posts: 93
Joined: Thu Mar 22, 2012 10:02 am
Has thanked: 14 times
Been thanked: 0 time

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

Postby BillyBoyo » Wed May 15, 2013 3:26 pm

  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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post