Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
I should think that by the time you meet your condition the heading has already gone, so you are just blatting the current report line as you asked it to.
If you have two types of errors, acceptable and not, why don't you do two reports? Otherwise if you get a mix like in your example you'll have the wrong heading for one, or the other, set of data.
If you exclude the headings and any blank lines and split the remaining data into error/acceptable and then generate two reports, will that give you what you want?
REPORT: ACCEPTABLE ERRORS FOUND
----+----1----+----2----+----3----+-
RECORD STATUS ACCEPTABLE?
AAA ERRORS FOUND ERROR
BBB COMPLETE ACCEPTABLE
But what I'm look for is the "ACCEPTABLE ERRORS FOUND" which is in the line next to 'REPORT: ' should be replaced by "ERRORS FOUND". The file is FB and LRECL is 80.
Code:
REPORT: ERRORS FOUND
----+----1----+----2----+----3----+-
RECORD STATUS ACCEPTABLE?
AAA ERROR
BBB COMPLETE ACCEPTABLE
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Bhargav_1058,
As has been mentioned, twice, the heading that you want to change has already been read and written to the output file by the time your detail line arrives and you do the test.
You seem to have a report with two types of errors, Acceptable and Not.
Do you want both types of error in the same report? If so, decide on a heading for the report.
If you don't want to mix the two types of error on the same report, split into two reports each with a correct heading.
Best place to do it, either way, is where the report was created originally. If you are stuck having to take an existing report, then say exactly what you want (mix of data? one heading only, or one per page?) Etc.
Once you explain your requirement exactly, you'll probably get something useful.
I had to use the existing report, which will have both the errors acceptable or not. I want to know, if it is possible to change the REPORT line to 'ACCEPTABLE ERRORS FOUND' / 'ERRORS FOUND' based on the status of the record.
If either is not possible then I have to think of making some changes in the way existing report is produced.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
My thought is, you are going to end up with a report with a mixture of headings, and pages with a mixture of data of different statuses.
If you want it this way, it is possible with SORT. The experts will be in later, but they are on West Coast time. You need to get your requirement stated as clearly as possible. If this is the full thing, OK, but it is going to look a mess (my opinion).
Your heading can be used to define a "group" of records (from the heading to the next heading/eof). While processing the group you can check for your status. If you have blank lines, you might have some troubles looking for blanks for status, another reason I suggested going for "ERROR". If you find there is an ERROR set a status to say so. When processing the group, test the status and set overlay the heading if it says so.
Actual details I'll have to leave you to search the DFSORT forum for/consult the manual, but it certainly can be done.
As I say, get your requirement as clear as spring-water and you'll probably have a neat solution by tommorow morning.
Though I have worked around & achieved this with an alternate solution.
1). Search for 'ERROR FOUND' in input file using ISRSUPC
2). If found replace the the 'ACCEPTABLE ERRORS FOUND' with 'ERRORS FOUND'. using the IFTHEN & WHEN & OVERLAY as below.
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(9,31,CH,EQ,C'ACCEPTABLE ERRORS FOUND'),
OVERLAY=(9:C'ERRORS FOUND '))