1234567891011121314151617181920212223242526272829303132333435363738394041 |
- $PBExportHeader$f_rst_dept_bbala.srf
- global type f_rst_dept_bbala from function_object
- end type
- forward prototypes
- global function decimal f_rst_dept_bbala (long arg_accsetid, long arg_cmonth, string arg_subid, long arg_deptid)
- end prototypes
- global function decimal f_rst_dept_bbala (long arg_accsetid, long arg_cmonth, string arg_subid, long arg_deptid);//返回部门总帐期初数
- decimal rst_dept_bbala
- decimal init_dept_bala,cur_dept_bala
- SELECT isnull(sum(uv_dept_bala.credit),0) - isnull(sum(uv_dept_bala.debit),0)
- into :cur_dept_bala
- FROM uv_dept_bala
- WHERE ( uv_dept_bala.accsetid = :arg_accsetid ) AND
- ( uv_dept_bala.cmonth < :arg_cmonth ) AND
- ( uv_dept_bala.subid = :arg_subid ) and
- ( uv_dept_bala.deptid = :arg_deptid )
- GROUP BY uv_dept_bala.cmonth,
- uv_dept_bala.subid,
- uv_dept_bala.deptid ;
-
- SELECT isnull(uv_dept_init.balance,0)
- into :init_dept_bala
- FROM uv_dept_init
- WHERE ( uv_dept_init.accsetid = :arg_accsetid ) AND
- ( uv_dept_init.subid = :arg_subid ) and
- ( uv_dept_init.deptid = :arg_deptid ) ;
-
-
- if isnull(cur_dept_bala) then cur_dept_bala=0
- if isnull(init_dept_bala) then init_dept_bala=0
- rst_dept_bbala=cur_dept_bala + init_dept_bala
- return rst_dept_bbala
- end function
|