Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads

 MAINFRAME - TIP OF THE DAY : programming pearls - Good judgement comes from experience, and experience comes from bad judgement.

 Web mainframegurukul.com

Programmers Voted for below topics.      Please Vote for good Posts. Votes Salutes
Author Message

Active Member

Joined: 05 Nov 2008
Posts: 184

 0 salutes

Posted: Sun Apr 05, 2009 11:19 am    Post subject: Remove duplicates, Retain fisrt record , sum the amounts

Hi ,

Please provide the solutions for the following condition.

Input Records

 Code: 1111  2009-01-01   300 1111  2009-01-02   400 1111  2009-01-03   200 2222  2009-01-01   100 2222  2009-01-02   200 2222  2009-01-03   100

Output should be

 Code: 1111 2009-01-01    900 2222  2009-01-01   400

Input file is already sorted on 1st and second fields.
Need to retain first record.. should be first record only. ( least date record )
need to sumup the amounts in 3rd field, based on first field.
 <-- Click on right mark icon. If this post answer your question.

Moderator

Joined: 18 Feb 2006
Posts: 812
Location: San Jose, CA

 0 salutes

Posted: Sun Apr 05, 2009 8:06 pm    Post subject:

You can use a DFSORT job like the following to do what you asked for. Based on your example, I assumed your third field starts in position 17, is 6 bytes long and is always positive, but you can change the job appropriately if those assumption are incorrect. Since you said your records are already in order by the first field, I used a MERGE, which is more efficient then a SORT.

 Code: //S1    EXEC  PGM=SORT                              //SYSOUT    DD  SYSOUT=*                            //SORTIN01 DD *                                    1111  2009-01-01   300                              1111  2009-01-02   400                              1111  2009-01-03   200                              2222  2009-01-01   100                              2222  2009-01-02   200                              2222  2009-01-03   100          /*                    //SORTOUT DD SYSOUT=*                              //SYSIN    DD    *                                    OPTION EQUALS                                      MERGE FIELDS=(1,4,CH,A)                            SUM FIELDS=(17,6,ZD)                                OUTREC OVERLAY=(17:17,6,ZD,M10,LENGTH=6)          /*

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
_________________
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
 <-- Click on right mark icon. If this post answer your question.

Active Member

Joined: 05 Nov 2008
Posts: 184

 0 salutes

 Posted: Tue Apr 07, 2009 9:53 am    Post subject: It worked. Thanks a lot Frank. I did not understand OVERLAY in the card. If you have time, could you please Explain me.
 <-- Click on right mark icon. If this post answer your question.

Moderator

Joined: 09 Aug 2008
Posts: 1631
Location: Mumbai, India

 0 salutes

 Posted: Tue Apr 07, 2009 10:58 am    Post subject: Hi, Did you try to go through the link that Frank has provided? For specific information on DFSORT's OVERLAY function, see: www.ibm.com/servers/storage/support/software/sort/mvs/pdug/_________________Regards, Anuj
 <-- Click on right mark icon. If this post answer your question.

Moderator

Joined: 18 Feb 2006
Posts: 812
Location: San Jose, CA

 0 salutes

Posted: Tue Apr 07, 2009 8:06 pm    Post subject:

Vamsi99,

 Code: OUTREC OVERLAY=(17:17,6,ZD,M10,LENGTH=6)

OVERLAY here just takes the 6 byte ZD field starting at position 17 and overlays it with a 6-byte field starting at position 17 editted with the M10 mask (IIIIIT where I is 1-9 or a blank for 0 and T is 0-9).
_________________
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
 <-- Click on right mark icon. If this post answer your question.

Active Member

Joined: 05 Nov 2008
Posts: 184

 0 salutes

 Posted: Wed Apr 08, 2009 12:05 pm    Post subject: Thanks a lot Frank.
 <-- Click on right mark icon. If this post answer your question.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT + 5 Hours Page 1 of 1

 Jump to: Select a forum This Website----------------Admin AnnouncementsModerators Only APPLICATION PROGRAMMING----------------COBOLJCLDFSORT , ICETOOL & UtilitiesCICSEASYTRIEVE DATA MANAGEMENT SYSTEMS----------------DB2 SQL - DB2 PROGRAMMINGVSAM - File systemIMS DBIDMS TOOLS----------------XPEDITERFILE-AIDCHANGE MANENDEVOR, COOLGEN , PANVALET and CA-7 OTHER LANGUAGES----------------TSO, CLIST & REXXPL/IASSEMBLERIMS/DC CAREERS / JOBS DISCUSSIONS / INTERVIEW QUESTIONS----------------JOB VACANCIESJOB DISCUSSIONABEND CODES / ERROR CODESDB2 INTERVIEW QUESTIONSCOBOL INTERVIEW QUESTIONSJCL INTERVIEW QUESTIONSVSAM INTERVIEW QUESTIONSCICS INTERVIEW QUESTIONSINTERVIEW QUESTIONS OTHER MAINFRAME SUBJECTS----------------XMLMQSERIES & WEBSPHEREOTHER SUBJECTS GENERAL FORUMS----------------EntertainmentGeneral DiscussionPersonality DevelopmentOff TopicsSuggestions & Feedback
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

  Topics   Replies   Author   Views   Last Post Related topics To delete the Trailer REcord from the file 5 mkk157 11059 Mon Jan 25, 2016 10:59 pmacademyindia4 syncsort record count 2 valis 11663 Mon Jul 19, 2010 6:15 pmmouse13 how to update a record in a file using easytrieve 2 Malini 8679 Fri Jan 23, 2009 12:10 pmbata42 How to find out the record length using tso command? 4 bsriram 17322 Fri Oct 26, 2007 12:17 amvarun removing the duplicate record and picking up the last entery 2 pinaki_atha 7624 Fri Nov 10, 2006 3:18 amFrank Yaeger

 Cobol TutorialThis cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3..... DB2 TutorialDB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters CICS TutorialThis CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming... JCL TutorialThis is most popular JCL tutorial from mainframegurukul. It does contain important jcl .... SORT TutorialThis Tutorial covers all important aspects of DFSORT. Has more SORT examples INTERVIEW QuestionsThis page covers important interview questions Mainframe Jobs Mainframe Jobs posted by members of mainframegurukul forum FaceBook PageMainframeGurukul FaceBook Page LinkedIn PageMainframeGurkul Linkedin Page

 Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial Drona Educational Forums - Mainframe Cobol DB2 CICS Board Powered by phpBB
mainframetopic-3984.html