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

2013年(15)

2012年(17)

2011年(17)

2010年(135)

2009年(85)

2008年(18)

分类: 系统运维

2011-12-27 15:52:16

练习一

 

Module:Proc(程序代码)

 

  * Procedure 内部调用                            

  * Proc1(main) 调用 Proc2(nomain)                

  * 默认值: main                                 

  *                                               

 H*Main Proc1                                     

  *                                               

 d/copy QRPGLESRC2,RPGTXTSRC                      

  *                                                

 d MyParm2         s             20    inz('Hello')

 d Rc              s              7    inz        

  *                                               

  /free                                           

      Rc = Proc1(MyParm2) ;                        

                                                  

      *inlr = *on ;                               

      return ;                                    

  /end-free                                  

  *                                          

 pProc1            b                   export

 d Proc1           pi             7          

 d  MyParm2                      20          

  *                                          

  *                                          

  /free                                       

      //MyParm2 为Hello                 

      dsply MyParm2 ;                        

      // 调用 SubProcedure,Proc2             

      Rc = Proc2(MyParm2) ;                  

      //返回值MyParm2 为Hello,RPGLE                 

      dsply MyParm2 ;                        

      return  Rc ;                           

  /end-free                                  

pProc1            e                               

 

Module:Proc1(程序代码)

                                                

 H nomain                                           

 d/copy QRPGLESRC2,RPGTXTSRC                        

  *                                                 

 pProc2            b                   export       

 d Proc2           pi             7                 

 d  MyCallRet                    20                 

  *                                                 

 d MyParm2         s             20    inz('RPGLE') 

 d Rc              s              7    inz('0000000')

 d Erc             s              7    inz('1111111')

  *                                                 

  /free                                             

     monitor ;                     

        //MyParm2 为Hello     

        dsply MyParm2 ;             

        MyCallRet = 'Hello, RPGLE' ;

        dsply MyCallRet ;          

     on-error ;                    

        Rc = Erc ;                 

     endmon ;                      

                                   

      return Rc ;                   

  /end-free                        

 pProc2            e               

 

copybookRPGTXTSRC .TXT代码:

  d Proc1           pr             7

  d  MyCallRet                    20

   *                                

  d Proc2           pr             7

  d  MyCallRet                    20

 

程序*PGM生成步骤:

1) crtrpgmod,或编辑选项15,编译Proc.rpgle,生成Proc.module

2) crtrpgmod,或编辑选项15,编译Proc1.rpgle,生成Proc1.module;

3) CtrPgm,创建Proc.pgm

             CRTPGM PGM(PINGY/PROC) MODULE(PINGY/PROC PINGY/PROC2)

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