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

2013年(15)

2012年(17)

2011年(17)

2010年(135)

2009年(85)

2008年(18)

分类: 系统运维

2012-01-28 21:19:11

RPGLE高级练习(二):Procedure(2012-01-04 15:19:50)[编辑][删除]
 
    在这个练习中,放人了我对项目实施的实际做法。
    调用指针(pointer,*)有三个:
    1)Ptr1为项目总体参数指针,用于项目统一参数,如交易日日期;
    2)Ptr2为单元模块输入指针,即外部调用本模块时,用Ptr2传入参数;
    2)Ptr3为单元模块输出指针,即本单元模块处理完毕后,用Ptr3输出结果。
 
    这样就对项目规范起来,减少项目接口的复杂性。所有的参数定义,如一般通用变量、ds结构等定义,都放在copybook中,这样可以保持所有输入输出参数在整个项目中能够保持唯一。
 
H nomain                                   
H OPTION(*SHOWCPY)                         
 *                                         
 /copy QTXTSRC,MSGID                       
 /copy QTXTSRC,MYDS                        
 *                                         
d Proc13          pr             7         
d  Ptr1                           *        
d  Ptr2                           *        
d  Ptr3                           *        
 *                                         
pProc13           b                   export
d Proc13          pi             7         
d  Ptr1                           *        
d  Ptr2                           *        
d  Ptr3                           *        
 *                                                        
d MyParm2         s             20    based(Prt2)         
d Hello           s             20    inz('Hello, ')      
 *                                                        
 /free                                                    
     monitor ;                                            
        If Ds_Parms.Parm1 = 1 ;                           
           MyParm2 = %trim(Hello) + ' ' + %trim(MyParm2) ;
           Ptr3 = %addr(MyParm2) ;                        
        Else ;                                            
           Rc =  Ercode ;                                 
        EndIf ;                                           
      on-error ;                                          
        Rc = Ercode ;                                     
     endmon ; 
      return Rc ; 
  /end-free       
pProc13           e
 
H*Main Proc3                                      
H option(*showcpy)                                
H BNDDIR('MYBND')                                 
H*DFTACTGRP(*NO)                                  
 *                                                
 /copy QTXTSRC,MSGID                              
 /copy QTXTSRC,MYDS                               
 /copy QTXTSRC,PRDS                               
 *                                                
d MyParm2         s             20    inz('RPGLE')
 *                                                
 /free                                            
                                                  
     Ptr2 = %addr(MyParm2) ;                      
     Rc = Proc13(Ptr1:Ptr2:Ptr3) ;                
     If Rc = RcInz ;     
        dsply Rc ;     
     Else ;            
        dsply Rc ;     
     EndIf ;           
                       
     *inlr = *on ;      s
     return ;          
                       
 /end-free             
bndfile:
 QSRVSRC,PROCSRV:
    STRPGMEXP SIGNATURE('PROCSRV')  
      EXPORT SYMBOL('PROCSRV')     
      EXPORT SYMBOL('PROC12')      
      EXPORT SYMBOL('PROC13')      
    ENDPGMEXP   
 
 

生成PROCSRV.*SRVPGM命令:

CRTSRVPGM SRVPGM(MYLIB/PROCSRV)            
          MODULE(MYLIB/PROCSRV MYLIB/PROC12 MYLIB/PROC13)
          SRCFILE(MYLIB/QSRVSRC)  
 

                   

copybooks:
 MSGID.RPGLE :
  d RcInz           c                   '0000000'     
  d Ercode          c                   '1111111'     
   *                                                  
  d Rc              s              7    inz('0000000')   
 MYDS.RPGLE :
  d Ptr1            s               *            
  d Ptr2            s               *            
  d Ptr3            s               *            
   *                                             
   *Ds_Parms                                     
  d Ds_Parms        Ds                  qualified
  d  Parm1                         5p 2 inz(1)   
  d  Parm2                         5p 2 inz(2)   
  d  Parm3                         5p 2 inz(3) 
 PRDS.RPGLE :
  dProc13           pr             7    extproc('PROC13')
  d  Ptr1                           *                    
  d  Ptr2                           *                    
  d  Ptr3                           * 
bnddir:
 MYBND.*BNDDIR :
  PROCSRV        *SRVPGM     ITSMXH                                                           
阅读(2237) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~