I have a file containing records along with Header and trailer. Header and Trailer both contain count of records in file excluding Header and Trailer and is always equal.
Each detail record has 2 byte code appeaing at the end which will form the basis for spilitting into several file. Ex A1 , A2 , A3. No of codes appearing at the end of each detail record are fixed set of codes which i already know..
1. Spilt the file to various files based on 2 byte code appearing at end of each record.
2. attach Header and trailer to each output file having same info as in Combined file with COUNT field having the actual no of records written to each broken file.
Joined: 20 Oct 2006 Posts: 6970 Location: porcelain throne
how many different codes (output files can there be).
had you bothered to search the forum,
the kind of question that you are posing is repeated weekly,
you would know that the potential number of output files is handy to have.
other tidbits of handy info are:
actual column positions for fields within records,
the date in the header record is to be copied as is?
and why do you want the count in both header and trailer?
of course it is doable,
but why incur the extra resources necessary to generate the header count?
Input file will be 80 Bytes in length and Output files also required as 80 bytes.
1) there can be max 50 different codes and hence 50 output files.
2) Code for splitting the file is appearing at 79,80th byte position (2 char)
3) All info in header will be written to each output file, but COUNT having value equal to no of records written in file.
4) Header and Trailer will both contain COUNT of records in file excluding Header and Trailer.
4) In header, count field starts at 25th pos and length 8 bytes
5) Trailer has Count start at 8th position and length 8 bytes.
As enrico indicates, with no data for A2 it is foolish to expect the header/trailer for the A2-file to contain anything at all based on A2 data.
You did not mention in your original requirement the possibility of any of the codes not have data associated with it.
Kolusu did not "choose" 105, you did. Look at the REFORMAT record definition: 80 bytes from file 1 record, 88 bytes from file 2. On file 2 there is a field that you want which starts at position 25. 80 + 25 = 105.
Now I suppose you have an updated requirement? Or you'll manage that yourself with the information already provided?
Joined: 03 Oct 2009 Posts: 1781 Location: Bloomington, IL
Manoj, I note that you claim no mainframe skills in your profile. Perhaps this is an error, the more likely in that you seem to have entered a variant of your user name in the skills. To the left, perhaps this is a sign that you ought to turn this task over to a colleague who can write a bit of COBOL, PL/I, or Rexx to accomplish it, rather than attempt to blindly juggle hundreds of lines of JCL and DFSORT control cards.
The INB file, through the SUM, is reduced to (when all are present) 100 records with totals on. Each record is available, through the JOIN, for each data record on INA. Thus allowing the header and trailer to be based on the originals.
If you have a missing record-type, you only get 99 records on INB. If two missing, you only get 98, etc.
If you have a file with all your record-types on, you can use that in a new step to generate a file of 100 "dummy records". Concatenate that to the INB file.
You will have to adjust the record-count after the JOIN. Subtract one from it. This will get you zero for the "missing" record-types and actual-count-minus-one for the existing record-types.
Start with Kolusu's original code, you shouldn't need your changes.
Understand it fully this time. Test it fully this time. Don't come back in another eight months with more problems to do with the same thing, please.
I tried with above solution, creating a file containing all allowed codes with codes appearing at Pos79,80 and concantenating to INB.
However there is no change to output for those codes for which there are no records in INB they are still showing as
Output still showing :
record1 : BLANKS
Additonally, other files for which there were some records in INA have now started getting one addtional record count. Not sure how should i reduce the count in Header by 1 (I know how to reduce TRAILER COUNT). But trailer count is appearing correctly.
TTYA.SORT.TEST1 --> actual input file which is to be broken to several outputs based on codes.
TTYA.SORT.TEST2 --> exact replica of TTYA.SORT.TEST1.
TTYA.SORT.CODES --> Contains all the allowed codes ex. A1, A2 etc .. at Pos 79, 80. Pos 1-78 are Blanks
When there is no record for a code . ex A3 ... below is the output file which is getting created.
record1 : Blanks
record2 : TRAILER00000000
expected is :
Record 1: Byte 1-24 (same as appearing in header record in TTYA.SORT.TEST1) + Count 8 bytes (00000000) as there are no records present for A3 in input file.
For rest of the files created for each Code Ex A1, A2. Detail records and Trailer are coming as expected, however header has started getting one extra count compare to trailer value. Trailer value is coming properly as expected. Now i am confused how to get rid of extra 1 count from header ?