IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Fixed Decimal in PL/1


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ravikanth

New User


Joined: 12 Jan 2006
Posts: 29

PostPosted: Thu Mar 11, 2010 11:13 am
Reply with quote

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
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu Mar 11, 2010 11:25 am
Reply with quote

Hi,

What is this assignment? Why do you assign non-numeric here?
Code:
FD_DSTNC_QTY = '';


Am I missing something?
Back to top
View user's profile Send private message
ravikanth

New User


Joined: 12 Jan 2006
Posts: 29

PostPosted: Thu Mar 11, 2010 11:29 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 11, 2010 11:38 am
Reply with quote

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
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu Mar 11, 2010 11:41 am
Reply with quote

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
View user's profile Send private message
ravikanth

New User


Joined: 12 Jan 2006
Posts: 29

PostPosted: Thu Mar 11, 2010 12:46 pm
Reply with quote

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
View user's profile Send private message
Karthikeyan Subbarayan

New User


Joined: 24 Feb 2008
Posts: 62
Location: Boston

PostPosted: Thu Mar 11, 2010 6:42 pm
Reply with quote

Quote:
FT_DSTNC_QTY FIXED DEC (5);

Why you are using this variable
Quote:
IF TEMP = -1.

is mainly used to indicate the variable is NULL .
As Dick said Uninitialized numeric data often causes a s0c7.
Back to top
View user's profile Send private message
arivazhagan_k

New User


Joined: 05 Dec 2007
Posts: 57
Location: chennai

PostPosted: Thu Mar 11, 2010 9:20 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Mar 11, 2010 9:49 pm
Reply with quote

Quote:
is mainly used to indicate the variable is NULL .

since nothing in the topic is db2 related
the statement
Code:
if temp = -1
is simply a test to determine if the variable temp contains a -1 value!
Back to top
View user's profile Send private message
Karthikeyan Subbarayan

New User


Joined: 24 Feb 2008
Posts: 62
Location: Boston

PostPosted: Thu Mar 11, 2010 11:17 pm
Reply with quote

oh ... iam sorry icon_redface.gif
i learnt one new thing today
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Mar 12, 2010 3:34 am
Reply with quote

Gnana Sekaran Nallathambi wrote:
What is this assignment? Why do you assign non-numeric here?
Code:
FD_DSTNC_QTY = '';


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
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Mar 12, 2010 10:55 am
Reply with quote

Thanks, Robert for the information. BTW, Topic Starter solved the problem?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Converting fixed length file to excel... IBM Tools 7
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top