|
View previous topic :: View next topic
|
| Author |
Message |
Parthasarathy
New User
Joined: 24 Feb 2006 Posts: 18 Location: Chennai
|
|
|
|
Hi All,
I have the following requirement which i'm looking for a solution.
I have 3 input files.
File A - Control file in following layout lrecl = 4
RecNo (3 Bytes key field) and Indicator (1 Byte)
| Code: |
100Y
110N
120N
130N
140Y
150N |
File B - Product "Lookup" file in following layout lrecl = 8
Product id (7 bytes Key field) and Product type (1 Byte and values will be A or B)
| Code: |
1212111A
1212122A
1212133B
1212144A
1212155B |
File C- Location "Master" file lrecl = 16
Location id (5 Bytes and Key field), Product ID (7 bytes) and Year (4bytes)
(same product will be available in multiple locations)
| Code: |
DABCA12121112009
DABCB12121112010
DABCC12121112008
DABCD12121222010
DABCF12121222009
DABCG12121332008
DABCH12121332005 |
I need the file C to be copied to output file D of same layout and same data but the year populated with zeros or values from input file C based on the following condition.
1. If file A rec no 120 has indicator N then always populate zeros to year.
2. If file A rec no 120 has indicator Y, then look for the products in File B for product type, if A then populate year same as available in input and if B populate zeros to year field.
(In file A we should always look for rec no 120 and ignore the remaining records)
Partha |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Parthasarathy,
I am assuming that in control file, 1 byte indicator is always populated with either 'N' or 'Y'.
See if below works...
| Code: |
//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD CONTROL FILE/FB-4
//SORTOUT DD DSN=&&CNTL,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,3,CH,EQ,C'120')
OUTREC BUILD=(C'CONTROL-FIELD,C''',4,1,C'''',80:X)
/*
//STEP0002 EXEC PGM=SORT
//SYMNAMES DD DSN=&&CNTL,DISP=SHR
//SORTJNF1 DD PRODUCT LOOKUP FILE/FB-8
//SORTJNF2 DD LOCATION MASTER FILE/FB-16
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,7,A)
JOINKEYS FILE=F2,FIELDS=(6,7,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F2:01,16,F1:8,1)
INREC IFTHEN=(WHEN=INIT,OVERLAY=(18:CONTROL-FIELD)),
IFTHEN=(WHEN=(18,1,CH,EQ,C'N'),OVERLAY=(13:4C'0')),
IFTHEN=(WHEN=(17,1,CH,EQ,C'B'),OVERLAY=(13:4C'0'))
SORT FIELDS=COPY
OUTFIL BUILD=(1,16)
/*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=D
//SYSDBOUT DD SYSOUT=D |
OUTPUT with Control Field as N
| Code: |
DABCA12121110000
DABCB12121110000
DABCC12121110000
DABCD12121220000
DABCF12121220000
DABCG12121330000
DABCH12121330000 |
OUTPUT with Control Field as Y
| Code: |
DABCA12121112009
DABCB12121112010
DABCC12121112008
DABCD12121222010
DABCF12121222009
DABCG12121330000
DABCH12121330000 |
Thanks, |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| sqlcode1 wrote: |
| See if below works... |
Run your job with the following scenario's
1. There is no type 120 record FB-4/CONTROL FILE or Empty FB-4/CONTROL
2. More than 1 record for type 120 record with Y and N indicator.
I am not sure as to why you have SYSPRINT,SYSUDUMP,SYSDBOUT DDnames in your JCL. You don't need them.
Parthasarathy,
Use the following JCL which will give you the desired results. This job also takes care of not reading the product file when there is an "n" indicator in the control file.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your FB 4 byte control file,DISP=SHR
//INR DD DSN=&&INR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//JNF DD DSN=&&JNF,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
INCLUDE COND=(1,3,CH,EQ,C'120')
OPTION COPY,STOPAFT=1
OUTFIL FNAMES=INR,REMOVECC,NODETAIL,
HEADER1=(3:'INREC IFOUTLEN=16,',/,
3:'IFTHEN=(WHEN=INIT,OVERLAY=(18:C''',4,1,'''',')),',/,
3:'IFTHEN=(WHEN=(18,1,CH,EQ,C''','N''',
'),OVERLAY=(13:4C''','0''',')),',/,
3:'IFTHEN=(WHEN=(17,1,CH,EQ,C''','B''',
'),OVERLAY=(13:4C''','0''','))',80:X)
OUTFIL FNAMES=JNF,INCLUDE=(4,1,CH,EQ,C'N'),
BUILD=(3:C'OMIT COND=ALL',80:X)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=Your FB 16 byte Location Master file,DISP=SHR
//SORTJNF2 DD DSN=Your FB 8 byte Product Lookup file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS FILE=F1,FIELDS=(6,7,A)
JOINKEYS FILE=F2,FIELDS=(1,7,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:01,16,F2:8,1)
// DD DSN=&&INR,DISP=SHR
//*
//JNF2CNTL DD DSN=&&JNF,DISP=SHR
//* |
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
| I am not sure as to why you have SYSPRINT,SYSUDUMP,SYSDBOUT DDnames in your JCL. You don't need them. |
sqlcode1,
I would advise only adding SYSUDUMP if you get an ABEND from a DFSORT job and want to look at a dump. SYSPRINT and SYSDBOUT are NOT used by DFSORT.
I have been deleting these DD statements from your posts when I see them. They ARE NOT NEEDED. Please don't use them or post them in your solutions because people will use your JCL as a model and will propagate these unnecessary statements from job to job. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Kolusu,
| Quote: |
1. There is no type 120 record FB-4/CONTROL FILE or Empty FB-4/CONTROL
2. More than 1 record for type 120 record with Y and N indicator. |
Based on sample data, I assumed that Control File would have atleast one and unique type 120 record. Because OP didn't provided that information, I had to make that assumption. I may/could be wrong.
| Quote: |
| I am not sure as to why you have SYSPRINT,SYSUDUMP,SYSDBOUT DDnames in your JCL. You don't need them. |
| Quote: |
I would advise only adding SYSUDUMP if you get an ABEND from a DFSORT job and want to look at a dump. SYSPRINT and SYSDBOUT are NOT used by DFSORT.
I have been deleting these DD statements from your posts when I see them. They ARE NOT NEEDED. Please don't use them or post them in your solutions because people will use your JCL as a model and will propagate these unnecessary statements from job to job. |
Thank you for the information and I will take them off next time onwards.
Thanks, |
|
| Back to top |
|
 |
Parthasarathy
New User
Joined: 24 Feb 2006 Posts: 18 Location: Chennai
|
|
|
|
Thanks a lot.
| sqlcode1 wrote: |
Kolusu,
Based on sample data, I assumed that Control File would have atleast one and unique type 120 record. Because OP didn't provided that information, I had to make that assumption. I may/could be wrong.
|
In My control file I may or may not have record "120". If I don't have "120" then it should be treated as record with indicator "N" and hence populate zeros to year in output without considering product file.
The control file will never have duplicates on "120". |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Parthasarathy,
Grrrr...Why would you not say that control file may or may not have 120 records. However, did you try Kolusu's solution?
| Code: |
//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
100Y
110N
130N
140Y
150N
//CNTL DD DSN=&&CNTL,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,3,CH,EQ,C'120')
OUTFIL FNAMES=CNTL,REMOVECC,NODETAIL,
TRAILER1=('CONTROL-FIELD,C''',04,01,C'''')
/*
//STEP0002 EXEC PGM=SORT
//SYMNAMES DD DSN=&&CNTL,DISP=SHR
//SORTJNF1 DD *
1212111A
1212122A
1212133B
1212144A
1212155B
/*
//SORTJNF2 DD *
DABCA12121112009
DABCB12121112010
DABCC12121112008
DABCD12121222010
DABCF12121222009
DABCG12121332008
DABCH12121332005
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,7,A)
JOINKEYS FILE=F2,FIELDS=(6,7,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F2:01,16,F1:8,1)
INREC IFTHEN=(WHEN=INIT,OVERLAY=(18:CONTROL-FIELD)),
IFTHEN=(WHEN=(18,1,SS,EQ,C'N, '),OVERLAY=(13:4C'0')),
IFTHEN=(WHEN=(17,1,CH,EQ,C'B'),OVERLAY=(13:4C'0'))
SORT FIELDS=COPY
OUTFIL BUILD=(1,16)
/*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=D |
OUTPUT WITH NO 120 TYPE RECORD
| Code: |
DABCA12121110000
DABCB12121110000
DABCC12121110000
DABCD12121220000
DABCF12121220000
DABCG12121330000
DABCH12121330000 |
Thanks, |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Frank,
Sorry I missed below comment earlier. Thanks a lot for the clean up.
| Quote: |
| I have been deleting these DD statements from your posts when I see them. |
Thanks, |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
sqlcode1,
Your solutions are quite good, so I usually just needed to do that minor cleanup. I meant to mention it to you sooner.
Thanks. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Frank,
I am glad that I am learning from you guys and correcting my mistakes.
Thanks, |
|
| Back to top |
|
 |
Parthasarathy
New User
Joined: 24 Feb 2006 Posts: 18 Location: Chennai
|
|
|
|
| sqlcode1 wrote: |
Parthasarathy,
Grrrr...Why would you not say that control file may or may not have 120 records.
|
Sorry, I have missed to mention this earlier.
Thanks for the solution. I'm currently testing the solution. Will come back if I find any problem. Thanks all for the help |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|