How to end called-from job and return to menu

6680 pts.
Tags:
CL programming
ENDJOB
IBM iSeries
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.


Software/Hardware used:
i5/OS 6.1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 13  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Splat
    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?

    7,305 pointsBadges:
    report
  • WoodEngineer
    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.
    6,680 pointsBadges:
    report
  • philpl1jb

    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;

    50,205 pointsBadges:
    report
  • WoodEngineer
    Phil, yes that would definitely work.  However, it inserts more code into the vendor's program than is ideal. 
    6,680 pointsBadges:
    report
  • Splat
    I appreciate not wanting to modify third-party code (I'm in a similar situation) but there are times when it's necessary.

    What does happen in PGM A after PGM B returns with an error? 
    7,305 pointsBadges:
    report
  • WoodEngineer
    Program A needs to end immediately because a critical piece of control data is missing.  Too bad the vendor did not catch this in their code.
    6,680 pointsBadges:
    report
  • Splat
    If that's the case you're best served by following Phil's suggestion & bring PGM A to an ordered end.
    7,305 pointsBadges:
    report
  • WoodEngineer
    Thank you all for your suggestions.  I agree that the best solution, as several suggest, is to end program A if program B return an error code.
    Looks like I need to give up the dream of only adding a single line of code to the vendor's program.  :-(
    6,680 pointsBadges:
    report
  • philpl1jb

    Put it in a little copy book

    Add the /copy directive to vendor code.

    50,205 pointsBadges:
    report
  • WoodEngineer
    I like the /copy idea.  This is a CL program which I do not believe supports copy statements.
    6,680 pointsBadges:
    report
  • bvining
    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

    Bruce Vining
    6,510 pointsBadges:
    report
  • WoodEngineer
    I will check that out, Bruce.  Thanks for the tips.
    6,680 pointsBadges:
    report
  • ToddN2000
    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.
    11,820 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following