Live Test: Module Delete करने के बाद Program चलेगा या नहीं? | AS400 RPGLE

The "Why": Bind by Copy vs. Bind by Reference When you compile objects in AS400, the system handles the code in two different ways depending on what you are binding: *1. Modules (MODULE) = Bind by Copy If you bind a Module directly into your main program using CRTPGM, the compiler physically copies the subprocedure's code into your final program object. If you delete the original *MODULE object later, your program will still work perfectly fine because it already has its own physical copy of the code. *2. Service Programs (SRVPGM) = Bind by Reference Service Programs are completely different. When you bind a Service Program to your main program, the compiler does not copy the code. Instead, it just creates a "link" or a "pointer" (a reference) inside your main program that says: "Hey, when you need this subprocedure, go look inside this specific Service Program object to find the code." 💥 What Happens When You Delete It? Because your main program only has a reference (a map) to the Service Program, deleting the *SRVPGM object breaks that map. When your main program runs and tries to call AddNumbers() (like in our previous example), the operating system looks for the Service Program. Since you deleted it, the system panics and throws an exception. 🚨 The Errors You Will See If a developer accidentally deletes or renames a Service Program that is currently being used by a live program, the system will throw severe runtime errors. You will typically see: MCH3401 (Cannot resolve to object): The system is literally saying, "I am looking for the object you told me about, but it doesn't exist here anymore." CPFCE05: Service program not found during program activation. 💡 A Simple Real-World Analogy Think of a Module like a printed recipe card you put in your pocket. Even if the original cookbook is burned in a fire, you can still cook the meal because you have the copy. Think of a Service Program like a bookmark to a website link. If the website owner deletes the page (the service program), clicking your bookmark will just give you a "404 Page Not Found" error!