MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Tue May 04, 2010 6:27 am Post subject: copy records based on header and detail rec info
Hi,
My input file (LRECL=80, RECFM=FB) is in below shown fashion:
Input:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
ABC5 VERIFYSS1101250AB5 *A* 1
010011KID653GB3C9CGTBG 3110050311L015101028NCC31003 01230836 101
010011TUN663GB3C9CGKBG 3110050311L015101028NCC31003 01230836 101
ABC5 MACINSTS1101260AB5 KAN 1
010011TID653GB3C9CGVBG 3110050311L015101028NCC31003 01230836 101
010011TJN663GB3C9CGPBG 3110050311L015101028NCC31003 01230836 101
ABC5 JAYALYSS1108250AB5 *A* 1
010011BUJ653GB3C9CGCBG 3110050311L015101028NCC31003 01230836 101
010011POD663GB3C9CGABG 3110050311L015101028NCC31003 01230836 101
010011JUN663GB3C9CGDBG 3110050311L015101028NCC31003 01230836 101
My requirement is to extract the set of records based on below conditions. A header may follow by any number of detail records.
1). The header record should have '*A*' at 58th position.
2). The detail records under above said header record should have numeric value '11' at 37th position.
Expected Output:
Code:
ABC5 VERIFYSS1101250AB5 *A* 1
010011KID653GB3C9CGTBG 3110050311L015101028NCC31003 01230836 101
010011TUN663GB3C9CGKBG 3110050311L015101028NCC31003 01230836 101
ABC5 JAYALYSS1108250AB5 *A* 1
010011BUJ653GB3C9CGCBG 3110050311L015101028NCC31003 01230836 101
010011POD663GB3C9CGABG 3110050311L015101028NCC31003 01230836 101
010011JUN663GB3C9CGDBG 3110050311L015101028NCC31003 01230836 101
Please help.
Thanks. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
dbzTHEdinosauer Supermod Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
Posted: Tue May 04, 2010 6:34 am Post subject:
what indicates a header record? _________________ Dick Brenholtz
American living in Varel, Germany
Back to top
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Tue May 04, 2010 7:43 am Post subject: header rec
The values "ABC5", "AB5" and "*A*" at 1st, 25th and 58th positions are the typical ones.
Thanks. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue May 04, 2010 10:40 am Post subject:
ranga_subham,
Use the following DFSORT control cards
Code:
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'ABC5'),PUSH=(81:58,3))
OUTFIL BUILD=(1,80),
INCLUDE=((01,4,CH,EQ,C'ABC5',AND,81,3,CH,EQ,C'*A*'),OR,
(37,2,ZD,EQ,11,AND,81,3,CH,EQ,C'*A*'))
//*
_________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Tue May 04, 2010 11:28 am Post subject:
Hi,
I have tried this but getting all the header records that are not followed by the details records that have '11' at 37th position.
Would you please correct this to get only those set of records that have ABC5 and *A* in header followed by records that have '11' at 37th position.
Thanks. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Tue May 04, 2010 11:30 am Post subject: example
Hi,
Right now, it is happening like this: the last set of records have detailed records with '22' at 37th position.
Input:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
ABC5 VERIFYSS1101250AB5 *A* 1
010011KID653GB3C9CGTBG 3110050311L015101028NCC31003 01230836 101
010011TUN663GB3C9CGKBG 3110050311L015101028NCC31003 01230836 101
ABC5 MACINSTS1101260AB5 KAN 1
010011TID653GB3C9CGVBG 3110050311L015101028NCC31003 01230836 101
010011TJN663GB3C9CGPBG 3110050311L015101028NCC31003 01230836 101
ABC5 JAYALYSS1108250AB5 *A* 1
010011BUJ653GB3C9CGCBG 3110050311L015101028NCC31003 01230836 101
010011POD663GB3C9CGABG 3110050311L015101028NCC31003 01230836 101
010011JUN663GB3C9CGDBG 3110050311L015101028NCC31003 01230836 101
ABC5 JAYALYSS1108250AB5 *A* 1
010011BUJ653GB3C9CGCBG 3110050322L015101028NCC31003 01230836 101
010011POD663GB3C9CGABG 3110050322L015101028NCC31003 01230836 101
010011JUN663GB3C9CGDBG 3110050322L015101028NCC31003 01230836 101
Output:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
ABC5 VERIFYSS1101250AB5 *A* 1
010011KID653GB3C9CGTBG 3110050311L015101028NCC31003 01230836 101
010011TUN663GB3C9CGKBG 3110050311L015101028NCC31003 01230836 101
ABC5 JAYALYSS1108250AB5 *A* 1
010011BUJ653GB3C9CGCBG 3110050311L015101028NCC31003 01230836 101
010011POD663GB3C9CGABG 3110050311L015101028NCC31003 01230836 101
010011JUN663GB3C9CGDBG 3110050311L015101028NCC31003 01230836 101
ABC5 JAYALYSS1108250AB5 *A* 1
Please suggest. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue May 04, 2010 12:16 pm Post subject:
ranga_subham ,
You mean to say you don't want the header record if none of the detail records have a 11 in 37th position?
If so then use the following control cards
Code:
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'ABC5'),
PUSH=(81:1,80,SEQ=8))
OUTFIL IFOUTLEN=80,INCLUDE=(37,2,ZD,EQ,11,AND,138,3,CH,EQ,C'*A*'),
IFTHEN=(WHEN=(161,8,ZD,EQ,2),BUILD=(81,80,/,1,80))
//*
_________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Wed May 05, 2010 5:32 am Post subject: wonderful
Hi,
Wonderful............thx a lot.
May I request for a bit of explanation of the job so that I can put it in job before its promoted to PROD. It will be useful for us to understand/debug in future. Please......
Thanks.. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed May 05, 2010 10:23 am Post subject:
ranga_subham,
I noticed that the job will not write the header record if the first detail record does not have '11' in 37th position. Your sample data doesn't have that scenario but just in case if you do have such data , then use the following control cards
Code:
//SYSIN DD *
INCLUDE COND=(1,4,CH,EQ,C'ABC5',OR,37,2,ZD,EQ,11)
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'ABC5'),
PUSH=(81:1,80,SEQ=8))
OUTFIL IFOUTLEN=80,INCLUDE=(161,8,ZD,GT,1,AND,138,3,CH,EQ,C'*A*'),
IFTHEN=(WHEN=(161,8,ZD,EQ,2),BUILD=(81,80,/,1,80))
//*
And as for the explanation I suggest that you read this white paper which explains WHEN=GROUP with examples
http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000085 _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Wed May 05, 2010 11:03 am Post subject: thx
Hi,
Thanks for your shrewdness.
May I know
1). how the value "AB5" at 25th position in header record can be changed to "MEV"
and
2). how any numeric value of length 5 starting at 20th position in header record can be changed to "00001" on the output file
Please help.
Thanks. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed May 05, 2010 11:23 am Post subject:
ranga_subham ,
Both of the requirements are simple. Just change the BUILD statement to the following
Code:
BUILD=(81,19,C'00001MEV',108,53,/,1,80))
_________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Thu May 06, 2010 4:17 am Post subject:
Yeah........thanks a lot. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
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