Posted: Wed May 06, 2015 12:20 pm Post subject: SUM Fields with PUSH
Hi,
Please advise, Is it possible to sum the records from 1 to 5998(SEQNO) i.e a group of records will start from 1 to 5998 and a summary record will be in 5999th record
Once i use SUM FIELDS i will have 1 to 5998 records in one line, After that i need bring the 5999th records to the SUM'ed line.
I tried with Joinkeys have same input file, is it possible to do without joinkeys with one Pass
Code:
//SORTJNF1 DD DSN=FB1,DISP=SHR
//SORTJNF2 DD DSN=FB1,DISP=SHR
//SORTOUT DD DSN=FB.SORTOU15,DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE)
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(7,7,A)
JOINKEYS FILE=F2,FIELDS=(7,7,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F2:1,23,F1:18,6,?)
OPTION COPY
OUTFIL IFTHEN=(WHEN=(30,1,CH,EQ,C'B'),
BUILD=(7,5,C',',12,2,C',',18,6,PD,EDIT=(IIIIIIIIT.TT), Matching record will have values in F1
C',',24,6,PD,EDIT=(IIIIIIIIT.TT))),
IFTHEN=(WHEN=NONE,
BUILD=(7,5,C',',12,2,C',',18,6,PD,EDIT=(IIIIIIIIT.TT), unpaired record will not have any values in F1 so moving zeros.
C', 0.00'))
/*
//JNF1CNTL DD *
INCLUDE COND=(15,4,CH,LT,C'5999',AND, PIC the record till 5998
(13,2,CH,EQ,C'31',OR,13,2,CH,EQ,C'67',OR,
13,2,CH,EQ,C'01',OR,13,2,CH,EQ,C'61'))
INREC BUILD=(2,17,229,6)
SUM FIELDS=(18,6,PD) Sum the records
/*
//JNF2CNTL DD *
INCLUDE COND=(15,4,CH,EQ,C'5999',AND, GET the 5999th records
(13,2,CH,EQ,C'31',OR,13,2,CH,EQ,C'67',OR,
13,2,CH,EQ,C'01',OR,13,2,CH,EQ,C'61'))
INREC BUILD=(2,17,223,6)
/*
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
Posted: Wed May 06, 2015 12:28 pm Post subject:
Magesh_J,
If I understand correctly you just need 2 records with summed values? The first record will have summed values for 1 thru 5998 records and the second record will the summed values for 5999 thru end of file?
If that is indeed the requirement then you have complicated a simple request.
A few more clarifications.
You are sorting FIELD-4 and Field-5 as a key.
Field-5 can have the following values
Code:
01
31
61
67
So that would yield you a minimum of 4 summed records. Where do you want the summary record data? on all the records? or just on the last one or on the key
Note: Store1 has Four types of records 01,31,61,67.
For each type of record we have a summary record i.e 5999 in field 6.
In the above example Let us take Store1 01st record.
It has two sequence records and one summary record
I need to sum up the two sequence record and bring the total to the summary record. This is wat we did it with Joinkeys.
Otherway is also fine. Bring the summary record to the summed record.
As per our joinkeys output would be(for clarity reason i am displaying Field6 in the acutal output of the joinkey field6 will not be there)
Code:
Store1 01 5999 10000 +300
Otherway
Code:
Store1 01 2000 10000 +300
why both way is fine is because, we need not required Field6 in the output.
Also note Every store with a type will have summary records, but sequence may or may not be
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum