Exercise 3: Why RETURN-CODE Still Matters to STEP2 After STEP1 Has Already Ended — Possible Solution ==================================================================== WHAT SETTING RETURN-CODE GENUINELY DOES BEFORE STOP RUN This chapter's own real material shows TXNBATCH executing MOVE 16 TO RETURN-CODE immediately before STOP RUN when WS-FILE-STATUS indicates a real error. RETURN-CODE is a genuine special register - setting it records the program's own real, final exit status at the exact moment it's about to end. WHY THIS VALUE GENUINELY OUTLIVES THE PROGRAM ITSELF Once STOP RUN executes, TXNBATCH as a running program has genuinely finished - but the real value it left in RETURN-CODE doesn't simply vanish along with it. This chapter's own JCL material establishes that the job-management system itself records each step's own real return code as part of that step's outcome, specifically so later steps in the same job can reference it. HOW STEP2'S OWN COND CLAUSE ACTUALLY USES THAT RECORDED VALUE This chapter's own COND example, COND=(4,LT,STEP1), doesn't need STEP1 to still be running at all - it references STEP1's own already- recorded real return code, checked at the moment STEP2 is about to start, well after STEP1 has genuinely finished. The real return code TXNBATCH set via MOVE 16 TO RETURN-CODE is exactly the value STEP2's own COND clause would be comparing against in this scenario. WHY THE TIMING GENUINELY WORKS This is precisely the real point of RETURN-CODE and COND working together across job steps: STEP1 finishes and hands off its own recorded real outcome; STEP2 begins later and consults that already- recorded outcome before deciding whether to run at all. The two steps never need to be running simultaneously for this real handoff to work - the return code is durable information carried forward within the job, not something requiring STEP1 to still be active. ANSWER: TXNBATCH's real MOVE 16 TO RETURN-CODE, executed right before STOP RUN, records the program's own final exit status at the moment it ends. That real value doesn't disappear once STEP1 finishes - the job-management system retains each step's own return code specifically so later steps can reference it. STEP2's own COND clause checks STEP1's already-recorded return code at the point STEP2 is about to start, well after STEP1 has genuinely ended - it was never designed to require STEP1 to still be running, only for STEP1's own real outcome to have already been recorded, which is exactly what setting RETURN-CODE before STOP RUN accomplishes. WHY THIS WORKS AS AN ANSWER ------------------------------ This correctly explains that a step's return code is retained information rather than a live signal requiring the earlier step to still be active, connecting RETURN-CODE's own real purpose directly to how COND consults it later in the same job.