View previous topic :: View next topic
Author
Message
Mazahar New User Joined: 11 Dec 2007Posts: 82 Location: hyderabad
Hi All,
Can you please provide me a sort solution for this
i need to splice the record based on a key, record format is VB and LRECL is 3000
input file, key preset at 12th position (including RDW actual position is 8th)
Code:
....1234.................................................................XXXXXXXXXXXX
....1235.................................YYYYYYYYYY...................................
....1234.................................................................AAAAAAAAAAAA
....1235.................................zzzzzzzzzz.....................................
....1234.................................................................CCCCCCCCCCCC
....1235.................................MMMMMMMMMM................................
....1234.................................................................BBBBBBBBBBBB
if key is 1234 i need to extract the values at byte 200 to 211 (12 bytes)
if key is 1235 i need to extract the values at byte 150 to 159 (10 bytes)
my output should be written to a 80 FB file like this
Code:
1234 AAAAAAAAAAAA
1234 BBBBBBBBBBBB
1234 CCCCCCCCCCCC
1234 XXXXXXXXXXXX
1235 MMMMMMMMMM
1235 YYYYYYYYYY
1235 ZZZZZZZZZZ
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
You don't need SPLICE for this.
Here's a DFSORT job that will do what you asked for:
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=.. input file (VB)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
INREC IFTHEN=(WHEN=(12,4,CH,EQ,C'1234'),
BUILD=(1,4,12,4,2X,200,12)),
IFTHEN=(WHEN=(12,4,CH,EQ,C'1235'),
BUILD=(1,4,12,4,2X,150,10,2X))
SORT FIELDS=(5,4,CH,A,11,12,CH,A)
OUTFIL VTOF,BUILD=(5,18,80:X)
/*
Back to top
Mazahar New User Joined: 11 Dec 2007Posts: 82 Location: hyderabad
Thanks Frank,
Along with this can we get counts also with the sort? for example....same problem i explined above....need counts also......
Code:
....1234.................................................................XXXXXXXXXXXX
....1235.................................YYYYYYYYYY...................................
....1234.................................................................XXXXXXXXXXXX
....1234.................................................................AAAAAAAAAAAA
....1234.................................................................XXXXXXXXXXXX
....1235.................................zzzzzzzzzz.....................................
....1235.................................YYYYYYYYYY...................................
....1234.................................................................CCCCCCCCCCCC
....1235.................................YYYYYYYYYY...................................
....1235.................................MMMMMMMMMM................................
....1234.................................................................BBBBBBBBBBBB
....1235.................................MMMMMMMMMM................................
if you see above file we have couple of values at places with dupicates...i need output something like
Code:
1234 AAAAAAAAAAAA 1
1234 BBBBBBBBBBBB 1
1234 CCCCCCCCCCCC 1
1234 XXXXXXXXXXXX 3
1235 MMMMMMMMMM 2
1235 YYYYYYYYYY 3
1235 ZZZZZZZZZZ 1
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Here's a DFSORT job for your new requirement:
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=.. input file (VB)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
INREC IFTHEN=(WHEN=(12,4,CH,EQ,C'1234'),
BUILD=(1,4,12,4,200,12)),
IFTHEN=(WHEN=(12,4,CH,EQ,C'1235'),
BUILD=(1,4,12,4,150,10,2X))
SORT FIELDS=(5,12,CH,A)
OUTFIL VTOF,REMOVECC,NODETAIL,
BUILD=(80:X),
SECTIONS=(5,12,
TRAILER3=(12,4,2X,9,12,21:COUNT=(M10,LENGTH=14)))
/*
Back to top
Mazahar New User Joined: 11 Dec 2007Posts: 82 Location: hyderabad
Frank,
Code:
SYSIN DD *
INREC IFTHEN=(WHEN=(12,4,CH,EQ,C'1234'),
BUILD=(1,4,12,4,200,12)),
IFTHEN=(WHEN=(12,4,CH,EQ,C'1235'),
BUILD=(1,4,12,4,150,10,2X))
SORT FIELDS=(5,12,CH,A)
OUTFIL VTOF,REMOVECC,NODETAIL,
BUILD=(80:X),
SECTIONS=(5,12,
TRAILER3=(12,4,2X,9,12,21:COUNT=(M10,LENGTH=14)))
everything is fine, but can u please explain me why we are sorting on (5.12.ch.a) ?? when my requirement is if key is 1234(at 12th position) i need to extract the values at byte 200 to 211 (12 bytes) and if key is 1235(at 12th postion) i need to extract the values at byte 150 to 159 (10 bytes). i hope sort should be (5,16,ch,a).....please correct me if i am wrong.
as well can please explain below statments also in details...
SECTIONS=(5,12,
TRAILER3=(12,4,2X,9,12,21:COUNT=(M10,LENGTH=14))) [/code]
One more thing, what this code will do to a file which is having other records with different key like 1111 or 2222 in input file, but we are notmentioning them in IF condition..
Thanks a lot for all your help
Back to top
Mazahar New User Joined: 11 Dec 2007Posts: 82 Location: hyderabad
Frank,
never mind.....I understood why you gave... (5.12.ch.a)
but can you please explain me the below statement
Code:
SECTIONS=(5,12,
TRAILER3=(12,4,2X,9,12,21:COUNT=(M10,LENGTH=14)))
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Actually, it should be 5,16 - just a typo.
The OUTFIL statement uses NODETAIL to tell DFSORT not to write the data records. SECTIONS tells DFSORT where the key is so it can determine the sections. TRAILER3 writes a record for each key with the indicated fields and the COUNT of records in that section.
Back to top
Mazahar New User Joined: 11 Dec 2007Posts: 82 Location: hyderabad
Frank, As always and usual....IT WORKED. Thanks a lot.
Back to top
Please enable JavaScript!