Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Fixed Decimal in PL/1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: Fixed Decimal in PL/1
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: 785
Location: Chennai, India

PostPosted: Thu Mar 11, 2010 11:25 am    Post subject:
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    Post subject: Reply to: Fixed Decimal in PL/1
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

Site Director


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

PostPosted: Thu Mar 11, 2010 11:38 am    Post subject:
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: 785
Location: Chennai, India

PostPosted: Thu Mar 11, 2010 11:41 am    Post subject:
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    Post subject: Reply to: Fixed Decimal in PL/1
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: 56
Location: Boston

PostPosted: Thu Mar 11, 2010 6:42 pm    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Mar 11, 2010 9:49 pm    Post subject: Reply to: Fixed Decimal in PL/1
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: 56
Location: Boston

PostPosted: Thu Mar 11, 2010 11:17 pm    Post subject:
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

Active Member


Joined: 07 Feb 2009
Posts: 985
Location: Oostende, Belgium

PostPosted: Fri Mar 12, 2010 3:34 am    Post subject:
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: 785
Location: Chennai, India

PostPosted: Fri Mar 12, 2010 10:55 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm
No new posts conversion from char to packed decimal Musab Ahmed DFSORT/ICETOOL 7 Fri Apr 08, 2016 1:12 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us