免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: niuhua77
打印 上一主题 下一主题

闲谈call callb callp区别 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2011-06-30 11:01 |只看该作者
回复 10# passthru


     多谢,补充的非常好。

小弟有一点不明:而面向F表操作,用plist module.就是说如果有F表的操作,就不使用prototype,而是用PLIST来传参,我的理解对吗?

这样做的好处是什么呢?red book上说subprocedure可以操作F表,那为什么不用都prototype来传调呢?

我的实际编程经验比较少,以上都是我从理论上考虑的,望帮忙解答。

谢谢

论坛徽章:
0
12 [报告]
发表于 2011-06-30 11:12 |只看该作者
回复  passthru


     多谢,补充的非常好。

小弟有一点不明:而面向F表操作,用plist module.就是说 ...
niuhua77 发表于 2011-06-30 11:01



    module的入口有两种类型:1)plist;2)prototype

plist即main类型的,可以直接对F表进行操作。

prototype,通常情况先,如redbook所说,subprocedures不能对F表进行操作。

用服务程序把上述两种类型的module挂在bnddir下,plist的没有任何问题,但是用prototype的只能是subprocedures类型的。

论坛徽章:
0
13 [报告]
发表于 2011-06-30 11:18 |只看该作者
“red book上说subprocedure可以操作F表,...”那本redbook上有说呢?

用subprocedures对F表进行操作,编译会报10级警告性msg。

论坛徽章:
0
14 [报告]
发表于 2011-06-30 11:57 |只看该作者
回复 13# passthru

red book里有几处关于subprocedure操作f-spec的,我选2个贴出来,验证一下:

《ILE RPG Programmer’s Guide》
    Any of the calculation operations may be coded in a subprocedure. However, all files must be defined globally, so all input and output specifications must be defined in the main source section. Similarly, all data areas must be defined in the main procedure, although they can be used in a subprocedure.

这里说,FILE,I-SPEC,DATA AREA等都是可以在subprocedure中使用的。只不过要在main section中定义。

《A Sorcerer’s Guide to System Access andMore》
3.3.1 Subprocedure definition
Subprocedures are specified:
• After the main source section if one exists
• Following an H spec containing the NOMAIN keyword if there is no main
section
Note: There may be other specs between the H spec and the beginning of the
subprocedure, for example, F specs to define files to be used by the
subprocedures.

这里说在H-SPEC和subprocedure直接是可以定义其他表的,并且这些表的内容subprocedure是可以使用的。

论坛徽章:
0
15 [报告]
发表于 2011-06-30 14:51 |只看该作者
本帖最后由 passthru 于 2011-06-30 15:26 编辑

《ILE RPG Programmer’s Guide》
    Any of the calculation operations may be coded in a subprocedure. However, all files must be defined globally, so all input and output specifications must be defined in the main source section. Similarly, all data areas must be defined in the main procedure, although they can be used in a subprocedure.

这里说,FILE,I-SPEC,DATA AREA等都是可以在subprocedure中使用的。只不过要在main section中定义。”

这里main procedure就不是subprocedure。subprocedures是nomain。

第二引用没有违背IBM的mainprocedure定义odb。同时,也没有明确说subprocedures可用定义odp,注意main H表between subprocedures之间的含义,不是说subprocedures可用定义odp,仅仅是main procedure可以定义odp,而subprocedures可以使用odp。
    经验证明在subprocedures可以定义odp和使用odp,进行文件操作,是可用的。但是,编译时要报10级警告信息,IBM在v6r1版之前的文档都没有对此说明(不知道v7版是否有明确说明?),还是只限于main procedure。我们不能承担subprocedures定义odp和使用odp的风险和责任,如果这是一个金融项目。

我上面说的通过callb或callp对服务程序的有定义F表,odp,module的操作,对subprocedures是不能使用的。如果再需要function call对module的ODP进行操作,通常需要两级服务程序进行转换调用。

论坛徽章:
0
16 [报告]
发表于 2011-06-30 15:11 |只看该作者
本帖最后由 passthru 于 2011-06-30 15:15 编辑

说明一点,我把一个项目使用95%以上的module,通过bnddir和服务程序实施的项目叫做“module项目”。

如果项目是用module项目的模式实施,各module之间的调用,就要注意到function call对odp的操作。

论坛徽章:
0
17 [报告]
发表于 2011-06-30 15:39 |只看该作者
回复 15# passthru


这里说,FILE,I-SPEC,DATA AREA等都是可以在subprocedure中使用的。只不过要在main section中定义。”
这里main procedure就不是subprocedure。subprocedures是nomain。

我之前没说清楚。我想说的是F表要在main source section中有定义,并没说一定要在main procedure中定义。main source section和main procedure是两码事。
main source section是指H表和P表之间的内容,按照H, F, D, I, C, O的顺序依次定义的各表。如果定义H NOMAIN的话,那么这个module就没有main procedure。在main source section定义的各表,就可以被module中所有的subprocedure使用。

再贴一段red book的解释:
The NOMAIN keyword on the H spec is used if there is no mainline logic in this
module. That is to say that the only C specs are those in the subprocedures.
Note that the F specs always go at the beginning of the member, just after the
H spec. These files can be used, either by the mainline code and/or by the
subprocedures. Even if there is no main line logic, the F specs must always be
defined at the beginning of the module. By definition then, all fields defined in
files are global in nature.

二。我之前说的《A Sorcerer’s Guide to System Access andMore》应该算作IBM 官方的red book吧,因为我是从IBM官方网站上下的。
全称叫做:《Who Knew You Could Do That with RPG IV? A Sorcerer’s Guide to System Access and More》

三 贴一段代码,我今天测试的,可以正常调用,并且15编译没有报10级错误。

  1. H NOMAIN                                      
  2. FABC       O    E             DISK            
  3. D SUBF            PR                          
  4. D                               10A           
  5. P SUBF            B                   EXPORT  
  6. D SUBF            PI                          
  7. D  P1                           10A           
  8. C                   IF        NOT %OPEN(ABC)  
  9. C                   OPEN      ABC            
  10. C                   ENDIF                     
  11. C                   EVAL      F1 = P1         
  12. C                   WRITE     ABCR            
  13. C                   EVAL      *INLR = *ON     
  14. C                   CLOSE     ABC            
  15. C                   RETURN                    
  16. P                 E        

  17. DDS:
  18. A          R ABCR                  
  19. A             F1            10A                        
复制代码


以上只是想弄清楚subprocedure的用法,欢迎交流。
谢谢

论坛徽章:
0
18 [报告]
发表于 2011-06-30 15:58 |只看该作者
你是什么os400版本?我的是v5r4,编译会报:

*RNF7534 10      1 Files should be closed explicitly when NOMAIN is specified on
                   the Control specification.

论坛徽章:
0
19 [报告]
发表于 2011-06-30 16:13 |只看该作者
本帖最后由 niuhua77 于 2011-06-30 16:14 编辑

那就奇怪了,我的也是V5R4M0
我编译的信息:
  1. M e s s a g e S u m m a r y
  2. Msg id Sv Number Message text
  3. *RNF7086 00 1 RPG handles blocking for the file. INFDS is updated only
  4. blocks of data are transferred.
  5. * * * * * E N D O F M E S S A G E S U M M A R Y * * * * *
  6. 5722WDS V5R4M0 060210 RN IBM ILE RPG  
  7. F i n a l S u m m a r y
  8. Message Totals:
  9. Information (00) . . . . . . . : 1
  10. Warning (10) . . . . . . . : 0
  11. Error (20) . . . . . . . : 0
  12. Severe Error (30+) . . . . . . : 0
  13. Module PASSFSPEC placed in library XXXX. 00 highest severity. Created on 30/06/11 at 16:08:33
复制代码

论坛徽章:
0
20 [报告]
发表于 2011-06-30 16:17 |只看该作者
另外,你的英语理解与我的理解不同。

H nomain
FMyfile    o        e                    disk
....
就是subprocedures。

如果H表没有指出,默认值是main,无论是module,还是procedure编译的module都是upe模式的,而不是subprocedures的pep模式的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP