# SORT - Sum of Group records and ratio on group

Author Message
gcchowdary
Warnings : 1

New User

Joined: 26 Dec 2005
Posts: 18
Location: India

 Posted: Mon Aug 02, 2010 9:00 pm Hi, My requirement is like i need to sum the group of records and find the ration of that group. for example. Input file has the below data. GROUP AGENT AMOUNT AAAA agent1 100 BBBB agent2 200 AAAA agent3 300 BBBB agent4 400 AAAA agent5 500 BBBB agent6 600 And, I want this in the output file1 as GROUP AGENT AMOUNT RATIO AAAA agent1 100 BBBB agent2 200 AAAA agent3 300 BBBB agent4 400 AAAA agent5 500 BBBB agent6 600 Where RATIO = GROUP TOTAL / Agent Amount for group AAAA = 900 / Agent1 Amount 100 = RATIO of agent1 for group BBBB = 1200 / Agent2 Amount 200 = RATIO of agent2 like thi. and in the output file2 should be as below GROUP AMOUNT AAAA 900 BBBB 1200 Can anybody give me suggessions on this or sort cards. or for the first task do i need to write cobol program. please let me know. Thanks G C Chowdary
Skolusu

Senior Member

Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

Posted: Mon Aug 02, 2010 10:15 pm

gcchowdary,

Use the same file for SORTJNF1 and SORTJNF2 and the following DFSORT JCL will give you the desired results.

 Code: //STEP0100 EXEC PGM=SORT                                            //SYSOUT   DD SYSOUT=*                                              //SORTJNF1 DD *                                                    AAAA AGENT1 100                                                    BBBB AGENT2 200                                                    AAAA AGENT3 300                                                    BBBB AGENT4 400                                                    AAAA AGENT5 500                                                    BBBB AGENT6 600                                                    //SORTJNF2 DD *                                                    AAAA AGENT1 100                                                    BBBB AGENT2 200                                                    AAAA AGENT3 300                                                    BBBB AGENT4 400                                                    AAAA AGENT5 500                                                    BBBB AGENT6 600                                                    //OUT1     DD SYSOUT=*                                              //OUT2     DD SYSOUT=*                                              //SYSIN    DD *                                                      SORT FIELDS=COPY                                                    JOINKEYS FILES=F1,FIELDS=(1,4,A)                                    JOINKEYS FILES=F2,FIELDS=(1,4,A)                                    JOIN UNPAIRED                                                      REFORMAT FIELDS=(F1:1,80,F2:81,8)                                  OUTFIL FNAMES=OUT1,BUILD=(1,17,81,8,ZD,DIV,13,3,ZD,M11,LENGTH=5)   OUTFIL FNAMES=OUT2,REMOVECC,NODETAIL,BUILD=(13X),                  SECTIONS=(1,4,TRAILER3=(1,4,X,81,8))                              //JNF2CNTL DD *                                                      INREC OVERLAY=(81:5C'0',13,3)                                      SUM FIELDS=(81,8,ZD)                                              //*
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics Very Large Sort failed - Seeking reco... DFSORT/ICETOOL 7 Date conversion using SORT SYNCSORT 4 Merging more than two records DFSORT/ICETOOL 15 Matching and non matching records usi... DFSORT/ICETOOL 11 Which SORT utility can improve the Pe... DFSORT/ICETOOL 16
Search our Forums: