笨方法:
SELECT ddje,0 s1 FROM ls ORDER BY ddje desc INTO CURSOR tmp11 readwrite
LOCAL _je0,_je1,_v11,_r11
_v11=0
_je0=19138.92
SELECT tmp11
FOR _r11= 1 TO RECCOUNT('tmp11')
_je1=0
SCAN FOR s1<9
IF _je1=0
_je1=_je0-ddje
ELSE
IF _je1-ddje<0
LOOP
ELSE
_je1=_je1-ddje
ENDIF
ENDIF
DO CASE
CASE _je1>0
REPLACE s1 WITH 1
CASE _je1=0
REPLACE s1 WITH 1
_v11=1
exit
OTHERWISE
EXIT
ENDCASE
ENDSCAN
IF _v11=1
SELECT ddje FROM tmp11 WHERE s1=1 INTO CURSOR tmp12
EXIT
ELSE
REPLACE s1 WITH 9 FOR RECNO()=_r11
ENDIF
endf
IF _v11=1
MESSAGEbox('凑数成功')
SELECT tmp12
brow
ELSE
MESSAGEbox('凑数失败')
ENDIF