View previous topic :: View next topic |
Author |
Message |
lenovo Beginner
Joined: 27 Nov 2008 Posts: 31 Topics: 9 Location: India
|
Posted: Fri May 16, 2014 6:53 am Post subject: Create a generic program to validate header and trailer |
|
|
Hi,
Could anybody please help or provide some ideas on how to validate header and trailer records in a mainframe file using generic cobol program?
By Generic program I meant it should process different files with different file lengths and each can have different header and trailer.
I know this sounds some vague but in our system we have different input files coming in from other systems with different file length and different header and trailer and we have written seperate programs validating the same information and I planning to write some generic program to validate the header and trailer.
For instance, I will pass '1' from the JCL to program to process FILE1 and '2' to process FILE2
FILE1 with file length 500
Code: |
*header - divided into 3 parts
header id - 00000000000
Current date - 2014-05-16
File ID - FILE1
*detail records
*trailer - divided into 2 parts
trailer id - 99999999999
total count - 123456
|
Also we have FILE2 with input file length 80
Code: |
*header - divided into 2 parts
header id - HEADER
total rec - 123456
*detail records
*trailer - divided into 3 parts
trailer id - TRAILER
total count - 123456
current - 2014-05-16
|
|
|
Back to top |
|
|
gene montgomery Beginner
Joined: 18 Oct 2012 Posts: 10 Topics: 0 Location: Balt Md
|
Posted: Fri May 16, 2014 7:17 am Post subject: |
|
|
I would submit that it's not possible in COBOL.
In COBOL, you MUST know the characteristics of a file before you open it.
Otherwise, the OPEN fails. Anybody disagree? _________________ Gene |
|
Back to top |
|
|
William Collins Supermod
Joined: 03 Jun 2012 Posts: 437 Topics: 0
|
Posted: Fri May 16, 2014 8:17 am Post subject: |
|
|
I disagree.
RECORD CONTAINS 0 in the FD for fixed-length records, 01 at maximum record-size (not of files, but system maximum).
LRECL=maximum-LRECL-for-system on the DSN for the input for variable-length records. Similar 01 to above.
However, it can be done with SORT without the messing about.
lenovo, don't fall into the trap of validating the files only when you receive them. Everything which reads those files must validate them. There's no point validating independently, then feeding the wrong file into your system.
You get a false sense of security if you validate on receipt and then forget about it. You'll get bit. |
|
Back to top |
|
|
lenovo Beginner
Joined: 27 Nov 2008 Posts: 31 Topics: 9 Location: India
|
Posted: Fri May 16, 2014 11:21 am Post subject: |
|
|
Thanks Gene and William.
William - I understand your point for validation.
Quote: |
don't fall into the trap of validating the files only when you receive them. Everything which reads those files must validate them. There's no point validating independently, then feeding the wrong file into your system.
You get a false sense of security if you validate on receipt and then forget about it. You'll get bit.
|
The validation is already happening in the existing program (using file without header and trailer) and as part of the new change we are receiving file that includes header and trailer. And Since I dont want to touch the existing program just for header and trailer validations, so i am thinking if we can write a generic program for that. I hope you understand my point. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Fri May 16, 2014 11:53 am Post subject: |
|
|
Lenovo,
As William suggested you can use SORT product to perform the validation for any LRECL and it is quite easy to do it which can set a return code based on the validation. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Fri May 16, 2014 1:08 pm Post subject: |
|
|
On the other hand you have to change the existing programs to ignore the header and trailer records so instead of ignoring them - validate them. Besides which, trailers should have a record count on them so that your program knows that it has read all the records - not too few and not too many. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Sun May 18, 2014 6:31 am Post subject: .....and if you want to go down that road, Nic ..... |
|
|
you might also want (as we do here at the bank) code that checks:-
1) whether the file has already been processed once (based on the starter record which contains a timestamp)
2) whether the number of records sent in is the same as the number read in
3) the fact that various totals (accounts or whatever) sent in are the same as the totals read in _________________ Michael |
|
Back to top |
|
|
William Collins Supermod
Joined: 03 Jun 2012 Posts: 437 Topics: 0
|
Posted: Mon May 19, 2014 3:49 am Post subject: |
|
|
I think if you are pre-verifying and also verifying in the individual programs, I'd go for a SORT solution.
I'd look at using SORT symbols, or generating the sort cards, to keep things as simple as possible, but could be done using IFTHEN, if a somewhat generic error if file-name is unidentifiable. |
|
Back to top |
|
|
|
|