Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Tool to change the date format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Tool to change the date format
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 238
Location: USA

PostPosted: Tue Oct 07, 2003 10:07 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us