MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Create a generic program to validate header and trailer

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
lenovo
Beginner


Joined: 27 Nov 2008
Posts: 31
Topics: 9
Location: India

PostPosted: Fri May 16, 2014 6:53 am    Post subject: Create a generic program to validate header and trailer Reply with quote

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
View user's profile Send private message
gene montgomery
Beginner


Joined: 18 Oct 2012
Posts: 10
Topics: 0
Location: Balt Md

PostPosted: Fri May 16, 2014 7:17 am    Post subject: Reply with quote

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
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Fri May 16, 2014 8:17 am    Post subject: Reply with quote

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
View user's profile Send private message
lenovo
Beginner


Joined: 27 Nov 2008
Posts: 31
Topics: 9
Location: India

PostPosted: Fri May 16, 2014 11:21 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12368
Topics: 75
Location: San Jose

PostPosted: Fri May 16, 2014 11:53 am    Post subject: Reply with quote

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 - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Fri May 16, 2014 1:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
misi01
Advanced


Joined: 02 Dec 2002
Posts: 620
Topics: 173
Location: Stockholm, Sweden

PostPosted: Sun May 18, 2014 6:31 am    Post subject: .....and if you want to go down that road, Nic ..... Reply with quote

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
View user's profile Send private message Send e-mail
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Mon May 19, 2014 3:49 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group