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
 

 

Explanation about Day-of-week in cobol?

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

New User


Joined: 16 Oct 2007
Posts: 15
Location: bangalore

PostPosted: Tue Mar 25, 2008 5:58 pm    Post subject: Explanation about Day-of-week in cobol?
Reply with quote

Hi,

some one can help me out.......

the problem is

05 WS-INPUDATE PIC 9(08) VALUE ZEROS.

COMPUTE WS-DAY = FUNCTION MOD (FUNCTION
INTEGER-OF-DATE (WS-INPUDATE)7).


could you pls explain this how it works exactly.......
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Mar 25, 2008 6:01 pm    Post subject: Reply to: Explanation about Day-of-week in cobol?
Reply with quote

integer_of_date returns an integer which has the peculiarity that
the remainder of the division by 7 ( modulus function )
gives the number of the day of the week 0-subday .... 6-saturday
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Mar 25, 2008 6:07 pm    Post subject:
Reply with quote

also need to populate WS-INPUDATE with a valid date.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Mar 25, 2008 6:35 pm    Post subject:
Reply with quote

Hi,

What's the purpose of the "7" in your COMPUTE stmt?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 25, 2008 6:47 pm    Post subject:
Reply with quote

mmwife wrote:
Hi,

What's the purpose of the "7" in your COMPUTE stmt?



Quote:
the remainder of the division by 7 ( modulus function )
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 25, 2008 6:57 pm    Post subject: Explanation about Day-of-week in cobol?
Reply with quote

You can eliminate the MOD FUNCTION by doing -

Code:

03  WS-INTEGER-OF-DATE PIC  S9(09) COMP-3.
03  WS-REMAINDER       PIC  S9(03) COMP-3.
03  WS-JUNK            PIC  S9(09) COMP-3.
03  WS-DATE            PIC   9(08) VALUE 20080325.

COMPUTE WS-INTEGER-OF-DATE = FUNCTION INTEGER-OF-DATE(WS-DATE).
DIVIDE  WS-INTEGER-OF-DATE BY 7 GIVING WS-JUNK
                           REMAINDER WS-REMAINDER.

IF  WS-REMAINDER = ZERO
    MOVE 7 TO WS-REMAINDER
END-IF.

At this point, the value in WS-REMAINDER will be in the range of 1 through 7 (Monday through Sunday). In this example, it will equal 2.

HTH....

Regards,

Bill
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 25, 2008 7:03 pm    Post subject:
Reply with quote

If you divide by 7 the remainder must be in the range of 0 through 6!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Mar 25, 2008 7:07 pm    Post subject: Reply to: Explanation about Day-of-week in cobol?
Reply with quote

Code:
IF  WS-REMAINDER = ZERO
    MOVE 7 TO WS-REMAINDER
END-IF.


Quote:
f you divide by 7 the remainder must be in the range of 0 through 6!


fast fingers or fat eyes icon_biggrin.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Mar 25, 2008 8:38 pm    Post subject:
Reply with quote

Quote:
If you divide by 7 the remainder must be in the range of 0 through 6!

What Bill meant was that AFTER the IF stmt WS-REMAINDER will contain 1 thru 7 (Mon thru Sun).
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