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

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


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 6966
Location: porcelain throne

PostPosted: Sat Dec 12, 2009 7:05 pm
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
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
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: 6966
Location: porcelain throne

PostPosted: Sun Dec 13, 2009 9:29 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top