<< Back to man.lupaworld.com   LUPA网友原创,转载请注明出处lupaworld.com及作者

返回总目录

 

5.       程序开发部分-- 6

5.1.            Java. 6

5.2.            RPGLE. 6

5.3.            RPG.. 6

5.3.1.      在写程序之前-- 6

5.3.2.      显示程序DDS- 6

5.3.3.      执行程序RPG- 6

5.3.4.      编译及调试 其它-- 6

5.3.5.      数据库的操作及独占处理-- 6

5.3.6.      多个相关数据库操作的回滚ROLBKCOMIT操作-- 6

5.3.7.      SDA+ RPG IV 进行子文件系统设计-- 6

5.3.8.      使用SDA + RPG IV 进行交互式程序设计-- 25

5.4.            CL. 25

5.5.            DELPHI 26

5.5.1.      简单的利用ODBC- 26

5.6.            VB. 26

5.7  MS.NET. 26

5.8             API 26

5.9             业务相关的数据库设计、系统分析... 26

5.10           UDB/400 数据库JDBC 程序设计... 26

5.10.1 UDB/400 数据库JDBC 访问方法-- 26

5102  使用JDBC 连接池-- 26

5.程序开发部分

5.1.Java

5.2.RPGLE

5.3.RPG

 

5.3.1.在写程序之前

       关于程序开发,想强调的是:业务流程先于程序——程序是给计算机看得,流程是人执行的;程序是死的,而流程则是一个相对模糊的东西。所以在写程序前,要先弄清楚自己到底要做什么,然后将自己的思想表达给计算机——这个过程就是CODING。

 

      RPG的长处在于数据库处理,界面交互能力倒是其次。所以最开始需要了解一些关于数据库文件的相关知识(这里就只强调跟400有关的)。在下面的操作中,假设朋友已经会用STRPDM,会文件的COPY,修改。

       数据文件PF:COPY一个已经有的比较快点。然后修改一下里面的数据,就是自己的。

A*假设文件名字叫BAE

A          R BAER                                          ß记录名字

A            AREA           3          COLHDG('AREA CODE') ßfield

A            AREANM        22          COLHDG('AREA DESC ')ßfield

 *                                                        

A          K AREA                                          ßKey,可选

       关于域定义的参考,请在程序里面输入,然后在该行按F4,再在要看得参数上按F1,就可以得到详细信息。

       数据文件LF:逻辑文件的作用是按特定的关键字顺序来检索数据库里面的记录。LF中的域定义可以是任意顺序,不必跟PF中顺序的一致。更进一步,LF可以先过滤一部分的记录,减少搜索的范围。下面先看LF如何定义,具体使用程序中再说:

A          R BAER                     

A                                      PFILE(BAE) ß表示这个LF引用的是BAE文件

A          K AREA                                 ß搜索关键字是AREA CODE

这个是简单的,再看一个稍微复杂点的:

A          R BAER                     

A                                      PFILE(BAE)

A          K AREANM                              

A          S AREA                      COMP(EQ '001')

上面的片断里面,关键字S表示“选择”,COMP表示比较,EQ表示等于。整句连起来就是:只选择AREA等于001的那些记录。

       PS:如果一个PF每个库里面都有,如何确保被引用的就是自己希望的那个?将目标文件放在位于库列表的最上面的库里面。

5.3.2.显示程序DDS

       DDS的创建,有些朋友用SDU(屏幕设计工具)比较快。但是如果是有类似的界面,则COPY一下比较方便。以下片断是几乎每个DDS都要的,除了REF那句可选以外。

A* 假设显示文件名字叫EX001D

A                                      DSPSIZ(24 80 *DS3)ß设定显示屏大小

A                                      REF(*LIBL/BAE01L)ß参考文件,subfile中使用

A                                      CHGINPDFT       

A                                      PRINT           

再来看看接下来要定义什么东西:

A          R C0                                         ß显示画面的名字

A                                      CA11(11 ' 退出 ')

A                                      CF08(08 ' 测试 ')

现在我们知道我们有一个显示画面叫C0(因为一个程序可能不止一个画面,这样需要定义不同的画面来处理不同的事务);而且这个画面还有3个命令键可以响应:F11,F8,ENTER(ENTER是系统默认的处理键)

再给这个画面添上几个域:

001 A                                  5 19' 选项 ..........:' ß常量,说明用

002 A            VSELEC    R        B  5 38REFFLD(DICT/SELEC DICT00F)

003 A                                      DSPATR(HI CS MDT)         

004 A                                      VALUES('1' '2' '3')     

005 A*                                                              

006 A            VNAME          6A  I  7 20

007 A*                                                             

008 A  81                              9 20' 查询日期 :'             

009 A            VDDATE    R        B    +1REFFLD(DICT/O8DAT DICT00F)

010 A                                      DSPATR(HI UL)             

如上,

a.001和008行定义了2个显示常量,在屏幕上起提示和说明作用;

b.002行定义了一个选择域VSELEC,R表示是参考数据库里面已经有的域格式,B代表输入输出双向(双向的意思就是域里面的信息被程序修改了以后还可以反馈给画面), 5 38表示在第5行第38列,REFFLD(DICT/SELEC DICT00F)表示参考系统DICT00F文件里面的SELEC域的格式。003行和004行表示VSELEC的属性,003行是显示控制:HI高亮、CS字符分割方式、MDT必须输入。004行表示这个域可能/只能输入的值。

c.006行表示一个自己定义的域,名字叫VNAME, 6个字符长,I表示只做输入用

d.009行表示定义了一个VDDATE域,用来显示日期。010行表示显示控制:HI高亮、UL下划线。

e.008行的81是一个指示符,意思是当81号指示符是1的时候,“查询日期”才显示。

    这样,显示文件就算定义完毕。

5.3.3.执行程序RPG

    一个程序划分的粗一点,也就是2个部分:一是数据定义,一是执行代码。数据定义包括了文件引用(相当于C语言里面的头文件)、内部DS定义、普通常量等等;执行代码则包括主过程和子程序,也就是程序的主体及要调用的子函数。(详细定义方式请参见RPG400 REFERENCE)。

    整个程序的执行过程如下:

       定义部分(包括H/F/E/I/D等)à程序初始化(如果有INZ函数则自动执行,否则就是用户自己定义的变量初始化程序,也可以2个都执行)àMAIN循环(包括人机交互、数据处理、反馈)à退出(用户按退出命令键或者程序自动退出)。

    如果用代码的表示方式来讲,就是如下的结构:

H            Y                            ß头文件定义

F*----------------------------------------

FBAE01L  IF  E           K        DISK    ß引入LF,搜索用

FBAE02L  IF  E           K        DISK                     

F            BAE                                 KRENAMEBAE2

F*请注意以上的2句:在使用不同LF检索同一个PF的时候,由于PF记录名字相同而导致一个冲突,这里就通过将记录名字重新命名为BAE2而避免这个问题。

FEX001D  CF  E                    WORKSTN        ß显示界面

I* 下面定义一个DS结构,示范用

I@PARM       DS                                       ß结构名字叫@PARM

I                                        1   6 #FCDDI ß结构体内部的域

I                                        7  12 #TCDDI ß起止范围可以不连续

C* 下面进入代码段,包括初始化,子程序

C           *INZSR    BEGSR                     ß本片断可以放在程序的任何地方

C                     MOVE *OFF      INDEX  40  ß但无论放哪里都是最先执行

C                     MOVE *ZERO     RESULT  40

C                     ENDSR 

C*请注意以上的2句,最后2个40的位置错开了一位,但是意义完全不一样。第一个表示是INDEX变量的长度是40,类型是字符型(默认的,可以省略);第二行的40表示RESULT长度是4,小数点位置在0位——这是个数字型的变量。在用F4查看的时候,会很清楚地看到区别。所以MOVE到变量的数据也不一样(*OFF是字符0*ZERO是数字0)

C* 主体部分,包括接受命令和处理

010 C           *INLR     DOWEQ*OFF            ß程序在此不断循环,知道LR被置ON

011 C                     EXSR MAIN            

012 C                     ENDDO               

C* 往下就是子程序定义了,包括按钮处理在里面

C           MAIN      BEGSR     

C                     EXFMTC0    ß这句是让C0画面获得焦点成为活动画面,程序就停在这个地方,直到输入完数据按了F11/F8/ENTER中的一个。当MAIN执行完毕,程序会从上面的012行跳转到010行,继续执行,直到LR标志被置ON才退出整个程序。当再进来的时候,程序会再次停在这个地方,等待用户命令。

C* F11 = QUIT

C           *IN11     IFEQ *ON                            

C                     SETON                     LR       

C                     ELSE                                

C* F8  = TEST                                   

C           *IN08     IFEQ *ON                  

C           VSELEC    IFEQ '1'                 

C                     MOVE 'AAAA'    VNAME     

C                     ENDIF                    

C           VSELEC    IFEQ '2'                 

C                     MOVEL'BB'      VNAME      ß请注意MOVE和MOVEL的区别

C                     ENDIF                    

C                     ELSE                      

C* 如果有按键,既不是F11,也不是F8,那么就只有ENTER

C                     MOVE 20040623  VDDATE     ß这个域是数字型的,外面不加引号

C                     EXSR SEARCH               ß执行一个搜索子程序

C                     ENDIF

C                     ENDIF

C                     ENDSR

C*

C           SEARCH    BEGSR                    

C           *LOVAL    SETLLBAE         ß先将游标停到最低点,然后遍历整个数据库

C                     READ BAE                      92

C           *IN92     DOWEQ*OFF                      

C                     MOVELAREANM    LIST            

C                     READ BAE                      92

C                     ENDDO                          

C* 上面的片断中READ数据库,如果有记录,那么结果指示符92为OFF状态。如果没有读到记录(到文件末尾了?)就会置为ON。通过检测这个指示符状态可以完成遍历。

C* 下面再来试验一下KEY是如何工作的。

C           KBAE      KLIST                   ß定义一个搜索键

C                     KFLD           KNAME    

C*                                           

C                     MOVE ‘AAA’   KNAME            ß要查找的目标

C           *LOVAL    SETLLBAE                        ß还原游标位置

C           KBAE      CHAINBAE                  93    ß找到名字为AAA,93就置OFF

C           *IN93     DOWEQ*OFF                      

C                     MOVE AREANM    TMPSTR          

C           KLUPASHD    READELUPASHD                    93ß如果数据库有重复记录

就多次查找

C                     ENDDO                          

C                     ENDSR

    关于KLIST的使用:KLIST中FLD的定义必须跟要检索的目标LF中的域一一对应,但可以只有部分。比如LF中定义5个KEY域,分别是1 2 3 4 5,那么KLIST中的定义可以有1,1 2,1 2 3,但不能是2 3。各个对应的域的类型、大小都必须一样。

 

5.3.4.编译及调试 其它

    编译过程可以排除大部分的明显错误:字符拼错、未定义的变量、重复定义。编译完会产生一个SPLF,里面包含错误列表。编译过程不排除逻辑错误。

    去掉逻辑错误就是调试的任务。比如A B两个变量,A 12CHAR, B 8CHAR。希望去掉A的高4位,那么MOVE A   B, 再MOVE B  A就可以。但是这中间如果不CLEAR A,那么A的内容还是没有变化的。程序大了以后逻辑比较复杂,调试有时很困难,这个时候就是需要心细加耐心。

 

    RPG是采用一种结构化的语言,整个的结构可以采用模块化的编程方法。另外要注意的是变量的定义是即定义即用,而且都是全局的。这个将变量局部化的工作就留给程序员来完成——在其它地方不用就是~~~

 

5.3.5.数据库的操作及独占处理

RPG中如果要对数据库进行读取,更新,删除,追加记录的操作,必须以相对应的方式说明对这个文件的引用。关于对数据库各种操作的组合及相应的文件引用声明,总结如下:

只从文件读取纪录

FFILENAME    IF  E           K        DISK

向文件里面写纪录而读取

FFILENAME    O  E                    DISK

读取纪录并更改和/或删除,不追加纪录

FFILENAME   UF  E           K        DISK

读取纪录并更改和/或删除,且追加纪录

FFILENAME   UF  E           K        DISK                      A

读取纪录和追加纪录,不更新和删除

FFILENAME   IF  E           K        DISK                      A

需要注意的是对文件的操作必须和声明相对应,即有追加调用声明必须有WRITE, 有更新或删除声明必须有UPDAT和DELET操作。

在对文件进行操作的时候,通常会用到指示器来判断对数据库的操作是否成功的情况,关于指示器的位置及其所代表的意义,图示如下:

error.jpg
    对文件进行更新或者删除操作的时候,需要注意的一点是更新和删除属于独占操作,同一时间只能为一个SESSION所独占,因而如果有一个SESSION锁定一条纪录,之后再有其他SESSION想以独占的方式读取这个纪录的时候,就会发生显示界面停滞60秒的情况,所以这种现象必须避免。

    这种现象的避免相对来说在带有显示界面的程序中更为重要。因为中间有停顿的过程,所以如果在停顿前锁住某一条纪录,整个停顿期间其他人都不能试图以独占的方式来读取纪录。考虑到这种情况,独占的时间必须要尽可能短。对文件声明UF的时候,一般情况下在对文件纪录进行读取操作的时候,在下面的指示器前的H的位置加上N,这样文件就不是以独占的方式进行读取。

CL0N01N02N03FACTOR1+++OPCDEFACTOR2+++RESULTLENDHHILOEQCOMMENTS++++

C           SDKY0A      CHAINDBREC                  N9899              

在确认需要更新的时候,可以在临更新前锁住纪录,在对需要改变的字段赋值以后,立即进行更新操作。尽可能减少其间的代码以减少独占的时间来防止出现停滞的现象。

 

5.3.6.多个相关数据库操作的回滚ROLBKCOMIT操作

    COMIT和ROLBK主要目的是为了数据的统一性, 一般用在要同时对几个数据库进行增,,改, 确保几个数据库都能正确写入,删除,更新数据, 在程序(CL或RPG都可以, 其他语言不清楚)中, 只有执行了COMIT命令后,数据操作才真正被执行。 只要任何一个数据库的操作出错, 可以用ROLBK命令将之前的数据回档。这样的程序, 如果因为某种原因(如被其他用户强行终止, 短电...)而终止,系统会自动ROLLBACK。

    对需要进行COMIT的文件的声明:

    FFILENAMEIPEAF........L..I........DEVICE+......KEXIT++ENTRY+A....U

FFILENAMEUF   E      K   DISK       KCOMIT             

  数据库纪录的写入或者更新等都不变,有变动的就是根据实际的条件进行确认或者回滚。

CL0N01N02N03FACTOR1+++OPCDEFACTOR2+++RESULTLENDHHILOEQCOMMENTS++++

C                         ROLBK                                       

CL0N01N02N03FACTOR1+++OPCDEFACTOR2+++RESULTLENDHHILOEQCOMMENTS++++

C                         COMIT                                      

带有COMIT的RPG程序一般通过CL程序进行调用,在调用这个程序的时候有一些针对COMIT的操作,包括:

1、创建日志和日志收集器 CRTJRN 和CRTJRNRCV

2、把PF加入日志 STRJRNPF

3、用CL 执行STRCMTCTL和 ENDCMTCTL上面具体用法去查CL REFERENCE

这样任何对该文件的修改都会记日志,当碰到COMIT 命令时确认修改,碰到ROLBK放弃更新.关于后两步的部分代码如下:

STRJRNPF FILE(FILENAME1) JRN(JOURNAL)           

  STRJRNPF FILE(FILENAME2) JRN(JOURNAL)           

  STRCMTCTL  LCKLVL(*CHG)                      

  CALL     PGM(PGMNAME) PARM(&PARM1 &PARM2)   

 ENDCMTCTL                                    

 ENDJRNPF FILE(FILENAME1) JRN(JOURNAL)           

 ENDJRNPF FILE(FILENAME2) JRN(JOURNAL)           

 

5.3.7.SDA+ RPG IV 进行子文件系统设计

 

1、PF定义:

 Columns . . . :    1  71           Browse                     QINGZHOU/QDDSSRC

 SEU==>                                                                  REFILE

 FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        *************** Beginning of data *************************************

0001.00      A* DATA DICTIONARY REFERENCE FILE                                 

0002.00      A* CREATE BY TRF.LIU YUANY YAO 2004.12.18                         

0003.00      A*                                                                 

0004.00      A          R REFMT                                                

0005.00      A            CODE           5A                                    

0006.00      A            NAME          12O                                    

0007.00      A            DESCRPT       30O                                    

0008.00      A            QUATITY        7  0                                  

0009.00      A            PRICE         11  2                                  

0010.00      A            AMOUNT        15  2                                  

        ****************** 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, 2000.   

 

 Columns . . . :    1  71           Browse                     QINGZHOU/QDDSSRC

 SEU==>                                                                 INVOICE

 FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        *************** Beginning of data *************************************

0001.00      A* INVOICE DDS SOURCE CODE                                         

0002.00      A* CREATE BY TRF.LIU YUAN YAO 2004.12.18                          

0003.00      A*                                                                

0004.00      A                                      REF(*LIBL/REFILE)           

0005.00      A          R IV_FMT                                               

0006.00      A            IV_CODE   R               REFFLD(CODE)               

0007.00      A                                      COLHDG(' 发票 ')           

0008.00      A            IV_NAME   R               REFFLD(NAME)               

0009.00      A                                      COLHDG(' 名称 ')           

0010.00      A            IV_QUTITY R               REFFLD(QUATITY)             

0011.00      A                                      EDTCDE(O)                  

0012.00      A                                      COLHDG(' 总数 ')           

0013.00      A            IV_AMOUNT R               REFFLD(AMOUNT)             

0014.00      A                                      COLHDG(' 总金额 ')         

0015.00      A                                      EDTCDE(O)                  

0016.00      A            IV_DESC   R               REFFLD(DESCRPT)            

0017.00      A                                      COLHDG(' 备注 ')           

0018.00      A*                                                                

0019.00      A          K IV_CODE                                              

        ****************** End of data ****************************************

                                                                               

    

                                                                               

 F3=Exit   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle   F12=Cancel     

 F16=Repeat find        F24=More keys                                          

                                                                                 

 

2、SDA设计subfile:

 

A、使用SDA设计子文件:

                                Design Screens                                 

                                                                               

 Type choices, press Enter.                                                     

                                                                               

   Source file . . . . . . . .   QDDSSRC      Name, F4 for list                

                                                                                

     Library . . . . . . . . .   QINGZHOU     Name, *LIBL, *LUPARLIB             

                                                                               

   Member  . . . . . . . . . .   subfile1     Name, F4 for list                

                                                                                

                                                                               

                                                                               

                                                                                

 F3=Exit     F4=Prompt     F12=Cancel                                          

                                                                               

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

 1             SFL01                                                           

                                                                               

   (No records in file)                                                        

                                                                                

 

                                                                               

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

                                                                               

 

                               Add New Record                                  

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type choices, press Enter.                                                    

                                                                                

   New record  . . . . . . . . . . . . . . .   SFL01        Name               

                                                                               

   Type  . . . . . . . . . . . . . . . . . .   SFL          RECORD, USRDFN     

                                                            SFL,    SFLMSG     

                                                            WINDOW, WDWSFL     

                                                            PULDWN, PDNSFL      

                                                            MNUBAR             

                                                                               

                                                                                

                                                                                

 F3=Exit     F5=Refresh     F12=Cancel                                         

                                                                               

 

                               Add New Record                                  

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type choices, press Enter.                                                    

                                                                                

   New record  . . . . . . . . . . . . . . .   SFL01        Name               

                                                                               

   Type  . . . . . . . . . . . . . . . . . .   SFL          RECORD, USRDFN     

                                                            SFL,    SFLMSG     

                                                            WINDOW, WDWSFL     

                                                            PULDWN, PDNSFL     

                                                            MNUBAR             

   Subfile control record  . . . . . . . . .   SFL01C       Name               

                                                                               

  

                                                                               

 F3=Exit     F5=Refresh     F12=Cancel                                         

                                                                               

 

B、子文件主体设计:

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

                                                                               

 12      10    SFL01         SFL                         12/25/04              

         20    SFL01C        SFLCTL    SFL01             12/25/04              

                                                                               

                                                                               

                                                                                

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                      

 Record SFL01 added to member SUBFILE1.                                       +

 

                             Select Database Files                             

                                                                                

 Type options and names, press Enter.                                          

   1=Display database field list                                               

   2=Select all fields for input (I)                                           

   3=Select all fields for output (O)                                          

   4=Select all fields for both (B) input and output                           

                                                                               

 Option    Database File   Library      Record                                 

   1        INVOICE        QINGZHOU                                            

                                                                               

                                                                                

                                                                                

                                                                               

                                                                                

 F3=Exit     F4=Prompt     F12=Cancel                                          

                                                                               

 

                            Select Database Records                             

                                                                               

 Database file  . . . . . :   INVOICE        Library . . . :   QINGZHOU        

                                                                                

 Type options, press Enter.                                                    

   1=Select                                                                    

                                                                               

 Option   Record                                                               

   1      IV_FMT                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                         Bottom

                                                                               

 F3=Exit   F12=Cancel                                                          

                                                                                

 

                            Select Database Fields                             

                                                                               

 Record . . . :   IV_FMT                                                        

                                                                               

 Type information, press Enter.                                                

   Number of fields to roll  . . . . . . . . . . . . . . . . . .     8         

   Name of field to search for . . . . . . . . . . . . . . . . .               

                                                                               

 Type options, press Enter.                                                    

   1=Display extended field description                                        

   2=Select for input (I), 3=Select for output (O), 4=Select for both (B)      

                                                                               

 Option  Field        Length   Type    Column Heading                          

   3     IV_CODE           5    A       发票                                   

   3     IV_NAME          12    O       名称                                   

   3     IV_QUTITY       7,0    P       总数                                   

   3     IV_AMOUNT      15,2    P       总金额                                 

   3     IV_DESC          30    O       备注                                   

                                                                                

                                                                               

 

 

  

                                                                               

                                                                                

                                                                               

                                                                               

 1:IV_CODE 2:IV_NAME 3:IV_QUTITY 4:IV_AMOUNT 5:IV_DESC                          

 

                                                                               

                                                                                

                                                                                

                                                                               

              &1         &2             &3             &4                           

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

 1:IV_CODE 2:IV_NAME 3:IV_QUTITY 4:IV_AMOUNT 5:IV_DESC                         

 

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

                                                                               

                                                                               

                                                                                

 

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

 1:IV_DESC                                                                                                                                   

 

                                Work with Fields                               

                                                                               

 Record . . . :   SFL01                                                         

                                                                               

 Type information, press Enter.                                                

   Number of fields to roll . . . . . . . . . . . . . . . . . .     6          

                                                                               

 Type options, change values, press Enter.                                     

   1=Select keywords   4=Delete field                                           

                                                                               

 Option   Order   Field       Type Use  Length  Row/Col  Ref Condition  Overlap

             10   IV_CODE           O        5   07 015   Y                    

             20   IV_NAME       O   O       12   07 024   Y                    

             30   IV_QUTITY         O      7,0   07 041   Y                    

             40   IV_AMOUNT         O     15,2   07 056   Y                    

             50   OPTX              I        1   07 012                        

                                 

                                                                         Bottom

  Add                               H            Hidden                         

                                                                               

  Add                               P            Program-to-system             

                                                                               

 F3=Exit   F6=Sort by row/column   F12=Cancel                                  

                                                                               

 

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

                                                                                

                                                                               

                                                                               

    

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

 Subfile keywords...: SFLPAG:    12         SFLLIN:     0                      

 

 

                                                                                

                                                                               

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

                                                                               

                                                                               

                                                                                

 1:IV_DESC                                                                     

 

C、定义子文件隐藏字段:

 

                                                               Work with Fields                               

                                                                               

 Record . . . :   SFL01                                                         

                                                                               

 Type information, press Enter.                                                

   Number of fields to roll . . . . . . . . . . . . . . . . . .     6          

                                                                               

 Type options, change values, press Enter.                                     

   1=Select keywords   4=Delete field                                           

                                                                               

 Option   Order   Field       Type Use  Length  Row/Col  Ref Condition  Overlap

             10   IV_CODE           O        5   07 015   Y                    

             20   IV_NAME       O   O       12   07 024   Y                    

             30   IV_QUTITY         O      7,0   07 041   Y                    

             40   IV_AMOUNT         O     15,2   07 056   Y                    

             50   OPTX              I        1   07 012                        

   1         60   IV_DESC           H       30                                 

                                                                         Bottom

  Add                               H            Hidden                        

                                                                               

  Add                               P            Program-to-system             

                                                                                

 F3=Exit   F6=Sort by row/column   F12=Cancel                                  

                                                                               

 

                             Select Field Keywords                              

                                                                               

 Field . . . . . :   IV_DESC              Usage . . :  H                       

 Length  . . . . :   30                                                         

                                                                               

 Type choices, press Enter.                                                    

                                     Y=Yes   For Field Type                    

                                                                                

                                                                               

   Keying options  . . . . . . . . .         Hidden, Input or Both             

                                                                                

                                                                               

   General keywords  . . . . . . . .         All types                         

                                                                                

   Database reference  . . . . . . .   Y     Hidden, Input, Output, Both       

                                                                               

                                                                                

                                                                               

                                                                               

   TEXT keyword  . . . . . . . . . .                                            

                                                                               

                                                                               

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                            

                                                                               

 

                           Define Database Reference                           

                                                                                

 Field . . . . . :   IV_DESC              Usage . . :  H                       

 Length  . . . . :   30                                                        

                                                                               

 Type choices, press Enter.                                                    

                                      Keyword                                  

   Reference field  . . . . . . . .   REFFLD   Y            Y=Yes              

   Reference current DDS source . .     *SRC                Y=Yes              

   Field (if different) . . . . . .            IV_DESC      Name               

   Database file  . . . . . . . . .            INVOICE      Name               

     Library  . . . . . . . . . . .            QINGZHOU     Name, *LIBL, *LUPARLIB

     Record . . . . . . . . . . . .                         Name               

   Override existing field definition:                                         

     New field length . . . . . . .                         +nnnn, -nnnn, nnnn 

     New decimal positions  . . . .                         +n, -n, nn         

     New keyboard shift . . . . . .                         N A X W I D M      

                                                            J O E G            

   Ignore previously specified:                                                

     Validity check . . . . . . . .   DLTCHK                Y=Yes              

     Editing  . . . . . . . . . . .   DLTEDT                Y=Yes               

                                                                               

 F3=Exit   F12=Cancel                                                          

                                                                               

 

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

 1:IV_DESC                                                                     

 

                                Exit SDA Work Screen                           

                                                                                

 Select one of the following:                                                  

                                                                               

     1. Save work since last Enter and exit work screen                        

     2. Exit without saving any work done on the work screen                   

     3. Resume work screen session                                             

                                                                                

                                                                               

 

                                                                               

                                                                                

 Selection                                                                     

     1                                                                         

                                                                                

 F12=Cancel                                                                    

                                                                               

 

D、子文件控制设计:

 

 

                      Work with Display Records                                 

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                                

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

                                                                                

         10    SFL01         SFL                         12/25/04              

 12      20    SFL01C        SFLCTL    SFL01             12/25/04              

                                                                                

       

                                                                               

                                                                               

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

 Image updated for record SFL01.                                                

 

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                               

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

 Work screen for SFL01C. SFL01 displayed as additional record.                 

 

                                                                               

                                                                               

           *date                    发票查询                   *sysname        

                                                               *username       

                                                                                

                                                                               

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

                                                                               

                                                                               

                                                                               

                                                                               

 1:IV_DESC                                                                     

 

         DD/DD/DD               发票查询                  SSSSSSSS             

                    5= 明细查询                           UUUUUUUUUU           

                                                                               

                                                                                

           #   &2p       &3p             &4p              &5p                  

          --  -----    ------------     ---------      --------------------    

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

                                                                               

                                                                                

                                                                               

 1:IV_DESC 2:IV_CODE 3:IV_NAME 4:IV_QUTITY 5:IV_AMOUNT 6:IV_DESC               

 

         DD/DD/DD               发票查询                  SSSSSSSS             

                                                          UUUUUUUUUU           

                    5= 明细查询                                                

                                                                                

           #  发票        名称             总数               总金额           

          --  -----    ------------     ----------     ---------------------   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

           I  OOOOO    OOOOOOOOOOOO     -6,666,666     -6,666,666,666,666.66   

                                                                               

                                                                                  

                                                                               

 1:IV_DESC 2:IV_CODE 3:IV_NAME 4:IV_QUTITY 5:IV_AMOUNT 6:IV_DESC                               

 

 

E、子文件控制关键字:

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

                                                                               

         10    SFL01         SFL                         12/25/04              

 8       20    SFL01C        SFLCTL    SFL01             12/25/04               

                                                                               

                                                                               

                                                                               

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

                                                                                

 

                        Select Subfile Control Keywords                        

                                                                               

 Subfile control record . . . . . . . . . :   SFL01C                           

                                                                               

 Type choices, press Enter.                                                    

                                                                                

                                     Y=Yes                                     

   General keywords  . . . . . . . .   Y                                       

   Subfile display layout  . . . . .   Y                                        

   Subfile messages  . . . . . . . .                                           

                                                                               

   Select record keywords  . . . . .   Y                                        

                                                                               

   TEXT keyword  . . . . . . . . . .                                           

                                                                               

                                                                                   

                                                                               

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                           

                                                                                

 

 

 

                            Define General Keywords                            

                                                                               

 Subfile control record . . . . . . . . . :   SFL01C                           

                                                                               

 Type choices, press Enter.               Keyword                              

   Related subfile record . . . . . . .   SFLCTL     SFL01        Name         

   Subfile cursor relative record . . .   SFLCSRRRN               Name         

   Subfile mode . . . . . . . . . . . .   SFLMODE                 Name         

                                                                                

                                                                               

                                                                               

                                                     Y=Yes        Indicators/+ 

   Display subfile records  . . . . . .   SFLDSP       Y          N30          

   Display control record . . . . . . .   SFLDSPCTL    Y          N30          

   Initialize subfile fields  . . . . .   SFLINZ                                

   Delete subfile area  . . . . . . . .   SFLDLT                               

   Clear subfile records  . . . . . . .   SFLCLR                  30           

   Indicate more records  . . . . . . .   SFLEND                  N30          

     SFLEND parameter   . . . . . . . .     *MORE                              

     SFLEND parameter   . . . . . . . .     *SCRBAR                 *MORE ...  

   Record not active  . . . . . . . . .   SFLRNA                               

                                                                   More...     

 F3=Exit   F12=Cancel                                                          

                                                                               

 

                             Define Display Layout                             

                                                                               

 Subfile control record . . . . . . . . . :   SFL01C                           

                                                                                

 Type values, press Enter.                                                     

                                                                               

                                            Keyword  Number                    

   Records in subfile . . . . . . . . . .   SFLSIZ     12                      

     Program-to-system field  . . . . . .                                      

                                                                                

   Records per display  . . . . . . . . .   SFLPAG    200                      

                                                                               

   Spaces between records . . . . . . . .   SFLLIN                              

                                                                               

                                                                                   

                                                                               

 F3=Exit   F12=Cancel                                                          

                                                                               

 

 

 

                            Select Record Keywords                             

                                                                                

 Record . . . :   SFL01C                                                       

                                                                               

 Type choices, press Enter.                                                     

                                                                               

                                     Y=Yes                                     

   General keywords  . . . . . . . .                                            

   Indicator keywords  . . . . . . .   Y                                       

   Application help  . . . . . . . .                                           

   Help keywords . . . . . . . . . .                                            

   Output keywords . . . . . . . . .                                           

   Input keywords  . . . . . . . . .                                           

   Overlay keywords  . . . . . . . .                                            

                                                                               

   Print keywords  . . . . . . . . .                                           

   ALTNAME keyword . . . . . . . . .                                           

                                                                               

   TEXT keyword  . . . . . . . . . .                                           

                                                                               

                                                                                

                                                                               

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                           

                                                                                

 

                           Define Indicator Keywords                           

                                                                               

 Record . . . :   SFL01C                                                        

                                                                               

 Type keywords and parameters, press Enter.                                    

   Conditioned keywords:       CFnn CAnn CLEAR PAGEDOWN/ROLLUP PAGEUP/ROLLDOWN 

                               HOME HELP HLPRTN                                

   Unconditioned keywords:     INDTXT VLDCMDKEY SETOF CHANGE                   

                                                                                

 Keyword   Indicators/+ Resp Text                                              

 CA03                    03  Exit                                              

                                                                                

   

                                                                               

                                                                               

                                                                         Bottom

 F3=Exit   F12=Cancel                                                          

                                                                               

 

 

 

                            Select Record Keywords                             

                                                                                

 Record . . . :   SFL01C                                                       

                                                                               

 Type choices, press Enter.                                                    

                                                                               

                                     Y=Yes                                     

   General keywords  . . . . . . . .                                            

   Indicator keywords  . . . . . . .                                           

   Application help  . . . . . . . .                                           

   Help keywords . . . . . . . . . .                                            

   Output keywords . . . . . . . . .                                           

   Input keywords  . . . . . . . . .                                           

   Overlay keywords  . . . . . . . .   Y                                        

                                                                               

   Print keywords  . . . . . . . . .                                           

   ALTNAME keyword . . . . . . . . .                                            

                                                                               

   TEXT keyword  . . . . . . . . . .                                           

                                                                               

                                                                                

                                                                               

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                           

                                                                                

 

 

                            Select Overlay Keywords                            

                                                                               

 Record . . . :   SFL01C                                                        

                                                                               

 Type choices, press Enter.                                                    

                                          Keyword    Y=Yes  Indicators/+   Roll

   Overlay without erasing  . . . . . .   OVERLAY      Y                       

   Retain data on re-display  . . . . .   PUTRETAIN                            

   Protect all input fields . . . . . .   PROTECT                               

   Activate OVRDTA and OVRATR . . . . .   PUTOVR                               

   Override Data  . . . . . . . . . . .   OVRDTA                               

   Override Attribute . . . . . . . . .   OVRATR                                

   Initialize input fields  . . . . . .   INZINP                               

   Reset all modified data tags . . . .   MDTOFF                               

     MDTOFF parameter . . . . . . . . .     *UNPR                              

                                            *ALL                               

   Erase all input fields . . . . . . .   ERASEINP                             

     ERASEINP parameter . . . . . . . .     *MDTON                             

                                            *ALL                               

   Erase all records below  . . . . . .   ERASE                                

                                                                               

                                                                                

 F3=Exit   F12=Cancel                                                          

                                                                               

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

 1             SFL01T                                                          

         10    SFL01         SFL                         12/25/04              

         20    SFL01C        SFLCTL    SFL01             12/25/04              

                                                                                

                                                                                

                                                                               

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

 Keywords updated for record SFL01C.                                                                           

 

                     Select Additional Records for Display                     

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                    

   1,2,3=Select for display as additional record                               

                                                                               

 Option   Record         Type    Status                                         

   1                                                                           

   2                                                                           

   3                                                                            

   2      SFL01          SFL                                                   

   3      SFL01C         SFLCTL                                                

          SFL01T         RECORD  In use                                         

                                                                               

                                                                                 

                                                                                

                                                                         Bottom

 F3=Exit     F5=Refresh     F12=Cancel                                         

                                                                               

 

                                                                                

        DD/DD/DD                 发票查询                     SSSSSSSS         

                  5= 明细查询                                 UUUUUUUUUU       

                                                                               

        #  发票          名称             总数           总金额                

       --  -----      ------------     ----------    ---------------------     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66      

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

                                                                               

  

                                                                               

 Additional record(s) selected: SFL01 SFL01C                                   

 

                                                                               

        DD/DD/DD                 发票查询                     SSSSSSSS         

                  5= 明细查询                                 UUUUUUUUUU       

                                                                               

        #  发票          名称             总数           总金额                

       --  -----      ------------     ----------    ---------------------     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66      

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

        I  OOOOO      OOOOOOOOOOOO     -6,666,666    -6,666,666,666,666.66     

                                                                               

                                                                               

                                                                                

          'F3=@CCCC@'                                                          

                                                                               

 Additional record(s) selected: SFL01 SFL01C                                    

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

                                                                               

         10    SFL01         SFL                         12/25/04              

         20    SFL01C        SFLCTL    SFL01             12/25/04              

         30    SFL01T        RECORD                      12/25/04              

                                                                               

     

                                                                                

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

 Record SFL01T added to member SUBFILE1.                                       

 

F、设计显示记录窗体:

                      Work with Display Records                                

                                                                                

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                                

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                    

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

 1             DSP01W                                                          

         10    SFL01         SFL                         12/25/04              

         20    SFL01C        SFLCTL    SFL01             12/25/04              

         30    SFL01T        RECORD                      12/25/04              

                                                                                

                                                                                  

                                                                               

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

 Record SFL01T added to member SUBFILE1.                                        

 

                               Add New Record                                  

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type choices, press Enter.                                                     

                                                                               

   New record  . . . . . . . . . . . . . . .   DSP01W       Name               

                                                                                

   Type  . . . . . . . . . . . . . . . . . .   WINDOW       RECORD, USRDFN     

                                                            SFL,    SFLMSG     

                                                            WINDOW, WDWSFL     

                                                            PULDWN, PDNSFL     

                                                            MNUBAR             

                                                                               

                                                                                        

                                                                               

 F3=Exit     F5=Refresh     F12=Cancel                                         

                                                                                

 

                          Select Window Keywords                               

                                                                               

 Window record . . . . . . . . . . . . . :    DSP01W                           

                                                                               

 Type choices, press Enter.                                                    

                                                                                

                                     Y=Yes                                     

   General keywords  . . . . . . . .   Y                                       

   Select record keywords  . . . . .                                            

                                                                               

  

                                                                               

   TEXT keyword  . . . . . . . . . .                                            

                                                                               

    

                                                                               

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                           

                                                                               

 

                            Select General Keywords                            

                                                                               

 Window record . . . . . . . . . . . . . :   DSP01W                            

                                                                               

 Type choices, press Enter.                                                    

                                                                                

                                                Keyword    Y=Yes  Indicators/+ 

                                                                               

   Window parameters  . . . . . . . . . . . .   WINDOW       Y                 

     Select parameters  . . . . . . . . . . .                Y                 

   Window borders . . . . . . . . . . . . . .   WDWBORDER                      

     Select parameters  . . . . . . . . . . .                                   

   Remove windows . . . . . . . . . . . . . .   RMVWDW                         

   User Restore Display . . . . . . . . . . .   USRRSTDSP                      

                                                                                

                                                                               

                                                                                 

                                                                                

 F3=Exit   F12=Cancel                                                          

                                                                               

 

                            Define Window Parameters                           

                                                                                

 Record . . . :    DSP01W                                                      

 Keyword  . . :    WINDOW                                                      

                                                                                

 Referenced window  . . . . . . . . . . . .                      Name          

 -OR-                                                                          

 Window definition                                                              

   Default start positioning  . . . . . . .                      Y=Yes         

   -OR-                                                                        

   Start line                                                                   

     Program-to-system field  . . . . . . .                      Name          

     Actual line  . . . . . . . . . . . . .       9              1-25          

   Start position                                                               

     Program-to-system field  . . . . . . .                      Name          

     Actual position  . . . . . . . . . . .       12             1-128         

                                                                                

   Window lines . . . . . . . . . . . . . .      10              1-25          

   Window position  . . . . . . . . . . . .       60             1-128         

   Message line . . . . . . . . . . . . . .      Y               Y=Yes         

   Restrict cursor to window  . . . . . . .      Y               Y=Yes         

                                                                               

 F3=Exit   F12=Cancel                                                          

                                                                                

 

 

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                     

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                                

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

                                                                               

         10    SFL01         SFL                         12/25/04              

         20    SFL01C        SFLCTL    SFL01             12/25/04              

         30    SFL01T        RECORD                      12/25/04              

 12      40    DSP01W        WINDOW                      12/25/04               

                                                                               

   

                                                                               

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

                                                                               

 

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

           ................................................................    

           :                                                              :    

           :                                                              :    

           :                                                              :    

           :                                                              :    

           :                                                              :    

           :                                                              :    

           :                                                              :     

           :                                                              :    

           :                                                              :    

           :                                                              :    

           :..............................................................:    

                                                                               

                                                                               

                                                                                

 Work screen for record DSP01W: Press Help for function keys.                  

 

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

           ................................................................    

           :                   '@cccccccc@'                               :    

           :                                                              :    

           :                &1l                                           :    

           :                &2l                                           :    

           :                &3l                                           :    

           :                &4l                                           :    

           :                &5l                                           :    

           :                                                              :    

           :            '@cccccccccc@'                                    :    

           :                                                              :    

           :..............................................................:    

                                                                                

                                                                               

                                                                               

 1:IV_CODE 2:IV_NAME 3:IV_QUTITY 4:IV_AMOUNT 5:IV_DESC                         

 

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

           ................................................................    

           :                     显示明细                                 :    

           :                                                              :    

           :        发票 :  OOOOO                                         :    

           :        名称 :  OOOOOOOOOOOO                                  :    

           :        总数 :  -6,666,666                                    :    

           :      总金额 :  -6,666,666,666,666.66                         :    

           :        备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                :    

           :                                                              :    

           :              按执行继续                                      :    

           :                                                              :    

           :..............................................................:    

                                                                               

                                                                                

                                                                               

                                                                               

 

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   SUBFILE1  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                                

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

                                                                                

         10    SFL01         SFL                         12/25/04              

         20    SFL01C        SFLCTL    SFL01             12/25/04              

         30    SFL01T        RECORD                      12/25/04              

         40    DSP01W        WINDOW                      12/25/04              

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

                                                                                

 

H、定义文件级关键字:

 

                             Select File Keywords                              

                                                                               

 Member . . . :   SUBFILE1                                                     

                                                                               

 Type choices, press Enter.                                                    

                                                                               

                                     Y=Yes                                     

   General keywords  . . . . . . . .   Y                                       

   Indicator keywords  . . . . . . .                                           

   Print keywords  . . . . . . . . .                                           

   Help keywords . . . . . . . . . .                                           

   Display sizes . . . . . . . . . .                                           

   Alternate keywords  . . . . . . .                                            

   DBCS conversion . . . . . . . . .                                           

   Window Borders  . . . . . . . . .                                           

   Menu-bar keywords . . . . . . . .                                            

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                           

                                                                               

 

 

                            Select General Keywords                            

                                                                                

 Member . . . :   SUBFILE1                                                     

                                                                               

 Type choices, press Enter.                    Keyword    Y=Yes   Indicators/+ 

   Invite devices for later read . . . . . .   INVITE                          

   Allow graphics  . . . . . . . . . . . . .   ALWGPH                          

   Sound alarm on messages . . . . . . . . .   MSGALARM                        

   Separate indicators area  . . . . . . . .   INDARA       Y                  

   Manage display in S/36 mode . . . . . . .   USRDSPMGT                       

   Allow blanks  . . . . . . . . . . . . . .   CHECK(AB)                       

   Move cursor right-left, top-bottom  . . .   CHECK(RLTB)                     

   Move cursor right to left . . . . . . . .   CHECK(RL)                       

   Right to left processing  . . . . . . . .   DSPRL                            

   Change input defaults . . . . . . . . . .   CHGINPDFT                       

     Select parameters . . . . . . . . . . .                                   

   Entry field attribute . . . . . . . . . .   ENTFLDATR                        

     Select parameters . . . . . . . . . . .                                   

   Write error messages to subfile . . . . .   ERRSFL                          

                                                                               

                                                                                

                                                                   More...     

 F3=Exit   F12=Cancel                                                          

                                                                                

 

                         Save DDS - Create Display File                        

                                                                               

 Type choices, press Enter.                                                     

                                                                               

   Save DDS source  . . . . . . . . . . . .   Y            Y=Yes               

     Source file  . . . . . . . . . . . . .   QDDSSRC      F4 for list         

       Library  . . . . . . . . . . . . . .   QINGZHOU     Name, *LIBL ...     

     Member . . . . . . . . . . . . . . . .   SUBFILE1     F4 for list         

     Text . . . . . . . . . . . . . . . . .                                     

                                                                               

                                                                               

   Create display file  . . . . . . . . . .   Y            Y=Yes                

     Prompt for parameters  . . . . . . . .                Y=Yes               

     Display file . . . . . . . . . . . . .   SUBFILE1     F4 for list         

       Library  . . . . . . . . . . . . . .   QINGZHOU     Name, *LUPARLIB       

     Replace existing file  . . . . . . . .                Y=Yes               

                                                                               

   Submit create job in batch . . . . . . .   Y            Y=Yes               

                                                                                

   Specify additional                                                          

     save or create options . . . . . . . .                Y=Yes               

                                                                                

 F3=Exit   F4=Prompt   F12=Cancel                                              

 Member SUBFILE1 already exists. Press Enter to replace.                      +

 

 

 

 

 Columns . . . :    1  71           Browse                     QINGZHOU/QDDSSRC

 SEU==>                                                                SUBFILE1

 FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        *************** Beginning of data *************************************

0000.10      A*%%TS  SD  20041225  212604  QINGZHOU    REL-V5R1M0  5722-WDS    

0000.20      A*%%EC                                                            

0000.30      A                                      DSPSIZ(24 80 *DS3)         

0000.40      A                                      INDARA                     

0000.50      A          R SFL01                     SFL                        

0000.60      A*%%TS  SD  20041225  201258  QINGZHOU    REL-V5R1M0  5722-WDS    

0000.70      A            IV_CODE   R        O  7 12REFFLD(IV_FMT/IV_CODE QINGZHOU/INVO-

0000.80      A                                      ICE)                       

0000.90      A            IV_NAME   R        O  7 23REFFLD(IV_FMT/IV_NAME QINGZHOU/INVO-

0001.00      A                                      ICE)                       

0001.10      A            IV_QUTITY R        O  7 40REFFLD(IV_FMT/IV_QUTITY QINGZHOU/IN-

0001.20      A                                      VOICE)                      

0001.30      A            IV_AMOUNT R        O  7 54REFFLD(IV_FMT/IV_AMOUNT QINGZHOU/IN-

0001.40      A                                      VOICE)                     

0001.50      A            OPTX           1   I  7  9                            

0001.60      A            IV_DESC   R        H      REFFLD(IV_DESC QINGZHOU/INVOICE)

0001.70      A          R SFL01C                    SFLCTL(SFL01)              

0001.80      A*%%TS  SD  20041225  201258  QINGZHOU    REL-V5R1M0  5722-WDS    

0001.90      A                                      CA03(03 'Exit')            

0002.00      A                                      OVERLAY                    

0002.10      A N30                                  SFLDSP                     

0002.20      A N30                                  SFLDSPCTL                  

0002.30      A  30                                  SFLCLR                     

0002.40      A N30                                  SFLEND                     

0002.50      A                                      SFLSIZ(0200)               

0002.60      A                                      SFLPAG(0012)               

0002.70      A                                  3 19'5= 明细查询 '             

0002.80      A                                  2  9DATE                       

0002.90      A                                      EDTCDE(Y)                  

0003.00      A                                  2 63SYSNAME                     

0003.10      A                                  3 63USER                       

0003.20      A                                  2 33' 发票查询 '               

0003.30      A                                  6  8'--  -----      -----------

0003.40      A                                      --------    ---------------

0003.50      A                                  5  9'#'                        

0003.60      A                                  5 11' 发票 '                   

0003.70      A                                  5 25' 名称 '                   

0003.80      A                                  5 42' 总数 '                   

0003.90      A                                  5 57' 总金额 '                 

0004.00      A          R SFL01T                                                

0004.10      A*%%TS  SD  20041225  201258  QINGZHOU    REL-V5R1M0  5722-WDS    

0004.20      A                                 22 12'F3= 退出 '                

0004.30      A          R DSP01W                                                

0004.40      A*%%TS  SD  20041225  211311  QINGZHOU    REL-V5R1M0  5722-WDS    

0004.50      A                                      WINDOW(9 12 10 60)         

0004.60      A                                  1 20' 显示明细 '                

0004.70      A                                  3  7' 发票 :'                  

0004.80      A            IV_CODE   R        O  3 16REFFLD(IV_FMT/IV_CODE QINGZHOU/INVO-

0004.90      A                                      ICE)                       

0005.00      A                                  4  7' 名称 :'                  

0005.10      A            IV_NAME   R        O  4 16REFFLD(IV_FMT/IV_NAME QINGZHOU/INVO-

0005.20      A                                      ICE)                       

0005.30      A                                  5  7' 总数 :'                  

0005.40      A            IV_QUTITY R        O  5 16REFFLD(IV_FMT/IV_QUTITY QINGZHOU/IN-

0005.50      A                                      VOICE)                     

0005.60      A                                  6  5' 总金额 :'                

0005.70      A            IV_AMOUNT R        O  6 16REFFLD(IV_FMT/IV_AMOUNT QINGZHOU/IN-

0005.80      A                                      VOICE)                     

0005.90      A                                  7  7' 备注 :'                  

0006.00      A            IV_DESC   R        O  7 16REFFLD(IV_FMT/IV_DESC QINGZHOU/INVO-

0006.10      A                                      ICE)                       

0006.20      A                                  9 13' 按执行继续 '             

        ****************** End of data ****************************************

                                                                               

                                                                                

F3=Exit   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle   F12=Cancel     

 F16=Repeat find        F24=More keys                                                                                                                        

 

 

5.3.8.使用SDA + RPG IV 进行交互式程序设计

 

SDA(Screen Design Aid)意思为:屏幕设计帮助。

SDA是屏幕设计工具,可以将屏幕设计用形象化画图方式进行设计。设计完成后可以同时生成DSPF源程序以及DSPF OBJECT目标。

显示文件+高级语言=程序。

以下以OS/400 V5R1M0为环境、RPGIV为高级语言基准,循序渐进地阐述如何利用SDA+RPGIV进行简单的交互式程序设计。

 

A创建QDDSSRC、QRPGLESRC注意事项:

 

由于要支持简体中文,所以在创建SRCPF时要注意选取参数User specified DBCS data . . .  > *YES,在创建QRPGLESRC还要设定Record length  . . .  > 112 。

                    

                     Create Source Physical File (CRTSRCPF)                    

                                                                                

 Type choices, press Enter.                                                    

                                                                               

 File . . . . . . . . . . . . . . > QRPGLESRC     Name                          

   Library  . . . . . . . . . . . >   QINGZHUO    Name, *LUPARLIB                

 Record length  . . . . . . . . . > 112           Number                       

 Member, if desired . . . . . . .   *NONE         Name, *NONE, *FILE           

 User specified DBCS data . . . . > *YES          *NO, *YES                    

 Text 'description' . . . . . . . > 'RPGIV source code'                        

                                                                               

                                                                                

                                                                         Bottom

 F3=Exit   F4=Prompt   F5=Refresh   F10=Additional parameters   F12=Cancel     

 F13=How to use this display        F24=More keys                              

                                                                               

B、PF文件说明:

 

a、QINGZHOU/QDDSSRC(REFILE)是数据公共字典:

 Columns . . . :    1  71           Browse                     QINGZHOU/QDDSSRC

 SEU==>                                                                  REFILE

 FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        *************** Beginning of data *************************************

0001.00      A* DATA DICTIONARY REFERENCE FILE                                 

0002.00      A* CREATE BY TRF.LIU YUANY YAO 2004.12.18                         

0003.00      A*                                                                

0004.00      A          R REFMT                                                

0005.00      A            CODE           5A                                    

0006.00      A            NAME          12O                                    

0007.00      A            DESCRPT       30O                                    

0008.00      A            QUATITY        7  0                                  

0009.00      A            PRICE         11  2                                  

0010.00      A            AMOUNT        15  2                                   

        ****************** 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, 2000.   

 

b、QINGZHOU/QDDSSRC(INVOICE)是参照数据公共字典的其中一个PF:

 

 Columns . . . :    1  71            Edit                      QINGZHOU/QDDSSRC

 SEU==>                                                                 INVOICE

 FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

0001.00      A* INVOICE DDS SOURCE CODE                                        

0002.00      A* CREATE BY TRF.LIU YUAN YAO 2004.12.18                           

0003.00      A*                                                                

0004.00      A                                      REF(*LIBL/REFILE)          

0005.00      A          R IV_FMT                                                

0006.00      A            IV_CODE   R               REFFLD(CODE)               

0007.00      A                                      COLHDG(' 发票 ')           

0008.00      A            IV_NAME   R               REFFLD(NAME)               

0009.00      A                                      COLHDG(' 名称 ')           

0010.00      A            IV_QUTITY R               REFFLD(QUATITY)            

0011.00      A                                      EDTCDE(O)                  

0012.00      A                                      COLHDG(' 总数 ')           

0013.00      A            IV_AMOUNT R               REFFLD(AMOUNT)             

0014.00      A                                      COLHDG(' 总金额 ')         

0015.00      A                                      EDTCDE(O)                  

0016.00      A            IV_DESC   R               REFFLD(DESCRPT)            

0017.00      A                                      COLHDG(' 备注 ')           

0018.00      A*                                                                 

0019.00      A          K IV_CODE                                              

        ****************** End of data ****************************************

                                                                                

 

                                                                               

 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      

 F16=Repeat find       F17=Repeat change          F24=More keys                 

                                                                               

三、利用SDA制作DSPF:

 

1、进入SDA单屏幕设计:

1.1、在OS/400命令行执行STRSDA,选择1. Design screens :

 

                         AS/400 Screen Design Aid (SDA)                        

                                                                                

 Select one of the following:                                                  

                                                                               

      1. Design screens                                                         

      2. Design menus                                                          

      3. Test display files                                                    

                                                                                

                                                                               

                                                                               

                                                                                

 Selection or command                                                          

 ===> 1                                                                        

                                                                                

 F1=Help   F3=Exit   F4=Prompt   F9=Retrieve   F12=Cancel                      

                                          (C) COPYRIGHT IBM CORP. 1981, 2000.  

 

1.2、敲入Source fileLibrary以及Member,注意Member名确定DSPF的名字。

 

                                Design Screens                                 

                                                                               

 Type choices, press Enter.                                                    

                                                                                

   Source file . . . . . . . .   QDDSSRC      Name, F4 for list                

                                                                               

     Library . . . . . . . . .   QINGZHOU     Name, *LIBL, *LUPARLIB             

                                                                               

   Member  . . . . . . . . . .   IVSCREEN     Name, F4 for list                

                                                                                

                                                                               

                                                                               

                                                                                

 F3=Exit     F4=Prompt     F12=Cancel                                          

                                                                               

1.3、选择1,并键入记录格式名DSP_PMPT,每一个记录格式表示显示文件的一个显示界面。最常用的是RECORD型,每个画面可以处理数据库文件一个记录。

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   IVSCREEN  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

 1             DSP_PMPT                                                        

                                                                               

   (No records in file)                                                         

                                                                               

                                                                               

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

                                                                               

1.4、执行后见如下画面:

我们可以看到Type类型有很多选择,RECORD是单屏幕设计,SFL是子文件类型,通过PULDWN、MNUBAR可以制作出精美的下拉菜单画面。由于篇幅有限,只能一笔带过。

 

                               Add New Record                                  

                                                                                

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   IVSCREEN  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type choices, press Enter.                                                    

                                                                               

   New record  . . . . . . . . . . . . . . .   DSP_PMPT     Name               

                                                                                

   Type  . . . . . . . . . . . . . . . . . .   RECORD       RECORD, USRDFN     

                                                            SFL,    SFLMSG     

                                                            WINDOW, WDWSFL     

                                                            PULDWN, PDNSFL     

                                                            MNUBAR             

                                                                                

                                                                               

                                                                               

 F3=Exit     F5=Refresh     F12=Cancel                                          

                                                                               

 

1.5、键入执行可以看见25行×80列5250显示空白画面如下:

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

 Work screen for record DSP_PMPT: Press Help for function keys.          

 

1.6、可以通过F14反复切换开启或者关闭标尺:

 

 ... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ... ... 8

  2                                                                            

  3                                                                             

  4                                                                            

  5                                                                            

  6                                                                            

  7                                                                            

  8                                                                            

  9                                                                            

 10                                                                             

 11                                                                            

 12                                                                            

 13                                                                             

 14                                                                            

 15                                                                            

 16                                                                             

 17                                                                            

 18                                                                            

 19                                                                             

 20                                                                            

 21                                                                            

 22                                                                             

 23                                                                            

 24                                                                            

 

2、选取数据库文件

2.1按F10,使用选项1,敲入Database File、Library,并将光标移至Record然后按F4:

 

                             Select Database Files                             

                                                                               

 Type options and names, press Enter.                                          

   1=Display database field list                                               

   2=Select all fields for input (I)                                           

   3=Select all fields for output (O)                                          

   4=Select all fields for both (B) input and output                           

                                                                               

 Option    Database File   Library      Record                                 

   1        INVOICE        QINGZHOU                                       

                                                                               

                                                                               

                                                                                

                                                                               

 F3=Exit     F4=Prompt     F12=Cancel                                          

                                                                               

2.2选择记录格式IV_FMT,执行

 

                            Select Database Records                            

                                                                               

 Database file  . . . . . :   INVOICE        Library . . . :   QINGZHOU         

                                                                               

 Type options, press Enter.                                                    

   1=Select                                                                    

                                                                                

 Option   Record                                                               

   1      IV_FMT                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                                                                         Bottom

                                                                               

                                                                                

 F3=Exit   F12=Cancel                                                          

                                                                               

 

2.3可见如下画面,我们可以暂时都选取为3输出型,我们可以在后面的屏幕重新定义。

备注:2=输入型(I),3=输出型(O),4=输入输出型(B)。

 

                            Select Database Fields                             

                                                                               

 Record . . . :   IV_FMT                                                        

                                                                               

 Type information, press Enter.                                                

   Number of fields to roll  . . . . . . . . . . . . . . . . . .     8         

   Name of field to search for . . . . . . . . . . . . . . . . .               

                                                                               

 Type options, press Enter.                                                    

   1=Display extended field description                                        

   2=Select for input (I), 3=Select for output (O), 4=Select for both (B)      

                                                                               

 Option  Field        Length   Type    Column Heading                          

   3     IV_CODE           5    A       发票                                   

   3     IV_NAME          12    O       名称                                   

   3     IV_QUTITY       7,0    P       总数                                   

   3     IV_AMOUNT      15,2    P       总金额                                  

   3     IV_DESC          30    O       备注                                   

                                                                               

                                                                                

                                                                               

                                                                         Bottom

 F3=Exit   F12=Cancel                                                          

                                                                                

 

2.4连续2次执行回到设计屏幕界面得到第24行显示的字段名集合。

至此我们完成了使用F10选取数据库文件功能。

 ... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ... ... 8

  2                                                                            

  3                                                                             

  4                                                                            

  5                                                                            

  6                                                                             

  7                                                                            

  8                                                                            

  9                                                                             

 10                                                                            

 11                                                                            

 12                                                                             

 13                                                                            

 14                                                                            

 15                                                                            

 16                                                                             

 17                                                                            

 18                                                                            

 19                                                                             

 20                                                                            

 21                                                                            

 22                                                                             

 23                                                                            

 1:IV_CODE 2:IV_NAME 3:IV_QUTITY 4:IV_AMOUNT 5:IV_DESC                         

 

c、在屏幕上放置数据库文件字段:

 

3.1使用“&+字段名序号”可以将字段放置在屏幕上,在字段名序号之后可以加上L表示字段标题居左。建议将字段放置在屏幕中部。

 

 ... ... 1 ... ... 2 ... ... 3 ... ... 4 ... ... 5 ... ... 6 ... ... 7 ... ... 8

   2                                                                           

   3                                                                            

   4                                                                           

   5                                                                           

   6                                                                            

   7                                    &1L                                    

   8                                                                           

   9                                    &2L                                    

  10                                                                            

  11                                    &3L                                    

  12                                                                           

  13                                    &4L                                    

  14                                                                           

  15                                    &5L                                    

  16                                                                            

  17                                                                           

  18                                                                           

  19                                                                            

  20                                                                           

  21                                                                           

  22                                                                            

  23                                                                           

 1:IV_CODE 2:IV_NAME 3:IV_QUTITY 4:IV_AMOUNT 5:IV_DESC                         

 

3.2键入执行后,所定义的字段标题、字段属性以及长度显示在屏幕上。                                                                                 

                                                                               

        

 

                                                                               

                                                                                

                   发票 :  OOOOO                                               

                                                                               

                   名称 :  OOOOOOOOOOOO                                        

                                                                                

                   总数 :  -6,666,666                                          

                                                                               

                 总金额 :  -6,666,666,666,666.66                                

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                                

                                                                               

                                                                               

                                                                               

                                                                               

                       

 

 

 

3.3我们可用I、O、B改变字段属性。

例如:将光标放在发票字段范围内,键入I之后执行,可以发现原字段属性已经由O改为I型。

备注:

字段类型

输入型

输出型

输入输出型

字符型

I

O

B

数值型

3

6

9

                                                                       

 

                                                                                

                                                                               

                   发票 :  IIIII                                               

                                                                               

                   名称 :  OOOOOOOOOOOO                                        

                                                                               

                   总数 :  -6,666,666                                          

                                                                                

                 总金额 :  -6,666,666,666,666.66                               

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                               

                                                                               

                                                                                

 

d、添加常数项:

 

4.1现在为屏幕添加一个标题。将光标置于顶部合适位置键入‘@cccccccc@’,其含义为‘  ’之内表示常数项,一对@之间表示为中文双字节倍数,注意cccccccc必须为偶数,因为汉字是双字节。

 

                                                                              

                              '@cccccccc@'                                  

                                                                             

                                                                              

                                                                             

                   发票 :  IIIII                                               

                                                                               

                   名称 :  OOOOOOOOOOOO                                        

                                                                                

                   总数 :  -6,666,666                                          

                                                                               

                 总金额 :  -6,666,666,666,666.66                                

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                             

                                                                             

                                             

4.2键入执行后,可见4行下划线,一行可输入一个汉字。

 

                                                                              

                            ____                                   

                                                                              

                                                                              

                                                                               

                   发票 :  IIIII                                               

                                                                               

                   名称 :  OOOOOOOOOOOO                                         

                                                                               

                   总数 :  -6,666,666                                          

                                                                                

                 总金额 :  -6,666,666,666,666.66                               

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                              

                                                                             

                                                                             

 

4.3在下划线上敲入汉字“发票查询”,执行:

 

                                                                              

                              发票查询                                   

                                                                              

                                                                               

                                                                              

                   发票 :  IIIII                                               

                                                                                

                   名称 :  OOOOOOOOOOOO                                        

                                                                               

                   总数 :  -6,666,666                                           

                                                                               

                 总金额 :  -6,666,666,666,666.66                               

                                                                                

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                    

                                                                

 

4.4我们可以使用F20开关反显常数项,然后使用>>>右移或<<<左移常数项。

 

                                                                               

                             发票查询 >>>>                            

                                                                              

                                                                               

                                                                              

                   发票 :  IIIII                                               

                                                                                

                   名称 :  OOOOOOOOOOOO                                        

                                                                               

                   总数 :  -6,666,666                                           

                                                                               

                 总金额 :  -6,666,666,666,666.66                               

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                             

                                                                             

                                                                              

                                                                             

                                                                             

4.5同时在屏幕下方放置一个既包括西文以及符号又包括汉字的常数项'F3=@cccc@',必须使用单撇号‘ ’将所有常数字段包括在里面。

 

                                                                             

                                   发票查询                             

                                                                             

                                                                              

                                                                             

                   发票 :  IIIII                                               

                                                                                

                   名称 :  OOOOOOOOOOOO                                        

                                                                               

                   总数 :  -6,666,666                                           

                                                                               

                 总金额 :  -6,666,666,666,666.66                               

                                                                                

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                             

                                                                              

                                                                             

                                                                             

                                                                             

                             'F3=@cccc@'                                     

 

4.6执行后,用同样方法在下划线上输入“退出”。

 

                                                                                

                                                                               

                               发票查询                               

                                                                       

                                                                               

                                                                               

                   发票 :  IIIIII                                               

                                                                               

                   名称 :  OOOOOOOOOOOO                                        

                                                                                

                   总数 :  -6,666,666                                          

                                                                               

                 总金额 :  -6,666,666,666,666.66                                

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                                

                                                                               

                                                                               

                        F3= 退出                                               

                                                                                

                                                                               

                                        

e、添加变量字段以及系统关键字:

 

5.1在屏幕24行,我们可以采用+OOOOOOOO增加字符型变量,或者采用+O(40)快速添加长度为40的输出型变量。

备注:

字段类型

输出型

输入型

输入输出型

字符型

+IIII 或 +I(4)

+OOOOO 或 +O(5)

+BBBBBBBB 或 +B(8)

数值型

+33.33 或 +3(4,2)

+666.66 或 +6(5,2)

+9999.999 或 +9(7,3)

 

                                                                                

                                                                                

                               发票查询                              

                                                                      

                                                                                

                                                                               

                   发票 :  IIIII                                               

                                                                                

                   名称 :  OOOOOOOOOOOO                                        

                                                                               

                   总数 :  -6,666,666                                          

                                                                                

                 总金额 :  -6,666,666,666,666.66                               

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                        F3= 退出                                               

                                                                               

                                                                               

                  +O(40)                     

 

5.2执行后发现在屏幕下方增加了一个字符型变量,系统自动给它命名为FLD001。

                                                                               

                                                                               

                                 发票查询                               

                                                                    

                                                                               

                                                                               

                   发票 :  IIIII                                               

                                                                               

                   名称 :  OOOOOOOOOOOO                                        

                                                                                

                   总数 :  -6,666,666                                          

                                                                               

                 总金额 :  -6,666,666,666,666.66                                

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                                

                                                                               

                                                                               

                                                                               

                                                                               

                        F3= 退出                                               

                                                                               

                                                                               

                  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                                                                                                     

 

5.3按F4,翻页找到FLD001:

 

                                Work with Fields                               

                                                                                

 Record . . . :   DSP_PMPT                                                     

                                                                               

 Type information, press Enter.                                                 

   Number of fields to roll . . . . . . . . . . . . . . . . . .     6          

                                                                               

 Type options, change values, press Enter.                                      

   1=Select keywords   4=Delete field                                          

                                                                               

 Option   Order   Field       Type Use  Length  Row/Col  Ref Condition  Overlap

            130   FLD001            O       40   24 019                        

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                         Bottom

  Add                               H            Hidden                        

  Add                               M            Message                       

  Add                               P            Program-to-system             

                                                                               

 F3=Exit   F6=Sort by row/column   F12=Cancel                                  

                                                                                

 

5.4FLD001改为MSGLINE:

 

                                Work with Fields                               

                                                                               

 Record . . . :   DSP_PMPT                                                      

                                                                               

 Type information, press Enter.                                                

   Number of fields to roll . . . . . . . . . . . . . . . . . .     6          

                                                                                

 Type options, change values, press Enter.                                     

   1=Select keywords   4=Delete field                                          

                                                                                

 Option   Order   Field       Type Use  Length  Row/Col  Ref Condition  Overlap

            130   MSGLINE           O       40   24 019                        

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                         Bottom

  Add                               H            Hidden                         

  Add                               M            Message                       

  Add                               P            Program-to-system             

                                                                                

 F3=Exit   F6=Sort by row/column   F12=Cancel                                  

                                                                               

 

5.5 在屏幕上方标题行左右位置键入:*DATE、*SYSNAME、*USER,“*名称”通常为系统定义的保留字。

                                                                                

                                                                               

         *DATE                   发票查询               *SYSNAME               

                                                        *USER                  

                                                                               

                                                                               

                                                                     

                      发票 :  IIIII                             

                                                

                      名称 :  OOOOOOOOOOOO                      

                                                

                      总数 :  -6,666,666                         

                                                

                    总金额 :  -6,666,666,666,666.66             

                                                

                      备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO    

                                                 

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                        F3= 退出                                               

                                                                               

                                                                               

                  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                     

 

5.6执行后,可见系统名、用户名放置在右上角,日期项放置在左上角。

                                                                               

         DD/DD/DD                发票查询               SSSSSSSS               

                                                        UUUUUUUUUU             

                                                                               

                                                                               

                   发票 :  IIIII                                                

                                                                               

                   名称 :  OOOOOOOOOOOO                                        

                                                                                

                   总数 :  -6,666,666                                          

                                                                               

                 总金额 :  -6,666,666,666,666.66                                

                                                                               

                   备注 :  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                      

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

                        F3= 退出                                               

                                                                               

                                                                               

                  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                     

 

f、修改字段属性:

6.1可以通过对屏幕字段前面键入通配符*修改字段属性:

例如:修改“F3=退出”的颜色属性。

 

                                                                               

                                                                                

         DD/DD/DD                发票查询               SSSSSSSS               

                                                        UUUUUUUUUU             

                                                                               

                                                                                

                      INVOICE:  IIIII                                          

                                                                               

                         NAME:  OOOOOOOOOOOO                                   

                                                                               

                          SUM:  -6,666,666                                     

                                                                                

                        TOTAL:  -6,666,666,666,666.66                          

                                                                               

                         DEMO:  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                 

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                       *F3= 退出                                               

                                                                               

                                                                               

                  OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO                     

 

6.2选取ColorsY :

 

                             Select Field Keywords                             

                                                                               

 Constant  . . . :   F3= 退出                                                  

 Length  . . . . :   9                    Row . . . :  21   Column . . . :  25 

                                                                               

 Type choices, press Enter.                                                    

                                     Y=Yes   For Field Type                    

   Display attributes  . . . . . . .         All except Hidden                 

   Colors  . . . . . . . . . . . . .   Y     All except Hidden                 

                                                                                

                                                                               

                                                                               

   General keywords  . . . . . . . .         All types                         

                                                                               

                                                                               

                                                                                

   TEXT keyword  . . . . . . . . . .                                           

                                                                               

                                                                                

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                           

                                                                               

 

6.3 1选择Blue . . . BLU蓝色颜色

 

                                 Select Colors                                 

                                                                               

 Constant  . . . :   F3= 退出                                                   

 Length  . . . . :   9                    Row . . . :  21   Column . . . :  25 

                                                                               

 Type choices, press Enter.                                                    

                                                                                

                                          Keyword   Order   Indicators/+       

                                                    (1-7)                      

   Colors:                                COLOR                                

     Blue . . . . . . . . . . . . . . .     BLU       1                        

     Green  . . . . . . . . . . . . . .     GRN                                

     Pink . . . . . . . . . . . . . . .     PNK                                

     Red  . . . . . . . . . . . . . . .     RED                                

     Turquoise  . . . . . . . . . . . .     TRQ                                

     White  . . . . . . . . . . . . . .     WHT                                

     Yellow . . . . . . . . . . . . . .     YLW                                

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

 F3=Exit   F12=Cancel                                                          

                                                                               

 

6.4键入2次执行,回到编辑屏幕,可以看到其颜色已经变成蓝色:

 

6.5用同样方法:“*IIIII”可改变字段IV_CODE字段属性为反白Reverse image,执行后选择Display attributes:

 

                             Select Field Keywords                             

                                                                               

 Field . . . . . :   IV_CODE              Usage . . :  I                        

 Length  . . . . :   5                    Row . . . :  7    Column . . . :  33 

                                                                               

 Type choices, press Enter.                                                     

                                     Y=Yes   For Field Type                    

   Display attributes  . . . . . . .   Y     All except Hidden                 

   Colors  . . . . . . . . . . . . .         All except Hidden                 

   Keying options  . . . . . . . . .         Hidden, Input or Both             

   Validity check  . . . . . . . . .         Input or Both, not float          

   Input keywords  . . . . . . . . .         Input or Both                     

   General keywords  . . . . . . . .         All types                         

                                                                               

   Database reference  . . . . . . .         Hidden, Input, Output, Both       

   Error messages  . . . . . . . . .         Input, Output, Both               

                                                                               

                                                                               

                                                                                

   TEXT keyword  . . . . . . . . . .   INVOICE                                 

                                                                               

                                                                                

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                           

                                                                               

6.6Y选择Reverse image :

 

                           Select Display Attributes                           

                                                                               

 Field . . . . . :   IV_CODE              Usage . . :  I                       

 Length  . . . . :   5                    Row . . . :  7    Column . . . :  33 

                                                                               

 Type choices, press Enter.                                                    

                                              Keyword   Y=Yes   Indicators/+   

   Field conditioning . . . . . . . . . . .                                    

   Program-to-system field  . . . . . . . .                                    

   Display attributes:                        DSPATR                           

     High intensity . . . . . . . . . . . .     HI                             

     Reverse image  . . . . . . . . . . . .     RI        Y                    

     Column separators  . . . . . . . . . .     CS                             

     Blink  . . . . . . . . . . . . . . . .     BL                             

     Nondisplay . . . . . . . . . . . . . .     ND                             

     Underline  . . . . . . . . . . . . . .     UL                             

     Position cursor  . . . . . . . . . . .     PC                             

     Set modified data tag  . . . . . . . .     MDT                            

     Protect field  . . . . . . . . . . . .     PR                             

     Operator ID magnetic card  . . . . . .     OID                            

     Select by light pen  . . . . . . . . .     SP                             

                                                                               

 F3=Exit   F12=Cancel                                                           

                                                                               

 

6.7键入2次执行同时也修改发票字段属性为B修改第24行的字符型变量MSGLINE颜色为红色以让提示信息醒目。

最后完成屏幕设计如下:

 

 

h、保存屏幕:

7.1按F3,选择1=保存退出:

 

                                Exit SDA Work Screen                           

                                                                                

 Select one of the following:                                                  

                                                                               

     1. Save work since last Enter and exit work screen                        

     2. Exit without saving any work done on the work screen                   

     3. Resume work screen session                                             

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

 Selection                                                                     

     1                                                                         

                                                                                

 F12=Cancel                                                                    

                                                                               

i、为屏幕添加控制关键字:

为了使用键盘上的F1至F24功能键控制屏幕动作,我们需要为屏幕添加控制关键字。

下列为我们刚设计的屏幕添加F3退出功能的控制关键字。

 

8.1键入8选择屏幕关键字:

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   IVSCREEN  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                     

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

                                                                               

 8       10    DSP_PMPT      RECORD                      12/19/04              

                                                                                

                                                                               

                                                                               

                                                                                

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

 Image updated for record DSP_PMPT.                                            

8.2Indicator keywordsY,然后执行。

使用指示符是为了嵌入在RPGIV中进行逻辑控制它仅有1’0’两种状态。

 

                            Select Record Keywords                             

                                                                               

 Record . . . :   DSP_PMPT                                                     

                                                                               

 Type choices, press Enter.                                                    

                                                                                

                                     Y=Yes                                     

   General keywords  . . . . . . . .                                           

   Indicator keywords  . . . . . . .   Y                                        

   Application help  . . . . . . . .                                           

   Help keywords . . . . . . . . . .                                           

   Output keywords . . . . . . . . .                                            

   Input keywords  . . . . . . . . .                                           

   Overlay keywords  . . . . . . . .                                           

                                                                                

   Print keywords  . . . . . . . . .                                           

   ALTNAME keyword . . . . . . . . .                                           

                                                                               

   TEXT keyword  . . . . . . . . . .                                           

                                                                               

                                                                               

                                                                                

 F3=Exit   F4=Display Selected Keywords   F12=Cancel                           

                                                                               

 

8.3 本界面是定义屏幕的功能键,可以定义F1至F24一共24键的功能,以及向上翻页、向下翻页、帮助键等等。

注意:CF键与CA键是有所不同的,CF键可以实现对屏幕键入数据的修改,而CA键仅仅是控制屏幕,不涉及修改数据。CF、CA键不可以混用。

 

                           Define Indicator Keywords                           

                                                                               

 Record . . . :   DSP_PMPT                                                     

                                                                               

 Type keywords and parameters, press Enter.                                    

   Conditioned keywords:       CFnn CAnn CLEAR PAGEDOWN/ROLLUP PAGEUP/ROLLDOWN 

                               HOME HELP HLPRTN                                

   Unconditioned keywords:     INDTXT VLDCMDKEY SETOF CHANGE                   

                                                                                

 Keyword   Indicators/+ Resp Text                                              

 CF03                    03  Exit                                              

                                                                                

                                                                               

                                                                               

                                                                         Bottom

 F3=Exit   F12=Cancel                                                          

                                                                               

j、保存DSPF文件并编译为目标

 

9.1F3后回到如下画面

 

                      Work with Display Records                                

                                                                               

 File  . . . . . . :   QDDSSRC                Member . . . . . . :   IVSCREEN  

   Library . . . . :     QINGZHOU             Source type  . . . :   DSPF      

                                                                               

 Type options, press Enter.                                                    

   1=Add             2=Edit comments          3=Copy          4=Delete         

   7=Rename          8=Select keywords       12=Design image                   

                                                                               

 Opt  Order    Record        Type      Related Subfile   Date        DDS Error 

                                                                               

         10    DSP_PMPT      RECORD                      12/19/04              

                                                                               

                                                                                

                                                                               

                                                                               

                                                                         Bottom

 F3=Exit                     F12=Cancel      F14=File-level keywords           

 F15=File-level comments     F17=Subset      F24=More keys                     

 Keywords updated for record DSP_PMPT.                                         

 

9.2再按F3时,出现编译DSPF画面:

连续2次执行。第一次表示保存DDS源码,第二次表示生成目标。

 

                         Save DDS - Create Display File                        

                                                                                

 Type choices, press Enter.                                                    

                                                                               

   Save DDS source  . . . . . . . . . . . .   Y            Y=Yes               

     Source file  . . . . . . . . . . . . .   QDDSSRC      F4 for list         

       Library  . . . . . . . . . . . . . .   QINGZHOU     Name, *LIBL ...     

     Member . . . . . . . . . . . . . . . .   IVSCREEN     F4 for list         

     Text . . . . . . . . . . . . . . . . .                                    

                                                                               

                                                                               

   Create display file  . . . . . . . . . .   Y            Y=Yes               

     Prompt for parameters  . . . . . . . .                Y=Yes               

     Display file . . . . . . . . . . . . .   IVSCREEN     F4 for list         

       Library  . . . . . . . . . . . . . .   QINGZHOU     Name, *LUPARLIB       

     Replace existing file  . . . . . . . .                Y=Yes               

                                                                               

   Submit create job in batch . . . . . . .   Y            Y=Yes               

                                                                               

   Specify additional                                                          

     save or create options . . . . . . . .                Y=Yes                

                                                                               

 F3=Exit   F4=Prompt   F12=Cancel                                              

 Member IVSCREEN already exists. Press Enter to replace.                      +

 

至此屏幕设计已经全部完成。

对于选项2. Design menus设计菜单由于很简单在次不再赘述。

IVSCREEN这个DSPF的源码如下

 

 Columns . . . :    1  71            Edit                      QINGZHOU/QDDSSRC

 SEU==>                                                                IVSCREEN

 FMT A* .....A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 

        *************** Beginning of data *************************************

0000.10      A*%%TS  SD  20041219  164718  QINGZHOU    REL-V5R1M0  5722-WDS    

0000.20      A*%%EC                                                             

0000.30      A                                      DSPSIZ(24 80 *DS3)         

0000.40      A          R DSP_PMPT                                             

0000.50      A*%%TS  SD  20041219  164718  QINGZHOU    REL-V5R1M0  5722-WDS    

0000.60      A                                      CF03(03 'Exit')            

0000.70      A                                  7 19' 发票 :'                  

0000.80      A            IV_CODE   R        B  7 28REFFLD(IV_FMT/IV_CODE QINGZHOU/INVO-

0000.90      A                                      ICE)                       

0001.00      A                                      DSPATR(RI)                 

0001.10      A                                  9 19' 名称 :'                   

0001.20      A            IV_NAME   R        O  9 28REFFLD(IV_FMT/IV_NAME QINGZHOU/INVO-

0001.30      A                                      ICE)                       

0001.40      A                                 11 19' 总数 :'                   

0001.50      A            IV_QUTITY R        O 11 28REFFLD(IV_FMT/IV_QUTITY QINGZHOU/IN-

0001.60      A                                      VOICE)                     

0001.70      A                                 13 17' 总金额 :'                 

0001.80      A            IV_AMOUNT R        O 13 28REFFLD(IV_FMT/IV_AMOUNT QINGZHOU/IN-

0001.90      A                                      VOICE)                     

0002.00      A                                 15 19' 备注 :'                  

0002.10      A            IV_DESC   R        O 15 28REFFLD(IV_FMT/IV_DESC QINGZHOU/INVO-

0002.20      A                                      ICE)                       

0002.30      A                                  3 33' 发票查询 '               

0002.40      A                                 21 25'F3= 退出 '                

0002.60      A            MSGLINE       40   O 24 19COLOR(RED)                          

0002.70      A                                  3 10DATE                       

0002.80      A                                      EDTCDE(Y)                  

0002.90      A                                  3 57SYSNAME                    

0003.00      A                                  4 57USER                       

        ****************** End of data ****************************************

                                                                               

                                                                               

 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      

 F16=Repeat find       F17=Repeat change          F24=More keys                

                                                                               

 

D、编制RPGIV交互式程序:

 

下面举例说明:编制一个数据查询程序,键入发票号,显示发票明细项。

 

4.1.利用SEU书写RPGIV代码,假设RPGIV程序名为QRYIV:

 

                       Start Source Entry Utility (STRSEU)                     

                                                                               

 Type choices, press Enter.                                                     

                                                                               

 Source file  . . . . . . . . . . > QRPGLESRC     Name, *PRV                   

   Library  . . . . . . . . . . . >   QINGZHOU    Name, *LIBL, *LUPARLIB, *PRV   

 Source member  . . . . . . . . .   QRYIV         Name, *PRV, *SELECT          

 Source type  . . . . . . . . . .   RPGLE         Name, *SAME, BAS, BASP...    

 Text 'description' . . . . . . .   Query Invoice RPGIV Program                

                                                                                

                                                                               

                                                                               

                                                                                

                                                                         Bottom

 F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display   

 F24=More keys                                                                  

                                                                               

4.2.出现SEU屏幕。

小技巧我们可以在左栏键入FMT,同时在通行代码栏键入F后执行可以调出FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++便于书写代码对应位置。

 

 Columns . . . :    6  76            Edit                    QINGZHOU/QRPGLESRC

 SEU==>                                                                   QRYIV

 FMT F  FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++++

        *************** Beginning of data *************************************

FMT     F                                                                      

        ****************** End of data ****************************************

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      

 F16=Repeat find       F17=Repeat change          F24=More keys                

Prompt or format not correct, or does not exist.                               

 

3.实现查询功能的RPGIV程序代码如下:

大家可以感觉到RPGIV书写格式明显比RPGIV自由了很多。

如果需要详细解说每行代码的意思,可以跟帖提出。

 Columns . . . :    6  76           Browse                   QINGZHOU/QRPGLESRC

 SEU==>                                                                   QRYIV

 FMT ** ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+.

        *************** Beginning of data *************************************

0000.04   //Create by TRF.LIU YUAN YAO 2004.12.18.                             

0000.05   //Query invoice RPGIV Program.                                       

0000.06                                                                         

0001.00 FINVOICE   IF   E           K DISK                                     

0002.00                                                                        

0003.00 FIVSCREEN  CF   E             WORKSTN                                  

0004.00                                                                        

0005.00  /FREE                                                                 

0005.01                                                                         

0006.00   DOW NOT *IN03;                                                       

0006.01                                                                        

0007.00    EXFMT DSP_PMPT;                                                      

0008.00                                                                        

0009.00    IF IV_CODE<>*BLANK;                                                 

0009.01                                                                         

0010.00       CHAIN IV_CODE IV_FMT;                                            

0011.00       *IN50=NOT %FOUND;                                                

0011.01                                                                         

0012.00       IF *IN50;                                                        

0012.01                                                                        

0013.00          IV_NAME=*BLANK;                                               

0014.00          IV_QUTITY=*ZERO;                                              

0015.00          IV_AMOUNT=*ZERO;                                              

0016.00          MSGLINE=' 无此备件 !';                                        

0016.01                                                                        

0017.00       ELSE;                                                            

0017.01                                                                         

0018.00          MSGLINE=*BLANK;                                               

0018.01                                                                        

0019.00       ENDIF;                                                            

0019.01                                                                        

0020.00    ENDIF;                                                              

0020.01                                                                         

0021.00   ENDDO;                                                               

0022.00                                                                        

0023.00   *INLR=*ON;                                                           

0024.00   RETURN;                                                              

0025.00                                                                        

0026.00  /END-FREE                                                             

        ****************** End of data ****************************************

                                                                               

                                                                               

                                                                                

                                                                               

 F3=Exit   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle   F12=Cancel     

 F16=Repeat find        F24=More keys                                           

                                                                               

E、利用DFU输入数据:

 

5.1.由于已经在上回有专门详细讲解DFU用法,在此只做一笔带过。

 

                          Work with Objects Using PDM                  S656C33B

                                                                                

 Library . . . . .   QINGZHOU         Position to . . . . . . . .              

                                      Position to type  . . . . .              

                                                                                

 Type options, press Enter.                                                    

   12=Work with             13=Change text           15=Copy file              

   16=Run                   18=Change using DFU      25=Find string ...        

                                                                               

 Opt  Object      Type        Attribute   Text                                 

      QRYIV       *PGM        RPGLE       Query Invoice RPGIV Program          

 18   INVOICE     *FILE       PF-DTA      invoice dds cource code              

      IVSCREEN    *FILE       DSPF        invoice screen display file          

      QDDSSRC     *FILE       PF-SRC      dds source code                      

      QRPGLESRC   *FILE       PF-SRC      rpgiv source code                    

      REFILE      *FILE       PF-DTA      data dictionary reference file       

                                                                                

                                                                               

                                                                         Bottom

 Parameters or command                                                         

 ===>                                                                          

 F11=Display names and types    F12=Cancel               F13=Repeat            

 F14=Display Size               F23=More options         F24=More keys         

                                                                                

5.2.输入2笔测试数据

 

 WORK WITH DATA IN A FILE                       Mode . . . . :   CHANGE        

 Format . . . . :   IV_FMT                      File . . . . :   INVOICE       

                                                                               

  发票 :   00001                                                               

  名称 :   DICTIONARY                                                          

  总数 :       100                                                             

  总金额 :            100000                                                     

  备注 :    测试数据                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

 F3=Exit                 F5=Refresh               F6=Select format             

 F9=Insert               F10=Entry                F11=Change                   

                                                                                

 

 WORK WITH DATA IN A FILE                       Mode . . . . :   CHANGE        

 Format . . . . :   IV_FMT                      File . . . . :   INVOICE       

                                                                                

  发票 :   00002                                                               

  名称 :   AS/400 教材                                                         

  总数 :         2                                                             

  总金额 :            560000                                                     

  备注 :   AS06 (RPGIV FUNDAMENTALS)                                           

                                                                               

                                                                                

                                                                               

                                                                               

                                                                                

 F3=Exit                 F5=Refresh               F6=Select format             

 F9=Insert               F10=Entry                F11=Change                   

                                                                                

5.3数据保存完毕,可以通过STRSQL查询结果:

 

                              Enter SQL Statements                             

                                                                               

 Type SQL statement, press Enter.                                               

      Current connection is to relational database S656C33B.                   

 ===> select * from qingzhou/invoice                                           

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                               

                                                                        Bottom 

 F3=Exit   F4=Prompt   F6=Insert line   F9=Retrieve   F10=Copy line            

 F12=Cancel            F13=Services     F24=More keys                          

                                         (C) COPYRIGHT IBM CORP. 1982, 2000.   

     

5.4STRSQL查询结果如下

 

                                  Display Data                                 

                                              Data width . . . . . . :      87 

 Position to line  . . . . .              Shift to column  . . . . . .          

 ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....

  发票    名称              总数                 总金额    备注                

 00001   DICTIONARY           100               1,000.00   测试数据            

 00002   AS/400 教材            2               5,600.00  AS06 (RPGIV FUNDAMENTA

 ********  End of data  ********                                               

                                                                               

 

                                                                                

                                                                               

                                                                               

                                                                                

                                                                       Bottom  

 F3=Exit      F12=Cancel      F19=Left      F20=Right      F21=Split           

                                                                                

5.5、或者通过STRQRY查询输入的结果。如果查询定义已经保存,下次可以直接通过执行:RUNQRY QRY(QINGZHOU/QUERY_IV) 快速查询结果。

 

                                 Display Report                                

                                              Report width . . . . . :      87 

 Position to line  . . . . .              Shift to column  . . . . . .         

 Line   ....+....1....+....2....+....3....+....4....+....5....+....6....+....7..

         发票    名称              总数                 总金额    备注         

 000001 00001   DICTIONARY           100               1,000.00   测试数据     

 000002 00002   AS/400 教材            2               5,600.00  AS06 (RPGIV FUN

 ****** ********  End of report  ********                                      

                                                                                

                                                                               

                                                                               

                                                                                

                                                                               

                                                                       Bottom  

 F3=Exit      F12=Cancel      F19=Left      F20=Right      F21=Split           

                                                                                

 

 

F、运行程序:

通过:编译—检查SPLF错误列表—修正程序—再编译—完成 步骤,调试好RPGIV程序。

确保LIBL库列表中含有放置代码的对应库,然后在命令行执行CALL QRYIV 。

6.1在发票栏输入00000后执行,下方提示“无此备件!”,说明程序实现了所期待的提醒机能。

 

6.2、再分别查询00001、00002发票号,屏幕列出该发票号对应的明细项。

 

 

G、结束语:

 

现在,我们终于完成了从DSPF到RPGIV编写过程,实现了简单的交互式程序的设计过程。我们学习了基本的SDA、RPGIV的F、C类定义,指示符的用法,以及如何使用DSPF+RPGIV来编制程序。

我们本篇用SDA所设计的是对文件单一记录进行操作的显示文件界面,而子文件可以同时对文件一组记录进行操作的显示文件界面。

子文件设计是程序设计的重点和难点,如果可能的话,将在下一篇幅进行逐步深入介绍。

 

 

5.4.CL

 

541

提要:

* CL 命令的作用

* CL 命令的分类

* 系统菜单

 

 

541 .1 CL 命令的作用

 

CL Control Language) 控制语言是用户与操作系统之间的主要接口。可以说用户管理和操作 AS/400 系统,均可以通过 CL 实现。用户在不同的工作站或客户端可以同时使用 CL,其输入方式有五种:

 

* 在命令行输入

* 在菜单画面选择

* work with 菜单中,option 选项

* CL 程序中执行

* 远程调用

 

前三种输入方式给用户提供一种交互式的操作方法,只执行一条命令;第四种方式给用户提供一种操作,并包含逻辑控制,可以完整地实现一项功能;第五种方式给用户提供在客户端直接执行主机操作的接口。

 

由于 CL 使用了统一的命名方法,提供 prompt 式的提示功能和具体到域值的在线帮助,以及自动生成命令参数的缺省值, 再加上有效性检查,从而使得 CL 的使用变得非常简单、方便和灵活。

 

 

541 .2 CL 命令的参数

 

CL 使用了一种很科学,较为成功的命名方法。每条命令由命令名和一系列参数组成。命令名通常由动词加上接受动词的名词定义为目标Ob ject)组成,单词通常缩写为三个字母。

 

例如:

CL 命令                  命令名

Send Message              SNDMSG

Copy File                  CPYF

Work with Device Desripyions  WRKDEVD

 

CL 的参数由关键字和参数值组成,关键字通常和命令一样缩写,它用于说明参数的作用,在命令输入屏,按 F11 键,即可看到关键字。在命令行输入命令时,如果参数是按照固定的顺序输入,则可以省略关键字。

 

例如: SNDMSG MSG (HOLLEO) TOUSR (LENG)

 

命令名 关键字 参数值

 

大多数 CL 都是 针对目标而言,目标是一个占据了一定存储空间的实体,它包括自身属性及其数据特征的描述,系统可以对它进行操作。目标的属性包括名字、类型、长度、建立日期及其它属性。不同目标具有不同的属性描述,大部分属性是可以修改的,而不需要重新建立。目标的数据值是储存于目标中的信息集合,例如: 程序的值是组成程序的执行码,文件的值是组成文件的记录。

 

目标的类型很多,常用的几种包括:

* LIB

* FILE 文件

* MSGF 信息文件

* PGM 程序

* CMD 命令

* JOBQ 作业队列

* DTAQ 数据队列

* MSGQ 信息队列

* OUTQ 输出队列

* DTAARA 数据域

* JRN 日志

* JRNRCV 日志接受器

* USRPRF 用户简要表

* SBSD 子系统描述

* JOBD 作业描述

* LIND 线路描述

* CTLD 控制器描述

* DEVD 设备描述

 

一个具体目标是由目标名和目标类型来唯一标识的,不同的目标类型可以使用同一个目标名。目标名由用户指定,目标类型由生成它的命令决定。不同类型的目标具有不同的操作。例如:

CALL 命令只针对 *PGM 目标进行操作。

 

关于目标的操作,系统也进行了统一的规范,常用的几种包括:

* WRK 工作

* CRT 建立

* ADD 增加

* CHG 改变

* DLT 删除

* DSP 显示

* EDT 编辑

* CPY 拷贝

* MOV 移动

* RNM 变名

* SAV 备份

* RST 恢复

* RTV 获取

* GRT 授权

* DMP 转储

 

542  CL 编程

542. 1 CL 程序的作用

 

CL 程序是由 CL 命令组成,这些命令被编译成可供随时调用的程序。使用 CL 程序的优点包括:

* CL 程序比单独输入和运行命令快,因为命令被编译成能够立即运行的形式。

* 有些功能需要多条 CL 命令一起完成。

* 参数可以传递给 CL 程序,CL 程序内部也接收变量的定义, 以适应特殊需要的程序操作。

* CL 程序能够像其它高级语言程序一样被测试和监控。

 

CL 程序可以应用到许多方面,包括:

* 通过 CL 程序完成单独输入 CL 命令所不能完成的功能,例如,人工或者定时提交批作用完成一项工作,如启动子系统, 进行文件备份,整顿系统资源。

* 给交互式或批处理的应用程序提供一个接口,使得在应用程序中直接进行系统操作或者获取系统参数。

* 在网络通信方面,CL 程序往往承担应用主控程序的角色。

 

542. 2 CL 程序的结构

CL 程序是借助于 ADT 工具中的 SEU 输入的,在输入过程中,键入一条命令并按 F4 键,就会显示出这条命令的提示画面,方便用户输入相应的参数值。CL 源程序主要分为以下几个部分:

 

* 程序的开始和结束:

PGM PARM&A &B 开始 CL 程序

END PGM 结束程序

* 变量定义: DCL 定义变量

DCLF 定义文件

* CL 处理命令: CHGVAR 变量赋值

MONMSG 监控错误信息

SNDPGMMSG 传送程序信息

RTVJOBA 获取作业属性值

* 逻辑控制命令: IF THEN ELSE

DO ENDDO

GOTO

* 内部函数:     % SST 取子串

* CAT 连接字符

* 程序控制命令: CALL 调用子程序

RETURN 返回调用程序

 

542. 3  CL 程序的命令

 

CL 程序中仅可包含 CL 命令,由系统提供的大多数 CL 命令可用于 CL 程序,而有些 CL 命令是专门用在 CL 程序中的。 下面是一张用在 CL 程序中的部分命令清单,其中带有星号的表示该命令仅能用于 CL 程序内部。

 

 变量的使用

 

* 变量说明,使用 DCL 命令来定义变量及其属性、长度和初值。标准格式如下:

* CHAR

DCL VAR (变量名) TYPE * DEC LEN (长度) VALUE(初值)

* LGL

 

使用 DCL 命令时,必须遵循的规则如下:

#CL 变量名必须以 & 开始,后跟字符不多于 10 & 后的第一个字符必须是字母,其余的可以是字母或数字。

#CL 变量值必须是:字符型最长为 9999 字符;数值型为压缩十进制数,最长为 15 位,其中小数位最长为 9 位; 逻辑型为“0或“1,表示假或真。

#CL 变量的缺省初值为:字符型为空,数值型为 0,逻辑型为“0

#对于字符型和数值型,如果指定了初值而未指定长度,则缺省长度为初值长度。

* 变量值中小写字符的限制

 

用作变量的保留值必须用大写字母表示,特别是当它们用引号起来的时候。例如:

DCL VAR(&LIB) TYPE(*CHAR) LEN(10) VALUE('*LIBL')

DLTPGM &LIB/MY PROG

注意:如果 VALUE 参数不使用引号,则小写是正确的。因为使用 SEU 编辑会自动转换成大写。

 

* 变量赋值,使用 CHGVAR 命令给变量赋值,其值可改变成:

#常量: CHGVAR VAR&A VALUE0

#变量: CHGVAR VAR&A VALUE&B

#计算量:CHGVAR VAR&A VALUE&A+1

#函数量:CHGVAR VAR&A VALUE(%SST(&B 1 5))

CHGVAR VAR(%SST(&A 1 5)) VALUE(&B)

 

赋值时应注意以下几点:

#对逻辑变量,被改变的值必须是一个逻辑值。

#对数值变量,只能赋予十进制数,或者数字字符变量(包括小数点和正负号)。

#对字符变量,既可接受字符,也可接受十进制数。赋十进制数时,该字符变量的值是右对齐,前导补零,负号放在最左边。

 

* CL 程序中注解的书写,在命令的头尾使用一对符号:/* */

如果一行写不下一条命令,使用 +

 

 

542. 4  CL 程序内部的逻辑控制

 

* 条件转移命令:

 

IF COND(条件) THEN(一条命令)

ELSE CMD(一条命令)

或者 IF COND(条件) THENDO

.

ENDDO

ELSE CMD DO

.

ENDDO

 

* 无条件转移命令:GOTO LABEL

 

* 操作符:

逻辑的 *AND *OR *NOT

算术的 + - * /

字符的 *CAT *TCAT

关系的 *EQ *GT *LT *GE *LE *NE

 

* 监视信息命令:MONMSG

MONMSG MSGID(信息标识 1 信息标识 50+ EXECCL命令)

 

系统对于CL命令执行错误所送出的信息都具有唯一的标识符,如果不进行监视,则系统会终断程序,自动显示错误信息。

 

542. 5 系统资源的获取

 

* 日期格式转换命令:CVTDAT

CVTDAT DATE(被转换日期) TOVAR(转换后日期) FROMFMT(原格式) TOFMT(新格式) TOSEP(新分隔符)

其中:转换后日期的长度至少是:

#对儒略日期(如 YMDDMY JUL 格式),不使用分隔符为 5 字符,使用分隔符为 6 字符。

#对非儒略日期,不使用分隔符为 6 字符,使用分隔符为8 字符。 日期格式和分隔符可以通过按 F4 键选择。

 

* 检索系统值命令:RTVSYSVAL

 

RTVSYSVAL SYSVAL(系统值名)RTNVARCL变量名)

其中:系统值名可以通过按 F4 键选择,如:系统当前日期的系统值是 QDATE。变量名必须和系统值的类型匹配,对字符型和逻辑型系统值而言,变量名的长度必须相符,对数字型,则长度不小于系统值长度。

 

* 检索配置源命令:RTVCFGSRC

用于将现有配置的描述存放到源文件成员中

 

* 配置状态检索命令:RTVCFGSTS

用于获取各类配置描述的现行状态,放入 CL 变量。

 

* 检索网络属性的命令:RTVNETA

用于获取系统的网络属性,放入相应的 CL 变量。如:系统名SYSNAME,本地网络标识 LCLNETID

 

* 检索作业属性命令:RTVJOBA

用于获取当前运行作业的属性,放入相应的 CL 变量。如:作业名 JOB,用户名 USER

 

* 检索目标描述命令:RTVOBJD

用于获取指定目标的描述属性,放入相应的 CL 变量。

 

* 检索用户档案命令:RTVUSRPRF

用于获取指定用户的档案资料,放入相应的 CL 变量。

 

5 .4 .3 程序间的通讯

程序间的通讯是指不同程序之间数据或参数的传递和交流。这种通讯可以出现在不同种类的程序中。如:RPG C 语言,也可以出现在不同机器上,如:PC AS/400。针对OS/400 而言,通常程序间的通讯具有三种方式:

* CALLRETURN 命令

* 数据队列通讯

* 数据域通讯

 

5.4.3.1 CALL 命令的使用

调用程序: CALL PGMPGMA PARM&A &B

被调用程序:PGM PARM&C &D

 

有关 CALL 命令使用的几点说明:

* 参数值可以是字符常量、数值常量、逻辑常量或 CL 常量,最多可达 40

* 参数值以 CALL 命令中出现的顺序传送,这必须与被调用程序的参数顺序相匹配,变量名不一定相同。

* 被调程序中的接收参数必须说明,但接收值不受变量说明中初值的影响。

* 接收参数值的改变会反映到调用程序中,但常量传送不会改变。

* 字符常量通常以 32 字节传送,数字常量以 15.5 长度压缩格式传送。

 

5.4.3.2 数据队列的程序通讯

数据队列(*DTAQ)是系统目标中的一种类型,当建立了这种目标后,一个程序可以发送数据给它,另一个程序再从中接收数据,从而达到程序之间的数据通讯。

 

5.4.3.3 数据队列的优点

 

* 数据队列是两个作业之间进行异步通讯的最快方法。相对数据库文件、消息队列或数据域而言,它需要较少的额外开销。

* 多个作业可以向相同的数据队列送数据和取数据,而数据队列的先进先出、后进先出或关键字顺序排列属性,能够保证数据送取的正确性。

* 在任何高级语言程序中,通过调用系统提供的程序,就可以对数据队列进行操作,而且操作方法灵活方便。数据队列的操作和使用包括两类:第一类使用 CL 命令;第二类调用系统程序。

CL 命令:

CRTDTAQ 建立数据队列

DLTDTAQ 删除数据队列

WRKDTAQ 工作数据队列

系统程序:

QSNDDTAQ 发送数据队列

QRCVDTAQ 接收数据队列

QCLRDTAQ 清除数据队列

QMHQRDQD 检索数据队列

 

5.4.3.4 数据队列的发送

 

需要将数据发送给数据队列,只要在程序中调用QSNDDTAQ 。在 CL 程序中,调用的格式如下:

CALL PGM(QSNDDTAQ) PARM(&QNAME &LIB &FLDLEN &FIELD &KEYLEN &KEY)

&QNAME 是长度为10的字符型,它命名了数据队列,如:IN_Q

&LIB 是长度为10的字符型,它命名了数据队列所在的库,如:*LIBL

&FLDLEN 是长度为5的数字型,它规定了发送给数据队列的字符数,如:100

&FIELD 是长度为&FLDLEN的字符型,它包含了具体发送给数据队列的数据。

&KEYLEN 是长度为3的数字型,它说明了传送给数据队列的关键字长度,如:6

&KEY 是长度为&KEYLEN的字符型,它包含了传送给数据队列的关键字数据。

注:后两个参数可以自选,如果说明了一个,则必须说明另一个。

 

5.4.3.5数据队列的接收

 

需要从数据队列中接收数据,只要在程序中调用QRCVDTAQ 。在 CL 程序中,调用的格式如下:

CALL PGM(QRCVDTAQ) PARM(&QNAME &LIB &FLDLEN &FIELD &WAIT &ORDER KEYLEN &KEY &SNDRLEN &SNDR)

&QNAME 是长度为10的字符型,它命名了数据队列。如: OUT_Q

&LIB 是长度为10的字符型,它命名了数据队列所在的库。如:*LIBL

&FLDLEN 是长度为5的数字型,它规定了发送给数据队列的字符数。

&FIELD 是长度为&FLDLEN的字符型,它包含了从数据队列中接收到的具体数据。

&WAIT 是长度为5的数字型,它说明了等待接收数据的时间。负数表示无限制的等待;零表示不等待;

正数示要等待的秒数,最大值是9999。这个参数只有在数据队列中无满足条件的数据时, 才起作

用。

&ORDER 是长度为2的字符型,它说明了按关键字接收数据的条件。可用的字符值是:GTLTEQ

GELE

&KEYLEN 是长度为3的数字型,它说明了接收数据队列的关键字长度。

&KEY 是长度为&KEYLEN的字符型,它标识了用于从数据队列中接收数据的关键字变量。

&SNDRLEN:是长度为3的数字型,它规定了发送者标识的长度。

&SNDR 是长度为&SNDRLEN 的字符型,它包含了发送者标识的数据。

 

注:后三个参数可以任选,但是&ORDER&KEYLEN&KEY 必须同时说明。

 

5.4.3.6 数据队列的清除

 

需要从数据队列中清除数据,只要在程序中调用 QCLRDTAQ CL 程序中,调用的格式如下:

CALL PGMQCLRDTAQ PARMM&QNAME &LIB

 

5.4.3.7 数据队列的检索

 

需要检索一个数据队列的描述项,只要在程序中调用QMHQRDQD。在 CL 程序中,调用的格式如下:

CALL PGMQMHQRDQD PARM&RCVR &RCVRLEN &FORMAT &DQNAME

&RCVR 是长度为&RCVRLEN的字符型,它标识了含有数据队列性的变量。

&RCVRLEN 是长度为4的数字型,它说明了&RCVR长度。

&FORMAT 是长度为8的字符型,它定义了接收模板的格式。

&DQNAME 是长度为20的字符型,它标识了数据队列和所在库,前十个字符是队列名字,后十个字符是库名。

 

5.4.3.8 数据域的程序通讯

 

数据域(*DTAARA)是系统目标中的一种类型。当建立了这种目标后,可以用来存入数据,以便任何程序进行读取和修改。数据域的典型用途如下:

* 提供用于几个程序中的常数字段,易于共享和修改。如:标题、说明等。

* 在一个作业中提供一个传递信息的区域。

* 在一个作业中提供一个字段作为控制参数,以便容易地得到修改。

 

数据域的 CL 命令包括:

CRTDTAARA 建立数据域,长度不超过2000

CHGDTAARA 改变数据域,改变时数据域被锁定

DSPDTAARA 显示数据域,可以以十六进制方式显示

RTVDTAARA 检索数据域,检索值需要存入 CL 变量

DLTDTAARA 删除数据域

WRKDTAARA 工作数据域

 

5 .4 .4测试功能

5.4.4.1 CL 程序的编译

CL 源程序必须经过编译,生成 *PGM 方可运行。建立程序的方法有两种:一是,使用 CL 命令 CRTCLPGM,二是,使用PDM 菜单选项 14,按 F4 键即可对命令参数进行选择。

系统编译的情况全部记录在编译清单中,通过 WRKSPLF 即可看到。编译过程中的错误被列在相应命令后面,以及文件的最后,方便用户查找。下列类型的错误将停止程序的建立:

* 值错

* 句法错

* 命令内部与参数间不符

* 有效性检查有错

 

CL 程序可以通过反编译命令 RTVCLSRC,重新建立 CL源程序。使用该命令时,必须满足建立编译程序的参数 ALWRTVSRC *YES 当源程序被反编后,任何注释信息不再重新产生,以下程序序言将被建立:

* 所有者名

* 源程序的最终修改日期

* 源程序的重建日期和时间

* 最初编译时的许可程序级

 

5.4.4.2程序的编译

CL 程序的测试

对于 CL 程序在编译和运行中的错误,系统提供以下几种测试功能:

* 程序转储。 CL 源程序中输入命令 DMPCLPGM,运行后通过 WRKSPLF 即可看到转储内容。包括程序信息队列的全部信息和全部变量的数值。如果程序运行出错,出现提示画面时,输入 D 也可进行程序转储。

* 设置断点。第一步,启动测试环境,使用命令 STRDBG PGM PGMA);第二步,设置断点,使用命令 ADDBKP STMT 1500 PGMVAR( '&A' '&B'); 第三步,运行程序,显示断点信息;第四步,结束测试环境,使用命令 ENDDBG

* 设置跟踪。跟踪是记录程序中语句执行顺序的过程。系统并不自动显示跟踪信息,而须使用命令 DSPTRCDTA 请求显示跟踪信息,信息包括语句执行的顺序和 ADDTRC 命令中指定的变量值。

 

例如:

Auto RGZPFM

STRCLPGM: PGM PARM(&LIBRARY)

DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10)

DCL VAR(&PERCENT) TYPE(*DEC) LEN(4 3)

DCLF FILE(QTEMP/WORKFILE) RCDFMT(QWHFDMBR)

DSPFD FILE(&LIBRARY/*ALL) TYPE(*MBR) +

OUTPUT(*OUTFILE) OUTFILE(QTEMP/WORKFILE)

NEXT: RCVF RCDFMT(QWHFDMBR)

MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDCLPGM))

IF COND(&MBFILA *EQ '*PHY') THEN(DO)

CHGVAR VAR(&PERCENT) VALUE(&MBNDTR / &MBNRCD)

MONMSG MSGID(MCH1211) EXEC(GOTO CMDLBL(NEXT))

IF COND(&PERCENT *GT .15) THEN(DO)

SBMJOB CMD(RGZPFM FILE(&MBLIB/&MBFILE) MBR(&MBNAME))

ENDDO

ENDDO

GOTO CMDLBL(NEXT)

ENDCLPGM: DLTF FILE(QTEMP/WORKFILE)

ENDPGM

 

5.45常用CL命令

系统功能

命令

命令功能

修改过程控制

 

 

CALL (Call)

调用一个程序

CALLPRC (Call Procedure)

调用一个过程

RETURN (Return)

返回到引起程序或过程运行的下一条命令

CL过程界限

PGM (program) (1)

指出CL过程源码的开始

ENDPGM (End Program) (1)

指出CL过程源码的结束

CL过程逻辑

IF (If) (1)

根据逻辑表达式的值执行命令

ELSE (Else) (1)

IF命令为假条件定义采取的行动

DO (Do) (1)

指出DO组的开始

ENDDO (End Do) (1)

指出DO组的结束

GOTO (Go To) (1)

转移到另外的命令

CL过程变量

CHGVAR (Change Variable) (1)

修改CL变量的值

DCL (Declare) (1)

说明一个变量

替换

CHGVAR (Change Variable) (1)

修改CL变量的值

CVTDAT (Convert Date) (1)

修改日期格式

数据区

CHGDTAARA (Change Data Area)

修改数据区

CRTDTAARA (Create Data Area)

生成一个数据区

DLTDTAARA (Delete Data Area)

删除一个数据区

DSPDTAARA (Display Data Area)

显示一个数据区

RTVDTAARA (Retrieve Data Area)

把数据区的内容复制到一个CL变量中

文件

ENDRCV (End Receive) (1)

 

取消由前面的RCVF,SNDFSNDRCVF

命令对一个显示文件发出的输入请求.

DCLF (Declare File) (1)

说明一个显示文件或数据库文件

RCVF (Receive File) (1)

从显示文件和数据库文件中读记录

RTVMBRD (Retrieve Member Description) (1)

取得数据库文件成员的描述

 

SNDF (Send File) (1)

往显示文件中写记录

SNDRCVF (Send/Reveive File)(1)

往显示文件中写记录,在用户回答后读记录

WAIT (Wait) (1)

 

待从显示文件发出的SNDF,RCVFSNDRVF命令接收文件

信息

MONMSG (Monitor Message)(1)

监控送往程序队列的逃逸,状态和通知信息

RCVMSG (Receive Message)(1)

把信息从信息队列复制到一个CL变量中

 

RMVMSG (Remove Message)(1)

从信息队列取消信息

RTVMSG (Retrieve Message)(1)

 

把预先定义的信息从信息文件复制到CL变量中

SNDPGMMSGSend Program Message(1)

往信息队列发送程序信息

 

SNDRPY Send Reply(1)

给查询信息的发送者发送回答信息

SNDUSRMSGSend User Message(1)

 

给显示工作站或系统操作员发送消息或查询信息

混杂命令

CHKOBJ (Check Object)

检查目标是否存在及使用目标必须有的权限

PRTCMDUSG Print Command Usage

 

产生一个用在某组CL过程中的一组命令中的交叉引用表

RTVCFGSRC (Retrieve Configuration Source)

 

对生成的已存在的配置目标建立一个CL命令源码且把它放在源文件成员中

RTVCFGSTS(RetrieveConfiguration Status)(1)

 

从三个配置目标(线路,控制器和设备)中取得配置状态

RTVJOBA Retrieve Job Attributes (1)

 

取得一个或多个作业属性的值且把它们放到CL变量中

RTVSYSVAL Retrieve System Value(1)

取得系统值并且把它放到一个CL变量中

RTVUSRPRF Retrieve User Profile(1)

取得用户文件属性并把它放到CL变量中

程序生成命令

CRTCLMOD Create CL Module

生成一个CL模块

DLTMOD  Delete Module

删除一个模块

DLTPGM   Delete Program

删除一个程序

CRTBNDCL (Create Bound Control Language Program)

生成一个联编的CL程序

CRTPGM Create Program

生成一个程序

CRTSRVPGMCreate Service Program

生成一个服务程序

(1) 表示这些命令仅能用在CL过程中。

 

5.5.DELPHI

5.5.1.简单的利用ODBC

其实,delphi 和其他语言一样,如果只是单纯的利用as400的数据库的功能,通常,我们都选用windows平台。数据驱动选择client 的odbc.如果AS400的服务器的OS版本>4.4应该就可以用OLDEB的方式。速度会快一些。如果主机版本比较低,只能用ODBC。

下面讲述从如何准备环境到开始写程序。

1.    安装client access

LUPA上面已经有ca5.2的下载了。下载下来安装,新版本的client access在ado的性能上总体来的好一些。不过也不是所有的主机都能够支持的。有一些特性仅限于比较高的版本。

2.    设置ODBC数据源

点击 添加

选择Client Access ODBC Driver (32-bit)

设置odbc的名字

System中,如果是新版本的可以直接填入ip,如果不是,得修改host表

然后从中选择一个

3.    ado连接

就是简单的ODBC的连接。

第二节:调用400上的rpg 或者cl程序

这个我每什么经验,所以等后人来填充5.5.2 Delphi 应用技术

Delphi for AS/400Borland公司现改为Inprise公司专门为AS/400用户提供的用于开发AS/400应用程序的Delphi前端开发工具。除了具有 3.0的全部功能外,Delphi/400提供了与AS/400相兼容的三组元件--SCD400 Data、SCD400 System和 DB。其中SCD400 Data和 DB两组元件与普通Delphi 3.0所属两组元件 Access和Data Controls中元件具有相同或类似的功能。在System元件组中,提供的元件,可以直接调用PGM程序和直接调用A/400 CL命令。

 

一、 在AS/400上编制实现打印货物舱单的RPG程序

 

为叙述方便,假设所需要用到的AS/400上的文件(在AS/400中称为对象--Object)都放在TEST库(Library)中。DCPRTMF为打印文件,用来输出打印舱单的打印格式和内容。DCRPGMF为RPG程序,带两参数VSLCOD(船代码)和VOYNO(航次),用来生成舱单。

 

二、 在AS/400上将打印文件转化为AS/400的物理文件

 

在AS/400上建一物理文件MFPC(相当于其它数据库的Table),记录名为MP,字段名为MP198,长度为198字符。此物理文件用来保存货物舱单打印文件内容。这个过程用MFCPYSPL程序(CLP类型)来实现,程序如下:

 

***************Beginning of data***************

01.0 PGM PARM(STRJOB STRUSR STRNBR)

 

0002.00 DCL VAR(STRJOB) TYPE(*CHAR) LEN(10)

0003.00 DCL VAR(STRUSR) TYPE(*CHAR) LEN(10)

04.0 DCL VAR(STRNBR) TYPE(*CHAR) LEN(6)

0005.00 CPYSPLF FILE(DCPRTMF) TOFILE(TEST/MFPC) +

0006.00 JOB(STRNBR/STRUSR/STRJOB) TOMBR(MFPC) +

0007.00 MBROPT(*REPLACE) ①

0008.00 DLTSPLF FILE(DCPRTMF)

JOB(STRNBR/STRUSR/STRJOB) ②

0010.00 ENDPGM

****************** End of data **************

上述文件定义了三个参数STRJOBSTRUSRSTRNBR,是与操作Spool File相关的参数。

 

将打印文件Spool File)拷贝到物理文件MFPC;②删除打印文件。

 

三、 Delphi/400AS/400上的打印文件转化为微机的文本文件

 

在进行程序处理以前先在Delphi Module进行如下VCL组件设置

 

1.AS400组件设置name--AS4001

 

2.Table组件设置name--MfpcTbl;

tablename--MFPC。与AS/400上的物理文件连接。

 

3.Call400组件设置name--Call400PRTMF;

AS400--AS4001;LibraryName--TEST;

ProgramName--DCRPGPC;Params定义对应VSLCODVOYNO

 

4.Call400组件设置name--Call400CPYSPL;

AS400--AS4001;LibraryName--TEST;

ProgramName--MFCPYSPL;Params

定义对应STRJOBSTRUSRSTRNBR

 

5.Cmd400组件设置name--Cmd400Addlible;

AS400--AS4001;CommandLine--ADDLIBLE LIB(TEST)

POSITION(*FIRST)。将TEST加入库表。

 

6.Cmd400组件设置name--Cmd400Rtvjob;AS400--AS4001;

CommandLine--RTVJOBA JOB(P.1) USER(P.2)

NBR(P.3) USRLIBL(P.4)。用于获取运行MFCPYSPL程序所需要的参数。

 

以下就是实现将AS/400上的打印文件DCPRTMF转化为微机的文本文件的源程序。

var

F,ToF:TextFile;

TempStr:String;

Fname:String;

Str_Job:String;

Str_Usr:String;

Str_Nbr:String;

begin

//获取运行将打印文件转换为物理文件程序的参数

CommDtmFrm.Cmd400Rtvjoba.Execute;

Str_Job:=CommDtmFrm.Cmd400Rtvjoba.Value[0];

Str_Usr:=CommDtmFrm.Cmd400Rtvjoba.Value[1];

Str_Nbr:=CommDtmFrm.Cmd400Rtvjoba.Value[2];

 

//增加库表

CommDtmFrm.Cmd400Addlible1.Execute;

 

//生成CARGO MENIFEST,其中StrVslcod

StrVoyage为打印舱单的参数

CommDtmFrm.Call400PRTMF.Value[0]:=StrVslcod;

CommDtmFrm.Call400PRTMF.Value[1]:=StrVoyage;

CommDtmFrm.Call400PRTMF.Execute ;

 

//转换为物理文件

CommDtmFrm.Call400Cpyspl.Value[0]:=Str_Job;

CommDtmFrm.Call400Cpyspl.Value[1]:=Str_Usr;

CommDtmFrm.Call400Cpyspl.Value[2]:=Str_Nbr;

CommDtmFrm.Call400Cpyspl.Execute ;

 

//产生一个新文件

Fname:='C:\Communication\Newmf.txt';

AssignFile(F,Fname);

ReWrite(F);

if CommDtmFrm.MfpcTbl.Active=false then

CommDtmFrm.MfpcTbl.Active:=True ;

 

//将物理文件的数据读出保存为文本文件

with CommDtmFrm.MfpcTbl do

begin

DisableControls;

try

First;

while not EOF do

begin

{ Process each record here }

TempStr:=CommDtmFrm.MfpcTblMP198.Value;

writeln(F,TempStr);

Next;

end;

finally

EnableControls;

end;

end;

 

if SaveDialog1.Execute then

begin

AssignFile(ToF, SaveDialog1.FileName);

ReWrite(ToF);

Reset(F);

while not EOF(F) do

begin

{ Process each record here }

Readln(F,TempStr);

writeln(ToF,TempStr);

 

end;

 

end;

CloseFile(F);

CloseFile(ToF);

 

5.6.VB

请先安装CA,才能使用一下开发技巧。

5.6.1            ODBC连接AS400

            ConnectString = "Provider=IBMDA400;Data Source='" & Trim(LjIp) & "';User ID='" & Trim(LjUser) & "' ;PassWord='" & Trim(LjPwd) & "'"

                     Sourece 处请填写400的地址

                     Useid   处请填写用户名

                     Password 处请填写密码

5.6.2            通过API下载数据

'   通过IBM提供的参数,下载400文件,并检查下载结果

'输入参数

'  

'输出参数

'   参照MAIN说明

'调用函数

'  

    Dim SysName As New cwbx.SystemNames

    Dim AsSys As New cwbx.AS400System

    Dim AsTr As cwbx.DatabaseTransferResults

    Dim Dlt As New cwbx.DatabaseDownloadRequest

    Dim DltACC As cwbx.DatabaseDownloadASCIIOptions

    Dim SysNum As Integer

    Dim SysExist As Boolean

    Dim StrTime As Date

    Dim FreeNum As Integer

    '检查收到的地址是否有效 AS400

    SysExist = False

    StrTime = Now()

    For SysNum = 1 To SysName.Count     ' RunInput(1) 就是400系统名

        If SysName.Item(SysNum) = RunInput(1) Then

            SysExist = True

            Exit For

        End If

    Next SysNum

    If SysExist = False Then

        Ca_Down = -305

        Exit Function

    End If

   

    '开始系统连接定义

On Error GoTo SysErr

    AsSys.Define RunInput(1)

    AsSys.UserID = RunInput(2)     '用户名

    AsSys.Password = RunInput(3)   '密码

    AsSys.Signon

   

    '开始下载定义

    Set Dlt.System = AsSys

    Dlt.AS400File = RunInput(4)       400文件名

    Dlt.Query.Select = RunInput(5)    '下载的字段列表

    Dlt.Query.Where = RunInput(6)    下载条件

    If Trim(RunInput(8)) = 0 Or Len(Trim(RunInput(8))) = 0 Then   '下载文件的保存格式

        Dlt.pcFile.FileType = cwbdtASCIIText

        Set DltACC = Dlt.pcFile.Options

        DltACC.TruncateSpaces = False

        DltACC.CodePage = cwbnlCodePageClientANSI

    Else

        Dlt.pcFile.FileType = cwbdtCSV

    End If

    Dlt.pcFile.Name = RunInput(7)       Pc机上保存的文件名

    '开始下载

On Error GoTo DltErr

    Dlt.Download

    Set AsTr = Dlt.TransferResults

    '下载结果处理

On Error GoTo AsTrErr

    If AsTr.DataErrors.Count > 0 Then

        Select Case AsTr.DataErrors.Item(1).ErrorType

            Case 1, 5

                Ca_Down = -311

            Case 2, 6

                Ca_Down = -312

            Case 3, 7

                Ca_Down = -313

            Case 4, 8

                '数据转换错误

                Ca_Down = -314

        End Select

    End If

    Ca_Down = DateDiff("s", StrTime, AsTr.CompletionTime)

    Set DltACC = Nothing

    Set Dlt = Nothing

    Set AsSys = Nothing

    Exit Function

DltErr:

    Select Case Dlt.Errors.ReturnCode

        Case 3

            '下载文件目录不存在

            Ca_Down = -322

        Case 112

            '磁盘空间满

            Ca_Down = -323

        Case 7004

            '空记录

            FreeNum = FreeFile

            Open RunInput(7) For Append As #FreeNum

            Close #FreeNum

            Ca_Down = -308

        Case 6053

            '通讯错误

            Ca_Down = -306

'        Case 7412

'            'AS400系统文件存在记录锁

'            Ca_Down = -307

        Case 7038, 7040, 7412

            '指定文件或者库不存在

            RunInput(4) = LCase(RunInput(4))

            If InStr(1, RunInput(4), "abjq/batfiles") > 0 Then

                If InStr(1, RunInput(4), "batfiles1") > 0 Then

                    RunInput(4) = Replace(RunInput(4), "batfiles1", "batfiles3")

                Else

                    RunInput(4) = Replace(RunInput(4), "batfiles3", "batfiles1")

                End If

                RepNum = RepNum + 1

                If RepNum >= 2 Then

                    Ca_Down = -316

                    Exit Function

                End If

                Set AsTr = Nothing

                Set DltACC = Nothing

                Set Dlt = Nothing

                Set AsSys = Nothing

                Ca_Down

            Else

                Ca_Down = -316

            End If

        Case Else

            '出现无法预测错误

            Ca_Down = -317

    End Select

    Set AsSys = Nothing

    Exit Function

SysErr:

    Select Case AsSys.Errors.ReturnCode

        Case 8002

            '密码错

            Ca_Down = -309

        Case 8001

            '用户名错

            Ca_Down = -310

        Case Else

            '出现无法预测错误

            Ca_Down = -317

    End Select

    Exit Function

AsTrErr:

    Ca_Down = -315

End Function

 

5.7  MS.NET

随着IT的发展,微软提出下一代将是.net的时代。如果五到十年之内,还是windows占据个人电脑的擦作系统的主流的话。那应该是这样的情况。

OS的要求:v5r1.

如果不需要事务支持4.4就可以了。

客户端,如果是应用程序,客户端需要安装client acess v5r3 或者 以上的。因为这个版本提供了.net provider

如果是基于web的,只需要web server安装client acessv5r3 或者以上就可以了。

connection 的连接串:

Protection Level=None;User ID=用户名;Force Translate=65535;Data Source=服务器ip;Password=密码;Provider=IBMDASQL;Transport Product=Client Access;Catalog Library List=;Default Collection=用户名;Persist Security Info=True;Convert Date Time To Char=TRUE;SSL=DEFAULT

这是对简单的,要求系统管理员对用户进行授权,最好是public 是*EXCLUDE.然后根据用户在进行授权。

ADO.NET强调的是断开式连接。就是说,如果你和数据库连接用完了,就断开。.net framework默认有数据库连接池管理。

目前的.net provider还不支持数据队列等一些比较高级的操作。

.net访问as400有很多种选择,我们为了提供可迁移性,所以只用oledb,其实client acess本身提供了一套类似ado.net的.net类。

客户端程序最重要的是索引。当然索引的设置最好慎重,过多的索引会浪费硬盘空间。

还有用户调用sql的时候需要事先测试sql是否安全,比如,我查找数据,但是我时间期限设置很大,然后又多表关联,这样会吃光内存,最终导致400当机。所以做程序的时候要考虑到这些范围。

目前做.net访问400感觉还是不是很快,但是至少可以接受。不过400的优点在于大批量数据检索的时候效率比sqlserver之类的来得快。当你的数据超过100万的时候,体现更加的明显。

由于速度不是太快,所以建议,尽可能减少数据库往返,不过如果关联的数据库都是数据量很大,我觉得宁愿多几次数据往返,因为400的关联实在是太慢了。他得建立访问路径,特消耗时间。、

我能写得就这么多了。其余的都是.net的知识了。

                                                                  

       经过一段时间的基于as400的.net开发之后,发现了一些常见的问题:

a)      如果需要事务支持,那么首先PF得添加journal,可以用strjrnpf绑定journal.

如果没有绑定journal,得到的exception通常都是在进行insert/update/delete的

时候发生,错误一般都是:xxx/xxxpf不能适用于这种操作。

b)      如果不用5250 ,client access只需要安装base.exe dataccess.exe

c)      As400的数据字典在qsys2/systables syscolumns里面,不过是被锁定,可以copf的形式拷贝到别的地方,修改ccid=935,供客户端建模使用。

d)      一般来说,我们在400上使用的数据类型对应pc

S----int32 

P----decimal

O等字符型—string

日期型没用过,不是很清楚

5. 报表最好用推模式,这样可以防止很多地方需要记住数据库连接串,具体的推模式

就是先build一个dataset,数据源用这个来绑定,写报表的时候,按照之前build

好的一个dataset的结构,填充数据,然后推给报表就可以了。

最好做一个dal层,统一管理数据访问,具体的可以参考微软的data acesss block

6. 推荐按照微软的duwamish的架构,个人感觉比较适合as400的开发,可以让你比较

容易的摆脱填写繁杂的sql语句,当然了,还有更加多更加优秀的架构,不过对于

应用框架,可以参考目前最先进的aop(面向方面编程)

7. 另外是关于ccid的事情(frank碰到的)

        如果发现你的pf的ccid不能更改,那么是因为这个object被人锁住了

        更改了,但是不能立马起效果,应该是还有人锁住,机器重新启动玩之后就可以

了,或者把tcp/ip重新启动一下就可以了。

        如果发现还是不行,那么就是userporfile的问题

以前默认的*SYSVAL 改成935或1388就可以了!

 

 

5.8           API

5.9           业务相关的数据库设计、系统分析

5.10  UDB/400 数据库JDBC 程序设计

5.10.1 UDB/400 数据库JDBC 访问方法

JDBC JAVA 程序中访问数据库系统的标准接口,主要的数据库厂商都为自己的数据库管理系统提供了配套的JDBC 驱动程序。IBM UDB/400 数据库提供了两种类型的JDBC 驱动程序。一种是IBM ToolBox for JAVA 中包含的com.ibm.as400.access.AS400JDBCDriver 驱动程序,另一种是UDB/400 自带的com.ibm.db2.jdbc.app.DB2Driver 驱动程序。现在两种驱动程序均广泛的应用在各种基于JAVA UDB/400 应用程序中。下面将详细的介绍两种驱动的使用方法和差别

A.  IBM ToolBox for JAVA JDBC 驱动程序

IBM ToolBox for JAVA IBM 提供的一个JAVA 类库。使用这个类库,开发者不但可以访问UDB/400 数据库。而且可以访问和使用OS/400 操作系统中的各种作业队列、消息队列、验证用户权限等相关服务和作业,功能非常强大。这里着重介绍IBM ToolBox for JAVA 提供的JDBC 驱动程序(简称ToolBox JDBC 驱动程序)的使用方法。

 

ToolBox JDBC 驱动程序包含在com.ibm.as400.access.* 包中,使用时通过注册com.ibm.as400.access.AS400JDBCDriver 来使用。在使用ToolBox JDBC 驱动程序之前,OS/400 系统必须安装许可程序“IBM Developer Kit for Java5722JV1 (或V4R5 版本以前5769JV1)和许可程序“IBM ToolBox for JAVA5722JC1(或5769JC1)。安装了IBM ToolBox for JAVA 后,需要将ToolBox for JAVA JAR 文件加入到系统的CLASSPATH 中,使JAVA 程序可以找到该类库。在OS/400 IFS文件系统下:/QIBM/ProdData/HTTP/Public/jt400/lib

引用ToolBox JDBC 驱动程序时,应在程序中导入com.ibm.as400.access.* 包。同时使用DriverManager 注册com.ibm.as400.AS400JDBCDriver 类。import com.ibm.as400.access.*; //导入com.ibm.as400.access.* try {//注册com.ibm.as400.access.AS400JDBCDriver 驱动程序Driver driver = (Driver) Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();DriverManager.registerDriver(driver);}

 

每种JDBC 驱动程序都有自己的数据库连接串(Database URL)格式,ToolBoxJDBC 驱动程序的数据库连接串格式为:jdbc:as400://HostAddress/DatabaseName,其中“jdbc:as400://”为JDBC 连接协议,指定连接数据库使用ToolBox JDBC 驱动程序。而“HostAddress”代表要连接的数据库服务器的IP 地址,如果OS/400 中指定了HostTable 或可用的DNS 服务器也可以使用要连接的主机名代替IP 地址。如果要连接的UDB/400 数据库和JAVA 程序在同一台机器上,则使用“*local”来表示本机地址。参见下面的例子:

jdbc:as400://169.254.200.4/testdb //连接169.254.200.4 上的testdb

jdbc:as400://*local/testdb //连接本地的testdb

下面是一个完整的在JSP 中引用ToolBox JDBC 驱动程序访问UDB/400 数据库

的例子:

<%@ page language="java" import="java.sql.*, com.ibm.as400.access.* "%>

<%

//加载数据库驱动程序

try{

//注册com.ibm.as400.access.AS400JDBCDriver 驱动程序

Driver driver = (Driver) Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();

DriverManager.registerDriver(driver);

out.print("iSeries 400 JDBC Driver 正确安装<br>");

}

catch(Exception e){

out.print("iSeries 400 JDBC Driver 安装失败<br>");

}

//连接数据库并执行查询

try {

Connection conn = null;

conn = DriverManager.getConnection("jdbc:as400://169.254.200.4/testdb","qsecofr","qsecofr");

out.print("正确连接 iSeries 400 数据库 <br>");

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("select * from test");

out.println("<br>查询结果:<br>");

while (rs.next()) {

String a = rs.getString(1);

out.print(" name= " + a + "<br>");

}

rs.close();

stmt.close();

conn.close();

} catch( Exception e ) {

out.println("<br>查询失败<br>");

}

%>

ToolBox JDBC 驱动程序是TYPE 2 类型的驱动程序(符合JDBC 3.0 标准),这意味着ToolBox JDBC 驱动程序是由纯JAVA 编写的,可以运行在任何支持JAVA 的平台上。比如运行在Linux 服务器上的JAVA 程序就可以通过ToolBox JDBC 驱动程序访问运行在iSeries 上的UDB/400 数据库。实现应用服务器和数据库服务器的分离。

B.  iSeries Native JDBC 驱动程序

iSeries Nativer JDBC 驱动程序又称为UDB/400 本地驱动程序,和ToolBox JDBCDriver 不同。Native JDBC 驱动程序的底层是用C/C++语言实现的,上层通过JNI(JAVA Native Interface)进行了封装。由于Native JDBC 驱动程序的底层是用高级语言实现的二进制代码,执行效率要比ToolBox for JAVA 驱动高。但是由于依赖于底层的二进制代码,Native JDBC 驱动程序只能运行在OS/400 操作系统之上。

 

Native JDBC 驱动程序包含在com.ibm.db2.* 包中, 使用时通过注册“com.ibm.db2.jdbc.app.DB2Driver”来使用。在使用之前Native JDBC 驱动程序的JAR 文件加入到系统的CLASSPATH 中,使JAVA 程序可以找到该类库。在OS/400的IFS 文件系统下:/QIBM/ProdData/Java400/ext引用ToolBox JDBC 驱动程序时,应在程序中导入com.ibm.as400.access.* 包。同时使用DriverManager 注册com.ibm.as400.AS400JDBCDriver 类。

import com.ibm.db2.*; //导入com.ibm.db2.* 包

try {

//注册com.ibm.db2.jdbc.app.DB2Driver 驱动程序

Driver driver = (Driver) Class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();

DriverManager.registerDriver(driver);

}

Native JDBC 驱动程序的数据库连接串格式为:jdbc:db2:DataBaseName,其中

jdbc:db2:”为JDBC 连接协议,指定连接数据库使用Native JDBC 驱动程序。而

DataBaseName”代表要连接的本地数据库名称(library name)。参见下面的例子:

jdbc:db2:testdb //连接本地的testdb 库

下面是一个完整的在JSP 中引用Native JDBC 驱动程序访问UDB/400 数据库的例子:

<%@ page language="java" import="java.sql.*, com.ibm.db2.* "%>

<%

//加载数据库驱动程序

try{

//注册com.ibm.db2.jdbc.app.DB2Driver 驱动程序

Driver driver = (Driver) Class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();

DriverManager.registerDriver(driver);

out.print("<br>iSeries 400 JDBC Native Driver 正确安装<br>");

}

catch(Exception e){

out.print("<br>iSeries 400 JDBC Native Driver 安装失败<br>");

}

//连接数据库并执行查询

try {

Connection conn = null;

conn = DriverManager.getConnection("jdbc:db2://*local/slb2b","slb2b","b2b720");

out.print("正确连接 iSeries 400 数据库 <br>");

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("select * from test");

out.println("<br>查询结果:<br>");

while (rs.next()) {

String a = rs.getString(1);

out.print(" name= " + a + "<br>");

}

rs.close();

stmt.close();

conn.close();

} catch( Exception e ) {

out.println("<br>查询失败<br>");

}

%>

5102  使用JDBC 连接池

A. 数据库连接池实例

import java.io.*;

import java.sql.*;

import java.util.*;

import java.util.Date;

/*

* 数据库连接池类

*/

public class DBConnectPool {

static private DBConnectPool instance; // 唯一实例

private int checkedOut = 0;

private Vector freeConnections = new Vector(); //连接池向量表

private int maxConn; //连接池中最大连接数

private String name; //连接池的名字

private String user; //数据库用户

private String password; //数据库密码

private String URL; //数据库连接串

/*

* 私有方法创建数据库连接池,防止随意的创建连接池。所有的客户端程序都使用统一的实例

* @param name 连接池名字

* @param URL 数据库的JDBC URL

* @param user 数据库帐号,或 null

* @param password 密码,或 null

* @param maxConn 此连接池允许建立的最大连接数

*/

private DBConnectPool (String name, String URL, String user, String password, int maxConn) {

this.name = name;

this.URL = URL;

this.user = user;

this.password = password;

this.maxConn = maxConn;

//注册数据库JDBC 驱动程序

try {

Driver driver = (Driver) Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();

DriverManager.registerDriver(driver);

}

catch (Exception e) {

return;

}

//创建连接池

try {

for (int i = 0; i<maxConn; i++) {

Connection conn = newConnection();

//如果连接不空则将给连接加入连接池

if (conn != null) {

freeConnections.addElement(conn);

}

}

}

catch (Exception e) {

}

}

/*

* 将不再使用的连接返回给连接池

* @param con 客户程序释放的连接

*/

public synchronized void freeConnection(Connection con) {

freeConnections.addElement(con); //将指定连接加入到向量末尾

checkedOut--; //将当前使用连接数减少一个

notifyAll();

}

/*

* 从连接池获得一个可用连接.如没有空闲的连接且当前连接数小于最大连接

* 数限制,则创建新连接.如原来登记为可用的连接不再有效,则从向量删除之,

* 然后递归调用自己以尝试新的可用连接.

*/

public synchronized Connection getConnection() {

Connection conn = null; //先生成一空的连接

//判断当前连接池的尺寸是不是大于0

if (freeConnections.size() > 0) {

// 获取向量中第一个可用连接

conn = (Connection) freeConnections.firstElement();

freeConnections.removeElementAt(0);

try {

if (conn.isClosed()) {

// 递归调用自己,尝试再次获取可用连接

conn = getConnection();

}

}

catch (SQLException e) {

// 递归调用自己,尝试再次获取可用连接

conn = getConnection();

}

}

else if (maxConn == 0 || checkedOut < maxConn) {

conn = newConnection();

}

//如果连接不空,则计数器怎加一

if (conn != null) {

checkedOut++;

}

return conn;

}

/*

* 从连接池获取可用连接.可以指定客户程序能够等待的最长时间,参见前一个getConnection()方法.

* @param timeout 以毫秒计的等待时间限制

*/

public synchronized Connection getConnection(long timeout) {

//记录开始时间

long startTime = new Date().getTime();

Connection conn;

while ((conn = getConnection()) == null) {

try {

wait(timeout);

}

catch (InterruptedException e) {

}

if ((new Date().getTime() - startTime) >= timeout) {

// wait()返回的原因是超时

return null;

}

}

return conn;

}

/*

*获取DBConnectPool 的唯一实例,如果实例为空,则创建一个实例

*/

static synchronized public DBConnectPool getInstance() {

if (instance == null) {

instance = new DBConnectPool("ConnPool","jdbc:as400://9.185.43.193/","chenjh","chenjh",3);

}

return instance;

}

/*

* 创建新的连接

*/

private Connection newConnection() {

//先建一个空连接

Connection conn = null;

try {

//获取一个新的数据库连接

if (user == null) {

conn = DriverManager.getConnection(URL);

}

else {

conn = DriverManager.getConnection(URL, user, password);

}

//取消自动提交

if (conn != null) {

conn.setAutoCommit(false);

}

}

catch (SQLException e) {

return null;

}

return conn;

}

/*

* 关闭所有连接

*/

public synchronized void release() {

//提取所有的连接元素到列举数组

Enumeration allConnections = freeConnections.elements();

while (allConnections.hasMoreElements()) {

//遍历每一个连接

Connection conn = (Connection) allConnections.nextElement();

try {

conn.close();

}

catch (SQLException e) {

}

}

//清空所有的连接

freeConnections.removeAllElements();

}

}

B. DBConnectPool 实现说明

DBConnectPool 是一个数据库连接池的具体实现,其中包括了7 具体的方法用来构件和撤销数据库连接池

ü DBConnectPool () 构建数据连接池

ü getInstance() 获取数据库连接池的唯一实例

ü freeConnection() 释放空闲的连接到连接池

ü getConnection() 从连接池中提取空闲的连接

ü getConnection(timeout) 等待指定的时间,从连接池中提取空闲的连接

ü newConnection() 构造连接池的时候新建连接

ü release() 释放数据库连接池

对所有使用连接池的JAVA 程序来说数据库连接池是一个共享的资源,因此所有的JAVA 程序应该使用唯一连接池实例。在DBConnectPool 程序中提供了一个方法getInstance(),供调用连接池的JAVA 程序获取连接池的唯一实例。调用getInstance()时如果连接池实例不存在,则调用DBConnectPool 方法创建一个新的连接池实例,并作为唯一的连接池实例保存。DBConnectPool 方法负责创建新的数据库连接池实例。DBConnectPool 方法被定义为私有的方法,只能够被getInstance 方法调用,这样就保证了连接池的实例是唯一的。在调用DBConnectPool 方法的时候,需要指定数据库连接串URL、用户名、密码、最大的数据库连接数等参数。在DBConnectPool 方法中注册JDBC 驱动程序,同时根据输入的相关参数创建指定数目的数据连接。所有的可用连接对象均登记在名为freeConnections 的向量(Vector)中。

 

如果向量中有多于一个的连接,getConnection()总是选取第一个。同时,由于新的可用连接总是从尾部加入向量,从而使得数据库连接由于长时间闲置而被关闭的风险减低到最小程度。客户程序可以使用DBConnectionPool 类提供的两个getConnection 方法获取可用连接。两者的共同之处在于:如连接池中存在可用连接,则直接返回,否则创建新的连接并返回。如果没有可用连接且已有连接总数等于最大限制数,第一个方法将直接返回null,而第二个方法将等待直到有可用连接为止。第一个getConnection 方法在返回可用连接给客户程序之前,调用了isClosed()方法验证连接仍旧有效。如果该连接被关闭或触发异常,getConnection()递归地调用自己以尝试获取另外的可用连接。如果在向量freeConnections 中不存在任何可用连接,getConnection()方法检查是否已经指定最大连接数限制。如已经指定,则检查当前连接数是否已经到达极限。此处maxConn 为0 表示没有限制。如果没有指定最大连接数限制或当前连接数小于该值,该方法尝试创建新的连接。如创建成功,则增加已使用连接的计数并返回,否则返回空值。

 

创建新连接由newConnection()方法实现。创建过程与是否已经指定数据库帐号、密码有关。JDBC 的DriverManager 类提供多个getConnection()方法,这些方法要用到JDBLUPARL 与其它一些参数,如用户帐号和密码等。DriverManager 将使用指定的JDBLUPARL 确定适合于目标数据库的驱动程序及建立连接。第二个getConnection()方法需要一个以毫秒为单位的时间参数,该参数表示客户程序能够等待的最长时间。建立连接的具体操作仍旧由第一个getConnection()方法实现。该方法执行时先将startTime 初始化为当前时间。在while 循环中尝试获得一个连接。如果失败,则以给定的时间值为参数调用wait()。wait()的返回可能是由于其它线程调用notify()或notifyAll(),也可能是由于预定时间已到。为找出wait()返回的真正原因,程序用当前时间减开始时间(startTime),如差值大于预定时间则返回空值,否则再次调用getConnection()。把空闲的连接登记到连接池由freeConnection()方法实现,它的参数为返回给连接池的连接对象。该对象被加入到freeConnections 向量的末尾,然后减少已使用连接计数。调用notifyAll()是为了通知其它正在等待可用连接的线程。release()方法供JAVA 程序调用。该方法遍历freeConnections 向量并关闭所有连接,然后从向量中删除这些连接。

5103. JDBC 程序设计优化

A. SQL 语句预处理

JDBC 中用ExecuteQuery 方法执行一条SQL 语句是通过PreparedStatementàExecute 两个步骤来完成的。如果每次都是用都使用ExecuteQuery 的方法的话,很多的时间都用来做预处理的工作。如果每次执行的SQL 语句操作都是一样的,只是操作的值不一样,则可以人工的执行PreparedStatement 操作,然后再执行Execute语句。减少重复进行的PreparedStatement。“一次Prepared,多次执行”。

BigDecimal bd = new BigDecimal("123456");

PreparedStatement ps = c.prepareStatement("insert into cujosql.xxx values(?, ?, ?, ?)");

ps.setInt(1, 99); //设置SQL 语句的参数

ps.setBigDecimal(2, bd);

ps.setBigDecimal(3, bd);

ps.setBigDecimal(4, bd);

ps.executeQuery(); //执行预处理语句

ps.setInt(1,200); //设置SQL 语句的参数

ps.setBigDecimal(2, bd);

ps.setBigDecimal(3, bd);

ps.setBigDecimal(4, bd);

ps.executeQuery(); //执行预处理语句

B. 合理的使用SELECT 语句

在使用SELECT 语句的时候尽量减少使用不确定的模糊查询,尽量精确的表达查询的条件和结果对象。加设一个表有COL1… COLN Column,查询需要选取COL1,COL2 作为查询结果。如果使用“SELECT * FROM TABLENAME”进行查询,则数据库会返回所有的Column 作为结果集。而实际被使用的只有COL1 和COL2两个Column 的结果。

 

建议将查询语句改为精确的查询语句“ SELECT COL1,COL2 FROM  TABLENAME”。将模糊的查询结果描述“*”,改变为精确的结果描述“COL1,COL2”COL1, COL2 是程序中实际需要得到的结果,其它COL3… .COLN 再生成查询结果集的时候就没有被包括在其中,系统资源得到了有效的利用,减少了浪费。同时应该尽量避免使用复杂的复合查询语句(如子查询嵌套),这些语句在运行的时候会产生大量的临时中间表,对系统资源的消耗是非常大的。建议将这些复合查询语句拆分为多个简单查询语句。

关于更详细的SQL 性能调整,请参见DB2 SQL Performance Tuning Guide。

C. 块插入功能支持

UDB/400 的JDBC 驱动程序支持块插入功能,支持一次插入多条数据纪录,块插入可以明显的减少插入大量数据消耗的时间和系统资源。并且在随V5R1 提供的JDBC 驱动程序中提供了新的块插入支持语句:”use block insert=true。快插入的限制条件:

l 必须是Insert 语句

l 必须使用 PreparedStatement 对Insert 语句进行预处理

l 必须在Insert 语句中描述表的每一个Columns

l 必须对本地系统进行操作

块插入的使用方法参见下面的例子:

// 获取一个数据库连接,并使用新的块插入语句

Connection c = DriverManager.getConnection("jdbc:db2:*local;use block insert=true");

BigDecimal bd = new BigDecimal("123456");

// 生成一个SQL 预处理语句

PreparedStatement ps = c.prepareStatement("insert into cujosql.xxx values(?, ?, ?, ?)");

for (int i = 1; i <= 10000; i++) {

ps.setInt(1, i); //设置SQL 语句的参数

ps.setBigDecimal(2, bd);

ps.setBigDecimal(3, bd);

ps.setBigDecimal(4, bd);

ps.addBatch(); //将参数加入到Batch 操作中

}

// 执行块插入

int[] counts = ps.executeBatch();

__