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

开发目的:
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 . . . :    1  71           Browse                    CL4DEVCPY/QLBLSRC 
 SEU==>                                                                 TIM3SKM 
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7  
        *************** Beginning of data ************************************* 
0001.00       *                                                                 
0002.00       *(c) Copyright CSC Corporation Limited 1986....2004.              
0003.00       *    All rights reserved.  CSC Confidential.                      
0004.00       *                                                                 
0005.00        01  TIM3-PARAMS.                                                 
0006.00          03  TIM3-FUNCTION             PIC X(00005).                    
0007.00          03  TIM3-STATUZ               PIC X(00004).                    
0008.00          03  TIM3-LEVEL-ID.                                             
0009.00            05  TIM3-GEN-DATE           PIC 9(00008).                    
0010.00            05  TIM3-GEN-TIME           PIC 9(00006).                    
0011.00            05  TIM3-VN                 PIC X(00001).                    
0012.00          03  TIM3-DATA-LOCATION        PIC X(00001).                    
0013.00          03  TIM3IO                    PIC X(00010).                    
0014.00          03  TIM3-RRN                  PIC 9(09) COMP-4.                
0015.00          03  TIM3-FORMAT               PIC X(00010).                    
0016.00       *                                                                                                                              
0017.00          03  TIM3-DATA-AREA.                                          
0018.00            05  TIM3-DATA-KEY                   PIC X(00256).          
0019.00            05  TIM3REC-KEY-DATA REDEFINES TIM3-DATA-KEY.              
0020.00             07  FILLER                         PIC X(00256).          
0021.00       *                                                               
0022.00            05  TIM3-NON-KEY                    PIC X(00084).          
0023.00            05  TIM3REC-NON-KEY-DATA REDEFINES TIM3-NON-KEY.           
0024.00             07  TIM3-JOB-NAME                  PIC X(00010).          
0025.00             07  TIM3-USER-PROFILE              PIC X(00010).                             
0026.00             07  TIM3-DATIME                    PIC X(00026).            
0027.00             07  TIM3-AGNTNUM                   PIC X(00008).            
0028.00             07  TIM3-ADDRESS                   PIC X(00030).            
0029.00       *                                                                 
        ****************** End of data **************************************** 
                                                                                
                                                                                
                                                                                                                     
View Code

 

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

结果:

 

 

返回值:

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

 

posted @ 2016-09-02 14:01  昕友软件开发  阅读(1391)  评论(1编辑  收藏  举报
欢迎访问我的开源项目:xyIM企业即时通讯