The DATE1P display date in hex format with CCYYMMDD, but I want only YYMMDD in hex, I tried various options to split but couldn't achieve it.
Please suggest.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
The DATE1P gives the current date in packed decimal format, not hex. Date in Packed Decimal, Zoned Decimal, Character or any other format - each of these will have a corresponding hex representation.
You could try multiplying the DATE1P value by +10, and then use the portion of the result having x'YYMMDD' to populate the required output field.
Joined: 08 May 2008 Posts: 8 Location: Mumbai, India
I am getting today's date in packed decimal format as '020170323C'...but I want to pick only '0170323C' to write it in output file. I am not able to pick 'YYMMDD' out of it. Is there way to pick portion of it in my above JCL example.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Well, your original requirement was
Quote:
I want only YYMMDD in hex
That would be - X'170323' for today's date.
But your latest post here
Quote:
I want to pick only '0170323C' to write it in output file
suggests differently. For the latter you would not need the multiplication by 10.
Either way, the idea is to append the date at the end of your record and then copy whatever is needed from there and insert into your actual field. You might need multiple 'IFTHEN=(WHEN=INIT's as in the first IFTHEN to append the current date(x'0ccyymmddC') in your OUTFIL OUTREC (you could always use OUTFIL BUILD instead of OUTFIL OUTREC for better readability) and the next IFTHEN to copy the required data using an OVERLAY.
In order to align the desired part of packed date X'0yymmddC' on the full-byte boundary you are suggested
first: to multiply it by +10 (giving you X'yymmdd0C' as the result), and
second: to use the first 3 bytes of the result.
SYNCSORT syntax doesn't allow to perform MUL operation when using any function result as its argument (like result of DATE1P); only a field of record can be used for multiplication.
You can:
1) Append the date to the original record using DATE1P function in
Code:
INREC FIELDS=(...........,&DATE1P)
(BTW, an ampersand is required to use the function in SYNCSORT), and
2) Multiply by +10, and use only 3 bytes of the result in
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Quote:
SYNCSORT syntax doesn't allow to perform MUL operation
AFAIK even DFSORT does not allow applying MUL directly on DATE1P either.
From the last post made by the OP, looks like he is trying to get rid of the cc - part. So there is NO need of MULtiplication if I understand correctly.
Appending DATE1P can be included in the OUTFIL itself instead of adding an INREC.
SYNCSORT syntax doesn't allow to perform MUL operation
AFAIK even DFSORT does not allow applying MUL directly on DATE1P either.
From the last post made by the OP, looks like he is trying to get rid of the cc - part. So there is NO need of MULtiplication if I understand correctly.
Appending DATE1P can be included in the OUTFIL itself instead of adding an INREC.
He needs the result of DATE1P shifted half-a-byte left:
X'0yymmddC' ==> X'yymmdd--'
and next use only 6 dec digits = 3 full bytes of it:
X'yymmdd'
That's why something like MUL,+10 is needed. No simple way to move data half-a-byte in SORT operations...