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
 

 

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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am


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