- 論壇徽章:
- 0
|
########## 請保留下面信息 ####################
作者 avid Mount
出處:http://www.texas400.com/BSquerypgm.html
翻譯:Eric Kong
E-Mail:eric_cc@qq.ccom
關(guān)鍵字: 葡萄牙語 Mainframe AS400 Java 廣州 求職 招聘 獵頭 www.puyufanyi.com
備注:本人Java高級工程師,初學(xué)AS400,有好的職位(廣州),可以跟我聯(lián)系,文章如果翻譯不正確,敬請?zhí)岢?br />
################################################
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.
在這個數(shù)據(jù)爆炸的時代,我們基本沒有可能去學(xué)習(xí)每一系統(tǒng)的所有的細(xì)節(jié),而有時,程序員經(jīng)常被要求在浩瀚和不容易理解的應(yīng)用系統(tǒng)中搜索數(shù)據(jù)和建立報表.即使,這些系統(tǒng)做了文檔化,但是閱讀這些文檔會花費(fèi)不少的時間,使你可能不能在項(xiàng)目期限完成任務(wù).
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程序員的第三天,你的老板告訴你,銷售部門現(xiàn)在有個很緊急的需求,需要一份關(guān)于曾經(jīng)在你公司購買過"Widget123"顧客的列表.下面我就教你如何實(shí)現(xiàn)這個需求:
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" 看看你系統(tǒng)上的用戶庫,如圖1,希望上天保佑,你能看到你感興趣的用戶庫,幸運(yùn)地,看來圖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,你可以看到這個庫的文件列表,看來文件并不多見,在我們這個例子中,帳單詳細(xì)文件ORD,它看來正是我們想要的.
Step 3 - Query the Data
第三步,查詢數(shù)據(jù)
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.
現(xiàn)在,使用Query/400去查看數(shù)據(jù),有幾種方法去開始查詢數(shù)據(jù),在這里我使用命令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要求你先選一個文件,所以你現(xiàn)在"Specify file selections"的前面輸入1,按回車,然后輸入你文件名"ORD"和庫"SLSFILES".每一次當(dāng)你完成一個選擇之后,你都會返回"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來開始查詢,現(xiàn)在就按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"記錄,現(xiàn)在你再運(yùn)行一次查詢,你現(xiàn)在就可以得到那些買了"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擁有簡單而直觀的界面,一路下來,不外乎選擇哪些字段,選擇哪些記錄,怎樣去排序,如何計(jì)算總值,改變列標(biāo)題和數(shù)字格式之類設(shè)置.輸出的結(jié)果可以是一個查詢的顯示,一個報表,或者是一個數(shù)據(jù)庫文件,你可以連接文件,這樣一來,你就可以連接CUS客戶文件和ORD訂單詳細(xì),你就可以把客戶名字和銷售人員等資料也加入到查詢里面來
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.
現(xiàn)在你已經(jīng)學(xué)習(xí)了快速研究問題的方法,掌握了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
|
|