Adding the values of the table using [SEARCH STATEMENT]



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Adding the values of the table using [SEARCH STATEMENT]

Postby Rayster » Sat Jan 08, 2011 10:10 pm

Hello guys! It's been a while that I am learning cobol .

Now, I need a little logic help. You see, I need to create a routine to add the values of DAYS depending on the input MONTH. I already got the idea of the Leap Year. Only the DAYS and MONTHS left.

Let's say I have a table that redefines my other variables '31283130313030313130313031' occurs 2, then the values of each number like, 31 will be added until 12 times is met.


or if there's a more efficient way to add the DAYS of the YEAR to an INPUT MONTH.

Let's say Feb 1 is equal to 32 days if it's not a leap year. Thanks!
Rayster
 
Posts: 8
Joined: Mon Dec 20, 2010 9:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding the values of the table using [SEARCH STATEMENT]

Postby Robert Sample » Sat Jan 08, 2011 10:18 pm

What is the problem you're trying to solve? Converting a date to integer using the INTEGER-OF-DATE FUNCTION, adding the right number of days, then converting back to a date using the DATE-OF-INTEGER FUNCTION is usually the best way to increment dates since you don't have to worry about the varying number of days per month.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Adding the values of the table using [SEARCH STATEMENT]

Postby Rayster » Sun Jan 09, 2011 9:26 pm

Alright. I already figured it out again by myself. I use Perform varying from that table until it reaches the specified month given. No sense asking this question on Yahoo Answer as people will reply "Are you still living on the current time?" lol :D
Rayster
 
Posts: 8
Joined: Mon Dec 20, 2010 9:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding the values of the table using [SEARCH STATEMENT]

Postby dick scherrer » Sun Jan 09, 2011 10:37 pm

Hello,

Well, you've chosen a "solution" that will most often use more system resources and require more code be maintained than if you'd have used the method Robert suggested. . .

Your "subject" mentions SEARCH, but your last post mentions "perform varying".

Alright. I already figured it out again by myself.
If you are going to prefer your learning-attempt solutions over experienced suggestions you might want to spend much more time on "your" solution and not be bothered by our suggestions that for whatever reason you prefer not to use. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Adding the values of the table using [SEARCH STATEMENT]

Postby Rayster » Tue Jan 11, 2011 8:42 pm

^ Hello sir! I already noted the function as I am learning cobol. I'll try it next time as your suggestions helps me. :)
Rayster
 
Posts: 8
Joined: Mon Dec 20, 2010 9:07 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post