MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PL/I Help on PIC variable.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
tvssv
Beginner


Joined: 11 Mar 2009
Posts: 58
Topics: 25

PostPosted: Tue Apr 14, 2020 7:00 am    Post subject: PL/I Help on PIC variable. Reply with quote

Hi,

I am declaring a variable as PIC '-------9'. I am getting value into this variable negative value for now. In future there is chance to getting positive value also to this variable. Actually we can declare as PIC 'SSSSS9' to receive any value either positive or negative. But the same program in production is using
PIC '-----9' and that program is running fine even if it is getting positive values. But as per PL/I manual it says

+ Position(s) of (drifting) plus sign if number >= 0
- Position(s) of (drifting) minus sign if number < 0
S Position(s) of (drifting) plus sign or minus sign

I am not getting the point how PIC '------9' is working for positive values also. Could someone please give clarification on this.

Thanks.
_________________
Thanks
TVSSV
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Tue Apr 14, 2020 8:23 am    Post subject: Reply with quote

You can clarify easily enough by yourself. Write a little program to declare a variable with a floating - and move a positive number into it and display it. Repeat with a negative number.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Tue Apr 14, 2020 10:50 am    Post subject: Reply with quote

tvssv,

As Nic mentioned Open the "Enterprise PL/I for z/OS Language Reference" Manual and read "Chapter 14. Picture specification characters" especially by paying attention to "Signs and currency symbols"

IBM Enterprise PL/I for z/OS V4.5 documentation
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tvssv
Beginner


Joined: 11 Mar 2009
Posts: 58
Topics: 25

PostPosted: Tue Apr 14, 2020 1:03 pm    Post subject: Read negarive value from file to variable in program. Reply with quote

Hi,

I need to read the value from file which is negative value for now but positive values also come . Now the value is -4912315.

I have declared in program is below.

DCL 1 BBK_DETAIL BASED (BBKDET_PTR),
3 NET_BOOKING FIXED FIXED BIN(31);

But I am not getting correct value into the field.I am getting 1626667505 instead of -4912315. Please help me out how to declare. I tried declaring it as pic 'ssssssss9'. It is working but this field is involved in arithmetic operations.

Please help.
_________________
Thanks
TVSSV
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Tue Apr 14, 2020 8:48 pm    Post subject: Reply with quote

tvssv,

what is stopping you from doing this simple thing? bonk

Code:

DCL INPT    CHAR(08) INIT('-4912315') ;   
DCL MYNUM   FIXED BIN(31) ;               
                                         
MYNUM = INPT ;                           
PUT  SKIP LIST('MYNUM =',MYNUM) ;       

INPT = '+15'                       
MYNUM = INPT ;                     
PUT  SKIP LIST('MYNUM =',MYNUM) ; 

 


PS: Make sure you handle conversion Errors
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tvssv
Beginner


Joined: 11 Mar 2009
Posts: 58
Topics: 25

PostPosted: Fri Apr 17, 2020 11:36 am    Post subject: Reply with quote

Thank You Kolusu.

DCL INPT CHAR(08) INIT('-4912315') ; with this declaration it is working fine.

I have delcared it as PIC 'SSSSSSS9' it was working fine but if value is '28653680' it is not working because I was getting value 2865368 instead of 28653680. So program was abending. With CHAR(08) DECLARE it is working fine now.

Thank You.

[/code]
_________________
Thanks
TVSSV
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group