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: 6966 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,
record length.
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.
One of my collegue has reported that when for a particualr code ex. A2 there is no record in input file. Header and trailer are not appearing properly in the file corresponding to A2.
Can you please help ?
Also INREC OVERLAY=(105:161,8)
how did you choose 105 ??
please, please tell Your colleague/friend to use his neuron ...
how is <somebody> supposed to manage/handle/carry_on_some_action based on something that is not there
if no record satisfying the condition
Code:
... INCLUDE=(79,2,CH,EQ,C'A2') ...
is found
the statement processing is <skipped>
and there is noo way to invent something to be written
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Did this take eight months to test?
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?
There is a possibility of No records present for a code ex. A2.
With current SORT condition, there are still 2 records appearing in Output file for A2 as:
Record 1 : Entire record with SPACES
Record 2: TRAILER
However , i want following should appear in case there is no records for A2 in Input file :
Original header record in input file with Count = 00000000 and trailer with COunt = 00000000 as there are no records coming in INPUT for code : A2.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
puneetvirmani143 wrote:
Hi,
One of my collegue has reported that when for a particualr code ex. A2 there is no record in input file. Header and trailer are not appearing properly in the file corresponding to A2.
Can you please help ?
Also INREC OVERLAY=(105:161,8)
how did you choose 105 ??
regards
Puneet
puneetvirmani143,
Thank you for your timely feed back and I am extremely sorry that I canNOT help you create something that doesn't exist.
This works fine if there is atleast 1 record for each code in input file. But does not produce a proper header/trailer file if for a particualr code there is no record in input file.
Joined: 03 Oct 2009 Posts: 1788 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.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
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
Record2: TRAILER00000000
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.
here
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 ?
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
Does this not bring you back to what Kolusu posted weeks ago?
Quote:
Thank you for your timely feed back and I am extremely sorry that I canNOT help you create something that doesn't exist.
Creating the dummy records should leave you with no codes without records.
If there is only a dummy record for a given code, that could be used to identify the codes with "no records". Possibly if you create a dummy record even for the codes with records, then when the record count for a code is 1 this code really has no records?
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
OK. This is a good example of the time wasted when the requirement is not fully described.
Your current control cards are not working because the HEADER1 is relying on the content of the first record output, and there isn't a first record output when there are no records.
Then, when adding JOIN UNPAIRED,F2 to get the dummies-matching-no-data the TRAILER, which is counting the records, no longer works as-is.
So, we have to make some extensive changes.
The header is now written not by HEADER1 but by using the / (slash operator) it is written before the first actual record. This requires the addition of a sequence number then tested for one. The unmatched dummy record also causes the header to be written, but with no dummy record written (obviously). The TRAILER1 is amended to make use of the count from the "header" which is on all the REFORMAT records via the processing in the JNF2CNTL.
The JNF2CNTL is amended to include a GROUP with only one record, which identifies the DUMMY records and takes the 0 mentioned below and PUSHes it over the 1 set by the WHEN=INIT so that the dummy records are not counted when it comes to the SUM.
The DUMMY records are to look something like this, single records with the A1, A2 and A3 starting in column 79:
Code:
DUMMY RECORD COUNT TO BE 0 (ZERO) A1
DUMMY RECORD COUNT TO BE 0 (ZERO) A2
DUMMY RECORD COUNT TO BE 0 (ZERO) A3
The 0 in the above is used, so if the position of the 0 is changed, you have to make the code reflect that.
It has been lightly tested. First make sure you understand it and that it meets all your requirements. Then test it thoroughly. Then enjoy applying the changes for 50 OUTFILs and testing it thoroughly again (lots of scope for typos/editos).
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
Bill,
could this not be done in two passes?
1st pass to build the control records
and the
2nd to actually execute?
that way the amount of control cards to generate for the 1st pass
would be less than the code needed to generate standard for all situations
and the generated (by 1st pass) control cards for the 2nd pass
would always be only what is needed.
if the TS manages to create that correctly,
he probably will not need to post anymore of these crazy requests.