Page 1 of 1

Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 4:17 pm
by Galwegian44
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

Re: Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 6:21 pm
by steve-myers
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.

Re: Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 6:26 pm
by Galwegian44
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.

Re: Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 7:08 pm
by prino
dcl 05 PRT_SALARY PIC '99,999v.99' INIT(0),

Re: Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 7:21 pm
by Galwegian44
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

Re: Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 8:01 pm
by prino
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.

Re: Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 9:22 pm
by Galwegian44
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

Re: Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 10:20 pm
by steve-myers
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.

Re: Decimal Point Not Lining Up

PostPosted: Fri Apr 05, 2019 10:24 pm
by prino
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

Re: Decimal Point Not Lining Up

PostPosted: Sun Apr 07, 2019 4:28 pm
by Galwegian44
It's always nice to 'talk', especially when you are the new kid in town :-)

Appreciate your time and the link.