|
View previous topic :: View next topic
|
| Author |
Message |
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
This requirement might have been posted before, but the JCL listed does not produce the right results.
1. PHRD.TEST1 has lrecl = 80, recfm = FB.
a) Sample records listed below- 12 records including the header record.
columns 1 thru 9 has U_ID
column 10 has delimiter '|'
column 11 thru 41 has USER_TYPE
column 42 has the delimiter '|'
column 43 thru 80 has spaces
b) Records already ordered in ascending order.
| Code: |
U_ID USER TYPE
100014730|Unit/Department Approver |
100018981|Unit/Department Approver |
100076455|Unit/Department Approver |
100076455|Creator |
100339086|Creator |
100430547|Dean/Department Head Approver |
100430547|Equity Administrator |
100687514|Dean/Department Head Approver |
101217499|UHR |
102035429|Unit/Department Approver |
104269754|Creator | |
-----------------------------------------------------------
2. PHRD.TEST2 has lrecl = 80, recfm = FB.
a) Sample records listed below - 3 records.
This file does NOT have the header record.
columns 1 thru 9 has U_ID (header absent in this file)
column 10 has delimiter '|'
column 11 thru 41 has USER_TYPE (header absent in this file)
column 42 has the delimiter '|'
column 43 thru 80 has spaces
b) Records already sorted by U_ID in ascending order.
| Code: |
101217499|HR Rep |
102035429|Creator |
104269754|Creator | |
NOTE - in this example, the last 3 records in the second file appear in the first file as the last 3 records, though the 'common' records between the two files
can exist anywhere in the first file.
------------------------------------------------------------------
3. Requirement is to compare the two files based on U_ID and create a third file which has ALL records in the first file PHRD.TEST1, but NONE from the second file PHRD.TEST2.
a) Output file will have lrecl=80, recfm = FB.
b) It will have the header record and look as follows
c) Retain the order of records in the first file, but remove records that exist in the second file based on U_ID.
| Code: |
U_ID USER TYPE
100014730|Unit/Department Approver |
100018981|Unit/Department Approver |
100076455|Unit/Department Approver |
100076455|Creator |
100339086|Creator |
100430547|Dean/Department Head Approver |
100430547|Equity Administrator |
100687514|Dean/Department Head Approver | |
-------------------------------------------------------------
The JCL listed below does not give the desired results.
Using 'NODUPS USING(CTL3)' removes duplicates from the first file and using
'ALLDUPS USING(CTL3)' removes the records with single U_ID.
| Code: |
//S2 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=PHRD.TEST1,DISP=SHR
//IN2 DD DSN=PHRD.TEST2,DISP=SHR
//T1 DD DSN=&&T2,UNIT=DISK,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=PHRD.TEST4,
// DISP=(NEW,CATLG,DELETE),
// UNIT=DISK,
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=27920),
// SPACE=(TRK,(5,5),RLSE)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT) ON(1,9,CH) -
NODUPS USING(CTL3)
/*
//CTL1CNTL DD *
INREC OVERLAY=(81:C'1')
/*
//CTL2CNTL DD *
INREC OVERLAY=(81:C'2')
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(81,1,CH,EQ,C'1'),
BUILD=(1,80)
/* |
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Suresh Shankarakrishnan,
The reason the sample job gives you incorrect results is because you have duplicates in your file PHRD.TEST1 on the key 1,9. and the select parm is removing them. You need to pick the right example.
Anyway here is a simple version of the job which would give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD DSN=&&HDR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,HEADER1=('$$$')
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
// DD DSN=PHRD.TEST2,DISP=SHR
// DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
// DD DSN=PHRD.TEST1,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),
IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(82:ID=1)),
IFTHEN=(WHEN=(1,4,CH,EQ,C'U_ID'),OVERLAY=(81:X))
SORT FIELDS=(81,1,CH,A,1,9,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(84:SEQNUM,8,ZD,RESTART=(1,9))),
IFTHEN=(WHEN=GROUP,BEGIN=(84,8,ZD,EQ,1),PUSH=(83:82,1))
OUTFIL INCLUDE=(82,2,ZD,EQ,22),BUILD=(1,80)
//* |
|
|
| Back to top |
|
 |
Suresh Shankarakrishnan
New User
Joined: 11 Jul 2008 Posts: 42 Location: USA
|
|
|
|
Thanks Kolusu, it works.
Can you explain it briefly? |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|