MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Date Conversion thru SORT OCTOBER 02 2017 to 10/02/2017

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 43
Topics: 9

PostPosted: Tue Oct 03, 2017 4:49 pm    Post subject: Date Conversion thru SORT OCTOBER 02 2017 to 10/02/2017 Reply with quote

Hi,

I need to convert an date format from OCTOBER 02 2017 to 10/02/2017 and similar for all months. datefield starts at 89 position of the file, have written the below logic and it works fine , but I have to hard-code 12 times for each month since position of the date and year would differ, is there better way to achieve this.

Code:

                                                                 
 OUTFIL INCLUDE=(134,07,CH,EQ,C'HEADER1',AND,                   
                 190,01,SS,EQ,C'1,2,3,4',AND,                   
                 2,3,CH,NE,C'   '),                             
     IFTHEN=(WHEN=INIT,BUILD=(                                   
                 11:180,2,                                       
                 2X,185,5,                                       
                 3X,195,3,                                       
                 2X,200,11,                                     
                 2X,215,25,                                     
                 2X,250,19,                                     
                 2X,150,15,                                     
                 31X)),                                         
      IFTHEN=(WHEN=(89,3,CH,EQ,C'OCT'),                         
                  OVERLAY=(2:C'10/',97,2,C'/',100,4,1X))         


Thanks in advance
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Tue Oct 03, 2017 8:02 pm    Post subject: Re: Date Conversion thru SORT OCTOBER 02 2017 to 10/02/2017 Reply with quote

Suchay wrote:
Hi,

I need to convert an date format from OCTOBER 02 2017 to 10/02/2017 and similar for all months. datefield starts at 89 position of the file, have written the below logic and it works fine , but I have to hard-code 12 times for each month since position of the date and year would differ, is there better way to achieve this.

Code:

                                                                 
 OUTFIL INCLUDE=(134,07,CH,EQ,C'HEADER1',AND,                   
                 190,01,SS,EQ,C'1,2,3,4',AND,                   
                 2,3,CH,NE,C'   '),                             
     IFTHEN=(WHEN=INIT,BUILD=(                                   
                 11:180,2,                                       
                 2X,185,5,                                       
                 3X,195,3,                                       
                 2X,200,11,                                     
                 2X,215,25,                                     
                 2X,250,19,                                     
                 2X,150,15,                                     
                 31X)),                                         
      IFTHEN=(WHEN=(89,3,CH,EQ,C'OCT'),                         
                  OVERLAY=(2:C'10/',97,2,C'/',100,4,1X))         


Thanks in advance


Suchay,

Are you sure you are getting the right results? Your INIT statement is building the record and you don't have the date field and your check for position 89 would fail as the date field is no longer in the record.

You need to parse the date before and then build it. something like this untested code
Code:

                                                                 
 OUTFIL INCLUDE=(134,07,CH,EQ,C'HEADER1',AND,                   
                 190,01,SS,EQ,C'1,2,3,4',AND,                   
                 2,3,CH,NE,C'   '),   
   IFOUTLEN=134,                                                         
   IFTHEN=(WHEN=INIT,                                                   
          PARSE=(%01=(ABSPOS=89,STARTAT=NUM,ENDBEFR=C' ',FIXLEN=2),     
                 %02=(ENDBEFR=C' ',FIXLEN=4)),                           
         OVERLAY=(003:C'/',                                             
                      %01,UFF,EDIT=(TT),                                 
                      C'/',                                             
                      %02,UFF,EDIT=(TTTT))),                             
   IFTHEN=(WHEN=INIT,                                                   
         BUILD=(01:89,3,CHANGE=(2,C'JAN',C'01',C'FEB',C'02',             
                                  C'MAR',C'03',C'APR',C'04',             
                                  C'MAY',C'05',C'JUN',C'06',             
                                  C'JUL',C'07',C'AUG',C'08',             
                                  C'SEP',C'09',C'OCT',C'10',             
                                  C'NOV',C'11',C'DEC',C'12'),           
                                  NOMATCH=(C'00'),                       
                    003,8,                                               
                    180,2,                                               
                    2X,185,5,                                           
                    3X,195,3,                                           
                    2X,200,11,                                           
                    2X,215,25,                                           
                    2X,250,19,                                           
                    2X,150,15))                                         
 /*                                                                     

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 43
Topics: 9

PostPosted: Wed Oct 04, 2017 11:11 am    Post subject: Reply with quote

Kolusu,

thanks for Parse logic it worked fine.

Quote:

Are you sure you are getting the right results? Your INIT statement is building the record and you don't have the date field and your check for position 89 would fail as the date field is no longer in the record.


It worked since I overplayed after the build.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Sun Oct 08, 2017 5:04 am    Post subject: Reply with quote

Suchay wrote:


It worked since I overplayed after the build.


Nope It will NOT. Since you overlaid the contents AFTER the build , the position 89 will have the contents from position 150 according to your build. Unless your initial description is wrong that your date field starts at position 89, there is no way that would have worked.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 43
Topics: 9

PostPosted: Mon Oct 09, 2017 2:06 pm    Post subject: Reply with quote

Quote:
Nope It will NOT. Since you overlaid the contents AFTER the build , the position 89 will have the contents from position 150 according to your build. Unless your initial description is wrong that your date field starts at position 89, there is no way that would have worked.


Position 150 has the date field and I have moved to position 89 using build, used the date in position 89 and converted,tested even today and It worked. if u want to test my logic I will send my input file and sort card you can test it out.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Tue Oct 10, 2017 1:10 am    Post subject: Reply with quote

Suchay wrote:
Quote:
Nope It will NOT. Since you overlaid the contents AFTER the build , the position 89 will have the contents from position 150 according to your build. Unless your initial description is wrong that your date field starts at position 89, there is no way that would have worked.


Position 150 has the date field and I have moved to position 89 using build, used the date in position 89 and converted,tested even today and It worked. if u want to test my logic I will send my input file and sort card you can test it out.



I don't need your input file you simply are referring to the date field after your BUILD which is incorrect way of describing the requirements. Your initial description mentioned this

Suchay wrote:

datefield starts at 89 position of the file, have written the below logic and it works fine , but I have to hard-code 12 times for each month since position of the date and year would differ, is there better way to achieve this.


So be clear on your requirements. I wrote the parse statement based on your description. You need to change the ABSPOS value to 150 instead of 89.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group