f_cmpl_qty_son.srf 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. $PBExportHeader$f_cmpl_qty_son.srf
  2. global type f_cmpl_qty_son from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_cmpl_qty_son (string arg_status, ref decimal arg_qty, ref string arg_msg)
  6. end prototypes
  7. global function integer f_cmpl_qty_son (string arg_status, ref decimal arg_qty, ref string arg_msg);Int rslt = 1
  8. String ls_temp[]
  9. String ls_option
  10. String ls_getvalue
  11. Long ll_cnt,i,beg
  12. String ls_rs
  13. datastore ds_cmp
  14. String ls_qty
  15. String ls_status
  16. ll_cnt = 0
  17. ls_status = arg_status
  18. ls_option = sys_option_cmpl_status_qty
  19. IF ls_status = '' THEN GOTO ext
  20. IF ls_option = '' THEN GOTO cmp
  21. DO WHILE Len(ls_option) <> 1
  22. ls_option = Replace( ls_option, 1, 1, '' )
  23. ls_getvalue = Left(ls_option,Pos(ls_option,',',1) - 1)
  24. ll_cnt++
  25. ls_temp[ll_cnt] = ls_getvalue
  26. ls_option = Replace ( ls_option, 1, Pos(ls_option,',',1) - 1, '' )
  27. LOOP
  28. IF ll_cnt = 0 THEN
  29. GOTO ext
  30. END IF
  31. FOR i = 1 TO ll_cnt
  32. beg = 1
  33. beg = Pos(ls_status,ls_temp[i],beg )
  34. DO WHILE beg > 0
  35. ls_status = Replace(ls_status,beg,len(ls_temp[i]),'')
  36. beg = Pos(ls_status,ls_temp[i],beg + 1)
  37. LOOP
  38. NEXT
  39. long ll_beg
  40. long ll_end
  41. ll_beg = 1
  42. if pos(ls_status,'{',ll_beg) = 0 then GOTO cmp
  43. if pos(ls_status,'}',ll_beg) = 0 then GOTO cmp
  44. do while pos(ls_status,'}',ll_beg) > 0
  45. ll_beg = pos(ls_status,'{',ll_beg)
  46. ll_end = pos(ls_status,'}',ll_beg)
  47. ls_status = Replace(ls_status,ll_beg,ll_end - ll_beg + 1,'')
  48. loop
  49. cmp:
  50. Dec ld_temp
  51. ld_temp = Dec(ls_status)
  52. IF ld_temp <> 0 THEN
  53. arg_qty = ld_temp
  54. GOTO ext
  55. END IF
  56. ds_cmp = CREATE datastore
  57. ds_cmp.DataObject = "ds_cmp_qty"
  58. ds_cmp.SetTransObject(sqlca)
  59. ds_cmp.InsertRow(0)
  60. ls_rs = ds_cmp.Modify("cmp.Expression='"+ ls_status+"'")
  61. IF ls_rs = '' THEN
  62. ds_cmp.AcceptText()
  63. arg_qty = ds_cmp.Object.cmp[ds_cmp.GetRow()]
  64. ELSE
  65. arg_msg = '非法格式,不能计算!'+arg_status
  66. rslt = 0
  67. GOTO ext
  68. END IF
  69. ext:
  70. RETURN rslt
  71. end function