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

count number of delimiters create seperate two files


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

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Wed May 05, 2010 3:54 pm
Reply with quote

i am getting data file from source which is | delimited.
need to count the number of delimiters from each record and if delimiter's count is plus one from other record's count then create seperate file and put record (which has plus one delimiter) in separate file and rest of the records in other file. could any one please suggest how it can be done?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 05, 2010 5:11 pm
Reply with quote

Do you have constant count of the delimiter expected and if it is not then needs to be written in seperate output?
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Wed May 05, 2010 5:16 pm
Reply with quote

yes that is correct
example every record shoudl only have 10 delimiter
if its 11 in any then it needs to be written in a seperteoutput file
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed May 05, 2010 9:45 pm
Reply with quote

pema_yozer,

use the following DFSORT JCL. I assumed the file to be FB recfm and 80 bytes length and the delimiter is semicolon. If your input has more than 10 delimiters it will be written to OUT2 and OUT1 file will have records with less than or equal to 10 delimiters

Code:

//STEP0100 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTIN   DD *                                   
1B7HC16Y9X3333339,,,,,,,,,,,,,                   
2001,PONTIAC,FIREBIRD,,,,,,,,,                   
2G2GGIK81333666,,,,,,,,,,,,,,,                   
4Y756JUKOD6767666653666,,,,,,,                   
1990,BENZ,CORVETTE,,,,,,,,,,,,                   
1C7HBAS805L510444,,,,,,,,,,,,,                   
1975,INTERNATIONAL,MODEL,1111,                   
8VRTT,43333666789,,,,,,,,,,,,,                   
//OUT1     DD SYSOUT=*                           
//OUT2     DD SYSOUT=*                           
//SYSIN    DD *                                   
  SORT FIELDS=COPY                               
  INREC PARSE=(%=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %=(STARTAT=C','),                 
               %1=(STARTAT=C',',FIXLEN=1)),       
        OVERLAY=(81:%1)                           
  OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C' '),BUILD=(1,80)   
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)                       
//*
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Thu May 06, 2010 9:26 am
Reply with quote

if data file is not FB i.e if it is variable length then also your suggetsed solution will work or not?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu May 06, 2010 10:06 am
Reply with quote

pema_yozer wrote:
if data file is not FB i.e if it is variable length then also your suggetsed solution will work or not?

No It might not.

Thats why, you need to tell your ALL requirements very clearly.


Now again,
if file is VB what is LRECL?
Back to top
View user's profile Send private message
pema_yozer

New User


Joined: 16 Feb 2009
Posts: 54
Location: pune

PostPosted: Thu May 06, 2010 10:17 am
Reply with quote

LRECL=436
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu May 06, 2010 10:20 pm
Reply with quote

pema_yozer,

You could have saved a lot of your time as well as other people's time if you had specified your requirements clearly in the first post itself. Even now there is a guess work as to what the delimiter is.

try this DFSORT JCL

Code:

//STEP0200 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD DSN=your input VB 436 file,DISP=SHR
//OUT1     DD SYSOUT=*                                       
//OUT2     DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC PARSE=(%=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %=(STARTAT=C','),                             
               %1=(STARTAT=C',',FIXLEN=1)),                 
        BUILD=(1,4,%1,5)                                     
                                                             
  OUTFIL FNAMES=OUT1,INCLUDE=(5,1,CH,EQ,C' '),BUILD=(1,4,6) 
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,4,6)                     
//*
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top