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: 10231
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: 6966
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: 10231
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
No new posts Is the explanation correct? XRST,CHKP Martylin IMS DB/DC 1 Wed Mar 15, 2017 9:26 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm


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