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
 

 

how to get current month and last 11 months in cobol?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sskpen

New User


Joined: 30 Aug 2006
Posts: 14

PostPosted: Sat Dec 12, 2009 3:16 pm    Post subject: how to get current month and last 11 months in cobol?
Reply with quote

I got a requirement where I need to read a field in file in MM/YY format and I should get all the past preceding 11 months considering the month in the file(MM/YY) as current month can someone give logic for this?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Sat Dec 12, 2009 7:05 pm    Post subject:
Reply with quote

define a table as:
Code:

01 DUH-SUBSCRIPTS.
   05  DUH-FIRST-MONTH    PIC S9(04) COMP.
   05  DUH-LAST-MONTH     PIC S9(04) COMP.


01 DUH-MONTH-DEFINITION.
   05  FILLER             PIC X(24)
       VALUE  '121110090807060504030201'.
   05  FILLER             PIC X(24)
       VALUE  '121110090807060504030201'.

01 DUH-MONTH-TAB
   REDEFINES
   DUH-MONTH-DEFINITION.
   05  DUH-MONTH-ITEM     OCCURS 24 TIMES.
                          PIC X(02).



find your MM in the DUH-MONTH-ITEM -
set DUH-FIRST-SUBSCRIPT to that occurance.
ADD 11 TO DUH-FIRST-SUBCRIPT GIVING DUH-LAST-SUBSCRIPT

now, your range is
current month - DUH-FIRST-SUBSCRIPT
thru
preceding - DUH-LAST-SUBSCRIPT
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sun Dec 13, 2009 3:57 am    Post subject:
Reply with quote

Fine as long as the current month is always 11 or 12, what happens when the range includes a year change? And that only gives you 11 months not the current + previous 11 months.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sun Dec 13, 2009 6:16 am    Post subject:
Reply with quote

Correction that does give you a full 12 months but there is still the problem with the year. I guess some people have all ready forgotten the problems with 2 digit years.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Sun Dec 13, 2009 9:29 am    Post subject:
Reply with quote

well, he did not say he wanted year,
but as soon as the month is larger than the last, then subtract 1 from the year.
Back to top
View user's profile Send private message
sskpen

New User


Joined: 30 Aug 2006
Posts: 14

PostPosted: Mon Dec 14, 2009 7:05 pm    Post subject:
Reply with quote

Thanks for your quick response
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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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