|
View previous topic :: View next topic
|
| Author |
Message |
abdul
EXPERT
.jpg)
Joined: 28 Jul 2003 Posts: 23 Location: Bangalore,India
|
|
|
|
Here's my requirement:
1. I have a file which has just the date in the format (ccyymmdd)
2. I want to create another file using this which has only the year and the month in the format YYYYMON.
Example:
Input file: 20030820
Output file: 2003AUG.
Is there any tool that I can use to do this. If yes,how ? |
|
| Back to top |
|
 |
yesgokul
New User
Joined: 20 Aug 2003 Posts: 9
|
|
|
|
Rather than searching for a tool you can write one.....
You can use Rexx....
The sample code for this will be like....
/*rexx*/
"Alloc da('Input dataset') f(ipfile) shr reuse"
"execio * ipfile(stem input. finis"
/*All the data in the file will be now in input. array*/
"free f(ipfile)"
do i=1 to input.0
a=words(input.i)
do j=1 to a
if length(strip(word(input.i,a))) = 8 then do
if substr(word(input.i,a),1,4) = 2003 then do
fdate = strip(substr(word(input.i,a),1,8))
if datatype(fdate) = 'NUM' & substr(fdate,5,2) <13 & substr(fdate,7,2) <31 then do
/* check & add change for month here*/
end
end
end
end
end
Let me know if I can be of further help
Thanks
Gokul
end |
|
| Back to top |
|
 |
yesgokul
New User
Joined: 20 Aug 2003 Posts: 9
|
|
|
|
made some mistakes & forgot the imp stuff....
it should be fine now.....
it would be more easier & helpful if u coul give the record length of the file & char position of the date
/*rexx*/
"Alloc da('Input dataset') f(ipfile) shr reuse"
"execio * ipfile(stem input. finis"
/*All the data in the file will be now in input. array*/
"free f(ipfile)"
do i=1 to input.0
a=words(input.i)
output.i=''
do j=1 to a
tmp=word(input.i,j)
if length(strip(word(input.i,j))) = 8 then do
if substr(word(input.i,j),1,4) = 2003 then do
fdate = strip(word(input.i,j))
if datatype(fdate) = 'NUM' & substr(fdate,5,2) <13 & substr(fdate,7,2) <31 then do
/* check & add change for month here*/
/* while u check for month & change it*/
if substr(fdate,5,2) = 01 then do
fdate=substr(fdate,1,4) || 'JAN'
tmp=fdate
/* for all months u can use a select expression here*/
end
end
end
output.i=ouput.i || tmp
end
end
"ALLOC DA('"outdsn"') F(OUTDD) shr reuse"
"EXECIO * DISKW OUTDD(STEM output. finis"
exit
Let me know if i can be of further help....
Thanks
Gokul |
|
| Back to top |
|
 |
abdul
EXPERT
.jpg)
Joined: 28 Jul 2003 Posts: 23 Location: Bangalore,India
|
|
|
|
Hi,
Thanks for your prompt reply.
Considering Mainframe I/O system, REXX program will utilise more resources than a utility program or COBOL program. Since I have more than 10k records to process,I cannot implement REXX program as a solution.
Pls let me know if thr is any utility that I can use. Any idea abt ICETOOL utility ?
Once again thanks a lot for your help.
-Abdul |
|
| Back to top |
|
 |
yesgokul
New User
Joined: 20 Aug 2003 Posts: 9
|
|
|
|
You can use DFSORT or SYNCSORT..... Y ICETOOL when the solution is easier with these.....
Lets assume your 20030819 file is of record length 100 & this 20030819 is in position 51.
2 -51, 0 -52 et all.... so 08 will be in pos 55,56
Sort fields = copy
outrec =(1:1,54,
55:55,2,
change=(3,
C'01',C'JAN',
C'02',C'FEB', continue for all months
C'12',C'DEC'),
nomatch=(C'BAD'), optional....
58:59,100) ==> u r skipping the date here by giving 59,100
Let me know if this is not clear...
Thanks
Gokul |
|
| Back to top |
|
 |
mdtendulkar
Active User

Joined: 29 Jul 2003 Posts: 237 Location: USA
|
|
|
|
Hello Abdul,
You can even write an easytrieve program for this.
FILE INFILE
IN-DATE 01 08 A
IN-DATE-YEAR 01 04 A
IN-DATE-MONTH 05 02 A
IN-DATE-DAY 07 02 A
FILE OUTFILE
OUT-DATE 01 09 A
OUT-DATE-YEAR 01 04 A
OUT-DATE-MONTH 05 03 A
OUT-DATE-DAY 08 02 A
*------------------------------------------------------
JOB INPUT INFILE
*------------------------------------------------------
CASE IN-DATE-MONTH
WHEN '01'
OUT-DATE-MONTH = 'JAN'
WHEN '02'
OUT-DATE-MONTH = 'FEB'
similarly repeat the steps for 12 months
END-CASE
OUT-DATE-YEAR = IN-DATE-YEAR
OUT-DATE-DAY = IN-DATE-DAY
PUT OUTFILE
here output file will contain the date format as specified by you.
Hope this helps
Regards,
Mayuresh Tendulkar |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|