Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
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    Post subject: How to pick only YYMMDD from DATE1P (Hex) format?
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: 2278
Location: @my desk

PostPosted: Wed Mar 22, 2017 11:03 pm    Post subject:
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    Post subject: Reply to: How to pick only YYMMDD from DATE1P (Hex) format?
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: 2278
Location: @my desk

PostPosted: Thu Mar 23, 2017 6:04 pm    Post subject:
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

New User


Joined: 29 Apr 2008
Posts: 91
Location: Maryland

PostPosted: Thu Mar 23, 2017 10:35 pm    Post subject:
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: 2278
Location: @my desk

PostPosted: Thu Mar 23, 2017 11:12 pm    Post subject:
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

New User


Joined: 29 Apr 2008
Posts: 91
Location: Maryland

PostPosted: Thu Mar 23, 2017 11:34 pm    Post subject:
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: 2278
Location: @my desk

PostPosted: Thu Mar 23, 2017 11:46 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us