$PBExportHeader$f_find_spt.srf global type f_find_spt from function_object end type forward prototypes global function integer f_find_spt (string arg_sptcode, ref s_spt arg_s_spt) end prototypes global function integer f_find_spt (string arg_sptcode, ref s_spt arg_s_spt);Int rslt = 1 Long cnt = 0 String ls_sptcode,ls_name,ls_find_code Long ll_sptid Boolean if_find = False IF Trim(arg_sptcode) = '' THEN rslt = 0 GOTO ext END IF SELECT u_spt.sptid INTO :ll_sptid FROM u_spt WHERE ( sptcode = :arg_sptcode OR Name = :arg_sptcode ) And inuse = 1; IF sqlca.SQLCode <> 0 THEN IF Pos(Trim(arg_sptcode),'%') = 0 THEN ls_find_code = '%'+ Trim(arg_sptcode) + '%' ELSE ls_find_code = Trim(arg_sptcode) END IF SELECT count(*) INTO :cnt FROM u_spt WHERE ( sptcode LIKE :ls_find_code OR Name LIKE :ls_find_code ) And inuse = 1; IF sqlca.SQLCode <> 0 THEN rslt = 0 GOTO ext END IF IF cnt <> 1 THEN rslt = 0 GOTO ext END IF SELECT u_spt.sptid INTO :ll_sptid FROM u_spt WHERE ( sptcode LIKE :ls_find_code OR Name LIKE :ls_find_code ) And inuse = 1; IF sqlca.SQLCode <> 0 THEN rslt = 0 GOTO ext END IF if_find = True ELSE if_find = True END IF IF if_find THEN SELECT u_spt.sptid, u_spt.name, u_spt.sptcode INTO :ll_sptid, :ls_name, :ls_sptcode FROM u_spt Where ( sptid = :ll_sptid ); arg_s_spt.sptid = ll_sptid arg_s_spt.sptcode = ls_sptcode arg_s_spt.Name = ls_name END IF ext: RETURN rslt end function