* Dia da Semana 77 WK-DIAS PIC 9(008) BINARY. 77 DATA-DESEJADA PIC 9(008). * AAAAMMDD 77 WK-SOBRA PIC 9(008) BINARY. COMPUTE WK-DIAS = FUNCTION INTEGER-OF-DATE(DATA-DESEJADA) COMPUTE WK-SOBRA = (FUNCTION REM (WK-DIAS 7)) + 1 SE WK-SOBRA FOR 1 = DOMINGO 2 = SEGUNDA 3 = TERÇA 4 = QUARTA 5 = QUINTA 6 = SEXTA 7 = SÁBADO COMPUTE WS-DIA-SEMANA = 1 + ( FUNCTION REM ( FUNCTION INTEGER-OF-DATE ( WS-SUA-DATA ), 7 ) ) EVALUATE WS-DIA-SEMANA WHEN 1 MOVE "DOMINGO" TO WS-CAMPO WHEN 2 MOVE "SEGUNDA" TO WSCAMPO WHEN 3 MOVE "TERCA " TO WSCAMPO WHEN 4 MOVE "QUARTA " TO WSCAMPO WHEN 5 MOVE "QUINTA " TO WSCAMPO WHEN 6 MOVE "SEXTA " TO WSCAMPO WHEN 7 MOVE "SABADO " TO WSCAMPO ENDEVALUATE
tem outro jeito de pegar o dia da semana, porém é o dia corrente. Pedro Junior Cobol MF + POWER + NET IDENTIFICATION DIVISION. PROGRAM-ID. DIASEM. * SABER DIA DA SEMANA. AUTHOR. PJR-DESENVOLVIMENTO CONSULTORIA EM INFORMATICA S/C LTDA. DATE-WRITTEN. 08/11/2007. DATE-COMPILED. 08/11/2007. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. DECIMAL-POINT IS COMMA. INPUT-OUTPUT SECTION. FILE-CONTROL. DATA DIVISION. FILE SECTION. WORKING-STORAGE SECTION. 01 DIASEMANA PIC X(10) VALUE SPACES. 01 DIASEMR REDEFINES DIASEMANA. 02 D1 PIC X(02). 02 D2 PIC X(08).
PROCEDURE DIVISION. INIC1. DISPLAY (01, 01) ERASE. ACCEPT DIASEMANA FROM DAY-OF-WEEK. IF D1 = "1" MOVE "SEGUNDA" TO D2. IF D1 = "2" MOVE "TERCA" TO D2.
IF D1 = "3" MOVE "QUARTA" TO D2. IF D1 = "4" MOVE "QUINTA" TO D2. IF D1 = "5" MOVE "SEXTA" TO D2. IF D1 = "6" MOVE "SABADO" TO D2. IF D1 = "7" MOVE "DOMINGO" TO D2. DISPLAY D1 " " D2. EXIT PROGRAM STOP RUN.
No MF é possível pegar o dia da semana assim: 77 dia pic 9. procedure division. accept dia from day-of-week evaluate dia when 0 stop "domingo" when 1 stop "segunda" ..... end-evaluate goback.