- 论坛徽章:
- 0
|
本帖最后由 seouldeng 于 2012-07-24 11:08 编辑
引用 PASSTRU的博客文章
目的:
本例子演示RPGLE使用服务程序(*SRVPGM)通过指针传递参数进行调用。调用程序可以通过bnddir对服务程序进行直接调用,无需服务程序与子系统直接关联。
服务程序:TSRV.*SRVPGM
服务程序下挂服务应用程序M1.*Module
BNDDIR:BTEST
测试程序:TEST.*PGM
M1.RPGLE:(用15编译成M1.*Module,放在MyLib目录下。)
d M1 Pr
d Ptr1 *
d Ptr2 *
*
d C_Str s 20
d C_String s 20 based(Ptr1)
d Ptr1 s *
d Ptr2 s *
*
c *entry plist
c parm Ptr1
c parm Ptr2
/free
C_Str = C_String ;
C_Str = 'Hello! ' + C_Str ;
Ptr2 = %addr(C_Str) ;
*inlr = *on ;
return ;
/end-free
服务程序TSRV.rpgle:(用15编译成TSRV.*Module,放在MyLib目录下)
/free
Return ;
/end-free
服务程序TSRV下的服务应用程序定义bnd.rpgle文件:(放在MYLIB/BNDSRC目录下,无需编译)
STRPGMEXP SIGNATURE('TSRV')
EXPORT SYMBOL('M1')
ENDPGMEXP
创建服务程序TSRV.*srvpgm:(编译结果放在MyLib目录下)
CRTSRVPGM SRVPGM(MYLIB/TSRV)
MODULE(MYLIB/TSRV MYLIB/M1)
SRCFILE(MYLIB/BNDSRC)
创建BTEST. *BNDDIR(放在MyLib目录下):
CRTBNDDIR BNDDIR(MYLIB/BTEST)
加载服务程序TSRV.*srvpgm到BTEST bnddir下:
ADDBNDDIRE BNDDIR(MYLIB/BTEST) +
OBJ((MYLIB/TSRV))
或者用WRKBNDDIR对BTEST.*bnddir进行交互操作。
测试程序TEST.rpgle:(用14进行编译,放在MYLIB下)
H BNDDIR('BTEST')
H DFTACTGRP(*NO)
H OPTION(*ShowCpy)
*
d M1 Pr ExtPgm('M1')
d Ptr1 *
d Ptr2 *
*
d C_Str s 20 inz('Body')
d C_String s 20 based(Ptr2)
d Ptr1 s *
d Ptr2 s *
*
/free
Ptr1 = %addr(C_Str) ;
callp M1(Ptr1 tr2) ;
*inlr = *on ;
return ;
/end-free
最后一步调用程序TEST,报错
Message . . . . : Error occurred while calling program or procedure *LIBL/M
(C G D F).
Cause . . . . . : RPG procedure TEST in program POPGLIB/TEST at statement 1
attempted to call program or procedure *LIBL/M1, but was unable to access
the program or procedure, the library, or a required service program. If th
name is *N, the call was a bound call by procedure pointer.
Recovery . . . : Check the job log for more information on the cause of th
error and contact the person responsible for program maintenance.
Possible choices for replying to message . . . . . . . . . . . . . . . :
D -- Obtain RPG formatted dump.
S -- Obtain system dump.
G -- Continue processing at *GETIN.
单步进去,CALLP那里报错
Message . . . . : Cannot resolve to object M1. Type and Subtype X'0201'
Authority X'0000'.
Cause . . . . . : Either a system pointer or a data pointer can not be
resolved.
For a system pointer, it can not be resolved to object M1, type and
subtype X'0201', authorization X'0000', because either the named object wa
not in any context referred to or the correct object was located but the
user profile did not have the required authority.
The object types for common type or subtype codes follow:
-- 0100-Access group, 0201-Program, 0401-Library,
-- 0701-Journal receiver, 0801-User profile, 0901-Journal,
-- 0B90-Data space, 0C90-Data space index, 0D50-Data base file member,
不知道我是什么原因导致出错的呢?
|
|