f_billmsg.srf 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. $PBExportHeader$f_billmsg.srf
  2. global type f_billmsg from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_billmsg (long arg_scid, string arg_billcode, string arg_msgtitle, string arg_s_msg, transaction arg_transaction, ref string arg_msg, boolean arg_ifcommit)
  6. end prototypes
  7. global function integer f_billmsg (long arg_scid, string arg_billcode, string arg_msgtitle, string arg_s_msg, transaction arg_transaction, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  8. String empname
  9. Long i = 1,it_mxbt
  10. String ls_billcode,ls_r_billcode,ls_sccode
  11. String arg_objdpm
  12. uo_transmsg uo_msg
  13. arg_billcode = Upper(arg_billcode)
  14. SELECT sccode
  15. INTO :ls_sccode
  16. FROM u_scdef
  17. Where scid = :arg_scid USING arg_transaction;
  18. ls_billcode = Mid(Trim(arg_billcode),Len(ls_sccode) + 1,2)
  19. SELECT billstyle
  20. INTO :ls_r_billcode
  21. FROM u_billcode
  22. Where firststr = :ls_billcode;
  23. IF sqlca.SQLCode = 1 THEN ls_billcode = ls_r_billcode
  24. DECLARE cur_empmx CURSOR FOR
  25. SELECT u_rs_empinfo.empname
  26. FROM u_billemp INNER JOIN
  27. u_rs_empinfo ON u_billemp.empid = u_rs_empinfo.empid
  28. WHERE billcode = :ls_billcode
  29. USING arg_transaction;
  30. OPEN cur_empmx;
  31. FETCH cur_empmx INTO :empname;
  32. DO WHILE arg_transaction.SQLCode = 0
  33. i++
  34. arg_objdpm = empname+';'+arg_objdpm
  35. FETCH cur_empmx INTO :empname;
  36. LOOP
  37. CLOSE cur_empmx;
  38. it_mxbt = i - 1
  39. IF it_mxbt > 0 THEN
  40. IF uo_msg.f_create_admsg(sys_empid,publ_operator,arg_objdpm,arg_msgtitle,arg_s_msg,arg_msg,arg_scid,arg_billcode,FALSE) = 0 THEN
  41. arg_msg = '消息发送失败{'+arg_msg+'}'
  42. rslt = 0
  43. GOTO ext
  44. END IF
  45. END IF
  46. ext:
  47. IF rslt = 0 THEN
  48. ROLLBACK USING arg_transaction;
  49. ELSEIF rslt = 1 AND arg_ifcommit THEN
  50. COMMIT USING arg_transaction;
  51. END IF
  52. RETURN rslt
  53. end function