IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sort Lookup and Update


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Wed Sep 02, 2009 9:32 pm
Reply with quote

Hi all,

i have a File1 like this, i would say this a s loookup file
Code:

----+----1----+----2----
************************
123                TN   
345                KA   
456                KL   
************************


and file2 like this , i would like to call this as data file

Code:

----+----1----+--
*****************
123 1111111     
123 1111111     
123 1111111     
345 2222222     
345 2222222     
456 3333333     
*****************


and would like to have my output file like this

Code:

----+----1----+--
*****************
123 1111111   TN   
123 1111111   TN 
123 1111111   TN   
345 2222222   KA   
345 2222222   KA 
456 3333333   KL   
*****************


in essence, i need to look up the value for the key in the datafile and fetch it and append it to the data file record.
could some one please say me how to do this using SORT.

would be of great help.

Kindly write back if am not comprehensible
Thanks.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Sep 02, 2009 9:54 pm
Reply with quote

What is the RECFM and LRECL of each input file?
Back to top
View user's profile Send private message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Wed Sep 02, 2009 9:58 pm
Reply with quote

we can have it same ..say 80 byte file. we write both those files so there is no constraint on Lrecl, so its totally under our jurisdiction. icon_smile.gif
Back to top
View user's profile Send private message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Wed Sep 02, 2009 10:49 pm
Reply with quote

and the Recfm is FB.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Sep 02, 2009 11:37 pm
Reply with quote

karthik_sripal,

Since both files are of the same length we can simply concatenate them together and use the group function to get the desired results. Just make sure that state code file has spaces in pos 5 thru 11 as we are using that field as indicator as to which file the record belongs to


Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
----+----1----+----2----+----3----+----4----+----5----+----6----+---
123                TN                                               
345                KA                                               
456                KL                                               
//         DD *
123 1111111                                                         
123 1111111                                                         
123 1111111                                                         
345 2222222                                                         
345 2222222                                                         
456 3333333                                                         
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'1')),                       
  IFTHEN=(WHEN=(5,7,CH,GT,C' '),OVERLAY=(81:C'2'))                 
  SORT FIELDS=(1,3,CH,A),EQUALS                                     
                                                                   
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,8,ZD,RESTART=(1,3))),
  IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(20:20,2,82:81,1))   
                                                                   
  OUTFIL INCLUDE=(81,2,ZD,EQ,21),BUILD=(1,80)                       
/*


The output from this job is

Code:

123 1111111        TN
123 1111111        TN
123 1111111        TN
345 2222222        KA
345 2222222        KA
456 3333333        KL
Back to top
View user's profile Send private message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Thu Sep 03, 2009 7:32 pm
Reply with quote

Thank you very Much Friend.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top