Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
to get weekday for a date from input file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Sathish Gurumoorthy

New User


Joined: 12 Feb 2009
Posts: 33
Location: Chennai, India

PostPosted: Mon Jul 13, 2009 6:23 pm    Post subject: to get weekday for a date from input file
Reply with quote

Hi,

i have an input file like below. the input file can contain any no of such records with different dates

Code:
07-13-2009


the date is in format MM-DD-YYYY

i want the output as below

Code:
07-13-2009 2


Here 2 indicates the 2nd day (i.e monday) of the week.
the output can look like below too

Code:
07-13-2009 MON
Back to top
View user's profile Send private message

rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Mon Jul 13, 2009 7:11 pm    Post subject:
Reply with quote

Hi Sathish,

You can try the below code


SORT FIELDS=COPY
OUTREC FIELDS=(1:1,10,X,
11:11,1,CHANGE=(3,C'2',C'MON',
C'3',C'TUE'),
C'4',C'WED'),
C'5',C'THU'),
C'6',C'FRI'),
C'7',C'SAT'),
C'1',C'SUN'),
NOMATCH=(C'N/A'))

I haven't tried this on mainframe but hope it will work.

Please let me know if it doesn't work.

Thanks And Regards
Rahul Gupta
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jul 13, 2009 10:13 pm    Post subject:
Reply with quote

Sathish Gurumoorthy,

Sort products do not have the ability to produce the day of week from a given date. However with a bunch of IFTHEN statements we can get the day of the week. In order to help you with that I need to know the LRECL and RECFM of the input dataset along with the position and format of the date field.

Rgupta71,

Please read the question once again and try to answer the question. If you can't test your solution please do NOT post the solution. Satish does NOT have the numerical value of the day of the week in the input. He just have a date field and he needs it to be converted to a numerical number which represents the day of the week or literal name of the day of week.
Back to top
View user's profile Send private message
Sathish Gurumoorthy

New User


Joined: 12 Feb 2009
Posts: 33
Location: Chennai, India

PostPosted: Tue Jul 14, 2009 10:05 am    Post subject:
Reply with quote

Skolusu,

LRECL of the input file is 254 and RECFM is FB. The date field YYYYMMDD starts at 19th position in the input file and it's format is BINARY 9
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jul 14, 2009 9:13 pm    Post subject:
Reply with quote

Sathish Gurumoorthy,

The following JCL will give you the desired results. I did not do any do any kind of date validation as I assumed that your input has valid dates in CCYYMMDD format in 4 byte binary field at pos 19 in your input.

Code:

//STEP0100 EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD DSN=Your input FB 254 byte file,DISP=SHR           
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                           
  OPTION COPY,NOSZERO                                                 
  INREC IFTHEN=(WHEN=INIT,BUILD=(19,4,BI,ZD,LENGTH=8)),               
  IFTHEN=(WHEN=(5,2,ZD,LT,3),OVERLAY=(9:1,4,ZD,SUB,+1,EDIT=(TTTT),     
  13:5,2,ZD,ADD,+10,EDIT=(TT),15:9,4,ZD,DIV,+100,EDIT=(TTTT),         
  19:9,4,ZD,MOD,+100,EDIT=(TT))),                                     
  IFTHEN=(WHEN=(5,2,ZD,GE,3),OVERLAY=(9:1,4,                           
  13:5,2,ZD,SUB,+2,EDIT=(TT),15:9,4,ZD,DIV,+100,EDIT=(TTTT),           
  19:9,4,ZD,MOD,+100,EDIT=(TT)))                                       
  OUTREC IFTHEN=(WHEN=INIT,                                           
  OVERLAY=(21:((+26,MUL,13,2,ZD),SUB,+2),DIV,+10,M11,LENGTH=8)),       
  IFTHEN=(WHEN=INIT,                                                   
  OVERLAY=(29:21,8,ZD,ADD,7,2,ZD,ADD,19,2,ZD,M11,LENGTH=8)),           
  IFTHEN=(WHEN=INIT,                                                   
  OVERLAY=(37:29,8,ZD,ADD,(19,2,ZD,DIV,+4),ADD,(15,4,ZD,DIV,+4),       
           M11,LENGTH=8)),                                             
  IFTHEN=(WHEN=INIT,                                                   
  OVERLAY=(45:(37,8,ZD,SUB,(+2,MUL,15,4,ZD)),MOD,+7,LENGTH=8)),       
  IFTHEN=(WHEN=(45,8,SFF,LT,0),OVERLAY=(53:+7,ADD,45,8,SFF,EDIT=(T))),
  IFTHEN=(WHEN=(45,8,SFF,GT,0),OVERLAY=(53:45,8,SFF,EDIT=(T)))         
  OUTFIL IFOUTLEN=20,                                                 
  IFTHEN=(WHEN=INIT,BUILD=(1,4,C'-',5,2,C'-',7,2,53,1)),               
  IFTHEN=(WHEN=(11,1,ZD,EQ,0),OVERLAY=(11:C' SUNDAY   ')),             
  IFTHEN=(WHEN=(11,1,ZD,EQ,1),OVERLAY=(11:C' MONDAY   ')),             
  IFTHEN=(WHEN=(11,1,ZD,EQ,2),OVERLAY=(11:C' TUESDAY  ')),             
  IFTHEN=(WHEN=(11,1,ZD,EQ,3),OVERLAY=(11:C' WEDNESDAY')),             
  IFTHEN=(WHEN=(11,1,ZD,EQ,4),OVERLAY=(11:C' THURSDAY ')),             
  IFTHEN=(WHEN=(11,1,ZD,EQ,5),OVERLAY=(11:C' FRIDAY   ')),             
  IFTHEN=(WHEN=(11,1,ZD,EQ,6),OVERLAY=(11:C' SATURDAY '))             
/*


The output will be of this format

Code:

2008-03-01 SATURDAY   
2008-02-28 THURSDAY   
2009-02-28 SATURDAY   
2009-07-13 MONDAY     
2009-07-14 TUESDAY   
2009-07-15 WEDNESDAY 
Back to top
View user's profile Send private message
Sathish Gurumoorthy

New User


Joined: 12 Feb 2009
Posts: 33
Location: Chennai, India

PostPosted: Wed Jul 15, 2009 5:07 pm    Post subject:
Reply with quote

Thanks Skolusu icon_smile.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Nov 17, 2009 4:43 am    Post subject:
Reply with quote

Sathish Gurumoorthy

With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707, you can use the new date conversion function WEEKDAY like shown below to get the desired results . This job also validates the dates. If an invalid date is found then the output will have asterisks
Code:

//STEP0100 EXEC PGM=SORT                   
//SYSOUT   DD SYSOUT=*                     
//SORTIN   DD DSN=Your input FB 254 byte file,DISP=SHR           
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *         
  OPTION COPY                                           
  INREC IFTHEN=(WHEN=INIT,BUILD=(19,4,BI,ZD,LENGTH=8)), 
  IFTHEN=(WHEN=INIT,BUILD=(1,8,Y4T,TOGREG=Y4T(-),X,     
                           1,8,Y4T,WEEKDAY=CHAR9))       
//*


For complete details on date conversion functions and the other new functions available with the Nov, 2009 DFSORT PTF, see:

http://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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us