$PBExportHeader$f_get_defsptprice.srf global type f_get_defsptprice from function_object end type forward prototypes global function integer f_get_defsptprice (long arg_sptid, long arg_mtrlid, string arg_unit, string arg_status, string arg_pcode, string arg_woodcode, ref decimal arg_def_dftsptprice) end prototypes global function integer f_get_defsptprice (long arg_sptid, long arg_mtrlid, string arg_unit, string arg_status, string arg_pcode, string arg_woodcode, ref decimal arg_def_dftsptprice);Long rslt = 1 Decimal rtn_price SELECT top 1 fprice INTO :rtn_price FROM u_spt_price_mx WHERE u_spt_price_mx.mtrlid = :arg_mtrlid AND u_spt_price_mx.sptid = :arg_sptid AND u_spt_price_mx.unit = :arg_unit AND u_spt_price_mx.status = :arg_status AND u_spt_price_mx.woodcode = :arg_woodcode AND u_spt_price_mx.pcode = :arg_pcode AND u_spt_price_mx.billtype = 2 Order By Opdate Desc; IF sqlca.SQLCode <> 0 THEN rslt = 0 rtn_price = 0.00 GOTO ext END IF ext: arg_def_dftsptprice = rtn_price RETURN rslt end function