f_cmpl_status_qty.srf 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. $PBExportHeader$f_cmpl_status_qty.srf
  2. global type f_cmpl_status_qty from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_cmpl_status_qty (decimal arg_addqty, string arg_status, ref decimal arg_qty, ref string arg_msg)
  6. end prototypes
  7. global function integer f_cmpl_status_qty (decimal arg_addqty, 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 * arg_addqty
  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. IF Round(arg_qty,0) = arg_qty THEN
  65. ls_qty = String(arg_qty,'#######')
  66. ELSE
  67. ls_qty = String(arg_qty,'#######0.#######')
  68. END IF
  69. IF ls_qty = ls_status THEN
  70. arg_qty = arg_qty * arg_qty
  71. END IF
  72. ELSE
  73. arg_msg = '非法格式,不能计算!'+arg_status
  74. rslt = 0
  75. GOTO ext
  76. END IF
  77. arg_qty = arg_qty * arg_addqty
  78. ext:
  79. RETURN rslt
  80. end function