Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort Area / Temporary File

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
manishapatnaik

New User


Joined: 10 Nov 2008
Posts: 3
Location: chennai

PostPosted: Mon Oct 17, 2011 11:41 am    Post subject: Sort Area / Temporary File
Reply with quote

Hi,

I have a requirement of validating an input file. The input file contains a header record, detail records and a trailer record at the end. I have the match the number of detail records in the input file with the count mentioned in the trailer record. The input file looks something like this,

127032011
2asdsadasd
2dfgsdfgfdg
2dfdsfdsfer
2dfsdfgfgfg
3000000004

This question might look like reinventing the same wheel since it is possible with a SORT icon_cry.gif . But the solution is required in a COBOL pgm using either SORT area or TEMP File.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Oct 17, 2011 12:07 pm    Post subject: Reply to: Sort Area / Temporary File
Reply with quote

And the question is?

You should be able to take any Cobol program which reads this file and strip out the specific processing for that program, leaving just the routine validation of data integrity that is coded without thinking about it.

Why you'd need "stand alone" validation when it should always be there... I suppose it isn't always there?

Code:
Open file
Blow up if bad return
Read file
Blow up if not header
Blow up if filename on header not equal to filename expected by program
Blow up if date on header not = date on business date file

Process until end of file or trailer found
  Read
  Check sequence of data
  Add to count(s)

Blow up if end of file
Validate counts on trailever vs program and blow up if different
Read file
Blow up if not end of file

"Blow up" should always include sufficient diagnostic messages/data to identify position on file where problem exists.


Edit: Forgot the Code tags!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Oct 17, 2011 12:08 pm    Post subject: Reply to: Sort Area / Temporary File
Reply with quote

Quote:
But the solution is required in a COBOL pgm using either SORT area or TEMP File.


ok, prince of Demmark ...
COBOL or SORT, that is the question?
Back to top
View user's profile Send private message
manishapatnaik

New User


Joined: 10 Nov 2008
Posts: 3
Location: chennai

PostPosted: Mon Oct 17, 2011 4:13 pm    Post subject:
Reply with quote

Quote:
Why you'd need "stand alone" validation when it should always be there... I suppose it isn't always there?

Once the Validation is done, I need to pick up every single detail record in the file and do other processing. And i need to read the file content after the validation to process the detail record one by one.

I have to use COBOL Program only. And SORT i mentioned was COBOL internal SORT Area or usage of Temporary File.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Oct 17, 2011 4:31 pm    Post subject: Reply to: Sort Area / Temporary File
Reply with quote

This is really unclear to me.

You have a file with header (containing a date), data and trailer (containing at least record counts).

You want to process the file.

You read the header, checking the date.
You read the next record, ensuring it is data or trailer.
If data, you check for sequence, you count it and do your processing.
Repeat until EOF or trailer encountered.
If EOF encountered before trailer, invalid.
If trailer encountered, check counts.
Read, if not EOF, invalid.

Produce a report (DISPLAY usually) with totals, dates etc. Output files should have header/trailer generated with correct values on.

Good to have a "filename" on the header, so you know you're reading the right file. Good to have "hash totals" per record-type on the trailer, so you reduce the chance of duplicating the wrong record on the output.

This type of stuff should exist in every program which reads a file with header and trailer on.

I don't know why you think SORT comes into the equation.

You can do all that in SORT, but then JCL errors can happen so your Cobol program might not be using the file verified by the SORT. No point in doing it with an internal SORT in the Cobol program when you can just do it as you are going along.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Oct 17, 2011 4:35 pm    Post subject: Reply to: Sort Area / Temporary File
Reply with quote

Quote:
I have to use COBOL Program only.

plain stupidity ... ( the way the issue is described )

how do You prioritize the validation ?
1) the count
2) the record content

can they be mixed ?
what other processing should be done ?

in case 1 the smarter solution would be to use sort to check the counts
after that do any other processing with a cobol program
You will have to do two passes of data anyway
Back to top
View user's profile Send private message
manishapatnaik

New User


Joined: 10 Nov 2008
Posts: 3
Location: chennai

PostPosted: Mon Oct 17, 2011 5:45 pm    Post subject:
Reply with quote

Quote:
plain stupidity ... ( the way the issue is described )

Probably use a better way to explain my requirements.
1. I need to perform validation of input detail records count and count mentioned at the trailer.
2. Once validation is perfect, process each detail record one by one.

If i go with only validation of trailer count alone, my problem isnt solved .
I have to pick up each detail record one by one after the validation of count is done and I dont want to open-read-close the input file again and again due to huge amount of records. So i want to use a temporary file (which can be used with SD) which will ease my problem. This temp file can be used to first perform validation and then aagin to do the processing. So i am performing two things with a single read of the input file. I hope this clarifies the doubt.

Quote:
how do You prioritize the validation ?
1) the count
2) the record content

First the Count, Then the Record content.

Quote:
what other processing should be done ?

This will happen only when record count is tallyed. and Processing will include fetching data from tables etc.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Oct 17, 2011 5:49 pm    Post subject:
Reply with quote

well, since a sorted file is not necessary to the cobol program doing the record content validation,
why not have a simple OPTION=COPY Sort preceding the COBOL program
and bypass the COBOL program if the counts are not correct?

less strain on the mainframe, but more strain on logic ability.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Oct 17, 2011 6:18 pm    Post subject: Reply to: Sort Area / Temporary File
Reply with quote

Quote:
So i am performing two things with a single read of the input file.


whatever Your beliefs You will have in any case ( cobol,sort,pencil and paper ) at least two passes of data

You have two <processes>

<process> 1 validate
validate the total count
validate the records

<process> 2 update
update the <thing>

what is the show stopper for the update ???
1) total count mismatch
2) a record in error also ???

case ( 1 ) TWO PASSES
<step 1 > just use sort to check the count and set the condition code accordingly
<step 2 > check records and if not in error update accordingly

case ( 1 + 2 ) --- a) TWO PASSES
record checking does not depend on the total count
<step 1 > use a COBOL program to achieve both results
<step 2 > update things

case ( 1 + 2 ) --- b) THREE PASSES
record checking depends on the total count
<step 1 > validate and save the fucking total count
<step 2 > validate each record
<step 3 > update <things>
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Oct 17, 2011 6:54 pm    Post subject: Reply to: Sort Area / Temporary File
Reply with quote

OK, I think you need to tell us a bit more before we go off in all directions.

Is it an "external" file, ie data delivered to you from another source?

Is it an existing file from part of your system?

If it is the second, it is easier, since you expect the data to be correct (don't you?).

Proceed as I have already outlined. One pass of the file. No extra steps. Nuffink.

If it is external and you, code one program to do a full validation of the data that you are going to use, if you are concered about the data.

If your sole concern is to verify the counts, use SORT. Check the date (can be done), sequence (can be done) and trailer record total (can be done).

Then in your Cobol program, do all the same again, even though you "know" the file is OK.

The SORT will tell you more quickly if the file is dodgy.

The stuff in the Cobol program is to ensure you're reading a good file, which to my mind should be done every time.

If it is external and you have no expectation that it is dodgy, just go with the Cobol.[/b]
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Oct 17, 2011 9:31 pm    Post subject:
Reply with quote

Hello,

Quote:
I need to pick up every single detail record in the file and do other processing.
What is thyis "other processing"? Depending on exactly what this is, you may styill be able to do this with one pass of the data. Why does someone in your organizatoin believe you need either a SORT or a TEMP file?

You might consider reading the file and doing whatever "other processing" is needed and at the end (when the trailer is processed) check the count and if not equal terminate the run without saving the results of the run. This will depend on just what is the "other processing".

If the "other processing" prohibits the suggeston, then suimply run a pre-process that validates the count before entering your program. There is no business reason that this has to be done in one step. If the file has millions and milljons of records, i suggest a single pass is a better choice.

If the count is off, the code generating the count needs to be fixed - not caught later and then retroactively dealt with. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us