Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

EXTPGM for OPM Program

956 views
Skip to first unread message

Brian

unread,
Jun 23, 2005, 8:31:16 AM6/23/05
to
I know that I have to be missing something and it is driving me crazy.
I have an RPG OPM program that I am trying to call inside an RPG ILE
program. I have defined the prototype in the ILE program like this:

D DocSearch PR EXTPGM('HW102')
D Doccd 4P 0
D Validate 1A
D Bad 1A

I sampled it after the QMCDEXEC example in the ILE reference. We are
running V5R1.

When I compile, I get this:

*RNF7030 30 107 013728 The name or indicator BAD is not defined.

*RNF7030 30 110 013731 The name or indicator DOCCD is not defined.

*RNF7030 30 106 013727 The name or indicator VALIDATE is not
defined.
*RNF5410 30 162 014116 The prototype for the call is not defined.

I remember reading something about a procedure interface to get the
return values(which I need) so I added this:

DDocSearch Pi
D Doccd 4P 0
D Validate 1A
D Bad 1A

Then when I compile, I get this:

*RNF3776 10 a 001656 External program on prototype for main
procedure is not the same as program being created.


*RNF7545 30 1 The main procedure cannot be called from this module
when it is an external program call.

I am new to ILE and am trying to learn this on my own. What am I
missing?

Thank you in advance.

James Perkins

unread,
Jun 23, 2005, 12:42:55 PM6/23/05
to

"Brian" <brk...@gmail.com> wrote in message
news:1119529876.5...@z14g2000cwz.googlegroups.com...


Just a guess, but do you reference these fields anywhere else in your
program? If you do this is where your error is coming from.

The call should look like so:

/free
DocSearch(parm1:parm2:parm3);
/end-free

So basically if you do an
C eval bad = something

this would cause this error.

Regards,
James R. Perkins


Brian

unread,
Jun 23, 2005, 1:42:13 PM6/23/05
to
I do reference them elsewhere in my program because I am trying to set
the value before the program is called. You can do this in an OPM RPG
program so I made an assumption.

Is there an explanation as to why I can't reference them elsewhere or
is it just the way it works? I will remove the references in my
program and see if that works.

Carl

unread,
Jun 23, 2005, 2:19:03 PM6/23/05
to


Two comments, although they are really just guesses based on the small
bit of code you provided.

1. Did you define the vars BAD, DOCCD & VALIDATE? From the message
above, it would appear you did not. The PR/Prototype section is for
prototyping the call only, the parameter definitions do not define the
variables by name, and you can actually omit the name all together.

2. What is the PI/Proc interface for? What do you expect it to do? I
would omit it as it appears to me that you are using the prototype to
define a call to an external program, in which case the PI is not required.

HTH,
Carl.

B Bauer

unread,
Jun 23, 2005, 2:22:12 PM6/23/05
to
Hello Brian

Try defining the values within their own D-spec block then reference them in
your prototype.

For example:

D Doccd S 4P 0
D Validate S 1A
D Bad S 1A

D DocSearch PR EXTPGM('HW102')

D Like(Doccd)
D Like(Validate)
D Like(Bad)

Hope this helps

"Brian" <brk...@gmail.com> wrote in message

news:1119548533.3...@g44g2000cwa.googlegroups.com...

Thomas Raddatz

unread,
Jun 23, 2005, 2:23:58 PM6/23/05
to Brian
Brian,

A prototype is just a prototype. All it does is to define the interface
(*ENTRY-List) of a program or procedure. It does not allocate any storage. It
does not define any fields. That is what you have to do, too.

D DocSearch PR EXTPGM('HW102')
D Doccd 4P 0
D Validate 1A
D Bad 1A


D Doccd S 4P 0 inz
D Validate S 1A inz
D Bad S 1A inz


/free
DocSearch(parm1:parm2:parm3);
/end-free

... or ...

C Callp DocSearch(parm1:parm2:parm3)

A procedure interface is the replacement for the old fashioned *ENTRY-list. In
contrast to a prototype it does allocate storage for its parameters because the
procedure interface is the vehicle that carries the parameters into your program.

A prototype only tells the compiler how to bind to the routine (EXTPROC or
EXTPGM). It it is an EXTPROC the compiler generates a CALLP (or something
similar in case of a function call) and if it is an EXTPGM the compiler
generates a CALL.

Thomas Raddatz.


Brian schrieb:

B Bauer

unread,
Jun 23, 2005, 2:31:35 PM6/23/05
to
I need to revise my reply, if you use the "Like" key word a name is needed,
here's my revision:

D Doccd S 4P 0
D Validate S 1A
D Bad S 1A

D DocSearch PR EXTPGM('HW102')

D Doc Like(Doccd)
D Valdt Like(Validate)
D Bd Like(Bad)

I hit the send key a little to quickly.


"B Bauer" <brad@_nospam_bauer1.com> wrote in message
news:42bafdda$0$3711$d36...@news.calweb.com...

James Perkins

unread,
Jun 23, 2005, 4:57:43 PM6/23/05
to

"Brian" <brk...@gmail.com> wrote in message
news:1119548533.3...@g44g2000cwa.googlegroups.com...

It's probably documented somewhere, but I couldn't tell you where. I
personally like it better, because as long as you don't have a return the
variable you don't have to use one. So you could do a:
/free
DocSearch(1234:'Y':parm)
/end-free

Regards,
James R. Perkins


Brian

unread,
Jun 23, 2005, 4:58:03 PM6/23/05
to
I defined my variables on a D spec and the program compiled
successfully. Thank you for the help.

In your statement about the PI, is it required if I want to get the
values back from my PR(external program) when it is called? Or is
defining the PR sufficient? I am just a little confused still on when
the PI is necessary. Based on what I read in the ILE RPG Reference for
V5R1 it seems like the PI is necessary. I do try to read the
documentation but sometimes, I just get a mental block on certain
things and this is one of them. I apologize if I have missed something
in your explanation.

Thomas Raddatz

unread,
Jun 23, 2005, 5:37:52 PM6/23/05
to Brian
The PI is not need in the caller. It is only needed in the called program. As
mention before the PI is the replacement for the *ENTRY PLIST. Instead of using
a *ENTRY PLIST nowadays you better use a PI:

*ENTRY PLIST
PARM command 512
PARM length 15 5

translates to:

D cmd_execute PI
D command 512A
D length 15P 5

The caller only neeeds the PR in order to know what parameters are needed to
call "cmd_execute". No more no less.

The program that implements "cmd_execute" needs the PI (as the replacement for
the *ENTRY PLIST) *and* the PR. Actually the PR might not be neded. However the
compiler "wants" to verify that the PR matches the PI in order to avoid problems
at runtime. You usually want to put the PR into a copy book. The the caller as
well as the called program can include the copy book. This way there is no more
trouble with parameter type mismatch!

Thomas Raddatz.


Brian schrieb:

SamL

unread,
Jun 23, 2005, 9:13:40 PM6/23/05
to
As Thomas says, the prototype just defines the interface. You don't even
need to have names on the fields.

D DocSearch PR EXTPGM('HW102')

D 4P 0
D 1A
D 1A


D DocPP S 4P 0 inz
D ValPP S 1A inz
D BadPP S 1A inz


/free
DocSearch(DocPP:ValPP:BadPP);
/end-free

/* ... or ... */

C Callp DocSearch(DocPP: ValPP: BadPP)

And if you do use field names on the prototype, they are purely for
decumentation. They don't have to be the same as actual field names in your
program.

Here's a (bad documentation) example:

D DocSearch PR EXTPGM('HW102')

D Parm1 4P 0
D Parm2 1A
D Parm3 1A


D DocPP S 4P 0 inz
D ValPP S 1A inz
D BadPP S 1A inz


/free
DocSearch(DocPP:ValPP:BadPP);
/end-free

/* ... or ... */

C Callp DocSearch(DocPP: ValPP: BadPP)

Sam


"Thomas Raddatz" <thomas.D...@ATtools400.DOTde> wrote in message
news:42BAFE3E...@ATtools400.DOTde...

Brian

unread,
Jun 24, 2005, 8:27:17 AM6/24/05
to
OK. Now I think I understand when a PR and PI are needed. Thanks to
all who responded.

0 new messages