Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Finding the day for the date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
sriram.mukundan

New User


Joined: 20 Nov 2007
Posts: 20
Location: chennai

PostPosted: Fri Jun 13, 2008 10:24 am    Post subject: Finding the day for the date
Reply with quote

This topic is already been discussed. Find what day if we provide the date. I'm not getting the proper day for the day. Please help me.

Code:

IDENTIFICATION DIVISION.
                            PROGRAM-ID. DAYFIND.
                            DATA DIVISION.
                            WORKING-STORAGE SECTION.
                            01 Y PIC 9(4).
                            01 M PIC 9(2).
                            01 D PIC 9(2).
                            01 A PIC 99 VALUE ZERO.
                            01 B PIC 9 VALUE ZERO.
                            01 C PIC 99 VALUE ZERO.
                            01 F VALUE "12060708091011".
                                      05 FF PIC 99 OCCURS 7.
                            01 E PIC 9999 VALUE 0012.
                            01 T PIC 9999 VALUE ZERO.
                            01 I PIC 9 VALUE 1.
                         *****A MCMILLAN PRODUCT. PLEASE DON'T MISUSE!
                            PROCEDURE DIVISION.
                            0001A.
                                     DISPLAY "ENTER 4 DIGIT YEAR >=0001 & <=9999".
                                     ACCEPT Y.
                            0002A.
                                     DISPLAY "ENTER MONTH(INTEGER)".
                                     ACCEPT M.
                                     IF M < 1 OR > 12 DISPLAY "INVALID MONTH" GO 0002A.
                            0003A.
                                     DISPLAY "ENTER DATE(INTEGER)".
                                     ACCEPT D.
                                     IF D < 1 OR > 31 DISPLAY "INVALID DATE" GO 0003A.
                                     MOVE D TO C.
                            0000X.
                                    COMPUTE A = FF ( I ).
                                    IF E = Y GO 0000Y.
                                    ADD 1 TO I.
                                    IF I > 7 COMPUTE I = 1.
                                    DIVIDE E BY 4 GIVING T REMAINDER B.
                                    IF E < Y AND B = 0 ADD 1 TO I.
                                    IF I > 7 COMPUTE I = 1.
                                    ADD 1 TO E.
                                    GO 0000X.
                              0000Y.
                                     IF B = 0 AND M > 2 ADD 1 TO A.
                                     IF M = 1
                                     ADD A TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 2
                                     ADD A 3 TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 3
                                     ADD A 3 TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 4
                                     SUBTRACT 1 FROM A
                                     ADD A TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 5
                                     ADD A 1 TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 6
                                     ADD A 4 TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 7
                                     SUBTRACT 1 FROM A
                                     ADD A TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 8
                                     ADD A 2 TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 9
                                     SUBTRACT 2 FROM A
                                     ADD A TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 10
                                     ADD A TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 11
                                     ADD A 3 TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE IF M = 12
                                     SUBTRACT 2 FROM A
                                     ADD A TO D
                                     DIVIDE D BY 7 GIVING A REMAINDER B
                                     ELSE DISPLAY "COBOL FAILED".
                                     DISPLAY Y "/" M "/" C " IS:".
                                     IF B = 0 DISPLAY "SUNDAY"
                                     ELSE IF B = 1 DISPLAY "MONDAY"
                                     ELSE IF B = 2 DISPLAY "TUESDAY"
                                     ELSE IF B = 3 DISPLAY "WEDNESDAY"
                                     ELSE IF B = 4 DISPLAY "THURSDAY"
                                     ELSE IF B = 5 DISPLAY "FRIDAY"
                                     ELSE IF B = 6 DISPLAY "SATURDAY"
                                     ELSE DISPLAY "COBOL RUNTIME ERROR".
                                     STOP RUN.


Some questions are listed below.

1) Need to know why this value is assigned to this variable. and why not someother value. and also what this value represents
Code:

 01 F VALUE "12060708091011". 
      05 FF PIC 99 OCCURS 7.


2) What variable that A,B,C,E,T represents?

3) Logic I want to know.

I have pasted the Sysout of the day which I tried yesterday. Please look into it

THE YEAR IS 2008
MONTH 06
DATE(INTEGER) 12
2008/06/12 IS:
WEDNESDAY

THIS IS WRONG, it should show Thursday. I don't know where I have to change the code to get the proper day for the day since I don't understand the logic well.
Back to top
View user's profile Send private message
References
dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 1618
Location: germany

PostPosted: Fri Jun 13, 2008 11:42 am    Post subject:
Reply with quote

Suggest that you reformat your post using BBcode, here is a link to explain: http://ibmmainframes.com/faq.php?mode=bbcode

your code is not easy to follow, the way it is presented here. use CODE /CODE in order to preserve spacing.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 3081
Location: italy

PostPosted: Fri Jun 13, 2008 11:50 am    Post subject: Reply to: Doubt in Finding the day for the date
Reply with quote

simpler if You used integer-of-date

http://www.ibmmainframes.com/viewtopic.php?t=29344&highlight=integerofdate
http://www.ibmmainframes.com/viewtopic.php?t=28353&highlight=integerofdate
Back to top
View user's profile Send private message
sriram.mukundan

New User


Joined: 20 Nov 2007
Posts: 20
Location: chennai

PostPosted: Fri Jun 13, 2008 3:08 pm    Post subject:
Reply with quote

I will look in to this..
thank u very much !!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1