Page 1 of 2
Unkown result in the output of a routine which use SETFILE
Posted: Thu Jan 25, 2007 7:24 am
by rajiivnb
Hi,
We wrote a routine with the below, where to find the total number of records. (20 records)
Cmd = 'SETFILE ' : hshdflpth : ' ' : 'hsdfile' :' OVERWRITING '
PERFORM Cmd
PERFORM 'COUNT ' : 'hsdfile'
Ans = @SYSTEM.RETURN.CODE
If i run the routine with a hashed file path and name given, the output is as below,
Arg1 = d:/ds/sam1/sample
Test Failed.
Pointer "hsdfile" established in VOC file.
20 records counted.
Result = 20
The output is shown exactly the number as 20 records. But why its shows TEST FAILED ? The same routine runs fine in one environment and shows the TEST FAILED in another environment.
Need you suggestions on the same.
Thanks in advance.
Posted: Thu Jan 25, 2007 7:35 am
by chulett
No idea, really. What's different between the two environments?
Posted: Thu Jan 25, 2007 7:51 am
by rajiivnb
One is in Windows and another in UNIX. The problem is with UNIX server.
Can you please tell me, in what situation it gives TEST FAILED and TEST COMPLETED ?
Posted: Thu Jan 25, 2007 7:58 am
by chulett
If I knew for sure I would have told you. At this point just fishing for more information so more smarter people (hopefully) find it easier to help you.
Posted: Thu Jan 25, 2007 7:59 am
by rajiivnb
Thanks for your time, Chulett
Posted: Thu Jan 25, 2007 9:28 am
by ArndW
I think that your routine contains more than you've shown, since the output line "Arg1 = d:/ds/sam1/sample" isn't part of the normal code, either. Could you change your code portion to read
Code: Select all
PRINT 'Before'
PERFORM Cmd
PRINT 'After'
to prove that the "Not Found." text is being output by the PERFORM command?
Posted: Thu Jan 25, 2007 3:09 pm
by ray.wurlod
The "test fails" for a very obscure reason, which you can ignore.
Warning - Technical Content
The test bed uses a system variable called @SYSTEM.RETURN.CODE to indicate success or failure. 0 is success.
Query verbs (like COUNT) also use @SYSTEM.RETURN.CODE to transmit the number of records processed.
Therefore, after your COUNT, @SYSTEM.RETURN.CODE is 20, which the test bed interprets as a failure.
</Technical Content>
Posted: Thu Jan 25, 2007 3:12 pm
by DSguru2B
Very useful information Ray. Very useful. I was breaking my head trying to get to the bottom of this.
I still dont get one thing, how come it works in one environment for the OP and not in another
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
?
Posted: Thu Jan 25, 2007 3:31 pm
by ray.wurlod
That's a mystery. I could only ask "what's different between the two environments?" before attempting to essay an answer.
My guess would be that "d:/ds/sam1/sample" exists in one environment and not in the other, and that they've changed how the test bed detects failure (so that my previous post is no longer correct).
Posted: Thu Jan 25, 2007 3:32 pm
by DSguru2B
Or possible the hashed file in one environment is empty.
Posted: Thu Jan 25, 2007 3:35 pm
by ray.wurlod
Possible. In that case @SYSTEM.RETURN.CODE would return 0.
Posted: Thu Jan 25, 2007 3:38 pm
by DSguru2B
And I was correct in my hunch. I ran a CLEAR.FILE before running the Cmd in the OP's routine. It returned zero with "Test Completed" message. :D
They did'nt change the test bed, atleast we know that for sure.
Posted: Thu Jan 25, 2007 4:09 pm
by DSguru2B
Rajiivnb, use this routine instead and see what results you get. It works at my end
Code: Select all
Cmd = 'SETFILE ' : hshdflpth : ' ' : 'hsdfile' :' OVERWRITING '
PERFORM Cmd
PERFORM 'COUNT ' : 'hsdfile'
Ans = @SYSTEM.RETURN.CODE
@SYSTEM.RETURN.CODE = 0
All i did was to add "@SYSTEM.RETURN.CODE = 0" at the end to tell the underlying engine that everything is ok.
Ray, is that a safe thing to do?
Posted: Thu Jan 25, 2007 4:35 pm
by ray.wurlod
Not really. What if there really had been a failure? The following would be preferable. Not only because it's documented (hint!).
Code: Select all
* Construct and execute SETFILE command.
Cmd = 'SETFILE ' : hshdflpth : ' ' : 'hsdfile' :' OVERWRITING '
PERFORM Cmd
* Record result of SETFILE command.
Temp = @SYSTEM.RETURN.CODE
If Temp = 0
Then
* Determine number of records in hashed file for return by function.
PERFORM 'COUNT ' : 'hsdfile'
Ans = @SYSTEM.RETURN.CODE
End
Else
Ans = @NULL ; * SETFILE failed
End
* Report status of SETFILE command to test bed.
@SYSTEM.RETURN.CODE = Temp
Posted: Thu Jan 25, 2007 5:31 pm
by DSguru2B
Sweet.....Makes sense. Thanks Ray.
![Smile :)](./images/smilies/icon_smile.gif)