View previous topic :: View next topic
|
Author |
Message |
Skss
New User
Joined: 16 Feb 2010 Posts: 46 Location: India
|
|
|
|
Hi,
I have a requirement in which I have 2 input files. The structure of both the files are similar.
The requirement is: Check the field of file 1 against file 2. Check the value untill a match is found. If no match found then please write it into a discard file. If match found then write it to the output file.
I have tired with Evaluate and here is my code but it is not working as per my requirement.
PROCESS-INPUT.
EVALUATE TRUE
WHEN PART-NUMBER-FILE1 > PART-NUMBER-FILE2
PERFORM WRITE-PART-NTFND THRU WRITE-PART-NTFND-EXIT
PERFORM READ-FILE2 THRU READ-FILE2-EXIT
WHEN PART-NUMBER-FILE1 < PART-NUMBER-FILE2
PERFORM WRITE-DISCARD THRU WRITE-DISCARD-EXIT
PERFORM WRITE-PART-NTFND THRU WRITE-PART-NTFND-EXIT
PERFORM READ-FILE1 THRU READ-FILE1-EXIT
WHEN PART-NUMBER-FILE1 = PART-NUMBER-FILE2
PERFORM WRITE-PART THRU WRITE-PART-EXIT
PERFORM READ-FILE2 THRU READ-FILE2-EXIT
PERFORM READ-FILE1 THRU READ-FILE1-EXIT
WHEN OTHER DISPLAY '** FATAL ERROR, PLEASE FIX IT **'
END-EVALUATE.
Please advice which would fullfill my requirement.
Thank you, |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It might not be working, but wat is it doing? I assume both files are sorted? Duplicates? Or not? There is a "sticky" for file matching at the top of this forum. Has that been any use to you? |
|
Back to top |
|
|
Skss
New User
Joined: 16 Feb 2010 Posts: 46 Location: India
|
|
|
|
thanks for your response
yes the files are sorted, without any duplicates.
Where can I find the sticky?
Please let me know if you see any modification to be done to the existing code. |
|
Back to top |
|
|
Skss
New User
Joined: 16 Feb 2010 Posts: 46 Location: India
|
|
|
|
I checked the sticky and it does not display as a formatted program.
if you have the original sticky then could you just mail me @ ssamantasinghar@gmail.com |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The program is in an "attachment" (look for the paper-clip icon).
It is logic that works, and has worked for many years. Not mine, by the way. You'll have to put your specific stuff in the right sort of places. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
I checked the sticky and it does not display as a formatted program. |
have no idea what you mean.
if you mean that it is not written in a modularized manner (it uses goto's)
then you are correct.
but you want the original sticky, which is there.
not to belabor the point of your inability to navigate thru this website
ibmmainframes.com/viewtopic.php?t=22649
Now, back to your code.
you only provide us with an EVALUATE statement, which as Bill mentioned,
seems ok.
That you perform thru exit's,
instead of simply performing SECTIONs (apparently you don't use SECTIONs)
is one cause for alarm.
having no idea what your performed routines do,
and no idea of what your output is,
actually only seeing some [unCODE tagged code],
which in itself tends to indicate that you are not much of an IT Solution provider
and have very basic COBOL skills.
SORT JOINKEYS could provide a very easy solution to your problem.
But you want it in COBOL.
you have an isolated EVALUATE
you have not provided any loop control code,
how do you load the input to start?
you are having a problem with your output.
I suggest that you are spending too much time trying to find the fault in the EVALUATE
and not spending enough time with the basic control code
nor with the PERFORMed routines.
and within the last two lies lies your problem. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Quote: |
WHEN OTHER DISPLAY '** FATAL ERROR, PLEASE FIX IT **' |
What use is this error message? It gives no dignostic informtion to help one fix the problem. Just further emphasises Dick's comments. |
|
Back to top |
|
|
Skss
New User
Joined: 16 Feb 2010 Posts: 46 Location: India
|
|
|
|
thanks guys for your response
My issue has been resolved now and it is doing what I want it to do.
As per Dick, yes my shop wont allow me to use GOTO statements at all.
The problem was with the end of file condition.
I added an additional check for both the input files and it is working fine now. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
which means my analysis of your EVALUATE statement was incorrect.
congratulations for finding the problem,
I apologize for my lack of help. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I would also like to correct my previous comment
where I suggested that BILL thought the EVALUATE was ok.
He did not say that.
add this to my list of errors in this thread. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
dbzTHEdinosauer wrote: |
I suggest that you are spending too much time trying to find the fault in the EVALUATE
and not spending enough time with the basic control code
nor with the PERFORMed routines.
and within the last two lies lies your problem. |
Credit where it is due, you were exactly right here Dick.
If a particular piece of code looks right, but the program isn't working, it is a very good idea to look elsewhere. It might seem an obvious thing to say, but I've said it so often myself in the "real" world that I know it can take someone from "outside" the problem to be able to say it to you. If you remember this, Skss, it'll help you a lot in the future. And when you say it to someone else and it helps them fix their problem, they'll think you are really clever. Deny it, tell them Dick told you, and you learned from it. Then they'll maybe learn as well. |
|
Back to top |
|
|
Peter Nancollis
New User
Joined: 15 Mar 2011 Posts: 47 Location: UK
|
|
|
|
Quote: |
my shop wont allow me to use GOTO statements at all. |
I know it happens but ....
real programmers aren't afraid of GOTOs |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Skss wrote: |
my shop wont allow me to use GOTO statements at all. |
I once worked in a shop like that. I wrote a preprocessor that allowed me to use COME FROM statements in PL/I programs |
|
Back to top |
|
|
Skss
New User
Joined: 16 Feb 2010 Posts: 46 Location: India
|
|
|
|
[real programmers aren't afraid of GOTOs]
I agree.....in my previous shop also I have used GOTOs in many programs.....but sometimes the coding standards are set by people on there personal choice and we have to live with it [/quote] |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
@ Peter Nancollis & Skss
>> ...real programmers aren't afraid of GOTOs
Ok sir, but real programmers need no GOTO Statement in Cobol anyway.
They don't even need a Branch-Command in Assembler, if they use the old IBM Structured Macros for ASM.
Nice Weekend |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
i am not afraid to use goto's,
but the other fools scare me to death.
we relaxed our standards and allowed goto's to the end of section.
we also said, last para in a section
WILL ALWAYS BE: 9999-END.
but, of course they had to put the section name with -end as the last.
so, then they copy sections to do similar things and don't change the
goto's.
The more freedom you give a rookie
(or 10 years experience doing the same thing for 10 years - 10 year rookie)
the more problems he will create. |
|
Back to top |
|
|
|