Packed Decimals with Dates



High Level Assembler(HLASM) for MVS & VM & VSE

Packed Decimals with Dates

Postby Susansuth » Sat Nov 01, 2014 9:13 am

If I am using packed decimals to represent dates, is there a way to get a beginning zero to print to the screen?

So, let's say I have a date like this 02081940F in a packed decimal field of length 5.

I want to use ED to bring it to the screen so that I will get this: 02/08/1940.

I can get it to work if I have a date like this 22081940F -- 22/08/1940.

But the beginning zero will not print for the 02/08/1940. If I use F0 as a fill character, I can get the zero to print, but it also prints the extra zero that fills out the remainder of the packed decimal field.

Is there a way to get that zero to print without grabbing the extra 0 that fills out the remainder of the packed decimal field?

Or is that pretty much something that isn't going to happen?

Any help would be appreciated. :) Thank you so much!

Susan
Susansuth
 
Posts: 15
Joined: Tue Oct 07, 2014 8:36 am
Has thanked: 9 times
Been thanked: 0 time

Re: Packed Decimals with Dates

Postby steve-myers » Sat Nov 01, 2014 11:01 am

From time to time I've run into the same issue. There's no solid answer; this is one solution, though it's limited.
         ED    FIELD,DATA
         MVI   FIELD,C' '
         ...
DATA     DC    P'01021948'                                         
FIELD    DC    0C'0MM/DD/YYYY',C'0',X'2120',C'/',2X'20',C'/',4X'20'
My date is different than the date you proposed, though it presents the same problem. The way the fill character is specified for ED instruction formats is a bit clumsy - and this situation really clarifies it. One would wish for a better idea, but it's way too late now!

Just this morning I wrote code to format mm/dd/yyyy, though the date I started with was PL4'cyyddd' Getting month and day of month from that mess is moderately painful. I formatted mm, dd and yyyy as separate fields using UNPK rather than combine them into P'mmddyyyy'

I've been using the method to define complex ED instruction formats like in my little example and I think it works pretty well. It's better than memorizing character codes, like the / in the format. Oddly enough I had been thinking X'61' for the /, and that turned out to be correct. X'F021206120206120202020' - the "standard" method - is pretty hard to digest, and very easy to screw up.

These users thanked the author steve-myers for the post:
Susansuth (Sat Nov 01, 2014 9:39 pm)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Packed Decimals with Dates

Postby Susansuth » Sat Nov 01, 2014 9:27 pm

This is PERFECT. This helped me a lot. Just what I needed.

THank you so very much. You made my day! :)

Susan
Susansuth
 
Posts: 15
Joined: Tue Oct 07, 2014 8:36 am
Has thanked: 9 times
Been thanked: 0 time

Re: Packed Decimals with Dates

Postby steve-myers » Mon Nov 03, 2014 9:39 am

A couple of other “tricks” with ED and EDMK.

Append conditional text
         MVC   OUTPUT,EDMASK
         ED    OUTPUT,=P'-12345'
         ...
OUTPUT   DC    C' NNN.NN CR'
EDMASK   DC    0C' NNN.NN CR',C' ',X'202120',C'.',C'2020',C' CR'

The output will be 123.45 CR

Insert floating text
         MVC   OUTPUT,EDMASK
         LA    1,OUTPUT+4
         EDMK  OUTPUT,VALUE
         CP    VALUE,=P'0'
         BNM   PLUS
         BCTR  1,0
         MVI   0(1),C'-'
PLUS     BCTR  1,0
         MVI   0(1),C'$'
*                0----+--
OUTPUT   DC    C'  NNN.NN'
EDMASK   DC    0C'  NNN.NN',C' ',X'202120',C'.',X'2020'
VALUE    DC    P'-12345'

The output will be $-123.45. The tricky part is figuring out how to set register 1 before the EDMK so that something like P'00045' will format as $0.45. Using a ruler like I did helps.

An important rule with ED and EDMK is to have an odd number of digit select characters in the format. If you run into a situation where the report specifies an even number of digits, format the output in a separate area, and move the last even number of digits to the final report.

These users thanked the author steve-myers for the post:
Susansuth (Thu Nov 06, 2014 9:16 am)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Packed Decimals with Dates

Postby Susansuth » Thu Nov 06, 2014 9:16 am

This is great to know! Thanks for the extra information!! I appreciate the help!

Susan
Susansuth
 
Posts: 15
Joined: Tue Oct 07, 2014 8:36 am
Has thanked: 9 times
Been thanked: 0 time

Re: Packed Decimals with Dates

Postby Aliraza521 » Tue Jan 12, 2016 6:41 pm

It appears you have to specify some parameter though I'm not 100% sure how to do this.????
Ali
Aliraza521
 
Posts: 1
Joined: Tue Jan 12, 2016 6:38 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Packed Decimals with Dates

Postby Akatsukami » Tue Jan 12, 2016 7:39 pm

Please do not append a query to a thread that has been dormant for over a year.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Packed Decimals with Dates

Postby steve-myers » Tue Jan 12, 2016 11:24 pm

Aliraza521 wrote:It appears you have to specify some parameter though I'm not 100% sure how to do this.????
There are three "parameters" with the ED instruction.
  • The address of the edit "pattern."
  • The length of the edit "pattern."
  • The address of the data area to be edited by the instruction.
Or do you mean something else?

To return to the topic starter's query, another solution might be -
         ED    PATTERN,=P'01021948'
         MVC   OUTPUT,PATTERN+1
         ...
PATTERN  DC    0C'0MM/DD/YYYY'
         DC    C'0',X'2120',C'/',X'2020',C'/',X'20202020'
OUTPUT   DC    C'MM/DD/YYYY'
Here the real output is separated from the pattern, though there is a real MVC to copy the edited data to the real output area. Writers of training material often seemed wired into the idea the edit pattern is part of the actual output image, but that is not always a real requirement.

I generally agree with Akatsukami that dormant threads should not be reopened, though I'm not the guilty party here. At least Aliraza521 attempted to stay on topic, which is often not the case when a dormant thread is restarted.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post