IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COBOL Questions How to set a subscript or index to zero


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mf_user
Currently Banned

New User


Joined: 05 Jan 2006
Posts: 47

PostPosted: Thu Apr 20, 2006 6:48 pm
Reply with quote

Hi,

I've two questions.

1). How to set a subscript or index to zero AUTOMATICALLY when it reaches it's max count. We should not use any "move 0 to subscript" or "set index to 0" in the code. Is it possible?

2). How to execute a program on Friday's only with COBOL logic? Is this possible too?

Any help? Any sample codes?
Back to top
View user's profile Send private message
BruceC

New User


Joined: 14 Mar 2006
Posts: 6
Location: Los Angeles

PostPosted: Fri Apr 21, 2006 4:09 am
Reply with quote

How to execute only on Friday...
Does this mean the program starts, discovers it is not Friday and halts?

Or does it mean the program starts, discovers its Friday and starts another COBOL program, perhaps a called program?

Or does it mean a COBOL program that does not have to run to find if it is Friday, perhaps by being in a load library that is run from another job?

Mainframe COBOL programs running under LE can use LE services to find the day. It is rarely done since a job may start on one day and end on another, but the day can be found.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Apr 21, 2006 7:44 am
Reply with quote

Not sure what you mean by "max count".
If you mean it's pic 99 and it's reached "99" just bump it by 1. That resets it to zero.
Back to top
View user's profile Send private message
mf_user
Currently Banned

New User


Joined: 05 Jan 2006
Posts: 47

PostPosted: Fri Apr 21, 2006 8:44 am
Reply with quote

Thanks mmwife. I tried it and it worked the way intended.

BruceC, sorry for the confusion. I should produce the output files only on Friday. Other day, it should end with a return code of 200.

Any idea?
Back to top
View user's profile Send private message
BruceC

New User


Joined: 14 Mar 2006
Posts: 6
Location: Los Angeles

PostPosted: Fri Apr 21, 2006 10:01 pm
Reply with quote

I find the examples in the COBOL and LE manuals incomplete as the important feedback code is changed to MOITTED. So, here is a code sample.

Test environment: z/OS 1.4 compiler: IBM Enterprise COBOL for z/OS

Code:


       ID DIVISION.
       PROGRAM-ID. TESTFUNC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.

       01  YYYYMMDD              PIC  9(08).
       01  SHOW-DAY              PIC  ZZZZZZZZ9.

       01 CEEDATE-INPUT.
           05 CEEDATE-INPUT-LEN COMP PIC S9(04) VALUE +8.
           05 CEEDATE-INPUT-DATE     PIC 9(08)  VALUE 0.

       01 CEEDATE-OUTPUT.
           05 CEEDATE-OUTPUT-LEN COMP PIC S9(04) VALUE +8.
           05 CEEDATE-OUTPUT-DATE     PIC X9(08) VALUE 'YYYYMMDD'.

       01 CEEDATE-LILIAN        BINARY PIC S9(08) VALUE +0.
       01 CEEDATE-FEEDBACK.
           05 CEEDATE-RC        COMP PIC S9(04) VALUE +8.
           05 CEEDATE-MSG       COMP PIC S9(04) VALUE +8.
           05                        PIC  X(08) VALUE ' '.

       01 CEEDATE-DAYNUM  BINARY PIC S9(09) VALUE +0.
           88 FRIDAY                        VALUE +6.

       PROCEDURE DIVISION.
      * Function:  Display today's date in Gregorian format      *
           MOVE FUNCTION CURRENT-DATE(1:8) TO YYYYMMDD
           DISPLAY 'YYYYMMDD: ' YYYYMMDD

           MOVE YYYYMMDD TO CEEDATE-INPUT-DATE

      * Function:  Find today's Lilian date (integer format)     *
           CALL 'CEEDAYS' USING
                 CEEDATE-INPUT,
                 CEEDATE-OUTPUT,
                 CEEDATE-LILIAN,
                 CEEDATE-FEEDBACK
           END-CALL

           IF CEEDATE-FEEDBACK > ZERO
                DISPLAY 'CEEDAYS error converting '  CEEDATE-INPUT-DATE
                MOVE +12 TO RETURN-CODE
                GOBACK
           END-IF

      * Function:  use CEEDYWK to return the day of the week
           CALL 'CEEDYWK' USING
                 CEEDATE-LILIAN,
                 CEEDATE-DAYNUM,
                 CEEDATE-FEEDBACK
           END-CALL

           IF CEEDATE-FEEDBACK > ZERO
                DISPLAY 'CEEDYWK error converting Lilian date'
                MOVE +12 TO RETURN-CODE
                GOBACK
           END-IF

           IF FRIDAY
                DISPLAY 'Friday processing started'
           ELSE
                MOVE +200 TO RETURN-CODE
                GOBACK
           END-IF

           GOBACK.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top