Page 1 of 1

Subtraction using JCL sort

PostPosted: Sat May 25, 2013 10:51 am
by Shweta Jain
I have a VB file of 80 bytes and I have to sort this file based on 1-3 bytes(key field) and then sum next 12 bytes for similar key values and subtract 4 from it and store the output in a VB file.

I have generated a JCl which sorts the file and calculates the sum of next 12 byte for similar key values. PFB the sort cord:
sort fields=(5,3,ch,a)
Sum fields=(8,12,ZD)
Outrec=(5:5,3,8:8,12,ZD)
Here I have used 5 because its an VB file and in VB file 1-4 bytes are reserved.

Input file data:
K01000000000010
K01000000000010
K02000000000010

Output file data:
K01000000000020
K02000000000010
Here sum is 12 bytes long.

Now as I have to subtract 4 from the sum I have changed my sort card as given below:
sort fields=(5,3,ch,a)
Sum fields=(8,12,ZD)
Outrec=(5:5,3,8:8,12,ZD,SUB,+4,M11)

On using above sort card I got unexpected result:
Output data:
K01000000000000016
K02000000000000006

The sum is now 15 bytes long instead of 12 bytes.

Can anybody please tell me why on using SUB keyword the size increases from 12 to 15bytes.

Re: Subtraction using JCL sort

PostPosted: Sat May 25, 2013 11:27 am
by BillyBoyo
Because you haven't said how long you want the result to be, so you get the default length.

You can specify the length with LENGTH= or with an EDIT.

Re: Subtraction using JCL sort

PostPosted: Sat May 25, 2013 12:21 pm
by Shweta Jain
Thanks a lot Billy. :)

Re: Subtraction using JCL sort

PostPosted: Sat May 25, 2013 1:21 pm
by NicC
Why was this posted in the FAQ section? Moving to DFSort but if you use another sort product (look at your sort messages) let us know and it will be moved to the correct section. And a quick note on terminology - the JCL does NOT sort your input - Sort does. It is a program, not JCL and its control card are sort control cards - again...not JCL.