View previous topic :: View next topic
|
Author |
Message |
ravikanth
New User
Joined: 12 Jan 2006 Posts: 29
|
|
|
|
Hi All,
I have declared two variables,
FD_DSTNC_QTY FIXED DEC (3);
FT_DSTNC_QTY FIXED DEC (5);
I have moved 5,
FD_DSTNC_QTY = 5; and
FD_DSTNC_QTY = '';
And then I am required to check for -1(negative number)
IF FD_DSTNC_QTY = -1
THEN;
ELSE blah blah...
The above IF statement is giving me a OC7 abend with the following message. INSTRUCTION CAUSING 0C7 ==> CP 247(2,1),247(1,2)
DATA ==> OPERAND#1 = 0D5C / OPERAND#2 = 1D
Also, the progam is currently checking for -1 on both these varaibles and it is executing successfully in a different place.
Please let me know if there any other detail that would help in finding out the reason.
Thanks In advance
Ravikanth Chavali |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi,
What is this assignment? Why do you assign non-numeric here?
Am I missing something? |
|
Back to top |
|
|
ravikanth
New User
Joined: 12 Jan 2006 Posts: 29
|
|
|
|
Sorry, My bad...
Please Ignore the statement
FD_DSTNC_QTY = '';
I wanted to say I did not move any value to ther other variable FT_DSTNC_QTY, |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Uninitialized numeric data often causes a s0c7. . . One way or another a valid value must be in the field before it is used in a numeric operation. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Please print the value of FD_DSTNC_QTY just before IF statement and see what value it has; Perhaps it got changed by the program logic. |
|
Back to top |
|
|
ravikanth
New User
Joined: 12 Jan 2006 Posts: 29
|
|
|
|
I displayed the value just before the IF statement and it is having the expected value of 5.
I have noticed that in One place Instead of evaluating the FIXED DECIMAL field FD_DSTNC_QTY directly, they are moving this variable to another varialbe defined as TEMP PIC'(03)S'; then evaluating IF TEMP = -1. So I am confused. Also based on the OPERAND 1 & 2, in my first post can we conclude that the value we are moving is correct?
Fyr: INSTRUCTION CAUSING 0C7 ==> CP 247(2,1),247(1,2)
DATA ==> OPERAND#1 = 0D5C / OPERAND#2 = 1D |
|
Back to top |
|
|
Karthikeyan Subbarayan
New User
Joined: 24 Feb 2008 Posts: 62 Location: Boston
|
|
|
|
Quote: |
FT_DSTNC_QTY FIXED DEC (5); |
Why you are using this variable
is mainly used to indicate the variable is NULL .
As Dick said Uninitialized numeric data often causes a s0c7. |
|
Back to top |
|
|
arivazhagan_k
New User
Joined: 05 Dec 2007 Posts: 57 Location: chennai
|
|
|
|
Karthikeyan wrote:
Quote: |
Why you are using this variable
Quote:
IF TEMP = -1.
is mainly used to indicate the variable is NULL . |
Who said
Code: |
MODU1: PROC OPTIONS(MAIN);
DCL VAR1 FIXED DEC (3);
DCL VAR2 PIC'(03)S';
VAR1 = -1;
VAR2 = VAR1;
IF VAR1 = -1 THEN
PUT SKIP LIST('VAR1 = -1');
IF VAR2 = -1 THEN
PUT SKIP LIST('VAR2 = -1');
END; |
If you have time excute this code and let us know the result..
ravikanth,
best coding standard and one way to avoid error is Initialize variables properly( either declaration or before use) |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
Quote: |
is mainly used to indicate the variable is NULL . |
since nothing in the topic is db2 related
the statement
is simply a test to determine if the variable temp contains a -1 value! |
|
Back to top |
|
|
Karthikeyan Subbarayan
New User
Joined: 24 Feb 2008 Posts: 62 Location: Boston
|
|
|
|
oh ... iam sorry
i learnt one new thing today |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Gnana Sekaran Nallathambi wrote: |
What is this assignment? Why do you assign non-numeric here?
Am I missing something? |
You are, PL/I allows you to use '' (quote-quote, with no intervening space) to initialize any type of computational variable with its standard initial value, i.e.
- 0 for numerical values
- spaces for character values
- null for pointers, with the value for null depending on the compiler setting, either '00_00_00_00'PX or 'FF_00_00_00'PX
|
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Thanks, Robert for the information. BTW, Topic Starter solved the problem? |
|
Back to top |
|
|
|