Smart/400开发上手5: Cobol开发标准

摘要:
ENVIRONMENTIVIVION.CONFIGURATIONSECTION.SOURCE-COMPUTER.IBM-AS400.OBJECT-COMPUUTER.IBM-AS4 00.DataDivision:工作存储·为任何用户定义的工作变量使用有效的WSAA字段

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.SOURCE-COMPUTER. IBM-AS400.
OBJECT-COMPUTER. IBM-AS400.

 这个没什么说的。

Data Division : Working Storage


· Use the prefix WSAA- for fields for any user defined working variables. You should group
together data which forms a logical group, e.g. subscripts.

使用WSAA-作为用户定义字段前缀;


· Use asterisks (*) to separate logical groups of data and to make the working storage easier
to browse.

使用星号*分隔数据逻辑组,使代码易读;


· Two fields must be set up at the beginning of working storage containing the program name
and its version number. Whenever the program is totally revised, the version number is
incremented by 1.
01 WSAA-PROG PIC X(05) VALUE(annnn).
01 WSAA-VERSION PIC X(02) VALUE(nn).

在working storage开头必须定义两个字段:程序名称和版本号,每次修改版本号增加1;


· All files which are used by the program, including subsystem specific logical files, must be
defined under an 01 level of:
01 FORMATS.
   03 aaaaREC PIC X(10) VALUE ('aaaaREC').
 03 bbbbbbbREC PIC X(10) VALUE ('bbbbbbbREC').

所有用到的逻辑文件(LF文件、子系统、表),都定义在01级;


· All tables used by the program must be defined under an 01 level of:
01 TABLES.
   03 Tnnnn PIC X(05) VALUE ('Tnnnn').
所有的表也定义在01级,表也要在01 FORMATS.定义,格式是:TnnnnREC

例子:

       01  FORMATS.
           03  BMSGREC                 PIC X(10) VALUE 'BMSGREC'.
           03  BPRDREC                 PIC X(10) VALUE 'BPRDREC'.
           03  BSPRREC                 PIC X(10) VALUE 'BSPRREC'.
           03  BSSCREC                 PIC X(10) VALUE 'BSSCREC'.
           03  BUPAREC                 PIC X(10) VALUE 'BUPAREC'.
           03  DESCREC                 PIC X(10) VALUE 'DESCREC'.
           03  AE52DATREC              PIC X(10) VALUE 'AE52DATREC'.
           03  GR04DATREC              PIC X(10) VALUE 'GR04DATREC'.
           03  AA01REC                 PIC X(10) VALUE 'AA01REC'.
           03  ITEMREC                 PIC X(10) VALUE 'ITEMREC'.
           03  TT832REC                PIC X(10) VALUE 'TT832REC'.


· All errors used by the program must be defined under an 01 level of:
01 ERRORS.
  03 annn PIC X(04) VALUE ('annn').

错误必须定义在01级。


· All PICs must start in column 40.

PIC必须起始在40列;


· Always use indentation and line up the levels. Ideally, 4 characters of indentation should be
used:
01 WSAA-GROUP-NAME
    03 WSAA-DATA-NAME-1
    03 WSAA-SUB-GROUP-NAME
        05 WSAA-DATA-NAME-2

一般使用4个字符的缩进;

Procedure Division


· Each section must begin on a new page.

所有的节必须开始在新页;


· All sections must be prefixed by a number. These should be incremented sequentially to
simplify locating them within the program.

所有的节开始于一个递增的数字前缀;


· Paragraphs within a section should all increment from the section header number in steps of
at least 10.

数字前缀至少递增10,比如1000-INITIALISE,后面的第一个节必须是1010-,第二个是1020-,也可以跳增,比如第二个也可以1080-;


· Section headers should be underlined by a row of asterisks (*). Above each section there
must be a brief description of the functions, enclosed in asterisks.
· Asterisks (to indicate comment lines) must be used to separate logical blocks of statements
and to improve readability.

使用星号*分隔块;


· Use 4 characters of indentation for IF, PERFORM statements etc.

IF、PERFORM也是4个字符缩进;


· Always complete IF, PERFORM statements with END-IF, END-PERFORM etc.
· All statements must have their right hand portion aligned to column 48.

所有的声明,必须在右侧对齐于48列,包括了TO,=, USING, OF......


· The exit paragraph for each section will be called nnnn-EXIT, where n has the same first
digit as the section header.

退出段以nnnn-EXIT定义,其中nnnn是起始数字;


· All CALLs to subroutines and subprograms must be explicit, not dynamic, i.e. a working
storage variable should NOT be used to hold the name of the subroutine / program to be
called. The only exception to this is for table driven subroutine calls.

不能使用子程序的变量名称定义;


· STOP RUN must not be used.

不能使用STOP RUN;


· On-line mainline programs should never explicitly issue an EXIT PROGRAM, but should
allow MAINF/MAING to do this.
· For on-line screen programs, the procedure division will be using two linkage areas, both in
copybooks. The first area is WSSPCOMN and the second depends on the area you are
working in, as follows:

  • SMART - WSSPSMART
  • LIFE - WSSPLIFE
  • POLISY - WSSPFANG
  • FSU - WSSPFSU
  • Window Program - WSSPWINDOW

· The GO TO command should only be used with a very good reason. Its use should be
restricted to jumping past a block of code that is not required, and even then it is preferable
to PERFORM a section instead.

谨慎使用GO TO;

· When validating an item against a table, read the ITEM or the ITDM file first and then the
DESC file if you want the description. The DESC file is read using a specific language
code, and if the description is not present in the language of operation, it will appear that
the item does not exist.

当验证一个表对应的一个项,先读ITDM或ITDM文件,如果需要描述说明则读DESC描述文件。

读DESC文件使用特定的语言代码,如果描述不存在于操作语言中,它会提示该项目不存在;


· Use the literal from working storage instead of a character string for such things as MRNF,
READR, T1690 in the procedure division, i.e.

使用原词而不是引用字符定义MRNF, READR, T1690之类的东西;

  • MOVE T1690 TO... 正确
  • MOVE ‘T1690’ TO...错误
  • MOVE READR  TO AA01-FUNCTION... 正确
  • MOVE ‘READR’  TO AA01-FUNCTION... 错误


· When setting up a key comprised of multiple fields, set the fields up in the order that they
appear in the key, since this is easier to read and to check.

· After all I/O calls, check for the abend conditions first.

在I/O调用之后,首先要检查退出条件(非常重要);


· If there is an abend condition, move the PARAMS to SYSR-PARAMS as well as the
STATUZ to SYSR-STATUZ.

在退出条件内部,以下两项需要赋值,SYSR-STATUZ、SYSR-PARAMS :

           IF AE52DAT-STATUZ        NOT = O-K AND ENDP

  •               MOVE AE52DAT-STATUZ      TO SYSR-STATUZ
  •               MOVE AE52DAT-PARAMS      TO SYSR-PARAMS
  •               PERFORM 600-FATAL-ERROR

           END-IF.


· All subroutines should be called with a FUNCTION. The subroutine should check that the
function passed is held in its working storage, and, if it is not, should return a status of
FUNC to the calling program.
· All subroutines should pass back a STATUZ to the calling program. This should always be
'****' if the subroutine did not encounter an error condition. The calling program must
always check for a STATUZ of O-K on return from the call. A returned STATUZ other
than O-K is passed to SYSR-STATUZ and the abort processing is performed, or the
returned STATUZ is placed in the XXXX-ERR field as an error code.

Batch Program Sections Standards


All batch programs must include a copybook called MAINB as the first statement of the
procedure division. This copybook controls the overall logic flow of the program and will
perform the following, if required:
· Open, update and close a batch audit group during processing
· Remove all softlocks except those with an error status or held status
· Maintain a count of all records read, records not processed and records in error
· Restarting logic.
MAINB performs the following sections in the appropriate place:
0900-RESTART
Please refer to the Restart Logic section below.
1000-INITIALISE

  • Read any tables etc. applicable to the whole process,
  • Open files, set up report headings,
  • OPEN SQL cursors, etc.
  • Test for valid restart method 1 (re-run), 2 (continue) or 3 (skip completed cycles).

2000-PRIMARY-READ

  • Read primary file record
  • Call I/O module
  • SQL FETCH
  • COBOL READ etc.)
  • At end, set WSSP-EDTERROR to ENDP.

2500-EDIT

  • If applicable, perform any checking/validation to ensure the record read really requires
  • if not required, set WSSP-EDTERROR to spaces, (验证不需要的记录)
  • if error, move an error code to WSSP-EDTERROR,(错误发生)
  • else move OK to WSSP-EDTERROR.(验证正确的数据)
  • IF WSSP-EDTERROR = O-K Soft lock the entity, if applicable. (如果需要修改记录,则Soft lock)
  • If entity already locked, move spaces to WSSP-EDTERROR.(如果已上锁)

3000-UPDATE
Perform all the processing related to the primary record read, writing of details to a report etc.

执行所有与主记录相关的处理


3500-COMMIT
Please refer to the Restart Logic section below.
3600-ROLLBACK

Batch Program Development Checklist

Listed below is a summary of the steps required when building and maintaining batchprograms. Before starting, ensure that you have the following:
· The design of any reports required.
· The new subsystem specification or updated current manual.
To develop a new program or modify an existing one:
1. Build any new data sets required and modify any existing ones if required (CB ... *PF).
2. Generate any new or modified access methods required and their I/O modules (CB ... *LF).
3. If required, generate a new, or modify the existing, parameter prompt program (CB ...
*PARM).
4. Build or modify any printer files required (ED and CB ... *PRTF).
5. Create or modify the Batch Cobol program (ED Bnnnn). The standard batch skeleton
*CBL in PAXUS/XGENSKEL is for a report program.
6. For a new program, add the coding required in the standard section (ED ...).
7. Compile the program (CB ... *CBL).
8. If a CL program is required, for new programs, copy the standard CL skeleton program in
PAXUS/XGENSKEL (ED Cnnnn *CLP).
9. Compile the CL program (CB ... *CLP).
10.Ensure that the batch schedule details, batch extract details (T1697), control total details
(T1671) and reconciliation rules (T1672) are set up as required.
11.Test the programs.
While testing the program, you should ensure that:
1. All standards have been adhered to, especially that all error numbers, tables, record formats,
etc. are included in the appropriate places in working storage. (This information is required
by the Data Dictionary).
2. All control totals are accumulated correctly.
3. The program will run successfully even if the primary input file is empty or no processing is
required.
4. All database maintenance is performed correctly, including updates to the schedule
submissions file.
5. The program successfully traps any database or system errors which could occur.
6. The program will restart correctly if it is cancelled prior to successful completion.
7. On completion of a new mainline program, the program is registered to the correct
subsystem in the Data Dictionary.

 

Restart Logic

免责声明:文章转载自《Smart/400开发上手5: Cobol开发标准》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇关于ios苹果系统的中的右键事件,查遍了全网都没有的小技巧。几个常见规则引擎的简单介绍和演示下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

PIC中档单片机汇编指令详解(7)完

GOTO 程序无条件跳转到指定的地址 语法形式:GOTO m 操作数:m为11位立即数指定的目标地址 执行时间:2个指令周期 执行过程: m→PC【10:0】 PCLATH【4:3】→PC【12:11】 状态标志影响:无 说明:程序无条件立即强行跳转到目的地址处继续执行。目的地址由本指令内含的11位地址码和特殊寄存器PCLATH中的【4:3】一起构成完整的...

微信公众平台开发(104) 自定义菜单扫一扫、发图片、发地理位置

关键字:微信公众平台 自定义菜单扫一扫 发图片 发地理位置作者:方倍工作室原文:http://www.cnblogs.com/txw1958/p/weixin-menu-new-type.html 自定义菜单能够帮助公众号丰富界面,让用户更好更快地理解公众号的重要功能。微信增加了点击菜单后调起扫一扫(支持二维码/一维码)、发图片、发地理位置的能力,需开发实...

vue 图片下载到本地,图片保存到本地

  必须同源(访问的网站域名与服务器域名一致)才能下载 1 2 3 4 5 6 downs() {   var alink = document.createElement("a");   alink.href = this.shop.shoppic_url;   alink.download = "pic"; //图片名   al...

Npoi XWPF Word 导出时插入图片无法显示

npoi中XWPFRun.AddPicture,各种尝试,各种看源代码,也无法将插入的图片显示出来,用RAR程序打开word查看Document.xml文件,提示xml文件错误.在网上找到java的poi的解决办法,自定义Pic元素. int EMU = 9525; width *= EMU; he...

移动端屏幕适配+事件+常见问题解决

移动端屏幕适配 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> 移动端屏幕适配与响应式的区别移动端屏幕适配: 移动端 宽高% / rem 字体px 宽...

PIC 里面关于 __CONFIG( ) 配置位

一.配置字PIC单片机的配置字可以用__CONFIG命令来定义:#i nclude__CONFIG(x) ;其中x是配置字,头文件中定义了相应的配置说明符。 如:__CONFIG(WDTDIS & XT & UNPROTECT);这将关闭看门狗,设置XT振方式,程序不加密。注意:不同的配置符间用'&'相联,未定义的部分保留未编程状态...