Recommendations

Consider moving the cycle-main procedure logic into a subprocedure, and making the module a NOMAIN module, or changing the cycle-main procedure to be a linear-main procedure.

If you mix cycle-main procedures with exported subprocedures, ensure that your cycle-main procedure is called first, before any subprocedures.

Do not allow cycle-main-procedure initialization to happen more than once, since this would reinitialize your global data. The best way to prevent reinitialization is to avoid using the LR indicator.

If you want to call your cycle-main procedure intermixed with your subprocedures, you should declare all your files as USROPN and not use UDS data areas. Open files and lock data areas as you need them, and close files and unlock data areas when you no longer need them. You might consider having a subprocedure in the module that will close any open files and unlock any locked data areas.