|
View previous topic :: View next topic
|
| Author |
Message |
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Dear All,
I have a file, say, with the below record format.
LINE1 MPR BBB CCCC
LINE2 1112223334445
LINE3 0006666689076
LINE4 ####AAKSLSLS
LINE5 MPS FFF LLLL
LINE6 47474748009
LINE7 97777474747
LINE8 *****uieure0
Say, LINE1 to LINE4 and LINE5 to LINE8 constitute a particular Block of Record.
IF the 1st 3 characters = 'MPR', THEN select the entire block (LINE1 through LINE4).
On the other hand, IF the 1st 3 characters = 'MPS', THEN reject the entire Block (LINE5 through LINE8).
How could this be acheived using SORT? |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
Hello,
Will all the blocks have only 4 records?
What SORT product do you have at your shop?
Does the input file actually have a blank line separating blocks between line4 and line5?
What are the LRECL & RECFM of the input and output datasets.? |
|
| Back to top |
|
 |
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Hi Vasanth,
Yeah, you are right. The Block structure would be fixed (say, 4 Records per block). DFSORT is what we use.
The input file does not have any blank line separating the blocks between LINE4 and LINE5. Actually, the Input File would have hundreds and thousands of such block of records and there would be absolutely no space separating each block of record.
RECFM=FB and LRECL=80. |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1753 Location: Tirupur, India
|
|
|
|
Try this,
| Code: |
//JS010 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=WELLS.SORTIN
//SORTOUT DD DISP=OLD,DSN=WELLS.SORTOUT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(81:7,3))
OUTFIL FNAMES=SORTOUT,INCLUDE=(81,3,CH,EQ,C'MPR'),BUILD=(1,80)
/* |
This type of topics have already been discussed several times. Next time please search the forum for previous similar topics before posting. |
|
| Back to top |
|
 |
Subhasish Sarkar
New User
Joined: 21 Oct 2011 Posts: 16 Location: India
|
|
|
|
Hi Vasanth,
Working perfectly fine as per my expectations and requirements!!! Thanks a lot. |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| vasanthz wrote: |
Try this,
| Code: |
//JS010 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=WELLS.SORTIN
//SORTOUT DD DISP=OLD,DSN=WELLS.SORTOUT
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,RECORDS=4,PUSH=(81:7,3))
OUTFIL FNAMES=SORTOUT,INCLUDE=(81,3,CH,EQ,C'MPR'),BUILD=(1,80)
/* |
This type of topics have already been discussed several times. Next time please search the forum for previous similar topics before posting. |
Hi vasanthz,
What if input is like this..
| Code: |
LINE2 1112223334445
LINE1 MPR BBB CCCC
LINE2 1112223334445
LINE3 0006666689076
LINE4 ####AAKSLSLS
LINE5 MPS FFF LLLL
LINE6 47474748009
LINE7 97777474747
LINE8 *****UIEURE0
|
|
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| Subhasish Sarkar wrote: |
Hi Vasanth,
Working perfectly fine as per my expectations and requirements!!! Thanks a lot. |
You can use this.. Small change to Vasanthaz change.
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(7,3,CH,EQ,C'MPR'),RECORDS=4,
PUSH=(81:7,3))
OUTFIL FNAMES=SORTOUT,INCLUDE=(81,3,CH,EQ,C'MPR'),BUILD=(1,80)
/*
|
|
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
The requirement says that the records will be blocks beginning with MPR.
I would think that anything else would be an error. . . |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|