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

Tool to change the date format


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abdul

EXPERT


Joined: 28 Jul 2003
Posts: 23
Location: Bangalore,India

PostPosted: Sun Oct 05, 2003 3:25 pm
Reply with quote

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
View user's profile Send private message
yesgokul

New User


Joined: 20 Aug 2003
Posts: 9

PostPosted: Mon Oct 06, 2003 12:31 am
Reply with quote

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
View user's profile Send private message
yesgokul

New User


Joined: 20 Aug 2003
Posts: 9

PostPosted: Mon Oct 06, 2003 12:52 am
Reply with quote

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
View user's profile Send private message
abdul

EXPERT


Joined: 28 Jul 2003
Posts: 23
Location: Bangalore,India

PostPosted: Mon Oct 06, 2003 9:21 am
Reply with quote

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
View user's profile Send private message
yesgokul

New User


Joined: 20 Aug 2003
Posts: 9

PostPosted: Mon Oct 06, 2003 5:34 pm
Reply with quote

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
View user's profile Send private message
mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 237
Location: USA

PostPosted: Tue Oct 07, 2003 10:07 am
Reply with quote

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
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top