Getting Net amount using SORT



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Getting Net amount using SORT

Postby djprakash1ml » Tue May 03, 2011 3:33 pm

Hi - Could you please suggest a way to get this output using SORT?

CR stands for credit
DR stands for debit

If a name has only one CR or one DR they should be left undisturbed and displayed as net amount.

Sample:-
=======

Name code amt
=============
AAA CR 110
AAA DR - 50
BBB CR 200
BBB DR -150
CCC CR 85
DDD DR - 50

Name netamt
==============
AAA 60
BBB 50
CCC 85
DDD -50

Regards,
David
djprakash1ml
 
Posts: 17
Joined: Mon Jun 28, 2010 6:33 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Getting Net amount using SORT

Postby NicC » Tue May 03, 2011 6:41 pm

Usual questions...LRECL, RECFM, key position, key length, multiple records of one or each type etc etc.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Getting Net amount using SORT

Postby Frank Yaeger » Tue May 03, 2011 10:33 pm

David,

You can use a DFSORT job like the following to do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAA  CR   110
AAA  DR  - 50
BBB  CR   200
BBB  DR  -150
CCC  CR    85
DDD  DR  - 50
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    HEADER2=('Name   netamt',/,
             '=============='),
    SECTIONS=(1,3,
     TRAILER3=(1,3,5:TOT=(9,5,SFF,EDIT=(SIIIT),SIGNS=(,-))))
/*
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
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Getting Net amount using SORT

Postby djprakash1ml » Wed May 04, 2011 12:05 pm

Thanks Frank.
djprakash1ml
 
Posts: 17
Joined: Mon Jun 28, 2010 6:33 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post