Compare fields from the current and previous record

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

Compare fields from the current and previous record

Postby Arthwr81 » Thu May 10, 2012 12:00 am

Hi,

I´m trying to find a solution using DFSORT for this problem but I can't find any function to solve it.

I have one dataset that contains information of initial balance and final balance of an account. The first column is the account number, the second column is the initial balance and the third column is the final balance.

0192002682|0000001004931|0000000706570
0192002682|0000000706570|0000000706571
4000000018|0001935277780|0001943580986
4000000018|0001943580989|0001943580999

On this example the second record are OK because the final balance of the first record is 0000000706570 and the initial balance of the second record is the same 0000000706570. The fourth record is wrong because it's initial balance (0001943580989) is different from the final balance of the third record (0001943580986).

What i need is to extract records where the initial balance is different from the final balance on the previous record.

Is possbile to compare data from the current record with data from the previos record using DFSORT, ICETOOL, etc.?
Arthwr81
 
Posts: 1
Joined: Thu Apr 26, 2012 4:09 am

Re: Compare fields from the current and previous record

Postby skolusu » Thu May 10, 2012 1:11 am

Arthwr81,

Use the following DFSORT/ICETOOL JCL which will give you the desired results. I assumed that the data is already sorted on the account number.

Code: Select all
//STEP0100 EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//IN       DD *                                           
0192002682|0000001004931|0000000706570                     
0192002682|0000000706570|0000000706571                     
4000000018|0001935277780|0001943580986                     
----+----1----+----2----+----3----+----4----+----5----+----
4000000018|0001943580989|0001943580999                     
//OUT      DD SYSOUT=*                                     
//TOOLIN   DD *                                           
  SELECT FROM(IN) TO(OUT) ON(81,8,CH) ALLDUPS USING(CTL1) 
//CTL1CNTL DD *                                           
  OPTION COPY                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),       
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,10),                     
     PUSH=(90:SEQ=1,26,13),RECORDS=2),                     
  IFTHEN=(WHEN=(90,1,ZD,GT,1,AND,(12,13,ZD,NE,91,13,ZD)), 
  OVERLAY=(81:81,8,ZD,SUB,+1,M11,LENGTH=8))               
                                                           
  OUTFIL BUILD=(1,80)                                     
//*


The output from this is
Code: Select all
4000000018|0001935277780|0001943580986
4000000018|0001943580989|0001943580999
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
Global moderator
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post