$PBExportHeader$f_findspt_paydate.srf global type f_findspt_paydate from function_object end type forward prototypes global function datetime f_findspt_paydate (long arg_sptid, datetime arg_indate) end prototypes global function datetime f_findspt_paydate (long arg_sptid, datetime arg_indate);Int rslt = 1 String ls_paydate_style Date ld_paydate String ls_now_nextmonth Long ll_days Int thismonth,nextmonth,nextyear SELECT u_plandate_style.dscrp INTO :ls_paydate_style FROM u_plandate_style INNER JOIN u_spt ON u_plandate_style.styleid = u_spt.styleid Where u_spt.sptid = :arg_sptid; IF sqlca.SQLCode <> 0 THEN rslt = 0 GOTO ext END IF ls_paydate_style = Trim(ls_paydate_style) ld_paydate = Date(String(arg_indate,'yyyy-mm-dd')) ls_now_nextmonth = Mid(ls_paydate_style,1,Pos(ls_paydate_style,'+') - 1) ll_days = Long(Mid(ls_paydate_style,Pos(ls_paydate_style,'+') + 1)) IF ls_now_nextmonth = 'now' THEN else thismonth = Month(ld_paydate) nextyear = Year(ld_paydate) IF thismonth = 12 THEN nextyear++ nextmonth = 1 ELSE nextmonth = thismonth + 1 END IF ld_paydate = Date(nextyear,nextmonth,1) END IF ld_paydate = RelativeDate ( ld_paydate, ll_days - 1) ext: IF rslt = 0 THEN SetNull(ld_paydate) END IF RETURN DateTime(ld_paydate) end function