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

Append previous month name to file name


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Mon Jul 12, 2010 6:05 pm
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

Global Moderator


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

PostPosted: Mon Jul 12, 2010 7:13 pm
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
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

Superior Member


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

PostPosted: Wed Jul 14, 2010 3:40 pm
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
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

Global Moderator


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

PostPosted: Wed Jul 14, 2010 5:03 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top