Joined: 10 Jun 2005 Posts: 10 Location: Hyderabad, India
Hi
Please help me to solve the following problem -
My input file record looks like this
01 123 A ** - first record
01 123 B
01 123 A ** - Dup of 1st record
01 123 C
01 123 D
01 123 D
02 456 A ** - 1st record
02 456 A ** - Dup of 1st record
02 456 A ** - Dup of 1st record
02 456 C
02 456 D
03 789 A ** - 1st record
04 123 A ** - 1st record
04 123 B
i need only those records in output file which are neither 1st record not the duplicate of the first.
i.e.
My output file should look like this
01 123 B
01 123 C
01 123 D
01 123 D
02 456 C
02 456 D
04 123 B
I am struggling with this for past 1 hr.. Please provide me the syntex for this at the earliest.
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
Excuse me... the first record end always in 'A'(I mean... is it fix?)
If is true I'm sure that a simple ICETOOL can help you otherwise try with a simple rexx program.
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
I tryed with ICETOOL but to avoid loser time I write for you this Rexx sample.
Rexx PGM:
Code:
/*% NOCOMMENT REXX */
/* PROGRAMMA: xxxxxxxx */
/* AUTORE : MGIndaco */
/* ENV. : BATCH */
Parse Arg WsFr WsTo
Say '-----------------------------------------'
Say '- Begin ---------------------------------'
Say '-----------------------------------------'
Say ' Argument passed from JCL : ' WsFr ',' WsTo
Say '-----------------------------------------'
EoF = 'NO'
CntInp = 0
CntOut = 0
KeyOld = ''
KeyNew = ''
RecOld = ''
RecNew = ''
Address Tso
"ExecIO 0 DiskR Input(OPEN"
"ExecIO 0 DiskW Output(OPEN"
Do While EoF = 'NO'
"ExecIO 1 DiskR Input"
If Rc = 0 Then Do
CntInp = CntInp + 1
pull RecNew
KeyNew = Substr(RecNew,WsFr,WsTo)
If KeyNew = KeyOld Then Do
If RecNew <> RecOld Then Do
push RecNew
CntOut = CntOut + 1
"ExecIO 1 DiskW Output"
End
Else Do
Say ' First record duplicated on row: 'CntInp '- 'RecNew
End
End
Else Do
Say ' New Key From: 'WsFr ' To: ' WsTo ' -> ' KeyNew
KeyOld = KeyNew
RecOld = RecNew
End
DELSTACK
End
Else Do
EoF = 'Yes'
End
End
"ExecIO 0 DiskR Input(Finis"
"ExecIO 0 DiskW Output(Finis"
"Free f(Input)"
"Free f(Output)"
Say ' Resume of process: '
Say ' -----------------------------'
Say ' Total input record : 'CntInp
Say ' Total output record: 'CntOut
Say '-----------------------------------------'
Say '- End -----------------------------------'
Say '-----------------------------------------'
Exit Rc
And this is the JCL:
Code:
//STEP010X EXEC PGM=IKJEFT01,PARM='NameOfRexxPGM 1 6'
//SYSEXEC DD DISP=SHR,DSN=LibWhereRexxPgmIsStored
//SYSTSPRT DD SYSOUT=B
//SYSPRINT DD SYSOUT=B
//INPUT DD *
01 123 A
01 123 B
01 123 A
01 123 C
01 123 D
01 123 D
02 456 A
02 456 A
02 456 A
02 456 C
02 456 D
03 789 A
04 123 A
04 123 B
//OUTPUT DD SYSOUT=*
//SYSTSIN DD DUMMY
When you copy-paste the source and the job use "Renum;Unnum" to avoid errors.
Try it and tell me your opinion.
P.S. = 1 and 6 are the start and length key i.e. "01 123"
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Tarun,
Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input file had RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
01 123 A ** - first record
01 123 B
01 123 A ** - Dup of 1st record
01 123 C
01 123 D
01 123 D
02 456 A ** - 1st record
02 456 A ** - Dup of 1st record
02 456 A ** - Dup of 1st record
02 456 C
02 456 D
03 789 A ** - 1st record
04 123 A ** - 1st record
04 123 B
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
// DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(1,6,CH) FIRST DISCARD(T2) USING(CTL1)
SPLICE FROM(CON) TO(OUT) ON(1,8,CH) -
WITHALL WITH(1,81) KEEPNODUPS KEEPBASE USING(CTL2)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,OUTREC=(1,80,81:C'11')
OUTFIL FNAMES=T2,OUTREC=(1,80,81:C'22')
/*
//CTL2CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(81,2,CH,EQ,C'22'),
OUTREC=(1,80)
/*