Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Copying a file based on two other files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Parthasarathy

New User


Joined: 24 Feb 2006
Posts: 18
Location: Chennai

PostPosted: Tue Jul 26, 2011 7:23 pm    Post subject: Copying a file based on two other files
Reply with quote

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
View user's profile Send private message

sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Jul 26, 2011 8:07 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jul 26, 2011 10:29 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Jul 26, 2011 10:52 pm    Post subject:
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Jul 26, 2011 11:29 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Parthasarathy

New User


Joined: 24 Feb 2006
Posts: 18
Location: Chennai

PostPosted: Wed Jul 27, 2011 11:41 am    Post subject:
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Jul 27, 2011 7:49 pm    Post subject:
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Wed Jul 27, 2011 7:51 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jul 27, 2011 11:11 pm    Post subject:
Reply with quote

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Thu Jul 28, 2011 2:34 am    Post subject:
Reply with quote

Frank,
I am glad that I am learning from you guys and correcting my mistakes.

36_8_15.gif


Thanks,
Back to top
View user's profile Send private message
Parthasarathy

New User


Joined: 24 Feb 2006
Posts: 18
Location: Chennai

PostPosted: Thu Jul 28, 2011 1:38 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us