RPG ILE question - external procedeures

nuffznuff

Member
I'm having trouble trying to create an RPG program using external procedures.

I think I've coded everything correctly, but I'm not sure which compiler commands and options to use.

Please advise.



Program P66206X
---------------

0036.00 **
0037.00 ** SUBPROC CvtToJul - Convert date to Julian
0038.00 ** -------------------------------------------
0039.00 **
0040.00 D CvtToJul PR EXTPROC('MX0028')
0041.00 D #SIDAT 6A
...
...
0706.00 CSR CALLP CvtToJul (#SIDAT)



MX0028
------

0001.00 H NOMAIN
0002.00 *****************************************************************
0003.00 **
0004.00 ** SUBPROC CvtToJul - Convert date to Julian
0005.00 ** -------------------------------------------
0006.00 **
0007.00 D CvtToJul PR 6S 0
0008.00 D #SIDAT 6A VALUE
0009.00 **---------------------------------------------------------------
...
...
0021.00 P CvtToJul B EXPORT
0022.00 D CvtToJul PI 6S 0
0023.00 D #SIDAT 6A VALUE
0024.00 **
...
...
0042.00 P CvtToJul E



COMPILER OPTIONS
----------------
CRTRPGMOD MODULE(FRDOBJ/MX0028) SRCFILE(JDESRCLE)
Module MX0028 placed in library FRDOBJ. 00 highest severity. Created on
30/11/11 at 10:44:57.

CRTSRVPGM SRVPGM(FRDOBJ/MX0028) MODULE(*SRVPGM) EXPORT(*ALL)
Service program MX0028 created in library FRDOBJ.

CRTRPGMOD MODULE(FRDOBJ/P66206X) SRCFILE(JDESRCLE)
Module P66206X placed in library FRDOBJ. 00 highest severity. Created on
30/11/11 at 10:48:20.

CRTPGM PGM(FRDOBJ/P66206X) MODULE(FRDOBJ/P66206X) ENTMOD(*FIRST) BNDSRVPG
M(FRDOBJ/MX0028)
Program P66206X not created.
Definition not found for symbol 'MX0028'.



Low level messages
------------------

Message . . . . : Definition not found for symbol 'MX0028'.

Cause . . . . . : No definition was found for reference MX0028 in *MODULE
object P66206X in library FRDOBJ. The definition either does not exist or is
not of the same data or procedure type as the reference.
Recovery . . . : Try the Create Program (CRTPGM) command again, supplying
an object that contains a definition for symbol MX0028.
 
Do not specify EXTPROC('MX0028') in your declaration for subprocedure CvtToJul in the P66206X program and it will compile properly...

Regards,
 
However, I see an inconsistency in the way you have your subprocedure defined in the program versus the service program.

For this work work properly, you need to define the subprocedure the same in both places (that is why I alway put my subprocedure prototypes in copy books...) :

D CvtToJul PR 6S 0

With the definition like this the subprocedure is expected to RETURN a numeric 6.0 value to the caller.

Given this fact, in P66206X you would need to define a variable to receive the returned value (RetDate) and call it like this:

CSR eval RetDate = CvtToJul(#SIDAT)

Regards,
 
Back
Top