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
avelayudhan

New User


Joined: 30 Nov 2005
Posts: 26

PostPosted: Wed Nov 30, 2005 7:04 pm
Reply with quote

Hi,

Date conversions are possible in DFSORT? For example, to convert Julian date format to greg format? Any help is greatly appreciated.
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 Nov 30, 2005 9:47 pm
Reply with quote

What is the length and format of your Julian date (CH, PD, ?) and what does it look like (yyyyddd? yyddd?). What is the length and format of the gregorian date you want and what does it look like?
Back to top
View user's profile Send private message
avelayudhan

New User


Joined: 30 Nov 2005
Posts: 26

PostPosted: Wed Nov 30, 2005 9:52 pm
Reply with quote

File contains date in Julain format in PD in the format yyyyddd. Like to convert into the format yyyymmdd, or any other format that the situation demands.
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 Nov 30, 2005 10:55 pm
Reply with quote

DFSORT does not really have date conversion functions, but for the case you're talking about, there is a trick we can use to convert from P'yyyyddd' to Z'yyyymmdd' or P'yyyymmdd'.

Are you only dealing with 20yy dates or are you dealing with 19yy and 20yy dates? And do you want the output date to be ZD or PD?
Back to top
View user's profile Send private message
avelayudhan

New User


Joined: 30 Nov 2005
Posts: 26

PostPosted: Wed Nov 30, 2005 10:59 pm
Reply with quote

Yaeger,

We are dealing with both 19 and 20 dates. Whether the output to be ZD or PD does not have a bearing on the method to be used, right?
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 Nov 30, 2005 11:26 pm
Reply with quote

Here's a DFSORT job that will handle both 19 and 20 dates and convert to both Z'yyyymmdd' and P'yyyymmdd'. I assumed the input P'yyyyddd' date starts in position 1, but you can change that as appropriate.

Code:

//S1  EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
* Convert X'19yyddds' to X'00yyddds'.
* Convert X'20yyddds' to X'01yyddds'.
  INREC FIELDS=(1:1,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
    NOMATCH=(X'02'),2:2,3)
* Use SMF date format (DT1) to convert X'0cyyddds' to Z'yyyymmdd'
* and P'yyyymmdd'.
  OUTREC FIELDS=(1,4,DT1,X,1,4,DT1,TO=PD,LENGTH=5)
/*
Back to top
View user's profile Send private message
avelayudhan

New User


Joined: 30 Nov 2005
Posts: 26

PostPosted: Thu Dec 01, 2005 12:49 am
Reply with quote

My date field (PD - YYYYDDD starts at 38. I used the following card, seems to have problems:

Code:

//SYSIN    DD    *                                         
   OPTION COPY                                               
   INREC FIELDS=(38:1,1,CHANGE=(1,X'19',X'00',X'20',X'01'), 
     NOMATCH=(X'02'),39:2,3)                                 
   OUTREC FIELDS=(38,4,DT1,X,38,4,DT1,TO=PD,LENGTH=5)       
/*                                                         
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 Dec 01, 2005 2:42 am
Reply with quote

Quote:
seems to have problems


You didn't change the statements correctly for a field starting at 38. Here's what you need:

Code:

//SYSIN    DD    * 
   OPTION COPY
   INREC FIELDS=(1:38,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
      NOMATCH=(X'02'),2:39,3)                               
   OUTREC FIELDS=(1,4,DT1,X,1,4,DT1,TO=PD,LENGTH=5)         
/*   


The converted fields will start in position 1 of the output record.
Back to top
View user's profile Send private message
avelayudhan

New User


Joined: 30 Nov 2005
Posts: 26

PostPosted: Fri Dec 02, 2005 1:41 am
Reply with quote

Yaeger..you rocks! thanks for all the help..looking forward for more of such great help. icon_biggrin.gif
Back to top
View user's profile Send private message
avelayudhan

New User


Joined: 30 Nov 2005
Posts: 26

PostPosted: Sat Dec 03, 2005 12:25 am
Reply with quote

Yaeger,

One more thing. The date format of DT1 is yyyymmdd, right? is there way to get the format to mmddyyyy? I have not seen any other mask that does this.
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: Sat Dec 03, 2005 12:50 am
Reply with quote

DT1 actually converts a P'0cyyddd' date to a Z'yyyymmdd' date. You could then move the Z'yyyymmdd' bytes around to get Z'mmddyyyy', and if necessary, convert that to PD. Here's an example:

Code:

  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
* Convert X'19yyddds' to X'00yyddds'.
* Convert X'20yyddds' to X'01yyddds'
          BUILD=(1:38,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
            NOMATCH=(X'02'),2:39,3)),
* Use SMF date format (DT1) to convert X'0cyyddds' to Z'yyyymmdd'
        IFTHEN=(WHEN=INIT,BUILD=(1,4,DT1)),
* Convert Z'yyyymmdd' to Z'mmddyyyy' - stop here if you don't
* want P'0mmddyyyy'
        IFTHEN=(WHEN=INIT,BUILD=(5,4,1,4)),
* Copy Z'mmddyyy' and convert Z'yyyymmdd' to P'0mmddyyyy'
        IFTHEN=(WHEN=INIT,BUILD=(1,8,X,1,8,ZD,TO=PD,LENGTH=5))
Back to top
View user's profile Send private message
SJI77

New User


Joined: 11 Jan 2007
Posts: 4
Location: Chennai

PostPosted: Thu Jan 11, 2007 6:38 pm
Reply with quote

Yaeger,

I have a requirement like this. A Julian date of 5 digits (YYDDD) needs to be converted to Greg format of (MM/DD/YYYY). Input field is in CH format and want the output also in same. The date starts at position 6 in a FB file. Please let me know how I can achieve this using the ICEMAN?

Thanks in advance
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 Jan 11, 2007 10:39 pm
Reply with quote

What range of years does YY represent - for example, 2000-2099 or 1980-2079 or what?
Back to top
View user's profile Send private message
SJI77

New User


Joined: 11 Jan 2007
Posts: 4
Location: Chennai

PostPosted: Fri Jan 12, 2007 11:22 am
Reply with quote

The date ranges between 1980-2079.
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: Fri Jan 12, 2007 9:47 pm
Reply with quote

Here's a DFSORT job that will do what you want. It's quite similar to the job I showed earlier.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY,Y2PAST=1980
  INREC IFTHEN=(WHEN=INIT,BUILD=(6,5,Y2T,TO=PD,LENGTH=4)),
        IFTHEN=(WHEN=INIT,
          OVERLAY=(1:1,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
              NOMATCH=(X'02'))),
        IFTHEN=(WHEN=INIT,BUILD=(1,4,DT1)),
        IFTHEN=(WHEN=INIT,BUILD=(5,2,C'/',7,2,C'/',1,4))
/*
Back to top
View user's profile Send private message
harish_mf

New User


Joined: 31 Jul 2005
Posts: 18
Location: bangalore

PostPosted: Wed Jan 17, 2007 2:10 pm
Reply with quote

Hi,

what is NOMATCH= ?


THANKS & REGARDS

HARISH.B
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 Jan 17, 2007 9:55 pm
Reply with quote

Code:

  1,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
        NOMATCH=(X'02')


NOMATCH tells DFSORT what to do if none of the CHANGE conditions are matched. For the statement above:

- if position 1 contains X'19', it is changed to X'00'
- if position 1 contains X'20', it is changed to X'01'
- if position 1 does not contain X'19' or X'20', it is changed to X'02'

For some more information on DFSORT's CHANGE and NOMATCH functions, see:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG20/2.4.11?DT=20060615173822
Back to top
View user's profile Send private message
SJI77

New User


Joined: 11 Jan 2007
Posts: 4
Location: Chennai

PostPosted: Thu Jan 18, 2007 5:55 pm
Reply with quote

Hi,

I am getting syntax error. We are using Syncsort in our mainframe. The control 'TO=PD' is getting error.Please find below the screen print.

Code:

SYSIN :                                                       
  OPTION COPY,Y2PAST=1980                                     
    INREC IFTHEN=(WHEN=INIT,BUILD=(6,5,Y2T,TO=PD,LENGTH=4)), 
                                           *                 
          IFTHEN=(WHEN=INIT,                                 
            OVERLAY=(1:1,1,CHANGE=(1,X'19',X'00',X'20',X'01'),
                NOMATCH=(X'02'))),                           
          IFTHEN=(WHEN=INIT,BUILD=(1,4,DT1)),                 
          IFTHEN=(WHEN=INIT,BUILD=(5,2,C'/',7,2,C'/',1,4))   
WER268A  INREC STATEMENT   : SYNTAX ERROR                     
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                 
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE               


I tried so many combinations but nothing worked out. Please help me in solving this issue.
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 Jan 18, 2007 9:33 pm
Reply with quote

The job works fine with DFSORT. I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
Back to top
View user's profile Send private message
SJI77

New User


Joined: 11 Jan 2007
Posts: 4
Location: Chennai

PostPosted: Fri Jan 19, 2007 2:12 pm
Reply with quote

Thanks Frank Yaeger for the help.
Back to top
View user's profile Send private 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
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 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
No new posts 10 byte RBA conversion DB2 2
Search our Forums:

Back to Top