Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7610861
  • 博文数量: 1769
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16352
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1769)

文章存档

2024年(15)

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类:

2006-04-21 17:32:23

这段时间在实施海关EDI联网系统,实施过程中,遇到了各式各样的问题,其间有需要清除一个PF中某个字段内容。
按照传统处理办法,会首先考虑使用RPG语言处理,如下面的ZIJ10R程序(ZCPSTP 親工程順序番号''''U''''标志清除 /BATCH )。

                           Work with Members Using PDM                 S65F6F8B
                                                                               
 File  . . . . . .   QRPGSRC                                                   
   Library . . . .     R21EMS               Position to  . . . . .             
                                                                               
 Type options, press Enter.                                                    
  2=Edit         3=Copy  4=Delete 5=Display       6=Print     7=Rename         
  8=Display description  9=Save  13=Change text  14=Compile  15=Create module...
                                                                               
 Opt  Member      Type        Text                                             
      ZIJ10R      RPG          ZCPSTP 親工程順序番号''''U''''标志清除 /BATCH       
      ZIJ101R     RPG          备案完成数据备份                                
      ZIJ102R     RPG          备案完成CM数据备份                            
      ZIJ201R     RPG          变更数据提取                                    
      ZIJ202R     RPG          变更数据提取/TRF专用                        
      ZIK01R      RPG          正式报核:料件库存数据生成(归类)              
      ZIK02R      RPG          正式报核:成品库存数据生成(归类)              
                                                                               
                                                                         Bottom
 Parameters or command                                                         
 ===>                                                                          
 F3=Exit          F4=Prompt             F5=Refresh            F6=Create        
 F9=Retrieve      F10=Command entry     F23=More options      F24=More keys    
                                                                               

处理PF文件的某个字段内容,RPG语言的模板(颜色区别PF、PFR、FIELD)如下:

 Columns . . . :    1  71           Browse                       R21EMS/QRPGSRC
 SEU==>                                                                  ZIJ10R
 FMT *  ..... *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 
        *************** Beginning of data *************************************
0001.00      **==============================================================* 
0004.00      FPF      UF  E           K        DISK                            
0004.01      F*                                                                
0004.02      C           *LOVAL    SETLLPF                                 
0004.03      C                     READ PFR                      90            
0004.04      C           *IN90     DOWEQ*OFF                                   
0004.05      C           FIELD     IFEQ ''''U''''                                   
0004.06      C                     MOVEL*BLANK    FIELD                       
0004.07      C                     ENDIF                                       
0004.08      C                     UPDATPFR                                 
0004.09      C                     READ PFR                      90            
0004.10      C                     ENDDO                                       
0004.11      C**                                                               
0120.00      C                     SETON                     LR                
        ****************** End of data ****************************************
                                                                               
                                                                               
 F3=Exit   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle   F12=Cancel     
 F16=Repeat find        F24=More keys                                          
                                         (C) COPYRIGHT IBM CORP. 1981, 2002.   

但事实上,如果是单独更新一些字段内容,可以采用另外一种更简便的处理方式,那就是利用RUNSQLSTM命令。
首先,利用CRTSRCPF在LIB下创建QTXTSRC的SOURCE FILE。
然后,创建类型为TXT的SOURCE MEMBER。
 Columns . . . :    1  71           Browse                       R21EMS/QTXTSRC
 SEU==>                                                               CLRZCPSTP
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 
        *************** Beginning of data *************************************
0001.00 UPDATE R21AFLB1/ZCPSTP SET ZGPSPR='''''''' WHERE ZGPSPR=''''U'''';                
        ****************** End of data ****************************************
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
 F3=Exit   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle   F12=Cancel     
 F16=Repeat find        F24=More keys                                          
                                         (C) COPYRIGHT IBM CORP. 1981, 2002.   

最后,调用RUNSQLSTM命令,插入到CLP程序当时,实现更新字段内容。

 Columns . . . :    1  71            Edit                         R21EMS/QCLSRC
 SEU==>                                                                 ZEIA1L0
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 
0021.00              CLRPFM     FILE(ZCPSTP)                                   
0022.00                                                                        
0026.00              CALL       PGM(ZEIA2R)                                    
0026.01                                                                        
0026.02 /* CLEAR ZCPSTP WHERE ZGPSPR=''''U'''' TRF LIU ADD 05.12.30*/               
0026.04              RUNSQLSTM  SRCFILE(R21EMS/QTXTSRC) SRCMBR(CLRZCPSTP) +    
0026.05                           COMMIT(*NONE)                                
0027.00 /* TRF LIU ADD END.*/                                                  
0027.01                                                                        
0031.00              CPYF       FROMFILE(ZCPSTP) TOFILE(ZCPSTB) +              
0032.00                           MBROPT(*REPLACE) FMTOPT(*NOCHK)              
0043.00                                                                        
0044.00  END:        ENDPGM                                                    
        ****************** End of data ****************************************
                                                                               
                                                                               
                                                                               
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                                                                  
                                                                              

△使用RUNSQLSTM需要注意事项:

(1). SQL语句的成员类型一定要指定为TXT;
(2). 每条语句要以分号“;”结束;
(3). 不支持Select语句;
(4). 如果不是使用事务处理,应该将COMMIT(*CHG)—>COMMIT(*NONE),否则执行RUNSQLSTM命令出错,而且会造成SQL语句失效。

阅读(3145) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~