Smart/400开发上手5: Cobol开发标准
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开发标准的更多相关文章
- Smart/400开发上手2: COBOL批处理程序处理过程
开发目的:1.建立DB2数据库表:2.建立逻辑视图:3.通过Cobol程序将一个源数据表的数据通过一定公式计算后导出到另一个目的数据库表源数据表:TIM3PF目的数据表:TIM4PF4.在AS400中 ...
- Smart/400开发上手1:入门
1.介绍 Smart/400是在AS/400之上的开发平台,管理开发.运维的全生命周期. 2.设计基础 Introducing Fields Smart通过字段字典Field Dictionary来存 ...
- Smart/400开发上手3: 练习实践
练习题 在2006年1月1日之前入职且在职的营销员,给予年资补贴2000元: 符合以上条件的,再按以下标准一次性发放职级补贴: 职级代码 简称 补偿金额 A1 AD 6000 B1 SBM 5000 ...
- Boost程序库完全开发指南——深入C++“准”标准库(第3版)
内容简介 · · · · · · Boost 是一个功能强大.构造精巧.跨平台.开源并且完全免费的C++程序库,有着“C++‘准’标准库”的美誉. Boost 由C++标准委员会部分成员所设立的Bo ...
- HTML5 HybridApp开发上手指引
眼下我们项目是基于AngularJS和ionic框架开发的Hybrid App.支持android phone/pad, iPhone,iPad四个平台版本号.以及微信版. 由于使用的技术有点新,所以 ...
- 微信小程序快速开发上手
微信小程序快速开发上手 介绍: 从实战开发角度,完整系统地介绍了小程序的开发环境.小程序的结构.小程序的组件与小程序的API,并提供了多个开发实例帮助读者快速掌握小程序的开发技能,并能自己动手开发出小 ...
- C#中??和?分别是什么意思? 在ASP.NET开发中一些单词的标准缩写 C#SESSION丢失问题的解决办法 在C#中INTERFACE与ABSTRACT CLASS的区别 SQL命令语句小技巧 JQUERY判断CHECKBOX是否选中三种方法 JS中!=、==、!==、===的用法和区别 在对象比较中,对象相等和对象一致分别指的是什么?
C#中??和?分别是什么意思? 在C#中??和?分别是什么意思? 1. 可空类型修饰符(?):引用类型可以使用空引用表示一个不存在的值,而值类型通常不能表示为空.例如:string str=null; ...
- 移动前端开发和 Web 前端开发的区别
http://www.itcast.cn/news/20180125/16033584753.shtml 1,普通PC端开发与移动端开发区别. 先说背景,我大言不惭的说一下,我pc端的前端开发干了有快 ...
- Xamarin Anroid开发教程之Anroid开发工具及应用介绍
Xamarin Anroid开发教程之Anroid开发工具及应用介绍 Xamarin开发Anroid应用介绍 如今智能手机已经盛行了好几年,而针对这些智能手机的软件开发也变得异常火热.但是在Andro ...
随机推荐
- 使用注解配置 AOP
一.使用注解(基于Aspect) 1.spring不会自动去寻找注解,必须告诉spring那个包下的类有注解 1.1 先引入xmlns:context命名空间 <context:componen ...
- Lecture2
共生矩阵:
- windows下Oracle数据库完全删除
1.1 停止所有oracle的服务 1.2 删除安装路径 app及其下所有文件 1.3 删除注册表 regedit 进入 在下列列表中找到与oracle相关的注册表项删除 1.HKEY_L ...
- ACM-ICPC 2018 徐州赛区网络预赛 G Trace(逆向,两颗线段树写法)
https://nanti.jisuanke.com/t/31459 思路 凡是后面的轨迹对前面的轨迹有影响的,可以尝试从后往前扫 区间修改需要push_down,单点更新所以不需要push_up(用 ...
- CSS Sprites (CSS 精灵) 技术
CSS Sprites在国内很多人叫css精灵,是一种网页图片应用处理方式.它允许你将一个页面涉及到的所有零星图片都包含到一张大图中去,这样一来,当访问该页面时,载入的图片就不会像以前那样一幅一幅地慢 ...
- Mysql中Left Join Right Join Inner Join where条件的比较
建立一对多的表 company 和 employee company表 id name address 1baidu北京 2huawei深圳 3jingdong北京 4tengxu ...
- BZOJ 3259 [Sdoi2014]数表 (莫比乌斯反演 + 树状数组)
3529: [Sdoi2014]数表 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 2321 Solved: 1187[Submit][Status ...
- readystatechange事件
IE为DOM文档中的某些部分readystatechange事件. 这个事件的目的是提供与文档或元素的加载状态有关的信息,但是这个事件的行为有时候也很难预测. 支持readystatechange事件 ...
- querySelectorAll()方法
querySelectorAll()方法 调用的对象包括:Document(文档) DocumentFragment(文档片段) Element(元素) querySelectorAll()方法接收的 ...
- 笔记 Bioinformatics Algorithms Chapter7
一.Lloyd算法 算法1 Lloyd Algorithm k_mean clustering * Centers to Clusters: After centers have been selec ...