View previous topic :: View next topic
|
Author |
Message |
jammy_27
New User
Joined: 06 Aug 2009 Posts: 17 Location: USA
|
|
|
|
Hi
I got a PS file with the following records
Every third record will act as an identifier
Example
DCAD010 EDIAPFS00100
DCAD010 NONEDIAPFS007
DCAD 101 021000021900510223509081911480094101BRENDAN SHAH
DCAD010 EDIAPFS00100
DCAD010 NONEDIAPFS007
DCAD 101 021000021900510223509081911480094101BRENDAN SHAH RETAIL
DCAD010 EDIAPFS00100
DCAD010 NONEDIAPFS007
DCAD 101 021000021900510223509081911480094101BRENDAN SHAH, N.A.
Now, i need to split the file into three different files depending on the 3rd record
i.e -
DCAD 101 021000021900510223509081911480094101BRENDAN SHAH
DCAD 101 021000021900510223509081911480094101BRENDAN SHAH RETAIL
DCAD 101 021000021900510223509081911480094101BRENDAN SHAH, N.A.
i wanted to avoid writing a cobol program for the same.
Please let me know if this can be done via File manager/DFSORT etc
(also, the original file can have the single indetifier or the combination of two or all three(as mentioned above) and then we need to split accordingly)
TIA |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Will there be maximum three identifiers present in your input dataset?
What is LRECL and RECFM of input dataset? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Please explain clearly the rules for splitting a file, such as which records go where.
It looks as though when an "identifier" is encountered the records before and including this record should be grouped together. That is my guess, but a guess is not good enough really.
What are the RECFM and LRECL of the file. What are the positions, lengths and formats of the split control fields. |
|
Back to top |
|
|
jammy_27
New User
Joined: 06 Aug 2009 Posts: 17 Location: USA
|
|
|
|
I am not concerned about the records preceeding and succeeding.The records which contain Brendan must be split into different files.
Example -
BRENDAN SHAH - should go to file 1
BRENDAN SHAH RETAIL - should go to file 2
BRENDAN SHAH,N.A - should go to file 3
The input file can contain various combinations of the identifiersBRENDAN SHAH, BRENDAN SHAH RETAIL and BRENDAN SHAH,N.A.
RECL = 600
RECFM = FB
start position of BRENDAN SHAH is 58
Please let me know if you need further details |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi Jammy, Use below to get desired result.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTIN DD DSN=your input dataset
//OUT1 DD DSN=your output dataset1
//OUT2 DD DSN=your output dataset2
//OUT3 DD DSN=your output dataset3
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL INCLUDE=(58,19,CH,EQ,C'BRENDAN SHAH '),FNAMES=OUT1
OUTFIL INCLUDE=(58,19,CH,EQ,C'BRENDAN SHAH RETAIL'),FNAMES=OUT2
OUTFIL INCLUDE=(58,19,CH,EQ,C'BRENDAN SHAH, N.A. '),FNAMES=OUT3
/*
|
Dheeraj,
SS is not required here as we know the starting position of string |
|
Back to top |
|
|
jammy_27
New User
Joined: 06 Aug 2009 Posts: 17 Location: USA
|
|
|
|
thanks Sambhaji.
i should have thought of the blanks to identify the first split
I will try and update you guys acordingly
many thanks
jammy |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
jammy wrote: |
thanks Sambhaji.
|
You are welcome.
jammy wrote: |
I thought of this but honestly havent tried.
|
That is something honestly you should do first and post when you encounter any issue with it.. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Jammy,
Based on your statement that
Quote: |
Now, i need to split the file into three different files depending on the 3rd record |
here's a more "generic" DFSORT solution:
Code: |
OPTION COPY
OUTFIL FNAMES=OUT1,STARTREC=3,ENDREC=3
OUTFIL FNAMES=OUT2,STARTREC=6,ENDREC=6
OUTFIL FNAMES=OUT3,STARTREC=9,ENDREC=9
|
|
|
Back to top |
|
|
|