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

Selecting & Reformatting KSDS file...


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

New User


Joined: 09 Jul 2008
Posts: 4
Location: pune

PostPosted: Wed Jul 30, 2008 10:53 am
Reply with quote

Hi all,

I am having a KSDS with variable length records as follows:

10001 ab zzzzz qqqq
10002 cd yyyy rrrrr
10001 ef xxxx ssss
10003 ab uuuu mm
10003 ef vvvv lll
...

PRIMARY KEY is 1st + 2nd fields.


Using DFSORT, I need to select records according to 2nd field, say if 2nd field is "ab" or "ef" & put in another file. Output is as follows:

10001 ab zzzzz qqqq
10001 ef xxxx ssss
10003 ab uuuu mm
10003 ef vvvv lll

Then, Reformat the new file so that output is :

10001 zzzzz xxxx qqqq ssss
10003 uuuu vvvv mm lll


Please help me out in this.


Thanks in advance.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Jul 30, 2008 11:49 am
Reply with quote

I have considered RECFM=FB LRECL=80 for both i/p and o/p.

Code:
//*******************************************************               
//STEP001  EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN1      DD *                                                         
10001 AB ZZZZZ QQQQ                                                     
10002 CD YYYY  RRRRR                                                   
10001 EF XXXX  SSSS                                                     
10003 AB UUUU  MM                                                       
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
10003 EF VVVV  LLL                                                     
/*                                                                     
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
 SPLICE FROM(IN1) TO(OUT) ON(1,5,CH) WITH(16,5) WITH(35,5)-             
    WITHALL                        USING(CP01)                         
/*                                                                     
//CP01CNTL DD   *                                                       
  INCLUDE COND=(7,2,SS,EQ,C'AB,EF')                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(7:2X,81:SEQNUM,8,ZD,RESTART=(1,5))),
         IFTHEN=(WHEN=(81,8,ZD,EQ,1),OVERLAY=(26:16,5)),               
         IFTHEN=(WHEN=(81,8,ZD,EQ,2),OVERLAY=(35:16,5,16:10,5))         
  OUTFIL FNAMES=OUT,BUILD=(1,80)                                       
/*                                                                     


output looks like
Code:
10001    ZZZZZ XXXX      QQQQ     SSSS
10003    UUUU  VVVV      MM       LLL
Back to top
View user's profile Send private message
rahul_bhardwaj

New User


Joined: 09 Jul 2008
Posts: 4
Location: pune

PostPosted: Wed Jul 30, 2008 5:11 pm
Reply with quote

This solution works fine for RECFM=FB but our file is having RECFM=VB

Will this solution work for RECFM=VB or otherwise, what will be the solution???


Thanks in advance
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Jul 30, 2008 5:21 pm
Reply with quote

If i/p and o/p both are VB files, then the following control card should work...(this is not tested)
Code:

//TOOLIN   DD *                                                         
 SPLICE FROM(IN1) TO(OUT) ON(5,5,CH) WITH(20,5) WITH(39,5)-             
    WITHALL                        USING(CP01)                         
/*                                                                     
//CP01CNTL DD   *                                                       
  INCLUDE COND=(11,2,SS,EQ,C'AB,EF')                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(11:2X,85:SEQNUM,8,ZD,RESTART=(1,5))),
         IFTHEN=(WHEN=(85,8,ZD,EQ,1),OVERLAY=(30:16,5)),               
         IFTHEN=(WHEN=(85,8,ZD,EQ,2),OVERLAY=(39:16,5,20:10,5))         
  OUTFIL FNAMES=OUT,BUILD=(1,84)                                       
/*                                                                     
Back to top
View user's profile Send private message
rahul_bhardwaj

New User


Joined: 09 Jul 2008
Posts: 4
Location: pune

PostPosted: Wed Jul 30, 2008 6:11 pm
Reply with quote

thanks... will test & update you on this... thanks again icon_biggrin.gif
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 Jul 30, 2008 10:33 pm
Reply with quote

Rahul,

Krisprem's "solution" will not work and does not handle the records as variable-length (he pads them out with blanks which is not what you want to do with variable-length records). This DFSORT/ICETOOL job will do what you asked for:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  VSAM V input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(5,5,CH) VSAMTYPE(V) VLENOVLY -
  WITH(17,5) WITH(29,5) USING(CTL1)
/*
//CTL1CNTL DD *
  INCLUDE COND=(11,2,SS,EQ,C'ab,ef')
  INREC IFTHEN=(WHEN=INIT,
     BUILD=(1,4,5:SEQNUM,1,ZD,RESTART=(5,5),6:5)),
    IFTHEN=(WHEN=(5,1,ZD,EQ,1),
     BUILD=(1,4,5:6,5,11:15,5,23:21)),
    IFTHEN=(WHEN=NONE,
     BUILD=(1,4,5:6,5,17:15,5,29:21))
/*


If your input file has these records:

Code:

len|data
24  110001 ab zzzzz qqqq
25  210002 cd yyyy  rrrrr
24  110001 ef xxxx  ssss
22  210003 ab uuuu  mm
23  110003 ef vvvv  lll


Your output file will have these records:

Code:

len|data
32  10001 zzzzz xxxx  qqqq  ssss
31  10003 uuuu  vvvv  mm    lll
Back to top
View user's profile Send private message
rahul_bhardwaj

New User


Joined: 09 Jul 2008
Posts: 4
Location: pune

PostPosted: Thu Jul 31, 2008 5:06 pm
Reply with quote

Thanks Yaeger... this solution works perfectly fine...


thanks for providing the solution...


cHeErS icon_biggrin.gif
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 FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top