On 1/25/2016 2:59 PM, Hoteltravelfundotcom wrote:
HI Problem I have is that apprently, Royalty info is stored in 2 files.
This assumption may be 100% correct.
It may also be 100% wrong.
Why don't you ask someone who works there what the database intent is?
Because:
The program was only looking at one file. The first set of code that gets
Royalty amt. was commented out.
There is a reason someone commented that code out. I wouldn't touch
this until I knew what that reason is.
I do not want to have a goto please can you inform me how to
do this code without the goto?
You've already made a serious structural change; one that affects every
field that comes from the first file. Why not swap out the whole lot
for a sub-procedure that implements whatever the business function is?
A sub-procedure would let you call the same functionality from anywhere,
and it has the distinct advantage that you could use local variables for
all of the file I/O thus passing out only the fields you really need.
You /will/ be testing this anyway, right?
And when it turns out (for example) that the first file was commented
out because it has a pile of records with a zero amount, you'll be able
to make one small change and fix the sub-procedure, and thus propagate
the change everywhere it's used. To my eye, the bug is that 'if it
finds an amt. skip the second.' That's not what that code is doing.
That code will write a zero amount as long as it finds a record in the
first file. The code needs an additional test before the second CHAIN
to make sure PPROYAL is zero.
Of course that may be an error too, because the downstream program may
assume that it always has a good CHAIN on the second file, but now it
won't always.
Maybe the proper code is more like
c eval pproyal = 0
*** Get Royalties for receipt (first)
c* hoping this record will have the royalty
C eval KeyLcType = ROY
C RecKey Chain SrbOrplc
C If %Found(SrbOrplc)
C eval PpRoyal = OcAmou
C EndIf
*** Get Royalties for receipt (**Second)
c* doing this chain every time because downstream code needs the fields
C If GrSpno > 0
C eval KeyLcType = ROY
C RecKey2 Chain Sr2Lca
C If %Found(Sr2Lca)
c* if the first try didn't have a royalty, use the
c* royalty from this file
c if pproyal = 0
C eval PpRoyal = CaAmou
c endif
C Else
C eval PpRoyal = 0
C EndIf
C EndIf
C Write GrtOutF
No GOTO and it implements the business rule as stated in your post.
Further, it CHAINs to the second file exactly as many times as it did
before the proposed change. Thus satisfying
I dont' want to touch what is currently working.
As an Amazon Associate we earn from qualifying purchases.