IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to pick only YYMMDD from DATE1P (Hex) format?


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
atulbaviskar

New User


Joined: 08 May 2008
Posts: 8
Location: Mumbai, India

PostPosted: Wed Mar 22, 2017 11:39 am
Reply with quote

Code:
//STPU040  EXEC PGM=SORT,ACCT='C=0',PARM='JP1"170320"'                     
//SORTIN    DD DSN=TEMP.TCU.INPUT,DISP=SHR                         
//SORTOUT   DD DSN=TEMP.TCU.TEST.OUTPUT,                         
//             DISP=(NEW,CATLG),UNIT=DISK,                                 
//             DCB=(RECFM=VB,LRECL=2064),                                 
//             SPACE=(27998,(30,30),RLSE)                                 
//SYSIN     DD *                                                           
  SORT FIELDS=COPY                                                         
      RECORD TYPE=F                                                       
      OUTFIL FTOV,OUTREC=(JP1,C'230000',C'FTL',01,24,01,24,               
             C'00000',X'0000000000000000000C',12X,DATE1P,                 
             C'2300',C'4H',2X,X'0000000000000000000C',X'0000000C',1X,     
             X'0000000000000000000C',X'0000000C',2X,1X,2X,1X,             
             C'BXYMGMT ',12X,2X,12X,1X,1X,1X,5X)                           
//SYSOUT    DD SYSOUT=*               



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.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Mar 22, 2017 11:03 pm
Reply with quote

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.
Back to top
View user's profile Send private message
atulbaviskar

New User


Joined: 08 May 2008
Posts: 8
Location: Mumbai, India

PostPosted: Thu Mar 23, 2017 10:54 am
Reply with quote

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.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Mar 23, 2017 6:04 pm
Reply with quote

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.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Thu Mar 23, 2017 10:35 pm
Reply with quote

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
Code:
OUTFIL ...,OUTREC=(...,p,l,MUL,+10,...)
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Mar 23, 2017 11:12 pm
Reply with quote

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.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Thu Mar 23, 2017 11:34 pm
Reply with quote

Arun Raj wrote:
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.

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...
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Mar 23, 2017 11:46 pm
Reply with quote

I agree his initial posts were on those lines. But his latest post says this:
atulbaviskar wrote:
I want to pick only '0170323C' to write it in output file
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
No new posts Need mmmyy date format SYNCSORT 6
Search our Forums:

Back to Top