When the input file is empty you would always want your COBOL program to end with MAXCC = 4. How would you achieve this?

Showing Answers 1 - 3 of 3 Answers

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.

  Was this answer useful?  Yes

altehexe74

  • Aug 3rd, 2007
 

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.

  Was this answer useful?  Yes

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

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions