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
 

 

Append previous month name to file name

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

New User


Joined: 16 Sep 2009
Posts: 4
Location: Chennai

PostPosted: Mon Jul 12, 2010 5:58 pm    Post subject: Append previous month name to file name
Reply with quote

My Job runs on first Sunday of every month. It extracts the data from database for the last month. I need to FTP the files created with file name appended with previous month name.
Say for example,


If my Job ran on June 4th, then file name should be like 'xxxx.xxx.xxx.May2010' or 'xxxx.xxx.xxx.May'.

Please let me know how previous month can be fetched from current date.

Thanks!
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Mon Jul 12, 2010 6:05 pm    Post subject:
Reply with quote

Talk to your scheduling people to see what date variables are defined and in use.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4649
Location: Raleigh, NC, USA

PostPosted: Mon Jul 12, 2010 7:13 pm    Post subject: Reply to: Append previous month name to file name
Reply with quote

This is what I came up with using DFSORT:

Code:

//STEPXXXX EXEC PGM=SORT                                         
//SYMNAMES DD   *                                               
MNTH,S'&LMON'                                                   
YEAR,S'&LYR4'                                                   
/*                                                               
//SORTIN   DD   *                                               
                                                                 
/*                                                               
//SORTOUT  DD   SYSOUT=*                                         
//SYSOUT   DD   SYSOUT=*                                         
//SYSIN    DD   *                                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(8:MNTH,4:YEAR)),             
    IFTHEN=(WHEN=INIT,OVERLAY=(1:8,2,ZD,ADD,-1,M11,LENGTH=2)),   
    IFTHEN=(WHEN=(1,2,CH,EQ,C'00'),OVERLAY=(1:C'DEC',           
      4,4,ZD,ADD,-1,M11,LENGTH=4)),                             
    IFTHEN=(WHEN=(1,2,CH,EQ,C'01'),OVERLAY=(1:C'JAN')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'02'),OVERLAY=(1:C'FEB')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'03'),OVERLAY=(1:C'MAR')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'04'),OVERLAY=(1:C'APR')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'05'),OVERLAY=(1:C'MAY')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'06'),OVERLAY=(1:C'JUN')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'07'),OVERLAY=(1:C'JUL')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'08'),OVERLAY=(1:C'AUG')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'09'),OVERLAY=(1:C'SEP')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'10'),OVERLAY=(1:C'OCT')),         
    IFTHEN=(WHEN=(1,2,CH,EQ,C'11'),OVERLAY=(1:C'NOV'))           
  OPTION COPY                                                   
  OUTFIL BUILD=(C'PUT //DD:SYSUT1 +',/,                         
                C'OUTPUT.FILENAME.',1,7,C'.TXT')                 
/*                                                               
//*                                                             
Back to top
View user's profile Send private message
ashok_ma

New User


Joined: 16 Sep 2009
Posts: 4
Location: Chennai

PostPosted: Wed Jul 14, 2010 2:42 pm    Post subject:
Reply with quote

Hi Kevin,

Thanks a lot for our reply!
Can I get the file name build in a dataset?

Thanks!
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Jul 14, 2010 3:40 pm    Post subject:
Reply with quote

?? instead of SYSOUT use DD DSN=...?
Back to top
View user's profile Send private message
ashok_ma

New User


Joined: 16 Sep 2009
Posts: 4
Location: Chennai

PostPosted: Wed Jul 14, 2010 3:43 pm    Post subject:
Reply with quote

Thanks Kevin! I have modified the JCL and now I got it in dataset and it is working fine.
Can you pls explain the syntax of the below one
Code:
INREC IFTHEN=(WHEN=INIT,OVERLAY=(8:MNTH,4:YEAR)),
  IFTHEN=(WHEN=INIT,OVERLAY=(1:8,2,ZD,ADD,-1,M11,LENGTH=2)),
  IFTHEN=(WHEN=(1,2,CH,EQ,C'00'),OVERLAY=(1:C'DEC',
    4,4,ZD,ADD,-1,M11,LENGTH=4)),


Thanks a lot for your help!
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4649
Location: Raleigh, NC, USA

PostPosted: Wed Jul 14, 2010 5:03 pm    Post subject: Reply to: Append previous month name to file name
Reply with quote

Well, of course, the variable MNTH is assigned to the value of the system variable &LMON, and the variable YEAR is assigned to the value of the system variable &LYR4.

First, the input record gets overlaid with the value of the current month number (MNTH) in column 8 and the current year (YEAR) in column 4.

Next, column 1 gets the value of column 8 less one. If the resulting value is 00 (so the current month is January), overlay the value of 'DEC' to column 1, and overlay the value of the current year less one.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Jul 14, 2010 10:22 pm    Post subject:
Reply with quote

ashok_ma,

Here is an alternative way of getting the desired results. DATE2 is C'yyyymm' format of current date and subtracting 1 gives you the last month and using FINDREP we change the numeric month name to alphabetic month name.

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                           
A                                                         
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC OVERLAY=(DATE2-1)                                 
  OUTREC FINDREP=(INOUT=(C'01',C'JAN',                     
                         C'02',C'FEB',                     
                         C'03',C'MAR',                     
                         C'04',C'APR',                     
                         C'05',C'MAY',                     
                         C'06',C'JUN',                     
                         C'07',C'JUL',                     
                         C'08',C'AUG',                     
                         C'09',C'SEP',                     
                         C'10',C'OCT',                     
                         C'11',C'NOV',                     
                         C'12',C'DEC'),STARTPOS=5)         
                                                           
  OUTFIL BUILD=(C'PUT //DD:SYSUT1 +',/,                   
                C'OUTPUT.FILENAME.',5,3,1,4,C'.TXT',80:X) 
//*



The output from this job is

Code:

PUT //DD:SYSUT1 +             
OUTPUT.FILENAME.JUN2010.TXT   
Back to top
View user's profile Send private message
ashok_ma

New User


Joined: 16 Sep 2009
Posts: 4
Location: Chennai

PostPosted: Fri Jul 16, 2010 3:30 pm    Post subject:
Reply with quote

Thanks a lot for the explanation Kevin!!
Thanks Kolusu for your solution!!
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 Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts Reg:Displaying the particular month o... bhavana yalavarthi All Other Mainframe Topics 4 Sat Jul 08, 2017 8:13 pm


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