× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On 19/03/2006, at 3:53 PM, Mike Pantzopoulos - (H/O) wrote:

I'm now having problems with point 3 of your answer. I've spent about 3 hours scanning ILE Concepts manual, MidRange Archive and the iSeries News site. To no avail.
How do I invoke a CL procedure from an RPG program?

Just like you do with any other module.

There was a hint in one inquiry implying that it should be with a CALLB, and in fact the CALLPRC documentation refers to it as a Bound Procedure call so I thought I should give that a go.

Both CALLB and CALLP will work.

But I crap out on the compilation.

If it fails on compilation then it has probably nothing to do with different modules. Module errors usually show up on the binding step.

Probably how I've implemented it. I have this gut feeling that I might need to go to a binder source solution, but I've never used those. Probably a good excuse to get immersed in them if that's what's required.

The CL module was created ok as ED991CL, so I presume the 'prcedure name' is the same as the module name since it's a 1:1 relationship.

That's correct. Make sure the name is in upper-case.

I used the CALLB ED991CL in the RPG(ED002), and compiled it with CRTBNDRPG. I also created a binding directory ED002 which referenced ED991CL as a *module.

The compile fails with:

*RNF7030 30 1734 116000 The name or indicator ED991CL is not defined.

Presumably the binding step hasn't resolved to the ED991CL in the CL module. Although when I look at the DSPMOD of ED991CL it says there's one exported defuned symbol, which I presume is the (implied) procedure name of ED991CL.

My first question would be "Did you specify the binding directory on the CRTBNDRPG command?" but the error message you show is a compiler error rather than a binding error so it's probably caused by your code. Did you remember to specify EXTPROC on the prototype? If not then show your code ... or see below for examples that do work.

Normally with RPG modules, there's an EXPORT statement assigned to the procedure names which are to be 'public'.

EXPORT doesn't mean public. It just means visible outside the module. If the module is bound into a program then the function being exported is not public because it cannot be invoked from outside the program. If the module is bound into a service program then it just means it is a candidate for public exposure. Whether it is public depends on the binding source. Using EXPORT(*ALL) makes all EXPORT procedures and data types public--always a dumb idea. Specifying the EXPORTed procedure in binding source also makes it public. However, not specifying it makes it accessible to other modules within the service program while keeping it secure from consumers of the service program.

Is the CL procedure public by definition since there's only one procedure?

Yes.

Or do I have to use the binder language to make it so?

Binder language is used only for service programs.

By the way I was intrigued by your definition of CALLP being a CALL with a prototype. I'd always thought of it as a CALL of a (P)rocedure. Perhaps they should have named the CALLPRC command CALLBNDPRC?

Not my definition. From the RPG Reference manual:
        o CALL (Call a Program)
        o CALLB (Call a Bound Procedure)
        o CALLP (Call a Prototyped Procedure or Program)

I'm just pedantic and pay attention when I read things (which I mostly remember).

Here is yet another trivial example (based on one I sent earlier):

CL source for CLMODULE1:
pgm
sndpgmmsg 'In module 1'
callprc clmodule2
endpgm

CL source for CLMODULE2:
pgm
sndpgmmsg  'In module 2'
endpgm

RPG IV source for RPGMODULE1:
H OPTION(*SRCSTMT)
C                   CALLB     'CLMODULE1'
C                   SETON                                        LR
C                   RETURN

CRTCLMOD CLMODULE1
CRTCLMOD CLMODULE2
CRTRPGMOD RPGMODULE1
CRTPGM RPGMODULE MODULE(RPGMODULE1 CLMODULE1 CLMODULE2)

Test it with:
CALL QCMD
CALL RPGMODULE
F10

If you want to do the compile and bind of the RPG in a conceptual single step then create a binding directory with the CL modules and specify this and DFTACTGRP(*NO) on the CRTBNDRPG command. You can make things easier by specifying these values on H-spec records. Thus:

CRTBNDDIR BNDDIR(MODULE)
ADDBNDDIRE BNDDIR(MODULE) OBJ((CLMODULE1 *MODULE))
ADDBNDDIRE BNDDIR(MODULE) OBJ((CLMODULE2 *MODULE))

RPG IV source for RPGMODULE2:
H OPTION(*SRCSTMT)
H DFTACTGRP(*NO) BNDDIR('MODULE')
C                   CALLB     'CLMODULE1'
C                   SETON                                        LR
C                   RETURN

CRTBNDRPG RPGMODULE2

Test it with:
CALL QCMD
CALL RPGMODULE2
F10

Should have the same result as RPGMODULE.

If you want to prototype the call then do so:

RPG IV source for RPGMODULE3:
H OPTION(*SRCSTMT)
H DFTACTGRP(*NO) BNDDIR('MODULE')
D clModuleByCopy  PR                  EXTPROC('CLMODULE1')
C                   CALLP     clModuleByCopy
C                   SETON                                        LR
C                   RETURN                                         

CRTBNDRPG RPGMODULE3

Test it with:
CALL QCMD
CALL RPGMODULE3
F10

Should have the same result as RPGMODULE and RPGMODULE2.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.