Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sort Lookup and Update

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

New User


Joined: 28 Mar 2008
Posts: 67
Location: 125.16.180.5

PostPosted: Wed Sep 02, 2009 9:32 pm    Post subject: Sort Lookup and Update
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 Moderator


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

PostPosted: Wed Sep 02, 2009 9:54 pm    Post subject:
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: 67
Location: 125.16.180.5

PostPosted: Wed Sep 02, 2009 9:58 pm    Post subject: Reply to: Sort Lookup and Update
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: 67
Location: 125.16.180.5

PostPosted: Wed Sep 02, 2009 10:49 pm    Post subject: Reply to: Sort Lookup and Update
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    Post subject: Reply to: Sort Lookup and Update
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: 67
Location: 125.16.180.5

PostPosted: Thu Sep 03, 2009 7:32 pm    Post subject: Reply to: Sort Lookup and Update
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    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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us