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

Date conversion using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sureshbabuamara

New User


Joined: 20 Sep 2007
Posts: 16
Location: India

PostPosted: Wed Oct 24, 2007 11:12 pm
Reply with quote

Code:

//* Convert Julian date to Gregorian date
//*
//* Example:1
//S1    EXEC  PGM=ICEMAN                           
//SYSOUT    DD  SYSOUT=*   
//SORTIN DD Input file with "Hex format date of 1945001"
//*1401
//*950F
//SYSIN    DD    *                                 
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
          BUILD=(1:1,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
            NOMATCH=(X'02'),2:2,3)),
        IFTHEN=(WHEN=INIT,BUILD=(1,4,DT1)),                    yyyyddd  to yyyymmdd
*       IFTHEN=(WHEN=INIT,BUILD=(5,4,1,4)),                    yyyymmdd to mmddyyyy
*       IFTHEN=(WHEN=INIT,BUILD=(5,2,C'-',7,2,C'-',1,4))       yyyymmdd to mm-dd-yyyy
*       IFTHEN=(WHEN=INIT,BUILD=(1,4,X,1,4,ZD,TO=PD,LENGTH=5)) Zoneddec to Packeddec date
/*
//*
//* Example:2
//S1    EXEC  PGM=ICEMAN                           
//SYSOUT    DD  SYSOUT=*                           
//SORTIN DD *
06012
/*                                               
//SORTOUT DD SYSOUT=*                               
//SYSIN    DD    *                                 
  OPTION COPY                                       
  INREC  IFTHEN=(WHEN=(1,2,ZD,GT,+49),               
                BUILD=(X'00',1,5,ZD,TO=PD,LENGTH=3)),           
         IFTHEN=(WHEN=NONE,                               
                BUILD=(X'01',1,5,ZD,TO=PD,LENGTH=3))           
  OUTREC IFTHEN=(WHEN=INIT,
                BUILD=(1,4,DT1)),                        X'00/01yydddC' to Z'19/20yymmdd'
*        IFTHEN=(WHEN=INIT,                               
*               BUILD=(5,2,C'-',7,2,C'-',1,4))           Z'19/20yymmdd' to C'mm-dd-ccyy'
/*


Quote:
I have gone through all the available threads on Date conversion from Julian date to Gregorian date and made these above 2 examples.
By the above examples I couldnt under stand how to perform the same logics for "n" number of dates at a time.

My concern is if I have 2 or more dates which need to convert from EX1: yyyyddd to mm-dd-yyyy EX2: yyddd to dd-mm-yyyy.... how can I achieve this, Kindly find the below example and help me how can I exactly use it here.


Code:

INPUT                                 
Cust# Emp#  DOB  DEP DOJ 
001   12345  á   ECE 07001
FFF   FFFFF 1401 CCC FFFFF
001   12345 950F 535 07001             
                                     
123   45678 9012 345 6789             
                                     
OUTPUT                               
Cust# Emp#  DOB        DEP DOJ       
001   12345 01-01-1945 ECE 01-01-2007
123   45678 9012345678 901 2345678901


This is my first post, kindly regret if I any inconvenience provided.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Oct 24, 2007 11:51 pm
Reply with quote

I can't figure out what your input records represent or how they relate to your output records. You seem to have 4 input records and 2 output records and only the first output record has dates.

For example 1, are you just trying to convert several yyyyddd dates in the same record to mm-dd-yyyy dates? If so, what is the starting position, length and format of each yyyyddd date in the input file and what is the corresponding starting position of each mm-dd-yyyy date in the output file? What is the RECFM and LRECL of the input file?

For example 2, are you just trying to convert several yyddd dates in the same record to dd-mm-yyyy dates? If so, what is the starting position, length and format of each yyddd date in the input file and what is the corresponding starting position of each dd-mm-yyyy date in the output file? Also, are the yyddd dates all 20yyddd dates or can there also be 19yyddd dates as well? What is the RECFM and LRECL of the input file?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 24, 2007 11:58 pm
Reply with quote

Quote:
You seem to have 4 input records and 2 output records


It is evident that the poster was just trying to helpful by showing both the character and the hexadecimal representation of his data,
at least as far the first record is concerned
Code:

001   12345  á   ECE 07001
FFF   FFFFF 1401 CCC FFFFF
001   12345 950F 535 07001


there is display garbage in positions 9-11 because of hex data
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Oct 25, 2007 1:10 am
Reply with quote

If that's the case, then I guess the first date field in the first record is a 4-byte PD field starting at position 13 (P'1945001' = X'1945001F') and the second date field in the first record is a 5-byte ZD field starting at position 22 (Z'07001').

But the second record still doesn't make sense and needs to be explained.
Back to top
View user's profile Send private message
sureshbabuamara

New User


Joined: 20 Sep 2007
Posts: 16
Location: India

PostPosted: Thu Oct 25, 2007 2:43 pm
Reply with quote

Hi Frank,

Sorry for not posting details properly in my previous post, now I have listed them.
Code:
INPUT (contains only one record)                     
Cust# Emp#  DOB  DEP DOJ               <--- Header   
001   12345  á   ECE 07001             <--- Data     
FFF   FFFFF 1401 CCC FFFFF             <--- Hexon line one
001   12345 950F 535 07001             <--- Hexon line two
                                                     
123   45678 9012 345 67890             <--- Columns 
                                                     
OUTPUT (need only one record)                       
Cust# Emp#  DOB        DEP DOJ         <--- Header   
001   12345 01-01-1945 ECE 01-01-2007  <--- Data     
                                                     
123   45678 9012345678 901 2345678901  <--- Columns 


Input file is of 80bytes FB, Date1(DOB) is an 4-byte PD starting at position 9 (X'1945001F') and Date2(DOJ) is an 5-byte ZD starting at position 16 (Z'07001').

I am unable to understand how to convert "n" number of dates at a time using the above technique(Ex:1 and EX:2 in previous post) given by Mr.Frank.

----------------------------
Suresh,
Hyderabad, India.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Oct 25, 2007 11:16 pm
Reply with quote

Here's a DFSORT job that will do what you asked for. I assumed that you wanted both output dates in the form mm-dd-yyyy. If you want dd-mm-yyyy that would require a simple change to the last IFTHEN clause.

Code:

//S1    EXEC  PGM=ICEMAN                                     
//SYSOUT    DD  SYSOUT=*                                     
//SORTIN DD DSN=... input file (FB/80)                       
//SORTOUT DD DSN=...  output file (FB/80)                     
//SYSIN    DD    *                                           
  OPTION COPY,Y2PAST=1920                                     
  INREC IFTHEN=(WHEN=INIT,                                   
          BUILD=(1,8,                                         
            9:9,4,                                           
           19:13,3,                                           
           22:16,5,Y2T,TO=PD,LENGTH=4)),                     
  IFTHEN=(WHEN=INIT,                                         
    OVERLAY=(9:9,1,CHANGE=(1,X'19',X'00',X'20',X'01'),       
            NOMATCH=(X'02'),                                 
            22:22,1,CHANGE=(1,X'19',X'00',X'20',X'01'),       
            NOMATCH=(X'02'))),                               
  IFTHEN=(WHEN=INIT,                                         
    OVERLAY=(9:9,4,DT1,                                       
            22:22,4,DT1)),                                   
  IFTHEN=(WHEN=INIT,                                         
    BUILD=(1,8,                                               
           9:13,2,C'-',15,2,C'-',9,4,                         
           19:13,3,                                           
           22:26,2,C'-',28,2,C'-',22,4,80:X))                 
/*                                                           
Back to top
View user's profile Send private message
sureshbabuamara

New User


Joined: 20 Sep 2007
Posts: 16
Location: India

PostPosted: Mon Oct 29, 2007 4:35 pm
Reply with quote

Thankyou very very much Mr.Frank.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Nov 24, 2009 2:21 am
Reply with quote

With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), DFSORT now has built-in date conversion functions for these types of situations . For complete details on date conversion functions and the other new functions available with the Nov, 2009 DFSORT PTF, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
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 -> DFSORT/ICETOOL Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts DFSORT GUID DFSORT/ICETOOL 3
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top