免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1934 | 回复: 0
打印 上一主题 下一主题

编写一个查询程序去显示一个文件,使用不同和文件和匹配的记录 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-09-21 17:23 |只看该作者 |倒序浏览
########## 请保留下面信息   ####################
作者avid Mount
出处:http://www.texas400.com/BSquerypgm.html
翻译:Eric Kong
E-Mail:eric_cc@qq.ccom
关键字: 葡萄牙语 Mainframe AS400 Java 广州 求职 招聘 猎头 www.puyufanyi.com
备注:本人Java高级工程师,初学AS400,有好的职位(广州),可以跟我联系,文章如果翻译不正确,敬请提出
################################################

Write a Query program to display a file, using multiple files with matched records
编写一个查询程序去显示一个文件,使用不同和文件和匹配的记录

In the expanding world of data processing, it is usually impossible to learn all details of every system. Often, programmers are asked to research information or produce reports from application systems that are too vast to comprehend easily. Even if the system is documented, reading the documentation may take longer that the timeframe allows.
在这个数据爆炸的时代,我们基本没有可能去学习每一系统的所有的细节,而有时,程序员经常被要求在浩瀚和不容易理解的应用系统中搜索数据和建立报表.即使,这些系统做了文档化,但是阅读这些文档会花费不少的时间,使你可能不能在项目期限完成任务.


Imagine, that on your third day as an AS/400 programmer, your boss tells you that the sales department has an emergency need for a list of all customers who have ever ordered a Widget123 from your company. Here are the three steps to take.

想象,在你作为AS/400程序员的第三天,你的老板告诉你,销售部门现在有个很紧急的需求,需要一份关于曾经在你公司购买过"Widget123"顾客的列表.下面我就教你如何实现这个需求:

Step 1 - Show Your Libraries
第一步,查看你的库表

Use the command "WRKLIB *ALLUSR" to see a list of the user libraries on your system; see Figure 1. Hopefully, you will see a library that looks interesting. In this case, the library "SLSFILES" looks promising.
使用命令 WRKLIB *ALLUSR" 看看你系统上的用户库,如图1,希望上天保佑,你能看到你感兴趣的用户库,幸运地,看来图1中的"SLSFILES"看起来正是你想要的

Step 2 - Show the Files

第二步,查看文件

Now, to see the files in the "SLSFILES" library, use the command: WRKOBJ SLSFILES/*ALL *FILE

使用命令WRKOBJ SLSFILES/*ALL *FILE查看库SLSFILES里面的文件

You now see a list of all files in this library; see Figure 2. There may be quite a few, so page down through the list. In our example, the order detail file, ORD looks like it could be what we want.
正如图2,你可以看到这个库的文件列表,看来文件并不多见,在我们这个例子中,帐单详细文件ORD,它看来正是我们想要的.

Step 3 - Query the Data
第三步,查询数据

Now, use Query/400 to view the data. There are several ways to start query. I use the command WRKQRY. Use option 1 to create a query.
现在,使用Query/400去查看数据,有几种方法去开始查询数据,在这里我使用命令WRKQRY,选1开始查询.

Query insists that you first choose a file to use, so it puts a "1" next to the "Specify file selections". Hit enter and fill in the file name "ORD" and the library "SLSFILES". Every time you finish a selection, you will return to the "Define the Query" screen; see Figure 3.
Query/400要求你先选一个文件,所以你现在"Specify file selections"的前面输入1,按回车,然后输入你文件名"ORD"和库"SLSFILES".每一次当你完成一个选择之后,你都会返回"Define the Query"的屏幕,如图三,

If you key "1" next to "Select and sequence fields", you see a list of the fields in the file. If the field descriptions are not visible, use "F11" to change the view so that you see the field names and their descriptions; see Figure 4.
假如你在"Select and sequence fields"前面输入1,你可以看到这个文件的所有字段,假如字段描述不可见,按F11改变视图,那么你就可以看到字段的名字和描述了,如图4

Query says that "F5=Report" but it really means "run the query now". This is a good time to hit "F5" to get a formatted view of the file. You may need to use "F19" and "F20" to shift the view left and right.

看"Define the Query"中的"F5=Report",它的意思是,你可以按F5来开始查询,现在就按F5开始查询吧,你可能需要按F19或者F20切换左右,字段太多了.

From the "Define the Query" screen, key "1" next to the "Select records". Now key in the selection criteria to select only records in which "ODPRDS EQ WIDGET123". Run the query again and you now have a list of orders that include WIDGET123.
回过头来再看看"Define the Query"屏幕,在"Select records"旁边输入1,输入查询条件,选择那些符合"ODPRDS EQ WIDGET123"记录,现在你再运行一次查询,你现在就可以得到那些买了"WIDGET123"的顾客的列表.

Query/400 has a simple and intuitive interface. Work through the selections to choose which fields to display, which records to select, how to sort the records, accumulate totals, change column headings and format numbers. The output can be a display query, a report or a database file. You can join files so that, in our case, you could join the "CUS" file to the "ORD" file to include the customer name and customer salesman in the query.
Query/400拥有简单而直观的界面,一路下来,不外乎选择哪些字段,选择哪些记录,怎样去排序,如何计算总值,改变列标题和数字格式之类设置.输出的结果可以是一个查询的显示,一个报表,或者是一个数据库文件,你可以连接文件,这样一来,你就可以连接CUS客户文件和ORD订单详细,你就可以把客户名字和销售人员等资料也加入到查询里面来

You are now armed with a powerful approach for quickly researching problems. You will be amazed at how powerful Query/400 is and at how easy it is to use.
现在你已经学习了快速研究问题的方法,掌握了Query/400的用法,知道它使用起来是如何的简单.



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


Figure 1 - Show Your Libraries

Results of "WRKLIB *ALLUSR"
                                                                    
Opt  Library    Attribute   Text                                 
      
  _    GLPGMS    PROD        G/L Programs                                                               
  _    GLTEST    PROD        G/L Test                                       
  _    GL123199  PROD        G/L files from end of year 1999                                       
  _    MANFILES  PROD        Manufacturing Files                                             
  _    MANPGMS   PROD        Manufacturing Programs                  
  _    SLSFILES  PROD        Sales Files                                               
  _    SLSPGMS   PROD        Sales Programs                                             
  _    TEST      PROD                                             
  _    WDOE      PROD        William Doe Test Library                                                      
                                                                     


Figure 2 - Show the Files

Results of "WRKOBJ SLSFILES/*ALL *FILE"
                                                                           
Opt  Object    Type    Library   Attribute   Text                       
  _   ADM       *FILE   SLSFILES    PF        Admin Masterfile
  _   ADM01     *FILE   SLSFILES    LF        Admin by Name            
  _   CTY       *FILE   SLSFILES    PF        City Masterfile   
  _   CUS       *FILE   SLSFILES    PF        Customer Master  
  _   CUS01     *FILE   SLSFILES    LF        Customer by name               
  _   CUS02     *FILE   SLSFILES    LF        Customer by city           
  _   INV       *FILE   SLSFILES    PF        Invoice Master            
  _   ORH       *FILE   SLSFILES    PF        Order Header
  _   ORH01     *FILE   SLSFILES    LF        Order Header by name      
  _   ORD       *FILE   SLSFILES    PF        Order Detail               
  _   ORD01     *FILE   SLSFILES    PF        Order Detail by part#      
                                                                        More...


Figure 3 - Query Screen                 

                                Define the Query                              
                                                                              
Query . . . . . . :     ORDLOOK         Option  . . . . . :   CREATE         
   Library . . . . :     SLSFILES        CCSID . . . . . . :   65535           
                                                                              
Type options, press Enter.  Press F21 to select all.                          
   1=Select                                                                    
                                                                              
Opt    Query Definition Option                                                
      > Specify file selections                                                
        Define result fields                                                   
        Select and sequence fields                                             
        Select records                                                         
        Select sort fields                                                     
        Select collating sequence                                             
        Specify report column formatting                                       
        Select report summary functions                                       
        Define report breaks                                                   
        Select output type and output form                                    
        Specify processing options                                             
                                                                              
F3=Exit            F5=Report                                                  
F13=Layout         F18=Files          F21=Select all                          
Select options, or press F3 to save or run the query.                                                                                                        


Figure 4 - Select and Sequence Fields

                          Select and Sequence Fields                           
                                                                              
Type sequence number (0-9999) for the names of up to 500 fields to            
appear in the report, press Enter.                                          
                                                                              
Seq Field        Text                     Len  Dec
     ODSTAT      Status                     1     
     ODCUS#      Customer #                10    0
     ODORDT      Order Date                 8    0
     ODPAR#      Part#                      7    0
     ODPRDS      Part Description          30   
     OD#ORD      # Items Ordered            5    0  
     ODWHLC      Warehouse Location         3   
     ODBKOR      Back Order Flag            1   
     ODSHDT      Ship Date                  8    0     



您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP