MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help needed. Compare columns and write out

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
shuko
Beginner


Joined: 08 Nov 2005
Posts: 73
Topics: 20

PostPosted: Thu Mar 02, 2006 8:55 am    Post subject: Help needed. Compare columns and write out Reply with quote

Please Help. I spent a few days trying to get my ICETOOL statements to work, but
was unable to come up with anything satisfactory.
Input files LRECL=80,FB. 3 keys with position 20,1, and 30,6 and 37,4

Rules

* If record in both files and 45,7 NE 85,7 AND 53,27 EQ 94,27
write File1 to OUT1 AND File2 to OUT2
*
* If record in both files and 45,7 EQ 85,7 AND 53,27 NE 94,27
OR 45,7 NE 85,7 AND 53,27 NE 94,27
write File1 to OUT3 AND File2 to OUT4
*
* If record in both files and 1,10 NE 85,10 AND 45,35 EQ 85,35
write File1 to OUT3 AND File2 to OUT4
*
* If record from File1 not in File2 write to DCARD1
* If File1 record = File2 record (1,80 = 85,80)
Write File1 to DCARD1 and File2 to DCARD2



Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//IN1 DD *                                                             
950.00     2005    N   CHF   RISKA  1111    OPEN    TECH    HOST   ABCD
2950.00    2005    N   CHF   EAB    1111    OPEN    TECH    HOST   EFGHI
250.00     2005    Y   CHF   RISK   2222    OPEN    TECH    HOST   MNOP
100.00     2004    Y   YEN   JAP    3333    BOOK    MECH    AS400  XYZ 
999.00     2003    N   CHF   LUGI   4444    BOOK    TEST    PC     ACCY
//IN2 DD *                                                             
2950.00    2005    N   CHF   EAB    1111    OPEN    TECH    HOST   EFGHI
950.00     2005    N   CHF   RISKA  1111    BOOKED  TECH    HOST   ABCD
550.00     2005    Y   CHF   RISK   2222    OPEN    TECH    HOST   MNOP
999.00     2003    N   CHF   LUGI   4444    BOOK    PROD    PC     LENT
345.00     2002    N   DEM   GERM   2134    SETL    TRAIN   HOST   SCHW
/*                                                                     
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)           
//OUT1   DD DSN=OUT1                                                   
//OUT2   DD DSN=OUT2                                                   
//OUT3   DD DSN=OUT3                                                   
//OUT4   DD DSN=OUT4                                                   
//DCARD1 DD DSN=DCARD1                                                 
//DCARD2 DD DSN=DCARD2                                                 
//TOOLIN DD *   
COPY FROM(IN1) TO(T1) USING(CTL1)           
COPY FROM(IN2) TO(T1) USING(CTL2)           
* SPLICE records on key to get:             
* IN1 key/data|id|IN2 data|                 
* id = 21 if key is in file1 and file2     
*      11 if key is in file1 only           
*      22 if key is in file2 only           
SPLICE FROM(T1) TO(OUT1)  -                 
   ON(20,1,CH) ON(30,6,CH) ON(37,4,CH)  -   
   WITH(81,1) WITH(85,80) -                 
  KEEPNODUPS USING(CTL3)                   
/*                                         
//CTL1CNTL DD *                             
  OUTREC FIELDS=(1,80,81:C'11',165:X)       
//CTL2CNTL DD *                             
  OUTREC FIELDS=(1,80,81:C'22',85:85,80)   
//CTL3CNTL DD * 

* If record in both files and 45,7 NE 85,7 AND 53,27 EQ 94,27     
* write File1 to OUT1 AND File2 to OUT2                           
*                                                                 
* If record in both files and 45,7 EQ 85,7 AND 53,27 NE 94,27     
* OR 45,7 NE 85,7 AND 53,27 NE 94,27                             
* write File1 to OUT3 AND File2 to OUT4                           
*                                                                 
* If record in both files and 1,10 NE 85,10 AND 45,35 EQ 85,35   
* write File1 to OUT3 AND File2 to OUT4                           
*                                                                 
* If record from  File1 not in File2 write to DCARD1             
* If File1 record = File2 record (1,80 = 85,80)                   
* Write File1 to DCARD1 and File2 to DCARD2                   
 
                                               





Expected output


Code:


OUT1
====

950.00     2005    N   CHF   RISKA  1111    OPEN    TECH    HOST   ABCD


OUT2
====

950.00     2005    N   CHF   RISKA  1111    BOOKED  TECH    HOST   ABCD


OUT3
====
250.00     2005    Y   CHF   RISK   2222    OPEN    TECH    HOST   MNOP
999.00     2003    N   CHF   LUGI   4444    BOOK    TEST    PC     ACCY

OUT4
====
550.00     2005    Y   CHF   RISK   2222    OPEN    TECH    HOST   MNOP
345.00     2002    N   DEM   GERM   2134    SETL    TRAIN   HOST   SCHW
999.00     2003    N   CHF   LUGI   4444    BOOK    PROD    PC     LENT

DCARD1
=======
2950.00    2005    N   CHF   EAB    1111    OPEN    TECH    HOST   EFGHI
100.00     2004    Y   YEN   JAP    3333    BOOK    MECH    AS400  XYZ 

DCARD2
=======
2950.00    2005    N   CHF   EAB    1111    OPEN    TECH    HOST   EFGHI


Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Mar 02, 2006 10:07 am    Post subject: Reply with quote

Shuko,

One more clarification. will there be any duplicates in either of your input files on the key fields (All three keys combined - 20,1, and 30,6 and 37,4) ?

If there are no duplicates, then you can go in for the traditional way of appending a Character '1' in File 1, and Char '2' in File 2. Concatenate both these files and then do a Sort on key fields and Sum on the literal - then separate the records into different files using OUTFIL INCLUDE. I believe, this would be simpler to use and understand than using Splice (Just my Personal Opinion).

Thanks,
Phantom
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Mar 02, 2006 1:23 pm    Post subject: Reply with quote

Shuko,

I came up with the following DFSORT/ICETOOL job that I think encompasses your rules, but it doesn't produce the same output you show. As far as I can tell, your rules don't actually match the expected output you show, but it's possible I misinterpreted your rules. I can't spend any more time on this, but perhaps my job will show you the technique you need to figure out what you want to do.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD *
950.00     2005    N   CHF   RISKA  1111    OPEN    TECH    HOST   ABCD
2950.00    2005    N   CHF   EAB    1111    OPEN    TECH    HOST   EFGHI
250.00     2005    Y   CHF   RISK   2222    OPEN    TECH    HOST   MNOP
100.00     2004    Y   YEN   JAP    3333    BOOK    MECH    AS400  XYZ
999.00     2003    N   CHF   LUGI   4444    BOOK    TEST    PC     ACCY
//IN2 DD *
2950.00    2005    N   CHF   EAB    1111    OPEN    TECH    HOST   EFGHI
950.00     2005    N   CHF   RISKA  1111    BOOKED  TECH    HOST   ABCD
550.00     2005    Y   CHF   RISK   2222    OPEN    TECH    HOST   MNOP
999.00     2003    N   CHF   LUGI   4444    BOOK    PROD    PC     LENT
345.00     2002    N   DEM   GERM   2134    SETL    TRAIN   HOST   SCHW
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT1   DD SYSOUT=*
//OUT2   DD SYSOUT=*
//OUT3   DD SYSOUT=*
//OUT4   DD SYSOUT=*
//DCARD1 DD SYSOUT=*
//DCARD2 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT1)  -
   ON(20,1,CH) ON(30,6,CH) ON(37,4,CH)  -
   WITH(101,81) -
  KEEPNODUPS USING(CTL3)
/*
//CTL1CNTL DD *
  OUTREC FIELDS=(1,80,180:X,181:C'11')
//CTL2CNTL DD *
  OUTREC FIELDS=(1,80,101:1,80,181:C'22')
//CTL3CNTL DD *

   OUTFIL FNAMES=OUT1,
    INCLUDE=(181,2,CH,EQ,C'21',AND,
    ((45,7,CH,NE,145,7,CH,AND,53,27,CH,EQ,153,27,CH),OR,
     (45,7,CH,EQ,145,7,CH,AND,53,27,CH,NE,153,27,CH),OR,
     (45,7,CH,NE,145,7,CH,AND,53,27,CH,NE,153,27,CH))),
    OUTREC=(1,80)

   OUTFIL FNAMES=OUT2,
    INCLUDE=(81,2,CH,EQ,C'21',AND,
    ((45,7,CH,NE,145,7,CH,AND,53,27,CH,EQ,153,27,CH),OR,
     (45,7,CH,EQ,145,7,CH,AND,53,27,CH,NE,153,27,CH),OR,
     (45,7,CH,NE,145,7,CH,AND,53,27,CH,NE,153,27,CH))),
    OUTREC=(101,80)

   OUTFIL FNAMES=OUT3,
     INCLUDE=(181,2,CH,EQ,C'21',AND,1,10,CH,NE,101,10,CH,
       AND,45,35,CH,EQ,145,35,CH),
     OUTREC=(1,80)

   OUTFIL FNAMES=OUT4,
     INCLUDE=(181,2,CH,EQ,C'21',AND,1,10,CH,NE,101,10,CH,
       AND,45,35,CH,EQ,145,35,CH),
     OUTREC=(101,80)

   OUTFIL FNAMES=DCARD1,
     INCLUDE=(181,2,CH,EQ,C'11',OR,
       (181,2,CH,EQ,C'22',AND,1,80,CH,EQ,101,80,CH)),
     OUTREC=(1,80)

    OUTFIL FNAMES=DCARD2,
      INCLUDE=(181,2,CH,EQ,C'22',AND,1,80,CH,EQ,101,80,CH),
      OUTREC=(101,80)
/*


The output is as follows:

Code:

OUT1
999.00     2003    N   CHF   LUGI   4444    BOOK    TEST    PC     ACCY
950.00     2005    N   CHF   RISKA  1111    OPEN    TECH    HOST   ABCD
OUT2
no records
OUT3
250.00     2005    Y   CHF   RISK   2222    OPEN    TECH    HOST   MNOP
OUT4
550.00     2005    Y   CHF   RISK   2222    OPEN    TECH    HOST   MNOP   
DCARD1
345.00     2002    N   DEM   GERM   2134    SETL    TRAIN   HOST   SCHW   
100.00     2004    Y   YEN   JAP    3333    BOOK    MECH    AS400  XYZ   
DCARD2
345.00     2002    N   DEM   GERM   2134    SETL    TRAIN   HOST   SCHW

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Mar 02, 2006 1:27 pm    Post subject: Reply with quote

Phantom,

I don't see how SORT and SUM vs SPLICE would make this "simpler to use and understand". As far as I can tell, the complication here isn't the use of SPLICE, but figuring out the correct OUTFIL INCLUDE conditions.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shuko
Beginner


Joined: 08 Nov 2005
Posts: 73
Topics: 20

PostPosted: Thu Mar 02, 2006 2:02 pm    Post subject: Reply with quote

Phantom,Frank

Phantom there will not be any duplicates on the 3 key fields.
Thank you Frank for the example.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group