الكود التالي يقوم بإنشاء View داخل الـ SQL يعرض لك الأصول ومبالغ إهلاكاتها الشهرية .
يمكن إستدعاء على الـ View من خلال الريبورت رايتر أو من صفحات تُبرمج بالـ ASP/ ASP.net أو كريستال ريبورت.
الجداول المستخدمة:
FA40200 FA00100 FA00902 =================================
كود بلغة HTML:
[LEFT]CREATE VIEW view_FA_Depreciation
AS
/*******************************************************************
view_FA_Depreciation
Created on Apr 7, 2010 by Victoria Yudin - Flexible Solutions, Inc.
For updates visit http://victoriayudin.com/gp-reports/
Tables used:
FA00100 – fm - Asset General Information Master
FA00902 – d - Financial Detail Master
FA40200 - b - Book Setup
Updated on Apr 7, 2010 to add Book ID
*******************************************************************/
SELECT
fm.ASSETID Asset_ID,
fm.ASSETIDSUF Asset_Suffix,
fm.ASSETDESC Asset_Description,
b.BOOKID Book_ID,
d.FAPERIOD Depr_Month,
d.FAYEAR Depr_Year,
d.AMOUNT Depreciation,
d.GLINTTRXDATE GL_Trx_Date,
fm.Master_Asset_ID,
fm.ASSETCLASSID Asset_Class,
fm.STRUCTUREID Stucture_ID,
fm.LOCATNID Location_ID,
fm.ACQDATE Acquisition_Date,
fm.Acquisition_Cost,
fm.Physical_Location_ID,
fm.Asset_Label
FROM FA00902 d -- financial detail
LEFT OUTER JOIN
FA00100 fm -- fa master
ON fm.assetindex = d.assetindex
INNER JOIN
FA40200 b -- book setup
ON b.BOOKINDX = d.BOOKINDX
WHERE d.TRANSACCTTYPE = 2 -- depreciation only
/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
GO
GRANT SELECT ON view_FA_Depreciation to DYNGRP
[/LEFT]
الكود أعلاه من مدونة فيكتوريا