- 论坛徽章:
- 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
这里应用ADD累加,需把所有大于100的amount累加@totalAmt.程序会读多次大于100的amount。而Q2只会有一个ItemA通过KeyItemA chainXXX筛选检索出来的ItemA的amount,只有一笔数,是不需要累加,故用Z-ADD.
4)
keyFR ReadeItemtypefile 92 /*KeyFR是搜寻查找ItemType这个栏位中的FR 然后按之排序/
*in92 DOWEQ*OFF
ADDamount @TotalAmt /*把上面查找出的ItemTYPe栏位中的FR的amount进行累加*/
KeyFR Reade itemtypefile 92
ENDDO
这里应是ADD,因是用KEY reade读出的keyType中的FR的金额,是需读多次的,是需把读多次读出的FR的金额进行累加 才会有FR 的@TotalAmt。和Q2中用chain筛选检索出的keyItemA的金额不一样(ItemA的金额chain检索出后的ItemA的amount只有一笔,而这里检索出来的FR的amount有两笔) |
|