- 論壇徽章:
- 0
|
本帖最后由 seouldeng 于 2012-07-24 11:08 編輯
引用 PASSTRU的博客文章
目的:
本例子演示RPGLE使用服務(wù)程序(*SRVPGM)通過指針傳遞參數(shù)進行調(diào)用。調(diào)用程序可以通過bnddir對服務(wù)程序進行直接調(diào)用,無需服務(wù)程序與子系統(tǒng)直接關(guān)聯(lián)。
服務(wù)程序:TSRV.*SRVPGM
服務(wù)程序下掛服務(wù)應(yīng)用程序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
服務(wù)程序TSRV.rpgle:(用15編譯成TSRV.*Module,放在MyLib目錄下)
/free
Return ;
/end-free
服務(wù)程序TSRV下的服務(wù)應(yīng)用程序定義bnd.rpgle文件:(放在MYLIB/BNDSRC目錄下,無需編譯)
STRPGMEXP SIGNATURE('TSRV')
EXPORT SYMBOL('M1')
ENDPGMEXP
創(chuàng)建服務(wù)程序TSRV.*srvpgm:(編譯結(jié)果放在MyLib目錄下)
CRTSRVPGM SRVPGM(MYLIB/TSRV)
MODULE(MYLIB/TSRV MYLIB/M1)
SRCFILE(MYLIB/BNDSRC)
創(chuàng)建BTEST. *BNDDIR(放在MyLib目錄下):
CRTBNDDIR BNDDIR(MYLIB/BTEST)
加載服務(wù)程序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
最后一步調(diào)用程序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,
不知道我是什么原因?qū)е鲁鲥e的呢?
|
|