|
View previous topic :: View next topic
|
| Author |
Message |
krsenthil85
New User
Joined: 31 Aug 2007 Posts: 55 Location: bangalore
|
|
|
|
Hi,
I am using following sort card to split a block of records into two files
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(16,8,CH,EQ,C'B0135101'),
OVERLAY=(1001,C'1'))
IFTHEN=(WHEN=GROUP,
BEGIN=(16,8,CH,EQ,C'B0135102'),
OVERLAY=(1001,C'2'))
OUTFIL FILES=01,INCLUDE=(1001,1,CH,EQ,C'1'),
BUILD=(1,1000)
OUTFIL FILES=02,INCLUDE=(1001,1,CH,EQ,C'2'),
BUILD=(1,1000)
OUTFIL FILES=XX,
SAVE,
BUILD=(1,1000)
/* |
Here the input file and output files having record length 1000. I am adding an unique identifier '1' or '2' at position 1001 in INREC command to a block of records using group option and in the Out files based on the unique identifier I am writing to two different files.
But my sort card is giving error at Overlay command. Could you please help me to resolve. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you get an error, post the error message.
OVERLAY is not part of WHEN=GROUP. Use PUSH=with ID=1 (length of one). |
|
| Back to top |
|
 |
krsenthil85
New User
Joined: 31 Aug 2007 Posts: 55 Location: bangalore
|
|
|
|
Hi Bill,
The GROUP function works but not getting expected result because the Group function perform auto increment after writing one block of record. For example I have input file as below
| Code: |
00HEADER B0135101
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135101
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135102
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135101
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135102
70XXXXXXX
70XXXXXXX
99TRAILER |
I want to get only two output files will a block of records containing 'B0135101' in one file and the other one 'B0135102' in the second file. So the output file should be as below
Output File 1
| Code: |
00HEADER B0135101
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135101
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135101
70XXXXXXX
70XXXXXXX
99TRAILER |
Output file 2:
| Code: |
00HEADER B0135102
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135102
70XXXXXXX
70XXXXXXX
99TRAILER |
Please help |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, you didn't describe or show your data previously :-)
If you look, the last digit of your BEGIN value is 1 or 2. Use that last digit to PUSH. |
|
| Back to top |
|
 |
krsenthil85
New User
Joined: 31 Aug 2007 Posts: 55 Location: bangalore
|
|
|
|
Ok. In that case it will add '00' for both the groups containing the Key B0135101 and B0135102, since Header record for both starts with '00'. But I want to add different Group number for each set of group, then only I can write each group of record in separate file. Example I need something like below
| Code: |
00HEADER B0135101 001
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135101 001
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135101 001
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135102 002
70XXXXXXX
70XXXXXXX
99TRAILER
00HEADER B0135102 002
70XXXXXXX
70XXXXXXX
99TRAILER |
Assuming last three character are PUSH record. Please help. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
This is a value: B0135101. This is the other: B0135102.
Those end in 1 and 2 respectively. You want 1 and 2 appended, respectively. So PUSH the final digit of that value.
I've no clue how you got the idea of using the record-type. Since it is the same for both your selection values, I don't see how you could have even imagined that would help. |
|
| Back to top |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
You don't need to create groups separately. You just need to identify each of them.
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,8,CH,EQ,C'00HEADER'),PUSH=(1001:16,8))
OUTFIL FILES=01,INCLUDE=(1001,8,CH,EQ,C'B0135101'),
BUILD=(1,1000)
OUTFIL FILES=02,INCLUDE=(1001,8,CH,EQ,C'B0135102'),
BUILD=(1,1000) |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| That could include RECORDS=4 (each group is shown in the example with four records) or END= for the 99 (if the groups actually aren't regular). Don't need to test the HEADER part, just the record-type. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|