Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1273003
  • 博文数量: 287
  • 博客积分: 11000
  • 博客等级: 上将
  • 技术积分: 3833
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-16 08:43
文章分类
文章存档

2013年(15)

2012年(17)

2011年(17)

2010年(135)

2009年(85)

2008年(18)

分类: 系统运维

2011-05-26 08:46:30

目的:

本例子演示RPGLE使用服务程序(*SRVPGM)通过指针传递参数进行调用。调用程序可以通过bnddir对服务程序进行直接调用,无需服务程序与子系统直接关联。

 

服务程序:TSRV.*SRVPGM

服务程序下挂服务应用程序M1.*Module

BNDDIRBTEST

测试程序: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.*srvpgmBTEST bnddir下:

ADDBNDDIRE BNDDIR(MYLIB/BTEST) +  

             OBJ((MYLIB/TSRV))

 

或者用WRKBNDDIRBTEST.*bnddir进行交互操作。

 

测试程序TEST.rpgle:(用14进行编译,放在MYLIB下)

H BNDDIR('BTEST')                                

H DFTACTGRP(*NO)                                 

H OPTION(*ShowCpy)                               

 *                                               

d M1              Pr                       ExtProc('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:Ptr2) ;                       

                                                 

    *inlr = *on ;                                

return ;                                     

 

 /end-free

 

运行测试结果:

调用TEST,把字符串“Body”通过指针Ptr1带入到服务应用程序M1中,M1把字符串做处理,把字符串改为:“Hello Body”。然后通过指针Ptr2返回到调用程序TEST

阅读(2179) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~