View previous topic :: View next topic
|
Author |
Message |
shreya19
New User
Joined: 13 Mar 2014 Posts: 34 Location: USA
|
|
|
|
I have a flat file and I need to copy few lines from it to another PS file.
I need to search for some words like "XYZ Report" and then copy next 10 lines after it to the other PS file.
Please suggest how this can be done |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
So, you mean, you need to copy a 'GROUP' of 'RECORDS' to another data set.
I think this should be a suggestion good enough.
. |
|
Back to top |
|
|
shreya19
New User
Joined: 13 Mar 2014 Posts: 34 Location: USA
|
|
|
|
Thanks, I got that working
Now, if I want to copy a group the begins with 'AB' at 1st position and should end when another 'AB' is found at 1st position.
and 5th row has a word "XYZ" at 10th column.
Can this be achieved? Any hints will be of help. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Update a sequence number when it is AB, use KEYBEGIN.
If you get stuck, post what code you have, representative sample input, expected output and what you get. |
|
Back to top |
|
|
shreya19
New User
Joined: 13 Mar 2014 Posts: 34 Location: USA
|
|
|
|
I got the below sequence numbers assigned using the code
Code: |
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'AB'),
PUSH=(31:ID=1))
OUTFIL BUILD=(1,30) |
Code: |
AB 1
Group data 1 1
Group data 1 ABC 1
Group data 1 1
Group data 1 1
AB 2
Group data 2 2
Group data 2 2
Group data 2 2
Group data 2 2 |
Now I want to display only those groups having ABC at (14,3) on any of the rows.
Stuck on how to get this done.
Code'd |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
No you can identify the different groups which start with AB, yes? |
|
Back to top |
|
|
shreya19
New User
Joined: 13 Mar 2014 Posts: 34 Location: USA
|
|
|
|
yes, I got the sequence numbers assigned as above.
stuck at the next step |
|
Back to top |
|
|
magesh23586
Active User
Joined: 06 Jul 2009 Posts: 213 Location: Chennai
|
|
|
|
Is the number of rows for a group is always four as shown in example,
If yes then you can use RESIZE to make all four records into one record and have an outfil include condition assuming your LRECL=50, then 50 * 4 (1,200,SS,EQ,C'ABC') and use '/' symbol to split the record back to multiple rows.
If the number of the rows are not fixed, then you may use joinkeys having the same input file in JNF1 and JNF2. |
|
Back to top |
|
|
|