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
 
Breaking records for every special character

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

New User


Joined: 08 Sep 2003
Posts: 32
Location: Toronto <-> Bangalore

PostPosted: Sun Dec 02, 2007 3:16 am    Post subject: Breaking records for every special character
Reply with quote

Hi,

I have records like below.

Code:

51133&ADMINISTRATION&54549985&THIS&99
12&SECURITIES&3434569&INVESTMENTS&3444


Can I break every single record into multiple records whenever & is encountered? My output file should contain

Code:

51133
ADMINISTRATION
54549985
THIS
99
12
SECURITIES
3434569
INVESTMENTS
3444


Thanks,
Karthik
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: Sun Dec 02, 2007 10:08 pm    Post subject:
Reply with quote

What is the RECFM and LRECL of the input file.

You show 5 fields in each input record. Does each input record always have 5 fields? Or can there be more or less fields in a record? If there can be more than 5 fields, what is the maximum number of fields you expect?

What is the maximum length of a single field?

Do you expect any blank fields, e.g. like the second field below:

Code:

ABC& &CDE
Back to top
View user's profile Send private message
karthikbabudh

New User


Joined: 08 Sep 2003
Posts: 32
Location: Toronto <-> Bangalore

PostPosted: Mon Dec 03, 2007 11:43 am    Post subject: Reply to: Breaking records for every special character
Reply with quote

Frank,

My input file is a FB file with LRECL of 133. Here is my original record:

ALLOC DSNAME('XED#DD.BNSS.ZZ.EN2) NEW -&SPACE(99,99) TRACKS -&LRECL(80) RECFM(F,B) BLKSIZE(800)
ALLOC DSNAME('XED#DD.BNSS.ZZ.FR11') NEW -&SPACE(99,99) TRACKS -&LRECL(80) RECFM(F,B) BLKSIZE(800)

All the records in the file will be having same number of fields as indicated above. Only difference between records will be the length of final qualifier in dataset name. For example, in the first record, it is "EN2" (3 characters) and in the second record, it is "FR11" (4 characters). This may vary from 2 to 8. There will not be any blank fields. I want output like

ALLOC DSNAME('XED#DD.BNSS.ZZ.EN2) NEW -
&SPACE(99,99) TRACKS -
&LRECL(80) RECFM(F,B) BLKSIZE(800)
ALLOC DSNAME('XED#DD.BNSS.ZZ.FR11') NEW -
&SPACE(99,99) TRACKS -
&LRECL(80) RECFM(F,B) BLKSIZE(800)

Hope I have answered your questions.

Thanks,
Karthik.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Mon Dec 03, 2007 3:20 pm    Post subject:
Reply with quote

Karthik,

Try this -

Code:
//S1    EXEC PGM=SORT                               
//SYSOUT  DD SYSOUT=*                               
//SORTIN DD DSN=I/PFILE   LRECL-ASSUMED=100         
//SORTOUT  DD SYSOUT=*                             
//SYSIN DD *                                       
  SORT FIELDS=COPY                                 
  OUTFIL IFTHEN=(WHEN=(33,2,CH,EQ,C''')'),         
           BUILD=(1,40,/,41,22,/,63,38)),           
         IFTHEN=(WHEN=(34,2,CH,EQ,C''')'),         
           BUILD=(1,41,/,42,22,/,64,37)),           
         IFTHEN=(WHEN=(35,2,CH,EQ,C''')'),         
           BUILD=(1,42,/,43,22,/,65,36)),           
         IFTHEN=(WHEN=(36,2,CH,EQ,C''')'),         
           BUILD=(1,43,/,44,22,/,66,35)),           
         IFTHEN=(WHEN=(37,2,CH,EQ,C''')'),         
           BUILD=(1,44,/,45,22,/,67,34)),           
         IFTHEN=(WHEN=(38,2,CH,EQ,C''')'),         
           BUILD=(1,45,/,46,22,/,68,33))           
/*                                                 


I/P:

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
********************************* Top of Data ******************************************************
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN234567') NEW -&SPACE(99,99) TRACKS -&LRECL(80)RECFM(F,B) BLKSIZE(800)
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN23456') NEW -&SPACE(99,99) TRACKS -&LRECL(80)RECFM(F,B) BLKSIZE(800)
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN2345') NEW -&SPACE(99,99) TRACKS -&LRECL(80)RECFM(F,B) BLKSIZE(800) 
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN234') NEW -&SPACE(99,99) TRACKS -&LRECL(80)RECFM(F,B) BLKSIZE(800)
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN23') NEW -&SPACE(99,99) TRACKS -&LRECL(80)RECFM(F,B) BLKSIZE(800)
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN2') NEW -&SPACE(99,99) TRACKS -&LRECL(80)RECFM(F,B) BLKSIZE(800)


O/P:

Code:
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN234567') NEW -                   
&SPACE(99,99) TRACKS -                                           
&LRECL(80)RECFM(F,B) BLKSIZE(800)                               
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN23456') NEW -                     
&SPACE(99,99) TRACKS -                                           
&LRECL(80)RECFM(F,B) BLKSIZE(800)                               
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN2345') NEW -                     
&SPACE(99,99) TRACKS -                                           
&LRECL(80)RECFM(F,B) BLKSIZE(800)                               
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN234') NEW -                       
&SPACE(99,99) TRACKS -                                           
&LRECL(80)RECFM(F,B) BLKSIZE(800)                               
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN23') NEW -                       
&SPACE(99,99) TRACKS -                                           
&LRECL(80)RECFM(F,B) BLKSIZE(800)                               
ALLOC DSNAME('XED#DD.BNSS.ZZ.EN2') NEW -                         
&SPACE(99,99) TRACKS -       
&LRECL(80)RECFM(F,B) BLKSIZE(800)   
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: Mon Dec 03, 2007 10:45 pm    Post subject:
Reply with quote

Karthik,

Here's an easier way to do what you asked for with DFSORT's PARSE function:

Code:

//S1    EXEC  PGM=ICEMAN                                             
//SYSOUT    DD  SYSOUT=*                                             
//SORTIN DD DSN=Y897797.KARTH2.TEXT,DISP=SHR                         
//SORTOUT DD SYSOUT=*                                               
//SYSIN    DD    *                                                   
  OPTION COPY                                                       
  OUTFIL PARSE=(%01=(ENDBEFR=C'&',FIXLEN=80),                       
               %02=(SUBPOS=1,STARTAT=C'&',ENDBEFR=C'&',FIXLEN=80),   
               %03=(SUBPOS=1,STARTAT=C'&',FIXLEN=80)),               
    BUILD=(%01,/,%02,/,%03)                                         
Back to top
View user's profile Send private message
karthikbabudh

New User


Joined: 08 Sep 2003
Posts: 32
Location: Toronto <-> Bangalore

PostPosted: Mon Dec 03, 2007 11:48 pm    Post subject: Reply to: Breaking records for every special character
Reply with quote

Murali,

Thanks, and this is what I want. Just for curiosity, if the input record contains many fields whose length is not consistent, (in my case, it is one field and is easy to code 6 IFs), what would be the solution?

Thanks,
Karthik.
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 add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 9 Thu Feb 22, 2018 5:37 pm
No new posts how to add the amount for duplicate r... SRUTHI DRAVIDAMANI COBOL Programming 6 Wed Feb 21, 2018 7:21 pm
No new posts Merging records, but not all the time prino DFSORT/ICETOOL 17 Sat Feb 17, 2018 4:20 pm
No new posts Need all records with high key kalidasvs SYNCSORT 15 Fri Feb 09, 2018 10:38 pm
No new posts Why is SORT rearranging records that ... cschablow DFSORT/ICETOOL 4 Wed Jan 24, 2018 10:14 pm

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