Decimal Point Not Lining Up



IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS

Decimal Point Not Lining Up

Postby Galwegian44 » Fri Apr 05, 2019 4:17 pm

Guys,

Any help would be appreciated on this issue as it is driving me nuts and I cannot see the wood for the trees at this point.

My SALARY field is defined as per the program specification:

05 TRANS_SALARY         PIC '(05)9V99',
 

The detail field in my Report Line is defined as follows (I've gone bare bones here to simplify, no dollar sign, zero suppression or anything):

05 PRT_SALARY       PIC '99,999.99' INIT(0),
 

My assignment code in the program is straightforward too:

PRT_SALARY     = TRANS_SALARY;
 

Yet, when I print my report line the Salary field is displayed as if the last 2 bytes of the input did not exist and the decimal point is moved 2 bytes to the left.
Here's an example with the first record and with the help of some debugging PUT LIST lines:
Record from file with Salary field highlighted - so this is a salary of 123.45:

123456ANITA     BATH           MR 001234519/02/10STRONG TEAM PLAYER  A
 

On the Output Report it displays as:

TRAN    NAME        NAME             TITLE   EMPLOYEE    SALARY     REVIEW     TYPE    SURNAME     FIRST               ID                      DATE          

A            BATH         ANITA             MR     123456       00,001.23      19/02/10
 


When I display the value in the input file I get:

TRANS_SALARY: 0012345 This is correct from the input file and is 123.45

PRT_SALARY: 00,001.23 This is how it appears on the Report and the PUT LIST command!!!!!!!!!!

It seems to be dropping the last 2 digits to the right of the decimal point so 0012345 becomes 00123 and then when the assignment happens it becomes 001.23
Any help is greatly appreciated.

Thanks,

Eamonn
Galwegian44
 
Posts: 7
Joined: Tue Apr 02, 2019 1:36 am
Has thanked: 2 times
Been thanked: 0 time

Re: Decimal Point Not Lining Up

 

Re: Decimal Point Not Lining Up

Postby steve-myers » Fri Apr 05, 2019 6:21 pm

The output from PUT LIST is not guaranteed to line up. See PUT list-directed. Its old, but it has been the same since PL/I F in the 1960s.

Use PUT EDIT with a format if you want output to line up neatly.
steve-myers
Global moderator
 
Posts: 2009
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 219 times

Re: Decimal Point Not Lining Up

Postby Galwegian44 » Fri Apr 05, 2019 6:26 pm

Thanks Steve, I used the PUT LIST to do some debugging but the crux of my issue is that the deimal point is two bytes to the left of where I expect it when I write to the OutPut Report File.

WRITE FILE(OREPORT) FROM (PRT_LINE_DETAIL);

DCL 01 PRT_LINE_DETAIL,
.
.
.
.
05 PRT_SALARY PIC '99,999.99' INIT(0),
.
.
;

Thanks for your reply.
Galwegian44
 
Posts: 7
Joined: Tue Apr 02, 2019 1:36 am
Has thanked: 2 times
Been thanked: 0 time

Re: Decimal Point Not Lining Up

Postby prino » Fri Apr 05, 2019 7:08 pm

dcl 05 PRT_SALARY PIC '99,999v.99' INIT(0),
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy

These users thanked the author prino for the post:
Galwegian44 (Fri Apr 05, 2019 7:22 pm)
User avatar
prino
 
Posts: 583
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 26 times

Re: Decimal Point Not Lining Up

Postby Galwegian44 » Fri Apr 05, 2019 7:21 pm

Thank you Robert once again :D

Why does PL1 not recognise where the decimal point aligns using the decimal point in the print field?
05 PRT_SALARY PIC '99,999.99' INIT(0), Incorrect - Decimal Point is not enough to align the data to the print field

05 PRT_SALARY PIC '99,999v.99' INIT(0), Correct - the v corrects the situation
Galwegian44
 
Posts: 7
Joined: Tue Apr 02, 2019 1:36 am
Has thanked: 2 times
Been thanked: 0 time

Re: Decimal Point Not Lining Up

Postby prino » Fri Apr 05, 2019 8:01 pm

The language is called PL/I, don't ever call it PL1 again!

Galwegian44 wrote:Why does PL1 not recognise where the decimal point aligns using the decimal point in the print field?

You can have multiple decimal points in a picture specification. Some countries use the "." as thousands separator and the "," as decimal separator, and some do exactly the reverse, and nothing stops you from adding three consecutive decimal points in an edit specification.

RTFM about Picture specification characters.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 583
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 26 times

Re: Decimal Point Not Lining Up

Postby Galwegian44 » Fri Apr 05, 2019 9:22 pm

Thanks Prino, appreciate the guidance.

So, phonetically, are we saying 'Pee El one' or is it always 'Pee El Eye'?

I've just started PL/I, any ideas where the PL1 came from?

Cheers,
Eamonn
Galwegian44
 
Posts: 7
Joined: Tue Apr 02, 2019 1:36 am
Has thanked: 2 times
Been thanked: 0 time

Re: Decimal Point Not Lining Up

Postby steve-myers » Fri Apr 05, 2019 10:20 pm

Galwegian44 wrote:Thanks Prino, appreciate the guidance.

So, phonetically, are we saying 'Pee El one' or is it always 'Pee El Eye'?

I've just started PL/I, any ideas where the PL1 came from?

Cheers,
Eamonn
Personally, I agree. You say P L 1, but for some unfathomable reason, you write PL/I. Wikpedia has a fairly decent PL/I article which may give you an idea about its origins. Google PL/I.
steve-myers
Global moderator
 
Posts: 2009
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 219 times

Re: Decimal Point Not Lining Up

Postby prino » Fri Apr 05, 2019 10:24 pm

Galwegian44 wrote:So, phonetically, are we saying 'Pee El one' or is it always 'Pee El Eye'?

I've just started PL/I, any ideas where the PL1 came from?

"Pee el one", as you could (and should) have found yourself... It's a Roman one!

https://en.wikipedia.org/wiki/PL/I
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 583
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 26 times

Re: Decimal Point Not Lining Up

Postby Galwegian44 » Sun Apr 07, 2019 4:28 pm

It's always nice to 'talk', especially when you are the new kid in town :-)

Appreciate your time and the link.
Galwegian44
 
Posts: 7
Joined: Tue Apr 02, 2019 1:36 am
Has thanked: 2 times
Been thanked: 0 time


Return to PL/I

 


  • Related topics
    Replies
    Views
    Last post