My FAQ,最新最全的IT技术FAQ
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 未整理篇 | 技术讨论
  当前位置: > 操作系统 > IBM Server
ADTS/400工具系列(四)使用SDA+RPGIV进行子文件程序设计(1)
作者:未知 时间:2005-09-13 15:53 出处:ChinaUnix.net 责编:My FAQ
              摘要:ADTS/400工具系列(四)使用SDA+RPGIV进行子文件程序设计(1)

什么是子文件?我们在ADTS/400工具系列(三)章节所设计的是对文件单一记录进行操作的显示文件的界面,而子文件可以同时对文件一组记录进行操作的显示文件界面。
子文件在屏幕上由三个部分拼接组成(注意:是拼接,不是叠加)。
子文件控制部分——显示附加信息,并且设置控制关键字;
子文件主体——数据库文件记录显示部分,显示一组记录;
子文件底部——功能键显示部分,显示F1、F2、F3……功能键。

PDM本身就是一个子文件的示例。

[code:1:6490a45b59]                           Work with Members Using PDM                 XXXXXXXX   

 File  . . . . . .   QDDSSRC
   Library . . . .     QINGZHOU                 Position to  . . . . . 

 Type options, press Enter.                                                    
  2=Edit         3=Copy  4=Delete 5=Display       6=Print     7=Rename     
  8=Display description  9=Save  13=Change text  14=Compile  15=Create module...
 
 Opt  Member      Type        Text                                              
      MCITCP      PF          Unit Price PF
      MCLTNP      PF          Workshop PF
      MJINVP      PF          Stockpile PF





                                                                         Bottom 
 Parameters or command                                                         
 ===>
 F3=Exit          F4=Prompt             F5=Refresh            F6=Create        
 F9=Retrieve      F10=Command entry     F23=More options      F24=More keys    [/code:1:6490a45b59]
[b:6490a45b59]一、PF定义:[/b:6490a45b59]
数据字典REFILE定义:

[code:1:6490a45b59] 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.    [/code:1:6490a45b59]
INVOICE是参照数据字典的PF:
[code:1:6490a45b59]
 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                                           
                                                            [/code:1:6490a45b59]

 qingzhou 回复于:2005-07-30 13:16:29
[b:4eb9f3f016]二、SDA设计subfile:[/b:4eb9f3f016]

[b:4eb9f3f016]1、使用SDA设计子文件:[/b:4eb9f3f016]
1.1键入显示文件名:subfile1
[code:1:4eb9f3f016] 
                               Design Screens                                  
                                                                                
 Type choices, press Enter.                                                     
                                                                                
   Source file . . . . . . . .   QDDSSRC      Name, F4 for list                 
                                                                                
     Library . . . . . . . . .   QINGZHOU     Name, *LIBL, *CURLIB              
                                                                                
   Member  . . . . . . . . . .   subfile1     Name, F4 for list                 
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
 F3=Exit     F4=Prompt     F12=Cancel   [/code:1:4eb9f3f016]                                        
                                                                                

1.2、键入1增加一个记录,将子文件名定义为SFL01。
[code:1:4eb9f3f016]
                      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         [/code:1:4eb9f3f016]             
                                                                                
1.3、在记录类型选择SFL(子文件类型)。
[code:1:4eb9f3f016]
                               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                                          
                                                                                [/code:1:4eb9f3f016]
1.4、添入Subfile control record…….SFL01C,键入2次执行,回到Work with Display Records界面。

[code:1:4eb9f3f016]
                               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                                          
                                                                                [/code:1:4eb9f3f016]

 qingzhou 回复于:2005-07-30 13:21:24
[b:9fe70e9cd5]2、子文件主体设计:[/b:9fe70e9cd5]

2.1、在SFL01选项OPT键入12=Design image,准备进入子文件主体设计。
[code:1:9fe70e9cd5]
                      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.                                       + [/code:1:9fe70e9cd5]
2.2、按下执行,出现24×80的屏幕,我们将在第8行至第19行定义子文件的主体部分,在这一部分数据库文件的记录将随着向上以及向下翻页实现滚动浏览。 
                                                                           
[code:1:9fe70e9cd5]                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
 Work screen for SFL01. SFL01C displayed as additional record.                
 [/code:1:9fe70e9cd5]

2.3、通过F10选择数据库。
[code:1:9fe70e9cd5]
                             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     IV_FMT                                        
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
 F3=Exit     F4=Prompt     F12=Cancel                                           
                       [/code:1:9fe70e9cd5]                                                         

2.4、先使用3暂时定义所有字段使其成为输出类型。
[code:1:9fe70e9cd5]
                            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                                                           [/code:1:9fe70e9cd5]
                                                                                

2.5、键入2次执行,回到屏幕设计界面,可见第24行显示数据库字段定义。

 [code:1:9fe70e9cd5]                                                                               
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
 1:IV_CODE 2:IV_NAME 3:IV_QUTITY 4:IV_AMOUNT 5:IV_DESC                      [/code:1:9fe70e9cd5]    


2.6、使用&1、&2、&3、&4以第8行第6列为起点依次把1:IV_CODE 2:IV_NAME 3:IV_QUTITY 4:IV_AMOUNT放置在屏幕上,键入执行。
[code:1:9fe70e9cd5]
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
              &1         &2             &3             &4                            
                                                                                
                                                                                
                                                                                
                                                                                
                           &n