View previous topic :: View next topic
|
Author |
Message |
bhavin.mehta
New User
Joined: 25 Jun 2012 Posts: 34 Location: India
|
|
|
|
I have a file which has some "Keyword" placed at some random line, but the position of the keywords are fixed.
I want to start the copy from that line where is "Keyword" is found. All the above lines should be skipped.
Simillary there is another "Keyword" at the end which indicates to stop.
Both the start and the stop keywords are at unpredicted line but at a definite position.
Is there a way where I can put such logic? |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Group the records when you encounter the keyword and PUSH SEQ or keyword
then OUTFIL INCLUDE + BUILD |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
With END= for the data which finishes the GROUP. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hello,
Try out something like this, It starts reading from START keyword and stops at END keyword.
Code: |
//STEP0010 EXEC PGM=SORT
//SORTIN DD *
USELESS RECORD
USELESS RECORD
START FROM HERE
PRETTY RECORD
PRETTY RECORD
END IT HERE
USELESS RECORD
USELESS RECORD
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'START'),PUSH=(81:1,5),
END=(1,3,CH,EQ,C'END'))
OUTFIL INCLUDE=(81,5,CH,EQ,C'START'),BUILD=(1,80)
/* |
Output:
Code: |
START FROM HERE
PRETTY RECORD
PRETTY RECORD
END IT HERE |
|
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
@Bill & Pandora
my DFSORT is rusty so used this as a practice. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Vasanthz,
It is just the same for me .Experiencing in seocond hand |
|
Back to top |
|
|
bhavin.mehta
New User
Joined: 25 Jun 2012 Posts: 34 Location: India
|
|
|
|
@Pandora-Box:
Thanks for your help, it worked.
@vasanthz:
Sorry, I didn't check you comment until I was done with my Logic. But our code is almost the same. Without the 'END'
@Bill Woodger:
Thanks for reducing my load. I'll use END, as explained by vasanthz. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Vasanthz,
You could PUSH a one-byte ID. Or a single character. Just save a bit of space on the intermediate records. Won't make a difference for the task in hand, I suspect. So mark that as a bit of rust shined off.
bhavin.mehta,
We assume that your values in those positions are unique. If not, you may not get the results you want. If you have multiple groups and only want the first, or a specific one, do PUSH the ID and test for that (equal to 1, for the first group, 3 for the third etc). |
|
Back to top |
|
|
bhavin.mehta
New User
Joined: 25 Jun 2012 Posts: 34 Location: India
|
|
|
|
@Bill Woodger
Yes, I have used ID and it is working perfecting fine
Thanks again. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Quote: |
You could PUSH a one-byte ID. Or a single character. Just save a bit of space on the intermediate records. |
Bill, thanks, using one byte would certainly be more effecient. I have to give more work to bwains.
Regards, |
|
Back to top |
|
|
|