f_group_email.srf 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. $PBExportHeader$f_group_email.srf
  2. global type f_group_email from function_object
  3. end type
  4. forward prototypes
  5. global function string f_cusorspt_name (long arg_relid, long arg_repid)
  6. global function string f_group_email (integer arg_reltype, long arg_relid, long arg_repid)
  7. end prototypes
  8. global function string f_cusorspt_name (long arg_relid, long arg_repid);string ls_name
  9. return ls_name
  10. end function
  11. global function string f_group_email (integer arg_reltype, long arg_relid, long arg_repid);String ls_name,ls_name1,ls_name2
  12. IF arg_reltype = 0 THEN
  13. IF arg_repid = 0 THEN
  14. SELECT Top 1 u_cust.email Into :ls_name1 From u_cust Where u_cust.cusid = :arg_relid;
  15. ls_name = ls_name1
  16. ELSE
  17. SELECT Top 1 u_cust_rep.email Into :ls_name2 From u_cust_rep Where u_cust_rep.cusid = :arg_relid and u_cust_rep.repid = :arg_repid;
  18. ls_name =ls_name2
  19. END IF
  20. ELSEIF arg_reltype = 1 THEN
  21. IF arg_repid = 0 THEN
  22. SELECT Top 1 u_spt.email Into :ls_name1 From u_spt Where u_spt.sptid = :arg_relid;
  23. ls_name = ls_name1
  24. ELSE
  25. SELECT Top 1 u_spt_rep.email Into :ls_name2 From u_spt_rep Where u_spt_rep.sptid = :arg_relid and u_spt_rep.repid = :arg_repid;
  26. ls_name =ls_name2
  27. END IF
  28. END IF
  29. RETURN ls_name
  30. end function