PL/I Help on PIC variable.
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Application Programming

#1: PL/I Help on PIC variable. Author: tvssv PostPosted: Tue Apr 14, 2020 7:00 am
    —
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.

#2:  Author: Nic CloustonLocation: At Home PostPosted: Tue Apr 14, 2020 8:23 am
    —
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.

#3:  Author: kolusuLocation: San Jose PostPosted: Tue Apr 14, 2020 10:50 am
    —
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

#4: Read negarive value from file to variable in program. Author: tvssv PostPosted: Tue Apr 14, 2020 1:03 pm
    —
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.

#5:  Author: kolusuLocation: San Jose PostPosted: Tue Apr 14, 2020 8:48 pm
    —
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

#6:  Author: tvssv PostPosted: Fri Apr 17, 2020 11:36 am
    —
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]



MVSFORUMS.com -> Application Programming


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group