phantom in routine
Moderators: chulett, rschirm, roy
phantom in routine
Hello,
I have an annoying phantom in my routine, I try to find it but I can't
Please help...
Nvl code:
If IsNull(arg) Then
Ans = default
End Else
Ans = arg
End
This is my routine code:
DEFFUN Nvl(arg,default) CALLING "DSU.Nvl"
Ans = ""
If IsNull(account_type) Then
Ans = 'Account Type is NULL for ID = ':Nvl(id,"")
return (Ans)
End
If IsNull(book_code) Then
Ans = 'Deal Book is NULL for CUSTOMER=':Nvl(customer,"")
return (Ans)
End
If IsNull(counterparty_code) Then
Ans = 'Counterparty Code is NULL for ORIGIN=':Nvl(origin,""):' and CUSTOMER=':Nvl(customer,"")
return (Ans)
End
If IsNull(currency) Then
Ans = 'Currency is NULL'
return (Ans)
End
If IsNull(balance_c) and IsNull(balance_d) Then
Ans = 'Balance is NULL for ID=':Nvl(id,"")
return (Ans)
End
cp = Nvl(compound_periodicity,'')
If Not(IsNull(compound_periodicity)) AND cp<>'A' and cp<>'S' and cp<>'Q' and cp<>'M' and cp<>'N' Then
Ans = 'Compound Periodicity not in (A, S, Q, M, N)'
return (Ans)
End
If Not(Nvl(interest_reinvest,'F')<>'T' or Nvl(compound_periodicity,'N')='N') Then
Ans = 'Check Interest Reinvest and Compound Periodicity'
return (Ans)
End
p = Nvl(periodicity, '')
If Not(IsNull(periodicity)) AND p<>'A' and p<>'S' and p<>'Q' and p<>'M' and p<>'N' Then
Ans = 'Periodicity not in (A, S, Q, M, N)'
return (Ans)
End
ab = Nvl(accrual_basis, '')
If Not(IsNull(accrual_basis)) AND ab<>'1' and ab<>'2' and ab<>'3' and ab<>'4' and ab<>'5' and ab<>'B' Then
Ans = 'Accrual Basis not in (1, 2, 3, 4, 5, B)'
return (Ans)
End
If (Nvl(interest_reinvest,'F')='T') and (Nvl(compound_periodicity,'N')<>'N') Then
Ans = 'Incorrect interest reinvest and/or compound periodicity'
return (Ans)
End
return (Ans)
Thanks in advance.
Best regards,
Piotrek
I have an annoying phantom in my routine, I try to find it but I can't
Please help...
Nvl code:
If IsNull(arg) Then
Ans = default
End Else
Ans = arg
End
This is my routine code:
DEFFUN Nvl(arg,default) CALLING "DSU.Nvl"
Ans = ""
If IsNull(account_type) Then
Ans = 'Account Type is NULL for ID = ':Nvl(id,"")
return (Ans)
End
If IsNull(book_code) Then
Ans = 'Deal Book is NULL for CUSTOMER=':Nvl(customer,"")
return (Ans)
End
If IsNull(counterparty_code) Then
Ans = 'Counterparty Code is NULL for ORIGIN=':Nvl(origin,""):' and CUSTOMER=':Nvl(customer,"")
return (Ans)
End
If IsNull(currency) Then
Ans = 'Currency is NULL'
return (Ans)
End
If IsNull(balance_c) and IsNull(balance_d) Then
Ans = 'Balance is NULL for ID=':Nvl(id,"")
return (Ans)
End
cp = Nvl(compound_periodicity,'')
If Not(IsNull(compound_periodicity)) AND cp<>'A' and cp<>'S' and cp<>'Q' and cp<>'M' and cp<>'N' Then
Ans = 'Compound Periodicity not in (A, S, Q, M, N)'
return (Ans)
End
If Not(Nvl(interest_reinvest,'F')<>'T' or Nvl(compound_periodicity,'N')='N') Then
Ans = 'Check Interest Reinvest and Compound Periodicity'
return (Ans)
End
p = Nvl(periodicity, '')
If Not(IsNull(periodicity)) AND p<>'A' and p<>'S' and p<>'Q' and p<>'M' and p<>'N' Then
Ans = 'Periodicity not in (A, S, Q, M, N)'
return (Ans)
End
ab = Nvl(accrual_basis, '')
If Not(IsNull(accrual_basis)) AND ab<>'1' and ab<>'2' and ab<>'3' and ab<>'4' and ab<>'5' and ab<>'B' Then
Ans = 'Accrual Basis not in (1, 2, 3, 4, 5, B)'
return (Ans)
End
If (Nvl(interest_reinvest,'F')='T') and (Nvl(compound_periodicity,'N')<>'N') Then
Ans = 'Incorrect interest reinvest and/or compound periodicity'
return (Ans)
End
return (Ans)
Thanks in advance.
Best regards,
Piotrek
If you look at that phantom message, and post it here, we could tell you what it is saying.
Chances are that your If statements are referencing variables that don't exist within the function.
account_type,book_code, counterparty_code, etc are not declared, are you passing them as arguments?
Chances are that your If statements are referencing variables that don't exist within the function.
account_type,book_code, counterparty_code, etc are not declared, are you passing them as arguments?
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
upsss, I forgot to post my phantom message ...kcbland wrote:If you look at that phantom message, and post it here, we could tell you what it is saying.
Chances are that your If statements are referencing variables that don't exist within the function.
account_type,book_code, counterparty_code, etc are not declared, are you passing them as arguments?
I will do it on monday.
These variables are all parameters passed to routine.
Are you able to compile it and test it without any error.
I think the phantom error is only during the call of the routine from within a job.
If thats the case, the phantom error during runtime occurs due to un-initialized variables.
I see you have not initialized the variables cp, p and ab.
That must be causing the phantom error.
Also, please surround the code with the code tags and use proper indentation so that we can understand it better.
Try initializing them, just put three lines in the begining where you have initialized Ans
I think the phantom error is only during the call of the routine from within a job.
If thats the case, the phantom error during runtime occurs due to un-initialized variables.
I see you have not initialized the variables cp, p and ab.
That must be causing the phantom error.
Also, please surround the code with the code tags and use proper indentation so that we can understand it better.
Try initializing them, just put three lines in the begining where you have initialized Ans
Code: Select all
cp = ''
p = ''
ab = ''
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
I get the following error:
<error>
DataStage Job 673 Phantom 24706
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
DataStage Phantom Finished
</error>
I can compile the routine without any error/warning and when I test it it works fine.
The code of the routine with indentations:
And once againg, thanks in advance.
Kind regards,
Piotrek
<error>
DataStage Job 673 Phantom 24706
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 44, Variable previously undefined. Zero length string used.
DataStage Phantom Finished
</error>
I can compile the routine without any error/warning and when I test it it works fine.
The code of the routine with indentations:
Code: Select all
DEFFUN Nvl(arg,default) CALLING "DSU.Nvl"
Ans = ""
p = ''
ab = ''
cp = ''
If IsNull(account_type) Then
Ans = 'Account Type is NULL for ID = ':Nvl(id,"")
return (Ans)
End
If IsNull(book_code) Then
Ans = 'Deal Book is NULL for CUSTOMER=':Nvl(customer,"")
return (Ans)
End
If IsNull(counterparty_code) Then
Ans = 'Counterparty Code is NULL for ORIGIN=':Nvl(origin,""):' and CUSTOMER=':Nvl(customer,"")
return (Ans)
End
If IsNull(currency) Then
Ans = 'Currency is NULL'
return (Ans)
End
If IsNull(balance_c) and IsNull(balance_d) Then
Ans = 'Balance is NULL for ID=':Nvl(id,"")
return (Ans)
End
cp = Nvl(compound_periodicity,'')
If Not(IsNull(compound_periodicity)) AND cp<>'A' and cp<>'S' and cp<>'Q' and cp<>'M' and cp<>'N' Then
Ans = 'Compound Periodicity not in (A, S, Q, M, N)'
return (Ans)
End
If Not(Nvl(interest_reinvest,'F')<>'T' or Nvl(compound_periodicity,'N')='N') Then
Ans = 'Check Interest Reinvest and Compound Periodicity'
return (Ans)
End
p = Nvl(periodicity, '')
If Not(IsNull(periodicity)) AND p<>'A' and p<>'S' and p<>'Q' and p<>'M' and p<>'N' Then
Ans = 'Periodicity not in (A, S, Q, M, N)'
return (Ans)
End
ab = Nvl(accrual_basis, '')
If Not(IsNull(accrual_basis)) AND ab<>'1' and ab<>'2' and ab<>'3' and ab<>'4' and ab<>'5' and ab<>'B' Then
Ans = 'Accrual Basis not in (1, 2, 3, 4, 5, B)'
return (Ans)
End
If (Nvl(interest_reinvest,'F')='T') and (Nvl(compound_periodicity,'N')<>'N') Then
Ans = 'Incorrect interest reinvest and/or compound periodicity'
return (Ans)
End
return (Ans)
Kind regards,
Piotrek
I add that code on the beginning of my routine and I still get the same error :/DSguru2B wrote:Code: Select all
cp = '' p = '' ab = ''
Yes, thats what happens when there is an undefined variable used. You have to try to pin point which variable has been left undefined.
Go through your code again and make sure that:
- you are passing account_type, book_code etc. and have not left any one of them out
- The ones you are not passing, have been defined
Go through your code again and make sure that:
- you are passing account_type, book_code etc. and have not left any one of them out
- The ones you are not passing, have been defined
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Now I left only that code:
<error>
And now I am getting such error:
DataStage Job 673 Phantom 8406
Program "DSU.chkAccount": Line 16, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 16, Variable "cp" previously undefined. Empty string used.
Program "DSU.chkAccount": Line 16, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 16, Variable "cp" previously undefined. Empty string used.
DataStage Phantom Finished
</error>
So how it is possible that cp is undefined?
How can I handle that?
Is there any way to catch the input record which cause the error?
Best regards,
Piotrek
Code: Select all
Ans = ""
cp = ""
If IsNull(account_type) Then
Ans = 'Account Type is NULL for ID = '
return (Ans)
End
If IsNull(book_code) Then
Ans = 'Deal Book is NULL for CUSTOMER='
return (Ans)
End
if isNull(compound_periodicity) then cp = "#" else cp = compound_periodicity
if isNull(cp) or cp="" or len(cp)=0 then cp="#"
If Not(IsNull(compound_periodicity)) then
if cp="A" or cp = "S" or cp="Q" or cp="M" or cp="N" Then Ans=""
else return("Compound Periodicity not in (A, S, Q, M, N)")
End
And now I am getting such error:
DataStage Job 673 Phantom 8406
Program "DSU.chkAccount": Line 16, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 16, Variable "cp" previously undefined. Empty string used.
Program "DSU.chkAccount": Line 16, Variable previously undefined. Zero length string used.
Program "DSU.chkAccount": Line 16, Variable "cp" previously undefined. Empty string used.
DataStage Phantom Finished
</error>
So how it is possible that cp is undefined?
How can I handle that?
Is there any way to catch the input record which cause the error?
Best regards,
Piotrek
Try doing a global replace of "cp" to "xx" in your manager to see if it really is cp and not perhaps op in your code. You could also change your line to "IF INDEX('ASQMN',cp,1) THEN Ans='' ELSE RETURN('yourtext')"
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
It seems that the problem was caused by value returned by another routine, and that value was used as an input parameter to this routine(compound_periodicity).
There was no null handling statement.
But the question is why datastage doesn't return the phantom or something else in that previous routine?
There was no null handling statement.
But the question is why datastage doesn't return the phantom or something else in that previous routine?
Ascen - say again? The INDEX function will return a 0 if the 1-char len value of the variable "cp" is not found in the string otherwise it will return a value. An condition in DataStage BASIC evaluates to 0 or '' as being the equivalent of false and anything else to be TRUE.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Is "default" in the Nvl function a hard coded value or a variable? If it's a variable, does it have a value assigned on every possible path through the code?
Check out the Assigned() or Unassigned() function - I always build one of these into routines that someone else may call, so as to check for arguments that may be in an unassigned state. It's called "bulletproofing".
Check out the Assigned() or Unassigned() function - I always build one of these into routines that someone else may call, so as to check for arguments that may be in an unassigned state. It's called "bulletproofing".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
default - an argument of the routineray.wurlod wrote:Is "default" in the Nvl function a hard coded value or a variable? If it's a variable, does it have a value assigned on every possible path through the code?
When I wrote post about that the phantom was caused by value returned by another routine, I wasn't writing about Nvl routine, but the other one.
And in that routine there was no path where the input args are nulls. So it was the problem.
But I am dissapointed about ds, that it didn't return some phantom about error in that previous routine.
These are builtin ds routines/transforms??Check out the Assigned() or Unassigned() function - I always build one of these into routines that someone else may call, so as to check for arguments that may be in an unassigned state. It's called "bulletproofing".
I will check it.
Thanks