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
 

 

cobol arrays with year divided into quarters

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

New User


Joined: 08 Oct 2006
Posts: 60
Location: San Diego

PostPosted: Mon Feb 02, 2009 5:55 pm    Post subject: cobol arrays with year divided into quarters
Reply with quote

i want to create a a code which will be simple and has less lines of code to declare and implement this kind of array in cobol: ( I am new to the comcept of arrays in COBOL). its some thing like this i will have a year divided into 4 quarters so the decl of array needs to be :

quarter 1 : YYYY-01-01 TO YYYY-03-31
quarter 2 : YYYY-04-01 TO YYYY-06-30
quarter 3 : YYYY-07-01 TO YYYY-09-30
quarter 4 : YYYY-10-01 TO YYYY-12-31

when i get a input as date like : 2006-07-30 , i replace all the YYYY with 2006. can this be implemented efficiently using arrays or is there any other COBOL mechansims besides this. any ideas are welcome and is greatly appreciated.
Thanks
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Mon Feb 02, 2009 6:33 pm    Post subject:
Reply with quote

Do you really need an array? 88 levels might be enough. If arrays are required, you'll need to show more about what you are trying to do before we can help -- I'm sure your problem is clear to you but your problem statement doesn't even indicate what your array looks like.
Back to top
View user's profile Send private message
Debabrata Pruseth

New User


Joined: 11 Dec 2008
Posts: 59
Location: Pune , India

PostPosted: Tue Feb 03, 2009 12:21 pm    Post subject:
Reply with quote

Hi rakesh

As far as i can judge from your query i think the requirement is that for a given input date you have to categorize in which quarter it falls and process accordingly. Try this 88 level PSEUDO code as an alternate to using arrays

In working storage section

01 DATE PIC 9(7)
88 QUARTER1 VALUE 2006001 THRU 2006090
88 QUARTER2 VALUE 2006091 THRU 2006181
88 QUARTER3 VALUE 2006182 THRU 2006273
88 QUARTER4 VALUE 2006274 THRU 2006365

In Procedure Division

Change the input date in YYYY-MM-DD format to julian format . And then move the date to variable DATE . You can then use the 88 levels as desired . Like

IF QUARTER1

**********

IF QUARTER2

**********
Back to top
View user's profile Send private message
rakesh17684

New User


Joined: 08 Oct 2006
Posts: 60
Location: San Diego

PostPosted: Tue Feb 03, 2009 2:52 pm    Post subject:
Reply with quote

finding out which quarter a date belong to is another question. the main purpose is to get a date, extract the year part and assign to all the YYYY's in the 4 quarters as i have mentioned. now why i need an array is that once i assign the dates i need to traverse the array between the 4 quarters reading the start and end date of each quarter.
for now i have declaration like this:
[/code]
01 QTR-YEARS-TBL VALUE 'YYYY-01-01YYYY-03-31'
' YYYY-04-01YYYY-06-30'
' YYYY-07-01YYYY-09-30'
' YYYY-10-01YYYY-12-31'.
03 WS-QTR-YEARS-ID-T OCCURS 4 TIMES INDEXED BY Q-Index.
05 WS-QTR-STR-DT.
07 WS-QTR-DT-YYYY PIC X(04).
07 FILLER PIC X(01) VALUE '-'.
07 WS-QTR-DT-MM PIC X(02).
07 FILLER PIC X(01) VALUE '-'.
07 WS-QTR-DT-DD PIC X(02).
05 WS-QTR-END-DT.
07 WS-QTR-DT-YYYY PIC X(04).
07 FILLER PIC X(01) VALUE '-'.
07 WS-QTR-DT-MM PIC X(02).
07 FILLER PIC X(01) VALUE '-'.
07 WS-QTR-DT-DD PIC X(02).
Code:


am not sure this is optimal way to do this is there any other method
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Feb 03, 2009 3:46 pm    Post subject:
Reply with quote

you need to carry the year with your dates, so that they still make business sense.
I don't understand all the chaos about quarters.

Nice thing about quarters, they always have the same starting and ending DAY/MONTH.

Following-up on what Debabrata said:

use level 88s. we are not dealing with a variable year, only DAY and MONTH,
the level-88s can be coded on every definition of the date that you have.

That means you can determine the qtr for a date without reformating or moving it to a different field.
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 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
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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