$PBExportHeader$f_group_email.srf global type f_group_email from function_object end type forward prototypes global function string f_cusorspt_name (long arg_relid, long arg_repid) global function string f_group_email (integer arg_reltype, long arg_relid, long arg_repid) end prototypes global function string f_cusorspt_name (long arg_relid, long arg_repid);string ls_name return ls_name end function global function string f_group_email (integer arg_reltype, long arg_relid, long arg_repid);String ls_name,ls_name1,ls_name2 IF arg_reltype = 0 THEN IF arg_repid = 0 THEN SELECT Top 1 u_cust.email Into :ls_name1 From u_cust Where u_cust.cusid = :arg_relid; ls_name = ls_name1 ELSE 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; ls_name =ls_name2 END IF ELSEIF arg_reltype = 1 THEN IF arg_repid = 0 THEN SELECT Top 1 u_spt.email Into :ls_name1 From u_spt Where u_spt.sptid = :arg_relid; ls_name = ls_name1 ELSE 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; ls_name =ls_name2 END IF END IF RETURN ls_name end function