|
View previous topic :: View next topic
|
| Author |
Message |
ashok_ma
New User
Joined: 16 Sep 2009 Posts: 4 Location: Chennai
|
|
|
|
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 |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8798 Location: Welsh Wales
|
|
|
|
| Talk to your scheduling people to see what date variables are defined and in use. |
|
| Back to top |
|
 |
superk
Global Moderator

Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
 |
ashok_ma
New User
Joined: 16 Sep 2009 Posts: 4 Location: Chennai
|
|
|
|
Hi Kevin,
Thanks a lot for our reply!
Can I get the file name build in a dataset?
Thanks! |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| ?? instead of SYSOUT use DD DSN=...? |
|
| Back to top |
|
 |
ashok_ma
New User
Joined: 16 Sep 2009 Posts: 4 Location: Chennai
|
|
|
|
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 |
|
 |
superk
Global Moderator

Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
ashok_ma
New User
Joined: 16 Sep 2009 Posts: 4 Location: Chennai
|
|
|
|
Thanks a lot for the explanation Kevin!!
Thanks Kolusu for your solution!! |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|