|
View previous topic :: View next topic
|
| Author |
Message |
saurabhgaikwad
New User
Joined: 29 Dec 2009 Posts: 4 Location: bangalore
|
|
|
|
Hi,
I have two flat files A and B both are similiar in all respect.
I need to add the records from the file A to B such that:
1. I have only one header and trailer on file B
2. A field of two character at the column 34 gets updated as shown below
3. Record count at trailer gets updated at column 35 as shown below
For Example:
| Code: |
File 1
00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 01
00011111111111111111111111111AA 01
00011111111111111111111111111SZ 01
00011111111111111111111111111SA 02
00011111111111111111111111111AA 02
00011111111111111111111111111SZ 02
99999999999999999999999999999GE A02
File 2
00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 01
00011111111111111111111111111AA 01
00011111111111111111111111111SZ 01
00011111111111111111111111111SA 02
00011111111111111111111111111AA 02
00011111111111111111111111111SZ 02
99999999999999999999999999999GE A02
O/P file - File 2
00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 01
00011111111111111111111111111AA 01
00011111111111111111111111111SZ 01
00011111111111111111111111111SA 02
00011111111111111111111111111AA 02
00011111111111111111111111111SZ 02
00011111111111111111111111111SA 03
00011111111111111111111111111AA 03
00011111111111111111111111111SZ 03
00011111111111111111111111111SA 04
00011111111111111111111111111AA 04
00011111111111111111111111111SZ 04
99999999999999999999999999999GE A04
|
Is this possible using DFSORT/ICETOOL.. please suggest. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
saurabhgaikwad,
You need to increment the counter in file 2 with the last value from file 1 at position 34? Is it just 2 bytes of zd number? What happens if the counter exceeds 99? |
|
| Back to top |
|
 |
saurabhgaikwad
New User
Joined: 29 Dec 2009 Posts: 4 Location: bangalore
|
|
|
|
yes i need to increment the counter in file 2 with the last value from file 1 at position 34.
in the original file this is of 10 bytes so size will not be a problem. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| saurabhgaikwad wrote: |
yes i need to increment the counter in file 2 with the last value from file 1 at position 34.
in the original file this is of 10 bytes so size will not be a problem. |
You want a solution with 2 bytes where as in reality it is a 10 byte field? What about the format? Does the 2 vs 10 bytes hold good for the trailer records also? Please provide detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question. |
|
| Back to top |
|
 |
saurabhgaikwad
New User
Joined: 29 Dec 2009 Posts: 4 Location: bangalore
|
|
|
|
Hi Skolusu,
Yes, 2 vs 10 bytes hold good for the trailer records also. I should not have put it as 2 bytes. Rest of the information is same.
Details:
Both files have same header and trailer. Each Detail record in both the file have SA at the 30th column (start of record) and SZ at the 30th column (end of record). So all the records between SA segment and SZ segment makes one complete record
Field at the 34th column which is of 10 bytes keeps the count of the SA/SZ segments. This field should be incremented each time another SA is encountered that is whenever we get new record.
Value of this field at the 34th column for the last record should be the value of counter in the trailer record at the 35th column.
When I add the records from the File A to B ( both files were shown above ) , I get the below result
00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 00000001
00011111111111111111111111111AA 00000001
00011111111111111111111111111SZ 00000001
00011111111111111111111111111SA 00000002
00011111111111111111111111111AA 00000002
00011111111111111111111111111SZ 00000002
00011111111111111111111111111SA 00000001
00011111111111111111111111111AA 00000001
00011111111111111111111111111SZ 00000001
00011111111111111111111111111SA 00000002
00011111111111111111111111111AA 00000002
00011111111111111111111111111SZ 00000002
99999999999999999999999999999GE A00000002
Whereas i should have the below result
00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 00000001
00011111111111111111111111111AA 00000001
00011111111111111111111111111SZ 00000001
00011111111111111111111111111SA 00000002
00011111111111111111111111111AA 00000002
00011111111111111111111111111SZ 00000002
00011111111111111111111111111SA 00000003
00011111111111111111111111111AA 00000003
00011111111111111111111111111SZ 00000003
00011111111111111111111111111SA 00000004
00011111111111111111111111111AA 00000004
00011111111111111111111111111SZ 00000004
99999999999999999999999999999GE A00000004
So Yes, I need to increment the record counter from the last value in file B
I hope this will help !! |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
saurabhgaikwad,
The following DFSORT JCL will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 0000000001
00011111111111111111111111111AA 0000000001
00011111111111111111111111111SZ 0000000001
00011111111111111111111111111SA 0000000002
00011111111111111111111111111AA 0000000002
00011111111111111111111111111SZ 0000000002
99999999999999999999999999999GE A0000000002
// DD *
00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 0000000001
00011111111111111111111111111AA 0000000001
00011111111111111111111111111SZ 0000000001
00011111111111111111111111111SA 0000000002
00011111111111111111111111111AA 0000000002
00011111111111111111111111111SZ 0000000002
99999999999999999999999999999GE A0000000002
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN(WHEN=GROUP,BEGIN=(34,3,CH,EQ,C'SAU'),PUSH=(81:ID=1)),
IFTHEN(WHEN=GROUP,BEGIN=(81,1,ZD,EQ,1,AND,30,2,CH,EQ,C'SZ'),
PUSH=(82:34,10)),
IFTHEN(WHEN=GROUP,BEGIN=(81,1,ZD,EQ,1,AND,1,3,CH,EQ,C'999'),
PUSH=(92:35,10))
OUTFIL IFOUTLEN=80,
OMIT=(81,1,ZD,EQ,1,AND,1,3,CH,EQ,C'999',OR,
81,1,ZD,EQ,2,AND,34,3,CH,EQ,C'SAU'),
IFTHEN(WHEN=(81,1,ZD,EQ,2,AND,1,3,CH,EQ,C'999'),
OVERLAY=(35:92,10,ZD,ADD,35,10,ZD,M11,LENGTH=10)),
IFTHEN(WHEN=(81,1,ZD,EQ,2,AND,1,3,CH,NE,C'999'),
OVERLAY=(34:34,10,ZD,ADD,82,10,ZD,M11,LENGTH=10))
//* |
|
|
| Back to top |
|
 |
saurabhgaikwad
New User
Joined: 29 Dec 2009 Posts: 4 Location: bangalore
|
|
|
|
| Thank You Very Much .. I will try this out and let you know .. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|