Scenario: From a menu, user runs vendor-supplied program A. PGM A calls user written PGM B for data validation. If program B discovers invalid data, it will issue an error message, then end itself and PGM A, returning the user to the menu.
Problem: How can PGM B end itself and PGM A without also ending the menu program? I tried ENDJOB but it ends everything and returns the user to the sign on screen.
ENDJOB will end the current job, in this case the job under which the programs are running.
If the menu program is being ended, I would suspect the process ending PGM A forces an abnormal end of high severity. If you can access the code of PGM A, find out why it's failing so dramatically.
Is there a particular reason for forcing PGM A to end when PGM B reports an error?
My goal is to add the least amount of code possible to the vendor's program. We find that minimizes pain and suffering when updates arrive.
I would like to add one line of code to the vendor's program (A) to call my program (B) which will perform some additional validation. If my program (B) discovers an error, it want to also end the vendor's program (A) and return the user to the vendor's menu.
1) If you're reasonably current on releases then CL does support the INCLUDE command
2) Assuming the menu you want to return to handles/monitors for failures in the called program (escapes) then your program B could send an escape message to the call stack entry prior to the vendor program A. That should end both your program B and the vendor program A
My only other suggestion would be to notify the vendor of the issue and hope they fix it in a future upgrade/release. We have a 3rd party package as well and updates are a pain when you have a lot of customization. I feel your pain. We do have a contact to report problems. Sometimes they will send us patch code then they will incorporate it into their future upgrade.
Discuss This Question: 13  Replies
If the menu program is being ended, I would suspect the process ending PGM A forces an abnormal end of high severity. If you can access the code of PGM A, find out why it's failing so dramatically.
Is there a particular reason for forcing PGM A to end when PGM B reports an error?
Assuming that Program A is RPGLE ..
This seems way to easy.
Program A calls program B passes enditNow bolean
EnditNow = *off;
Call PgmB EnditNow;
If EnditNow;
*inlr = *on;
Retrun;
Endif;
What does happen in PGM A after PGM B returns with an error?
Put it in a little copy book
Add the /copy directive to vendor code.