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.