GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Mainframe  >  COBOL
Go To First  |  Previous Question  |  Next Question 
 COBOL  |  Question 115 of 159    Print  
When the input file is empty you would always want your COBOL program to end with MAXCC = 4. How would you achieve this?

  
Total Answers and Comments: 3 Last Update: November 22, 2007     Asked by: pinky 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: sai mainframes
 

hi Pinky,

just follow the below code. i think it will work for it.

     ws-first-time pic  x(01)   value 'y'. 
     ws-end-of-file     pic     x(01)   value 'n'.


 open input-file.

 perform read-para
           until ws-end-of-file = 'y'.

   close input-file.

 stop run.


read-para.
**********

 read input-file
   at end move 'y' to ws-end-of-file

        if ws-end-of-file = 'y'
           if ws-first-time = 'y'
       move '4'  to   RETURN-CODE
    end-if
 else
    move 'n'      to  ws-first-time
 end-if



Regards
Saikrishna Yadav Jinka
jinka.saikrishna@gmail.com



Above answer was rated as good by the following members:
i_virus
August 02, 2007 09:51:28   #1  
sunayana.sarangi Member Since: August 2007   Contribution: 7    

RE: When the input file is empty you would always want...

In the cobol code, chk if the i/p file is empty. If yes, then pass '4' to the variable RETURN-CODE and GOBACK. Also make sure that the return code of all other steps of the JCL executing this pgm should be less than 4. Thus the RC of the step for i/p file check will become the MAXCC for the entire pgm.


 
Is this answer useful? Yes | No
August 03, 2007 17:27:40   #2  
altehexe74 Member Since: April 2007   Contribution: 12    

RE: When the input file is empty you would always want...
after open/read/close the file, you can check the file-status. (define status-variables in working storage) Dependent on this value (will be set automatic), you can set Returncode.

BUT:
I guess, it´s easier to define in internal returncode by yourself. Than make a senseful errorhandling. Otherwise it can happen sth beside your empty file and then the system´s returncode will be overwritten. So program does not end with MAXCC = 4 although your inputfile is empty.

 
Is this answer useful? Yes | No
November 22, 2007 04:57:18   #3  
sai mainframes Member Since: November 2007   Contribution: 13    

RE: When the input file is empty you would always want...

hi Pinky,

just follow the below code. i think it will work for it.

     ws-first-time pic  x(01)   value 'y'. 
     ws-end-of-file     pic     x(01)   value 'n'.


 open input-file.

 perform read-para
           until ws-end-of-file = 'y'.

   close input-file.

 stop run.


read-para.
**********

 read input-file
   at end move 'y' to ws-end-of-file

        if ws-end-of-file = 'y'
           if ws-first-time = 'y'
       move '4'  to   RETURN-CODE
    end-if
 else
    move 'n'      to  ws-first-time
 end-if



Regards
Saikrishna Yadav Jinka
jinka.saikrishna@gmail.com


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape