Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 6970
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: 6970
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 to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts Comparision with current time arunsoods DFSORT/ICETOOL 5 Thu Nov 09, 2017 10:37 am
This topic is locked: you cannot edit posts or make replies. Comparing current time with the time ... arunsoods SYNCSORT 1 Mon Oct 30, 2017 4:07 pm
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us