Difference between Procedure & Subprocedure

425 pts.
Tags:
AS/400
Can someone tell me the difference between Procedure & Subprocedure. And how/use NOMAIN MAIN applicable to procedures?

Software/Hardware used:
Iseries

Answer Wiki

Thanks. We'll let you know when a new response is added.

You can create procedure which don’t return a value or functions which have a return value. These can be placed in the same source as an actual program module or in a sorce member without any “runnable” or main module. If you put the procedure in a source that doesn’t have a main module you must use the H spec entry NOMAIN so the compiler understands that it shouldn’t be looking for in-line or main code.
Phil

========================================================

You don’t say what language you’re asking about, and you ask two different questions. But because the second question is about “NOMAIN”, all of this will be about how ILE RPG sees things as I understand it.

Can someone tell me the difference between Procedure & Subprocedure.

First, that’s not quite a correct question. It’s like asking “What’s the difference between a vehicle and a truck?” A better question than that might be “What’s the difference between a car and a truck?”

A subprocedure is a procedure, so there’s no difference except that subprocedure is a subcategory of procedure. The question you should have asked might have been better as “What’s the difference between a main procedure and a subprocedure?”

From the WebSphere Development Studio: ILE RPG Programmer’s Guide:

An ILE RPG module consists of a main procedure and zero or more subprocedures. (If there are subprocedures, the main procedure is optional.) A main procedure is a procedure that can be specified as the program entry procedure (and so receive control when an ILE program is first called). The main procedure is defined in the main source section, which is the set of H, F, D, I, C, and O specifications that begin a module. In V3R1, all ILE RPG modules had a main procedure and no other procedures.

A subprocedure is a procedure that is specified after the main source section. A subprocedure differs from a main procedure primarily in that:

* Names that are defined within subprocedure are not accessible outside the subprocedure.
* No cycle code is generated for the subprocedure.
* The call interface must be prototyped.
* Calls to subprocedures must be bound procedure calls.
* Only P, D, and C specifications can be used.

In short, a main procedure can be a PEP (program entry procedure). And a subprocedure can’t.

And how/use NOMAIN MAIN applicable to procedures?

This question also isn’t quite correct. It implies that NOMAIN is an attribute of procedures, when it’s actually an attribute of an ILE RPG module. A module can be compiled as NOMAIN. There can be one or more procedures in a NOMAIN module. All procedures in a NOMAIN module will necessarily be subprocedures.

From the WebSphere Development Studio: ILE RPG Language Reference:

The NOMAIN keyword indicates that there is no main procedure in this module. It also means that the module in which it is coded cannot be an entry module.

See NOMAIN Module for more detail.

Note that a NOMAIN module will compile more quickly since it doesn’t get any of the usual Cycle code and other parts that support main procedures. The module will also be smaller.

As you can see, all of this is in the current Information Centers and can be found by searching there.

Tom

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Littlepd
    The ILE Concepts manual describes concepts and terminology for the Integrated Language Environment (ILE) architecture of the i5/OS operating system. Topics covered include module creation, binding, how to run and debug programs, and exception handling.
    1,130 pointsBadges:
    report
  • Kar
    [...] Kar asks about the difference between Procedure & Subprocedure, and TomLiotta, Philpl1jb and Littlepd all help [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following