CLOSE DATABASES all CLOSE TABLES all OPEN DATABASE sj IF FILE('sjtj.dbf') REMOVE TABLE sjtj endif SELECT DISTINCT 物品名称 zdmc FROM huowu INTO cursor wpqdmp READWRITE SELECT DISTINCT 单位 FROM huowu INTO dbf sjtj database sj SELECT wpqdmp ALTER table sjtj ADD 汇总 n(18,2) SCAN _zdmc=ALLTRIM(zdmc) ALTER table sjtj ADD (_zdmc) n(18,2) ENDSCAN SELECT 单位 dw,物品名称 wpmc,金额 je FROM huowu INTO CURSOR tjmp GROUP BY dw,wpmc,je SCAN _dw =ALLTRIM(dw) _zdmc=ALLTRIM(wpmc) _je=je REPLACE (_zdmc) WITH _je,汇总 WITH 汇总+_je FOR ALLTRIM(sjtj.单位)==_dw IN sjtj ENDSCAN
CLOSE DATABASES SELECT DISTINCT 物品名称 FROM huowu INTO ARRAY amc lcStr = "单位 C(10)" FOR ln = 1 TO ALEN(amc, 1) lcStr = lcStr +", " + ALLTRIM(amc[ln, 1]) + " N(4)" ENDFOR lcStr = lcStr + ", 合计 N(6)" CREATE CURSOR hz (&lcStr) INSERT INTO hz (单位) SELECT DISTINCT 单位 FROM huowu INSERT INTO hz (单位) VALUES ("总计") INDEX ON 单位 TAG dw SELECT huowu SET RELATION TO 单位 INTO hz SCAN IF FOUND("hz") REPLACE (huowu.物品名称) WITH EVALUATE(huowu.物品名称) + huowu.金额, 合计 WITH 合计 + huowu.金额 IN hz REPLACE RECORD RECCOUNT() (huowu.物品名称) WITH EVALUATE(huowu.物品名称) + huowu.金额, 合计 WITH 合计 + huowu.金额 IN hz ENDIF ENDSCAN SET RELATION TO SELECT hz SET ORDER TO BROWSE
[此贴子已经被作者于2022-10-17 19:18编辑过]