What you are looking for is a Linear Main program. In a Linear Main program, you specify a subprocedure to be your mainline code using the MAIN control spec keyword.
When your mainline is a subprocedure, on-exit works fine.
Have a look here https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/rzasd/cycvslinear.htm
Pre-Sales and Customer Solutions
Profound Logic Software
877-224-7768 Toll Free
November 12-14 . Orlando, FL
Three days of Profound Logic education with our experts!
Register now: info.profoundlogic.com/plus2019
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Greg Wilburn
Sent: Wednesday, June 26, 2019 1:01 PM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: ON-EXIT for a Main program
I really like the on-exit for procedures... is there something similar for programs?
I'd rather not code a subroutine with *INLR=*ON and RETURN (along with my other stuff).
I'm looking to call a procedure anytime I need to end the program. I know I could do:
Just wondering if there is a way to do that in ONE line of code.
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l
Please contact support@xxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com