Cobol/COBOL

Advertisement


Eddie wrote at 2012-01-25 18:40:48
Here's the CODE:





===============================================================

01  DAY-OF-WEEK          PIC 9   VALUE ZERO.

      88 TODAY-IS-MONDAY          VALUE 1.

      88 TODAY-IS-TUESDAY          VALUE 2.

      88 TODAY-IS-WEDNESDAY          VALUE 3.

      88 TODAY-IS-THURSDAY          VALUE 4.

      88 TODAY-IS-FRIDAY          VALUE 5.

      88 TODAY-IS-SATURDAY          VALUE 6.

      88 TODAY-IS-SUNDAY          VALUE 0.



01 CURR-DATE          PIC X(8).

01 HCK-CCYYMMDD  

     REDEFINES CURR-DATE     PIC 9(8).





MOVE FUNCTION CURRENT-DATE TO CURR-DATE.          

COMPUTE  DAY-OF-WEEK  =  FUNCTION REM          

       (FUNCTION INTEGER-OF-DATE (HCK-CCYYMMDD), 7)

END-COMPUTE.          

==============================================================



Eddie


Heera Nand Khatri wrote at 2013-03-16 08:05:34
Here is a program to retrieve day of week.

PROCESS EXTDSPOPT (NODFRWRT)  DATETIME.

IDENTIFICATION DIVISION.          

PROGRAM-ID. DOW.          

AUTHOR. HEERA NAND KHATRI.          

REMARKS. Day Of Week.          

ENVIRONMENT DIVISION.          

CONFIGURATION SECTION.          

INPUT-OUTPUT SECTION.          

FILE-CONTROL.          

DATA DIVISION.          

WORKING-STORAGE SECTION.          

01  ANS          PIC 9(07).          

01  RM          PIC 9(01).          

01  WS-DT        PIC X(10).          

01  WS-DT-R      REDEFINES WS-DT.      

   05 YY        PIC 9(04).          

   05 FILLER    PIC X(01).          

   05 MM        PIC 9(02).          

   05 FILLER    PIC X(01).          

   05 DD        PIC 9(02).          

01  WS-DT8       PIC 9(08).          

01  WS-DT8-R REDEFINES WS-DT8.          

   05 YY        PIC 9(04).          

   05 MM        PIC 9(02).          

   05 DD        PIC 9(02).          

01  WEEK-TBL.          

   02 FILLER PIC X(09) VALUE "MONDAY".      

   02 FILLER PIC X(09) VALUE "TUESDAY".     

   02 FILLER PIC X(09) VALUE "WEDNESDAY".   

   02 FILLER PIC X(09) VALUE "THURSDAY".    

   02 FILLER PIC X(09) VALUE "FRIDAY".      

   02 FILLER PIC X(09) VALUE "SATURDAY".    

   02 FILLER PIC X(09) VALUE "SUNDAY".      

01  WEEK-TBL-R REDEFINES WEEK-TBL.          

    02 WEEK-DAY   OCCURS 7 PIC X(09).          

01  WS-DUM          PIC X(01).          

LINKAGE SECTION.          

01  LK-DATE      FORMAT DATE.          

01  LK-DAY       PIC X(09).          

PROCEDURE DIVISION USING LK-DATE LK-DAY.          

BEGIN.          

    MOVE LK-DATE TO WS-DT.          

    MOVE CORR WS-DT-R TO WS-DT8-R.          

    COMPUTE ANS = FUNCTION INTEGER-OF-DATE(WS-DT8).   

    DIVIDE ANS BY 7 GIVING ANS REMAINDER RM.          

    IF RM = ZERO MOVE 7 TO RM.          

    MOVE WEEK-DAY(RM) TO LK-DAY.          

*    DISPLAY WEEK-DAY(RM).          

*    ACCEPT WS-DUM.          

    EXIT PROGRAM.  


Related Articles

Cobol

All Answers


Answers by Expert:


Ask Experts

Volunteer


David Nelson

Expertise

I specialize in IBM z/OS COBOL and MicroFocus OCDS and Server Express non-OOP. Design, coding and performance oriented questions. Also linking to IBM Assembler from COBOL. Because the rules change with version, please state language level, version and platform environment. See CICS for questions about CICS.

Experience

Over 35 years working with COBOL on multiple platforms and OS.

Education/Credentials
Graduate, New York School of Computer Technology.

Past/Present Clients
Major Financial Institutions, State of NC (DHHS), Manufacturing, Financial services, Warehousing, Software developer and others.

©2016 About.com. All rights reserved.