Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Confusion b/w index and subscript Deepak kumar25 Mainframe Interview Questions 7 Thu Aug 31, 2017 6:50 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us