- 論壇徽章:
- 0
|
2.再解Question
1) Find the total amount of all item
2) Find the amount of item A
3) Find the total amount of item which greater than 100
4) Find the total amount of item type FR
Data
Item# Item type Amount
A FR 100
B FR 200
C FG 700
D PA 50
解答方法:
1)
Read Itemtypefile 90
*in90 DOWEQ*OFF
AddRamount AmountTotal
Read Itemtypefile 90
Enddo
2)keyItemA ChainiItemtypefile
*in90 IFEQ*OFF
Z-ADDamount @TotalAmt
ENDIF
3)Read itemtypefile 91
*in91 DOWEQ*OFF
IF Amount GE'100'
ADDAmount @TotalAmt
ENDIF
Read itemtypefile 91
ENDDO
這里應(yīng)用ADD累加,需把所有大于100的amount累加@totalAmt.程序會(huì)讀多次大于100的amount。而Q2只會(huì)有一個(gè)ItemA通過KeyItemA chainXXX篩選檢索出來的ItemA的amount,只有一筆數(shù),是不需要累加,故用Z-ADD.
4)
keyFR ReadeItemtypefile 92 /*KeyFR是搜尋查找ItemType這個(gè)欄位中的FR 然后按之排序/
*in92 DOWEQ*OFF
ADDamount @TotalAmt /*把上面查找出的ItemTYPe欄位中的FR的amount進(jìn)行累加*/
KeyFR Reade itemtypefile 92
ENDDO
這里應(yīng)是ADD,因是用KEY reade讀出的keyType中的FR的金額,是需讀多次的,是需把讀多次讀出的FR的金額進(jìn)行累加 才會(huì)有FR 的@TotalAmt。和Q2中用chain篩選檢索出的keyItemA的金額不一樣(ItemA的金額chain檢索出后的ItemA的amount只有一筆,而這里檢索出來的FR的amount有兩筆) |
|