Comments on: Difference between Module and a Program in AS/400http://itknowledgeexchange.techtarget.com/itanswers/difference-between-module-and-a-program/
Tue, 03 Mar 2015 16:25:46 +0000hourly1By: The Most-Watched IT Questions: February 1, 2011 - ITKE Community Bloghttp://itknowledgeexchange.techtarget.com/itanswers/difference-between-module-and-a-program/#comment-87325
Tue, 01 Feb 2011 06:16:33 +0000#comment-87325[…] All the usual suspects showed up to help Sangay tell the difference between module and a program in AS/400. 6. Rakei and Rechil do their best to describe how to properly mass delete user profiles in […]
]]>By: tomliottahttp://itknowledgeexchange.techtarget.com/itanswers/difference-between-module-and-a-program/#comment-87304
Mon, 31 Jan 2011 22:15:21 +0000#comment-87304Could you please also add the basic difference between module and a procedure…

For what language? ILE RPG and ILE C both have language constructs for including multiple procedures in modules. COBOL and CL both have a single procedure per module.

When multiple procedures are allowed, there will be prototypes for each one. (Though, in ILE RPG a prototype for the “main” procedure isn’t required.) In RPG, you’d recognize procedures by their P-specs.

Tom

]]>By: sangayhttp://itknowledgeexchange.techtarget.com/itanswers/difference-between-module-and-a-program/#comment-87263
Sun, 30 Jan 2011 14:38:09 +0000#comment-87263thanks a ton for the explaination. Could you please also add the basic difference between module and a procedure but again just by looking at it.
]]>By: tomliottahttp://itknowledgeexchange.techtarget.com/itanswers/difference-between-module-and-a-program/#comment-87238
Fri, 28 Jan 2011 21:20:48 +0000#comment-87238…how to differentiate between Module and program by looking at its source code.

Ah. Yes, that gets a little tricky.

First, a *MODULE must be compiled as ILE. If it’s not ILE-compatible source, it will always compile as a *PGM.

Second, ILE always compiles *MODULEs. ILE programs are never compiled; they are bound from modules.

However, the ILE languages all supply commands that do the module compilation and the program binding in a single command. For example, the CRTBNDRPG command will first compile the source as a *MODULE in QTEMP and then generate the bound *PGM from that *MODULE along with any system *MODULEs (service programs) that are indicated.

So, the distinction can be tricky since all ILE source that can be compiled is always *MODULE source. But some modules are not sufficient to create bound programs; they require other modules.

Generally, in order to result in a program, a “main” procedure must be supplied in the module source. So, the first clue with ILE RPG is likely to be the presence of the NOMAIN H-spec keyword. If the source compiles with NOMAIN, you know it can’t stand alone as a *PGM; some other module must supply the “main” procedure. (Note that the procedure doesn’t need to be named “main”. Being the main procedure isn’t the same as having a procedure named ‘main’.)

Also, RPG requires a way to end a *PGM. Usually, that means you’ll find a reference to indicator LR or *INLR in the source. Since that might be supplied in a /COPY member or similar means, it’s not guaranteed.

Now, with ILE CL, any source that compiles can be either a “main” procedure or a secondary procedure. There are no clues — the source can be handled either way.

ILE C will actually have a procedure named ‘main’ that you can search for in the source.

ILE COBOL… I’m not sure yet. Everything I tested resulted in a *PGM or *MODULE depending on the creation command that I used, even for source that I explicitly wrote for use as a *MODULE. I’ll see if I can track down details.

Well, in short, if the source doesn’t explicitly carry an indication such as the ILE RPG NOMAIN keyword, you may need to submit compiles into QTEMP and have the system tell you if it succeeds or fails when creating a *PGM. (A *MODULE can almost always succeed.) I’ve always found that the system is much faster at making the determinations than I am. After all, we’re programmers. We’re supposed to know how to get the system to do work for us.

It’s not necessarily the source that makes a difference. It’s what you do with the source that is most important.

If I find more, I’ll try to remember to add it.

Tom

]]>By: sangayhttp://itknowledgeexchange.techtarget.com/itanswers/difference-between-module-and-a-program/#comment-87199
Fri, 28 Jan 2011 07:12:10 +0000#comment-87199I think there was a confusion. I wanted to ask how to differentiate between Module and program by looking at its source code.

You open a source code and now there must be differences between the these two which actually makes them different.

if this question makes Modules and procedures same then for a procedure i believe we have specifications P, D and C. Not sure. Any suggestions?

]]>By: tomliottahttp://itknowledgeexchange.techtarget.com/itanswers/difference-between-module-and-a-program/#comment-86922
Fri, 21 Jan 2011 22:54:17 +0000#comment-86922As CharlieBrowne said, they have different object types. Obviously, though, “telling the difference” requires knowing how you are “looking”. What do you mean by “looking at it”?

You can’t look at a program nor a module except perhaps by going in through Service Tools and examining bytes on disk. So, you must be using some command to output some results. Perhaps you are “looking at” a list of objects in a library. What command or menu option created the list?