Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1026907
  • 博文数量: 125
  • 博客积分: 10490
  • 博客等级: 上将
  • 技术积分: 2386
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-03 18:26
文章分类

全部博文(125)

文章存档

2011年(1)

2010年(9)

2009年(17)

2008年(98)

分类:

2009-04-30 00:27:20

因为在创建服务程序时必须指定export参数,而export的值可以为*SRCFILE, *ALL两种中的一种,所以创建srvpgm有两种方法:

1使用*all时在创建srvpgm时系统不需要进行严格的绑定语言的检查,表示多有语言都可以支持。

2使用*srcfile时需要在创建完module时在source_file下写一个bnd类型的绑定语言成员,然后在创建srvpgm时在SRCFILESRCmbr两个参数上指定bnd成员。这里创建绑定语言成员时一般包含以下的信息,

STRPGMEXP  PGMLVL(*CURRENT/*prv)

EXPORT     SYMBOL('模块名字')   

ENDPGMEXP   
例如:
srvpgm1:
 
说明:rpg1和rpg2是module,其中rpg2调用rpg1中的procedure。
     rpg1建立procedure时需要将pro制定为export。
     rpg2应用rpg1中的pro时需要制定为一个外部的pro,即使用关键字extproc('pro_name')
建立srvpgm时需要将export制定为*all,表示允许任何语言共同创建
CRTSRVPGM SRVPGM(HHHTEMP1/SRPG) MODULE(HHHTEMP1/RPG1 HHHTEMP1/RPG2) EXPORT(*ALL)     
这里*all表示(All data and procedures that are exported from the specified modules are also exported from the service program.)    
建立pgm时直接使用下面的命令:(这里的*dupproc表示系统回到所绑定的module中找出第一个和exproc('pro_name')中pro-name相对应的procedure)
CRTPGM PGM(HHHTEMP1/RPG5) MODULE(HHHTEMP1/RPG3) BNDSRVPGM(HHHTEMP1/SRPG)
OPTION(*DUPPROC)                                                       
例子
RPG1:
DP1               PR             2A           
D                               10A           
D                               10A           
PP1               B                   EXPORT  
DP1               PI             2A           
DD1                             10A           
DD2                             10A           
DDD1              S             20A           
C                   EVAL      DD1=' 找到我了 '
C     Dd1           DSPLY                     
C                   RETURN    '99'            
C                   EVAL      *INLR='1'       
PP1               E                                                                        
rpg2:
0001.00 DP2               PR             2    EXTPROC('P1') 
0001.01 D                               10A                 
0001.02 D                               10A                 
0001.03 D                                2A                 
0006.04 DDD1              S             20A                 
0006.05 DD1               S             10A                 
0006.06 DD2               S             10A                 
0006.07 DD3               S              2A                 
0007.00 C                                                   
0008.00 C                                                   
0009.00 C                   EVAL      D3=P2(D1:D2:D3)       
0013.00 C                                                   
0014.00 C                                                   
0015.00 C                                                   
0016.00 C                                                   
0017.00 C                   EVAL      *INLR='1'                      
然后将rpg1和rpg2编译成module
1。接着建立srvpgm:
CRTSRVPGM SRVPGM(HHHTEMP1/SRPG) MODULE(HHHTEMP1/RPG1 HHHTEMP1/RPG2) EXPORT(*ALL)           
2。建立pgm:
CRTPGM PGM(HHHTEMP1/RPG5) MODULE(HHHTEMP1/RPG3) BNDSRVPGM(HHHTEMP1/SRPG)
OPTION(*DUPPROC)                                                       

rpg3:
DP2               PR             2    EXTPROC('P1') 
D                               10                  
D                               10                  
DD1               S             10                  
DD2               S             10                  
DD3               S              2                  
C                                                   
C                   EVAL      D3=P2(D1:D2)          
C                                                   
C                                                   
C                                                   
C                                                   
C                                                   
C                                                   
C                   EVAL      *INLR='1'             
这里使用srvpgm中的p1 (procedure)
建立pgm
CRTPGM PGM(HHHTEMP1/RPG5) MODULE(HHHTEMP1/RPG3) BNDSRVPGM(HHHTEMP1/SRPG) OPTION(*DUPPROC)                                                       
 
SRVPGM2:
说明:rpg1和rpg2是module,其中rpg2调用rpg1中的procedure。
     rpg1建立procedure时需要将pro制定为export。
     rpg2应用rpg1中的pro时需要制定为一个外部的pro,即使用关键字extproc('pro_name')
建立srvpgm时需要将export指定为*srcfile,表示需要程序员自己定义一个绑定语言成员bnd1
CRTSRVPGM SRVPGM(HHHTEMP1/SRPG) MODULE(HHHTEMP1/RPG1 HHHTEMP1/RPG2) EXPORT(*srcfile)     SRCFILE(hhhtemp1/qsrcfile) SRCMBR(BND1) 
建立pgm时直接使用下面的命令:(这里的*dupproc表示系统回到所绑定的module中找出第一个和exproc('pro_name')中pro-name相对应的procedure)
CRTPGM PGM(HHHTEMP1/RPG5) MODULE(HHHTEMP1/RPG3) BNDSRVPGM(HHHTEMP1/SRPG)
OPTION(*DUPPROC)                                                       
例子
RPG1:
DP1               PR             2A           
D                               10A           
D                               10A           
PP1               B                   EXPORT  
DP1               PI             2A           
DD1                             10A           
DD2                             10A           
DDD1              S             20A           
C                   EVAL      DD1=' 找到我了 '
C     Dd1           DSPLY                     
C                   RETURN    '99'            
C                   EVAL      *INLR='1'       
PP1               E                                                                        
rpg2:
0001.00 DP2               PR             2    EXTPROC('P1') 
0001.01 D                               10A                 
0001.02 D                               10A                 
0001.03 D                                2A                 
0006.04 DDD1              S             20A                 
0006.05 DD1               S             10A                 
0006.06 DD2               S             10A                 
0006.07 DD3               S              2A                 
0007.00 C                                                   
0008.00 C                                                   
0009.00 C                   EVAL      D3=P2(D1:D2:D3)       
0013.00 C                                                   
0014.00 C                                                   
0015.00 C                                                   
0016.00 C                                                   
0017.00 C                   EVAL      *INLR='1'                      
然后将rpg1和rpg2编译成module
BND1:
 STRPGMEXP  PGMLVL(*CURRENT) 
 EXPORT     SYMBOL('RPG1')
EXPORT     SYMBOL('RPG2')      
 ENDPGMEXP                   
 
 
1。接着建立srvpgm:
CRTSRVPGM SRVPGM(HHHTEMP1/SRPG) MODULE(HHHTEMP1/RPG1 HHHTEMP1/RPG2) EXPORT(*srcfile)     SRCFILE(hhhtemp1/qsrcfile) SRCMBR(BND1) 
2。建立pgm:
CRTPGM PGM(HHHTEMP1/RPG5) MODULE(HHHTEMP1/RPG3) BNDSRVPGM(HHHTEMP1/SRPG)
OPTION(*DUPPROC)                                                       

rpg3:
DP2               PR             2    EXTPROC('P1') 
D                               10                  
D                               10                  
DD1               S             10                  
DD2               S             10                  
DD3               S              2                  
C                                                   
C                   EVAL      D3=P2(D1:D2)          
C                                                   
C                                                   
C                                                   
C                                                   
C                                                   
C                                                   
C                   EVAL      *INLR='1'             
这里使用srvpgm中的p1 (procedure)
建立pgm
CRTPGM PGM(HHHTEMP1/RPG5) MODULE(HHHTEMP1/RPG3) BNDSRVPGM(HHHTEMP1/SRPG) OPTION(*DUPPROC)                                                       
阅读(2273) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~