|
View previous topic :: View next topic
|
| Author |
Message |
Srinivasan Selvam
New User
Joined: 25 May 2012 Posts: 11 Location: india
|
|
|
|
Hi Experts,
I am trying to write a sort card to copy records based on values.
For example, I have to copy records between A1 through AZ. A1 to AZ can be n times in the input file and I have to copy all those inbetween records along with those records.
Input:
A1
Record 1
Record 2
...........
...........
Record 10
AZ
B1
Record 11
Record 12
..........
Record 25
BZ
A1
Record 26
Record 27
AZ
Record 28
Output:
A1
Record 1
Record 2
...........
...........
Record 10
AZ
A1
Record 26
Record 27
AZ
Throw some light and I will catch up.
Thanks,
Srinivasan Selvam. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
Just impossible to understand anything from this complete mess of words...
0) Learn how to use the Code button when presenting your code, and/or data
1) Please give the clear examples of your input data and (mandatory!!!) your desired output data. For instance: what is the role of your B1-BZ records? What else except A1/B1/AZ/BZ you need to consider in your input data? Etc, etc, etc...
2) Please demonstrate what did you try to do by yourself, so far? |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
Try Grouping option
| Code: |
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,1,SS,EQ,C'ABCDEFGHIJKLMNOPRSTUVWXYZ',
AND,2,1,SS,EQ,C'0123456789'),
END=(2,1,CH,EQ,C'Z'),
PUSH=(81:1,2))
SORT FIELDS=(81,2,CH,A),EQUALS
OUTREC BUILD=(1,80)
END |
|
|
| Back to top |
|
 |
Srinivasan Selvam
New User
Joined: 25 May 2012 Posts: 11 Location: india
|
|
|
|
Hi Sergeyken,
I have used the grouping with BEGIN and END. But outrec is writing all the records of Input file.
For example, I need only the bolded records to my output file and I don't want the remaining records .
Input file:
Rec 1
Rec 2
A1
Rec 4
Rec 5
AZ
Rec 6
B1
Rec 7
Rec 8
BZ
Rec 9
A1
Rec 10
Rec 11
Rec 12
AZ
Output file:
A1
Rec 4
Rec 5
AZ
A1
Rec 10
Rec 11
Rec 12
AZ
| Code: |
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,SS,EQ,C'A1'),END=(1,2,SS,EQ,C'AZ'),
PUSH=(81:1,2))
SORT FIELDS=(81,2,CH,A),EQUALS
OUTREC BUILD=(1,80)
|
|
|
| Back to top |
|
 |
Srinivasan Selvam
New User
Joined: 25 May 2012 Posts: 11 Location: india
|
|
|
|
Hi Sergeyken,
I got the desired output after changing the code like below.
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'A1'),END=(1,2,CH,EQ,C'AZ'),
PUSH=(81:1,2))
OUTFIL INCLUDE=(81,2,CH,EQ,C'A1'),BUILD=(1,80) |
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
0) Learn how to use the Code button when presenting your code, and your data
1) Learn to express your ideas, and issues in such a manner and terminology, that other people to be able to understand your needs. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|