Chinaunix首页 | 论坛 | 博客
  • 博客访问: 99610
  • 博文数量: 64
  • 博客积分: 60
  • 博客等级: 民兵
  • 技术积分: 335
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-26 17:23
文章分类
文章存档

2012年(64)

我的朋友

分类:

2012-04-11 15:37:23

练习一

 

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)

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