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

Extracting month from input file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
umed

New User


Joined: 13 May 2005
Posts: 38

PostPosted: Sat Jan 27, 2007 2:53 am
Reply with quote

Hi,
I have two input files as given below :

Code:

File1:
------
01  03122004  David
02  03311994  Ram
03  03231997  George

File2 :
-------

Report   mon2007


I require an output file which will be same as that of second file except it will replace 'mon' by 3 char text format of month name where month
is determined from position 4-5 file1.

e.g. here if file1 contains 03 then in output file it will be

Code:

Report   Mar2007


if file1 contains 04 then in output file it will be

Code:

Report   Apr2007


Could you suggest any way to achive this rather than using COBOL
program.

Regards,
Amol
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Jan 27, 2007 5:06 am
Reply with quote

Amol,

I don't understand what you want to do. You say

Quote:
here if file1 contains 03 then in output file it will be
Report Mar2007
if file1 contains 04 then in output file it will be
Report Apr2007


But in your example, file1 has 01, 02 and 03, so which one goes in the output file and why - Jan for 01, Feb for 02 or Mar for 03?

You need to clarify the exact "rules" for what you want to do.
Back to top
View user's profile Send private message
umed

New User


Joined: 13 May 2005
Posts: 38

PostPosted: Sat Jan 27, 2007 6:13 am
Reply with quote

Hi,

the input file is as given below :

01 03122004 David
02 03311994 Ram
03 03231997 George

where the dates are 03122004 , 03311994 , 03231997 in mmddyyyy
format where mm is fix which we need to use to determine the text
name of the month in output file.

so output will be

Report Mar2007.

I hope now the requirement is clear.

Regards,
Amol
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Jan 27, 2007 6:57 am
Reply with quote

Hi Amol,

Should the output be 2007 no matter what year is in the input?

What should happen if the input has
Code:
01  03122004  David
     02  03311994  Ram
     03  03231997  George
     04  04151992  James
     05  04232005  Donald 


What kind of process is going to use this input file and the new output file? I ask because i wonder if the original file plus the literal "2007" might work with no new file (if everything isd gong to be 2007)?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Jan 27, 2007 9:15 pm
Reply with quote

Amol,

So the dates in file1 always all have the same month?

What is the RECFM and LRECL of each input file?
Back to top
View user's profile Send private message
umed

New User


Joined: 13 May 2005
Posts: 38

PostPosted: Sun Jan 28, 2007 11:08 am
Reply with quote

yes.. the month in every date would be always fix...
the record ength for first input file would be 250 and
second file has record length = 80.

Regards,
Amol
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sun Jan 28, 2007 10:29 pm
Reply with quote

Amol,

Here's a DFSORT job that will do what you asked for. I assumed mon in file2 was in positions 10-12.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file1 (FB/250)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
* Create DFSORT symbol from the first file1 record as follows:
* Month,'mon'
* where 'mon' is 'Jan' for '01', 'Feb' for '02', etc
  OPTION COPY,STOPAFT=1
  INREC BUILD=(C'Month,''',
    4,2,CHANGE=(3,
      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'),
    C'''',80:X)
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file2 (FB/80)
//SORTOUT   DD  DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
* Use the Month symbol to overlay mon in the file2 record.
  INREC OVERLAY=(10:Month)
/*
Back to top
View user's profile Send private message
umed

New User


Joined: 13 May 2005
Posts: 38

PostPosted: Mon Jan 29, 2007 10:55 pm
Reply with quote

Its working fine.

Thanks a lot for all your help.

Regards,
Amol
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 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
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top