I have CLP and a cobol program. CL program calls the cobol program in Batch mode by doing SBMJOB. The cobol program processing 1000 records from a database file. If it founds errorneous record in the time of processing, then it stops processing with a system generated error massage and control go backs to CL program. My requirement is to trap this errorneous record and also the system generated error massage and make a report with this information and resume the processing of records from very next of the errorneous record that was traped. Please help. My mail Id is mithunpaul123@gmail.com.
Please clarify what you mean by "calls the cobol program in Batch mode", "it stops processing with a system generated error massage" and "control go backs to CL program".
If you used SBMJOB to run the COBOL program, then control never left your CL program. Therefore, control can't "go back" to your CL program. Control never leaves your CL program. The execution of the COBOL program is totally unrelated to your remaining CL instructions.
The SBMJOB executes and that causes a request to call the COBOL program to be placed on a job queue. The COBOL might run practically immediately, it might wait on the queue for seconds, or minutes or forever.
Regardless of whether or not the COBOL runs and whether not the COBOL succeeds, your CL doesn't wait. Control has never left. The next instructions in your CL are already running and probably have completed long before the COBOL will have a chance to start. The CL instructions that follow the SBMJOB have no relationship to the submitted job at all.
So, please review your CL and rephrase your question.
If you want your CL to respond to errors in the COBOL program, you can't use SBMJOB. Your CL will need to call the COBOL directly.
(There are ways around that, but you seem to need a lot more experience before attempting more complex operations.)
Tom
And what you are describing is simple data verification - which can be done within the COBOL program. You read the record, verify its data, and based on what your find either process it or write it to an error report and reject it. No need for system messages - or leaving the COBOL program. What you describe is way too complicated for the results you desire.
Note that a MONMSG in the CL will have no connection to any error messages that might be signaled in a submitted job. A MONMSG can follow the SBMJOB command and react to errors in the SBMJOB command itself, but those errors will be totally unrelated to the COBOL instructions.
Tom
Its been a long time since I programmed in COBOL but I believe the same file handling features are available that are in RPG. Based on that assumption, can you add a file control data structure to your COBOL program - this will give you lots of good info about the file you are inspecting. It should also return the record number from the file in question. You could pass that number back to your CL along with the error number, which is also available in the finl control data structure. Then your CL program could take action such as displaying a message with the record number and error number.
can you add a file control data structure to your COBOL program...
About the only related element for COBOL is FILE-STATUS which is generally a two-character field. (I think it can be up to 6 bytes for some file types.) AFAIK, there's nothing in COBOL like the RPG INFDS. Each language is free to make available whatever that group chooses. I'd guess that the COBOL group is hampered by (1) having to adhere to COBOL standards while (2) serving 15-20% or less of the number of RPG developers.
Tom
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 6  Replies