Smart/400开发上手2: COBOL批处理程序处理过程

时间:2022-07-29 23:26:49

开发目的:
1、建立DB2数据库表;
2、建立逻辑视图;
3、通过Cobol程序将一个源数据表的数据通过一定公式计算后导出到另一个目的数据库表
源数据表:TIM3PF
目的数据表:TIM4PF
4、在AS400中建立批处理,处理Cobol程序

预先准备:建立Workunit、为用户建立权限 (略)

登陆400环境,开发需要更换company,比如开发是0,按F5刷新

Create DataSet

注意:

smart work unti 的severity control输入9

DataSet subsystem:lifeacs

选field的快捷键:F4 ,选中用*

1、第一步,建立2个物理文件PF
TIM3PF、TIM4PF
选择字段(可以用快捷键F4),比如AGNTNUM, ADDRESS
编译物理文件:
> CB MEMBER(TIM3PF) TYPE(*PF) WORKU(TIM003)
> CB MEMBER(TIM4PF) TYPE(*PF) WORKU(TIM003)

2、第二步,建立2个逻辑视图LF
TIM3、TIM4

编译逻辑视图:
> CB MEMBER(TIM3) TYPE(*LF) WORKU(TIM003)
> CB MEMBER(TIM4) TYPE(*LF) WORKU(TIM003)

编译完毕后可以看看逻辑文件的结构:
命令:
BR TIM3SKM *cpy

结果:

 Columns . . . :                 Browse                    CL4DEVCPY/QLBLSRC
SEU==> TIM3SKM
FMT ** ...+... ...+... ...+... ...+... ...+... ...+... ...+...
*************** Beginning of data *************************************
. *
. *(c) Copyright CSC Corporation Limited .....
. * All rights reserved. CSC Confidential.
. *
. TIM3-PARAMS.
. TIM3-FUNCTION PIC X().
. TIM3-STATUZ PIC X().
. TIM3-LEVEL-ID.
. TIM3-GEN-DATE PIC ().
. TIM3-GEN-TIME PIC ().
. TIM3-VN PIC X().
. TIM3-DATA-LOCATION PIC X().
. TIM3IO PIC X().
. TIM3-RRN PIC () COMP-.
. TIM3-FORMAT PIC X().
. *
. TIM3-DATA-AREA.
. TIM3-DATA-KEY PIC X().
. TIM3REC-KEY-DATA REDEFINES TIM3-DATA-KEY.
. FILLER PIC X().
. *
. TIM3-NON-KEY PIC X().
. TIM3REC-NON-KEY-DATA REDEFINES TIM3-NON-KEY.
. TIM3-JOB-NAME PIC X().
. TIM3-USER-PROFILE PIC X().
. TIM3-DATIME PIC X().
. TIM3-AGNTNUM PIC X().
. TIM3-ADDRESS PIC X().
. *
****************** End of data ****************************************

3、为DB2源数据库TIM3PF表灌数据
insert into "CL4DEVDTA"."TIM3PF"
(AGNTNUM, ADDRESS, USER_PROFILE, JOB_NAME, DATIME)
values ('003','珠海市', 'CHN0011484', 'J_ACSAG109', CURRENT DATE)

结果:

Smart/400开发上手2: COBOL批处理程序处理过程

返回值:

O-K (****) - Successful completion of database operation
MRNF - Record with key given was not found for read request (or no record is currently
stored)
ENDP - End / beginning of file reached when reading sequentially
HELD - Record required for updating is already held by another user
DUPR - The attempted addition of another record to the data set has failed because the
system has detected that the addition of the record would cause a duplicate key
in an access method that is defined as requiring unique keys
FULL - The attempted addition of another record to the data set has failed because the
current record number limit has been reached
BCTL - The key is blank when a non-sequential read/write has been requested
FUNC - Invalid function parameter passed to I/O module
IVRF - Invalid record format passed to I/O module
?? - An error has been detected when processing the database access request