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
 

 

COBOL Questions How to set a subscript or index to zero

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: COBOL Questions How to set a subscript or index to zero
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    Post subject: Re: COBOL Questions.
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    Post subject:
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    Post subject: Re: COBOL Questions.
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    Post subject: Re: COBOL Questions How to set a subscript or index to zero
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 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 setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm


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