|
View previous topic :: View next topic
|
| Author |
Message |
Anand Kumar
New User
Joined: 29 Aug 2007 Posts: 24 Location: chennai
|
|
|
|
Hi,
I have an input file with account no (1:10), Credit-amount(11:5) & Credit-correction-amount(16:5).
Example:
| Code: |
00000000010000200000
00000000010000200000
00000000020000200000
00000000030000200000
00000000030000200001
00000000040000000001
00000000040000000001
00000000050000200001
00000000050000300001 |
I have a requirement where I will have to select all the distinct accounts only whose credit-amount <> 0 and credit-correction-amount <> 0 with overlay of A for credit and C for correction.
For the above example:
I will have to select distinct accounts whose credit-amount with an overlay of A in front.
| Code: |
A0000000001
A0000000002
A0000000003
A0000000005 |
and also select distinct accounts with credit-correction-amount <> 0 with overlay of C in front.
| Code: |
C0000000003
C0000000004
C0000000005 |
so the output file will be:
| Code: |
A0000000001
A0000000002
A0000000003
A0000000005
C0000000003
C0000000004
C0000000005 |
It is possible to do this in a single sort card? Can you please help me out with this?
Thank you |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
With a single sort card? No.
You'll need more than one sort card, but it will be with a single "sort deck" and a single sort deck will only need one job step. Will that do you? |
|
| Back to top |
|
 |
Anand Kumar
New User
Joined: 29 Aug 2007 Posts: 24 Location: chennai
|
|
|
|
Hi Bill,
Its OK, can you please help me with the sort deck? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You'll need two OUTFIL statements, one for each file.
On the OUTFIL you can INCLUDE=(state,length,ZD,NE,0) for each of your fields, the BUILD=(C'A' and the data you need for one, and BUILD=(C'C' and the data you need for the other. |
|
| Back to top |
|
 |
hailashwin
New User

Joined: 16 Oct 2008 Posts: 74 Location: Boston
|
|
|
|
Try this..
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
00000000010000200000
00000000010000200000
00000000020000200000
00000000030000200000
00000000030000200001
00000000040000000001
00000000040000000001
00000000050000200001
00000000050000300001
//OUT1 DD DSN=XXXX.FORUM5A,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(2,2),RLSE),
// RECFM=FB
//OUT2 DD DSN=XXXX.FORUM5B,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(2,2),RLSE),
// RECFM=FB
//TOOLIN DD *
SORT FROM(IN) TO(OUT1) USING(CTL1)
SORT FROM(OUT1) TO(OUT2) USING(CTL2)
//CTL1CNTL DD *
OPTION COPY
INREC IFTHEN=(WHEN=(11,5,ZD,GT,0),
OVERLAY=(32:C'A',1,10),HIT=NEXT),
IFTHEN=(WHEN=(16,5,ZD,GT,0),
OVERLAY=(52:C'C',1,10))
OUTFIL FNAMES=OUT1,
OUTREC=(32,11,/,52,11)
//CTL2CNTL DD *
SORT FIELDS=(1,11,CH,A)
OMIT COND=(1,11,CH,EQ,C' ')
SUM FIELDS=NONE
//*
|
Thanks,
Ashwin. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Assuming that the data is already sorted on the key (1,10), the following DFSORT JCL will give you the desired results
The trick here is to the use the same file twice and pick the credit-amount > 0 records from file 1 and build the record as A...... . From File 2 we pick all the records with Credit-correction-amount > 0 and build the record as C......
Now we will match the 2 files and get the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
00000000010000200000
00000000010000200000
00000000020000200000
00000000030000200000
00000000030000200001
00000000040000000001
00000000040000000001
00000000050000200001
00000000050000300001
00000000060000000000
00000000070000000000
//INB DD *
00000000010000200000
00000000010000200000
00000000020000200000
00000000030000200000
00000000030000200001
00000000040000000001
00000000040000000001
00000000050000200001
00000000050000300001
00000000060000000000
00000000070000000000
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(1,11,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(1,11,A),SORTED,NOSEQCK
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,11,?,F2:1,11)
INREC IFOUTLEN=11,IFTHEN=(WHEN=(12,1,CH,EQ,C'2'),BUILD=(13,11))
OUTFIL REMOVECC,NODETAIL,SECTIONS=(1,11,TRAILER3=(1,11))
//*
//JNF1CNTL DD *
INCLUDE COND=(11,5,ZD,GT,0)
INREC BUILD=(C'A',1,10)
//*
//JNF2CNTL DD *
INCLUDE COND=(16,5,ZD,GT,0)
INREC BUILD=(C'C',1,10)
//* |
The output from this is
| Code: |
A0000000001
A0000000002
A0000000003
A0000000005
C0000000003
C0000000004
C0000000005
|
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Still like mine. You get two files, but you can always concatenate 'em. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|