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

cobol arrays with year divided into quarters


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rakesh17684

New User


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

PostPosted: Mon Feb 02, 2009 5:55 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Feb 02, 2009 6:33 pm
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
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: 61
Location: San Diego

PostPosted: Tue Feb 03, 2009 2:52 pm
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: 6966
Location: porcelain throne

PostPosted: Tue Feb 03, 2009 3:46 pm
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 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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top