Page 1 of 1

How to split the file based on some symbols?

PostPosted: Mon Jan 09, 2012 2:44 pm
by pjagathis
Hi all,

I have to split the input file in two files..

Input file is having symbol "+" any where in the record of lrecl=100.

some records won't have that symbol "+" in it.

Output file - 01 => Records with symbol "+".
Output file - 02 => Records without symbol "+".


Please help me...!

Re: How to split the file based on some symbols?

PostPosted: Mon Jan 09, 2012 10:33 pm
by dick scherrer
Hello,

You might consider SubString (SS):
INCLUDE COND=(1,yourlrecl,SS,EQ,C'+')
for one file and
INCLUDE COND=(1,yourlrecl,SS,NE,C'+')
for the other.

Re: How to split the file based on some symbols?

PostPosted: Tue Jan 10, 2012 12:57 am
by BillyBoyo
You should be able to do this in one step, using two OUTFIL statements, one with each of the INCLUDEs that Dick has suggested.

If you search here, you should find some examples. Let us know how it goes.

Re: How to split the file based on some symbols?

PostPosted: Tue Jan 10, 2012 6:15 pm
by pjagathis
Hi dick scherrer/BillyBoyo,

Thanks for your help...

Code works..!. Obtained the expected result...!

One more help..,

Can we split the file based on number of occurence of symbol ?

Output file1:
Record with ZERO "+" symbol

Output file 2:
Record with one "+" symbol

Output file3:
Record with two "+" symbol

Re: How to split the file based on some symbols?

PostPosted: Wed Jan 11, 2012 6:28 am
by dick scherrer
Hello,

Think about your Total requirement.

It is a complete waste of time for people to have to deal with things as you choose to post them.

Re: How to split the file based on some symbols?

PostPosted: Sat Jan 14, 2012 5:55 am
by BillyBoyo
This runs with DFSORT and works with that product.

If you want to know what it is doing, look at the second step, which is the same thing but coded with DFSORT symbols.

//SPLITPL EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SYSIN DD *
                                                   
 OPTION COPY
                                                   
 INREC IFTHEN=(WHEN=INIT,
   PARSE=(%01=(STARTAT=C'+',FIXLEN=1),
          %02=(STARTAT=C'+',FIXLEN=1)),
   OVERLAY=(81:%01,%02))
                                                   
 OUTFIL FILES=01,INCLUDE=(81,2,CH,EQ,C'  '),
         BUILD=(1,80)
 OUTFIL FILES=02,INCLUDE=(81,2,CH,EQ,C'+ '),
         BUILD=(1,80)
 OUTFIL FILES=03,INCLUDE=(81,2,CH,EQ,C'++'),
         BUILD=(1,80)
/*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SORTOF03 DD SYSOUT=*
//SORTIN DD *
++++
+++
++
+
-


//SPLITPLS EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*
//SYMNOUT  DD SYSOUT=*
//SYMNAMES DD *
INPUT-RECORD,1,80
FIRST-BYTE-AFTER-INPUT-RECORD,*,1,CH
EXTENDED-TEST-FOR-PLUS,=,2,CH
FIRST-PLUS-IF-PRESENT-ELSE-BLANK,%01
SECOND-PLUS-IF-PRESENT-ELSE-BLANK,%02
NO-PLUSSES,C'  '
ONE-PLUS,C'+ '
TWO-OR-MORE-PLUSSES,C'++'
//SYSIN DD *
                                                                     
 OPTION COPY
                                                                     
 INREC IFTHEN=(WHEN=INIT,
   PARSE=(FIRST-PLUS-IF-PRESENT-ELSE-BLANK=(STARTAT=C'+',FIXLEN=1),
          SECOND-PLUS-IF-PRESENT-ELSE-BLANK=(STARTAT=C'+',FIXLEN=1)),
   OVERLAY=(FIRST-BYTE-AFTER-INPUT-RECORD:
             FIRST-PLUS-IF-PRESENT-ELSE-BLANK,
             SECOND-PLUS-IF-PRESENT-ELSE-BLANK))
                                                                     
 OUTFIL FILES=01,INCLUDE=(EXTENDED-TEST-FOR-PLUS,
                          EQ,NO-PLUSSES),
         BUILD=(INPUT-RECORD)
 OUTFIL FILES=02,INCLUDE=(EXTENDED-TEST-FOR-PLUS,
                          EQ,ONE-PLUS),
         BUILD=(INPUT-RECORD)
 OUTFIL FILES=03,INCLUDE=(EXTENDED-TEST-FOR-PLUS,
                          EQ,TWO-OR-MORE-PLUSSES),
         BUILD=(INPUT-RECORD)
/*
//SORTOF01 DD SYSOUT=*
//SORTOF02 DD SYSOUT=*
//SORTOF03 DD SYSOUT=*
//SORTIN DD *
++++
+++
++
+
-

Re: How to split the file based on some symbols?

PostPosted: Sat Jan 14, 2012 10:48 am
by dick scherrer
Hi Bill,

This runs with DFSORT and works with that product.

However, this topic is in the Syncsort part of the forum. Possibly incorrectly, but i just figured TS was using Syncsort. . . ;)

Re: How to split the file based on some symbols?

PostPosted: Sat Jan 14, 2012 9:03 pm
by BillyBoyo
Hi Dick,

I checked that all the functions are available in Syncsort. I can't check the actual syntax of them. As far as I can see it "should" work, but that was my "get out" if it doesn't. If it gets any "syntax" errors, then it will be up to the TS to sit down with their Syncsort manual and do a bit of research/learning, before coming back with anything that is still a problem :-)

And to post the working solution for the benefit of future readers.

Re: How to split the file based on some symbols?

PostPosted: Sun Jan 15, 2012 11:50 am
by dick scherrer
Hi Bill,

Yup, hopefully, TS will let us know if all is well and share the final jcl/control statements.

Have a great rest of the wekend!

d