|
View previous topic :: View next topic
|
| Author |
Message |
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
Hi,
I have two files- Input File 1(FB/LRECL=162)- Master File and Input File 2:(FB/LRECL=24). The master file has a header(two records), data and Trailer(2 records). The format is repetitive which is standard
The header record1 always starts 1111 in first 4 bytes
The header record2 starts with 2222 in first 4 bytes
The trailer record1 starts with 8888 in first 4 bytes-- has the count of detail records + header and sum of amounts in Detail records
The trailer record2 starts with 9999 in first 4 bytes-- has the count of detail records + header + Trailer and sum of amounts in Detail records
I have a pull file(Input File2) which has key 24 bytes(Position 1:24 bytes) which exist in detail records(Position 5:24 bytes) of Input File 1. When i use join to extract/omit the records, as expected the output records are getting reformatted which is not expected.
I tried to split the files based on key and omit and concatenate, but not been able to do so.
There are sums and counts which needs to be re-counted, which i can perform in an additional step
Is there a way to retain the headers and trailers as they exist in input file and omit only records from detail records? Any suggestions/advice?
Input File 1:( FB/LRECL=162)
=============
| Code: |
1111AAAAAAAAAAAADDMMYYY 1234-XYZ
7777AAAAAAAAAAAA XYZCN CDEFGEH
2222AAAAAAAAAAAAXXXXXXXXXXXX GHJYE 10.00
3333AAAAAAAAAAAAXXXXXXXXXXXX MNOPQR
4444AAAAAAAAAAAAXXXXXXXXXXXX
2222AAAAAAAAAAAAYYYYYYYYYYYY QRETY 20.00
3333AAAAAAAAAAAAYYYYYYYYYYYY GEHEREW
4444AAAAAAAAAAAAYYYYYYYYYYYY
2222AAAAAAAAAAAAZZZZZZZZZZZZ RESTE 30.00
3333AAAAAAAAAAAAZZZZZZZZZZZZ JHDSAJDSA
4444AAAAAAAAAAAAZZZZZZZZZZZZ ABCDEF
8888AAAAAAAAAAAA 0000011 00060.00 6236215
9999AAAAAAAAAAAA 0000013 00060.00 6236215
1111BBBBBBBBBBBBDDMMYYY 1234-XYZ
7777BBBBBBBBBBBB
2222BBBBBBBBBBBBCCCCCCCCCCCC MNOPQ 100.00
3333BBBBBBBBBBBBCCCCCCCCCCCC GDFSADAS
4444BBBBBBBBBBBBCCCCCCCCCCCC
2222BBBBBBBBBBBBDDDDDDDDDDDD STUVW 100.00
3333BBBBBBBBBBBBDDDDDDDDDDDD YTEYWQTE
4444BBBBBBBBBBBBDDDDDDDDDDDD
8888BBBBBBBBBBBB 0000008 00200.00 6236215
9999BBBBBBBBBBBB 0000010 00214.00 6236215 |
....
Input file 2:(FB/LRECL=24)
=============
| Code: |
AAAAAAAAAAAAXXXXXXXXXXXXX
AAAAAAAAAAAAYYYYYYYYYYYYY
BBBBBBBBBBBBDDDDDDDDDDDDD
|
Final Output Expected:
=====================
| Code: |
1111AAAAAAAAAAAADDMMYYY 1234-XYZ
7777AAAAAAAAAAAA XYZCN CDEFGEH
2222AAAAAAAAAAAAZZZZZZZZZZZZ RESTE 30.00
3333AAAAAAAAAAAAZZZZZZZZZZZZ JHDSAJDSA
4444AAAAAAAAAAAAZZZZZZZZZZZZ ABCDEF
8888AAAAAAAAAAAA 0000011 00060.00 6236215
9999AAAAAAAAAAAA 0000013 00060.00 6236215
1111BBBBBBBBBBBBDDMMYYY 1234-XYZ
7777BBBBBBBBBBBB
2222BBBBBBBBBBBBCCCCCCCCCCCC MNOPQ 100.00
3333BBBBBBBBBBBBCCCCCCCCCCCC GDFSADAS
8888BBBBBBBBBBBB 0000008 00200.00 6236215
9999BBBBBBBBBBBB 0000010 00214.00 6236215 |
....
coded, for what is worth |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
What do you mean by 'reformatted'? Did you really mean re-sequenced?
Show your control cards. |
|
| Back to top |
|
 |
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
| Nic Clouston wrote: |
What do you mean by 'reformatted'? Did you really mean re-sequenced?
Show your control cards. |
I meant to not modify the header and trailer records and only omit the detail records using join
Below is my sortcard- straight forward join
| Code: |
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION
JOINKEYS F1=MASTER,FIELDS=(5,24,A)
JOINKEYS F2=PULL,FIELDS=(1,24,A)
JOIN UNPAIRED F1,F2
REFORMAT FIELDS=(F1:1,162,F2:1,24,?)
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOF1,INCLUDE=(187,1,CH,EQ,C'B'),
BUILD=(1,162)
OUTFIL FNAMES=SORTOF2,INCLUDE=(187,1,CH,EQ,C'1'),
BUILD=(1,162)
OUTFIL FNAMES=SORTOF2,INCLUDE=(187,1,CH,EQ,C'2'),
BUILD=(163,24) |
But this takes into account the header and trailer while joining and messes the format of the output file
Code'd |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It looks like the main file does need to be sorted in the JOINKEYS (which you are doing), but that would mess up the order of the headers/trailers.
If you attach a sequence number to the records, in JNF1CNTL, and SORT on the sequence number in the JOINKEYS main task, that should fix the order.
Ideally you could do the adjustment of totals in the main task as well. It would be rare that you would need a separate step for that. |
|
| Back to top |
|
 |
shajeeth
New User
Joined: 25 May 2005 Posts: 20
|
|
|
|
| Bill Woodger wrote: |
It looks like the main file does need to be sorted in the JOINKEYS (which you are doing), but that would mess up the order of the headers/trailers.
If you attach a sequence number to the records, in JNF1CNTL, and SORT on the sequence number in the JOINKEYS main task, that should fix the order.
Ideally you could do the adjustment of totals in the main task as well. It would be rare that you would need a separate step for that. |
Bill,
To clarify,
The sequence number addition to the records will work if there is a single header and trailer in the record?
The header details and trailer are repetitive in format.
Thanks,
Shajeeth |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I'm not sure what you were trying to clarify.
It looks like 7777s are a header as well.
1111s, 7777s, 8888s and 9999s don't have a key, unless for "false hits" (so check that that is not possible with the data).
2222s seem to have a key, so will be stripped off if the key matches.
All your output (unmatched F1s, matches) that make up the new file can have a sequence number on, and then you can return them to their original input sequence, even though you've now excluded some records (ie the relative sequence will remain the same).
The number of headers/trailers does not matter.
Remember to chop the sequence number off (OUTREC or OUTFIL) after you've used it.
The trickier part is updating the totals, especially whatever amounts appear on the 8888 and 9999 records because those don't make sense at first glance. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|