FI Asset Report通常都是用逻辑数据ADA来编写,但是有些程序员用自己去读AN*表,很难做到全面的考虑,修改此类程序真是件奔溃的事情,如果不想改变程序大体结构,那最好也要参考逻辑数据库的逻辑:
1. 注意Fical year
CALL FUNCTION ‘BKK_GL_FI_PERIOD_DETERMINE’
EXPORTING
i_bukrs = p_bukrs
i_budat = p_date
IMPORTING
e_monat = l_monat
e_gjahr = l_gjahr.
2. 注意一些相关的日期
SELECT * INTO CORRESPONDING FIELDS OF TABLE it_asset
FROM anla
WHERE bukrs IN p_bukrs
AND anln1 IN p_anln1
AND anln2 IN p_anln2
AND zugdt LE p_date
AND ( deakt > p_date OR deakt = ‘00000000′).
3. 取得ANLCV的值
TABLES: anlcv,ants,v_anepk.
DATA: BEGIN OF yanfm OCCURS 5.
INCLUDE STRUCTURE anfm.
DATA: END OF yanfm.
INCLUDE lafartab.
CLEAR anla.
SELECT SINGLE * FROM anla
WHERE bukrs = wa_asset-bukrs
AND anln1 = wa_asset-anln1
AND anln2 = wa_asset-anln2.
MOVE-CORRESPONDING anla TO ants.
CLEAR anlc.
READ TABLE it_anlc INTO anlc
WITH KEY bukrs = wa_asset-bukrs
anln1 = wa_asset-anln1
anln2 = wa_asset-anln2
gjahr = l_gjahr
BINARY SEARCH.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
REFRESH: xanlc,xanlb,xanlz,xanep,xanea.
APPEND anlc TO xanlc.
SELECT * INTO TABLE xanlb FROM anlb
WHERE bukrs = wa_asset-bukrs
AND anln1 = wa_asset-anln1
AND anln2 = wa_asset-anln2.
SELECT * INTO TABLE xanlz FROM anlz
WHERE bukrs = wa_asset-bukrs
AND anln1 = wa_asset-anln1
AND anln2 = wa_asset-anln2.
SELECT * FROM v_anepk
WHERE bukrs = wa_asset-bukrs
AND anln1 = wa_asset-anln1
AND anln2 = wa_asset-anln2
AND gjahr = l_gjahr
AND monat <= l_per.
MOVE-CORRESPONDING v_anepk TO xanep.
APPEND xanep.
ENDSELECT.
READ TABLE xanep WITH KEY xantw = ‘X’
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
SELECT * INTO TABLE xanea FROM anea
WHERE bukrs = wa_asset-bukrs
AND anln1 = wa_asset-anln1
AND anln2 = wa_asset-anln2
AND gjahr = l_gjahr.
ENDIF.
CALL FUNCTION ‘DEPR_RECALCULATE’
EXPORTING
i_ants = ants
i_datbis = p_date
i_fehler = ‘X’
i_function = ‘N’
i_cal_closed_fyears = ‘X’
TABLES
t_anlb = xanlb
t_anlc = xanlc
t_anlz = xanlz
t_anea = xanea
t_anep = xanep
t_anfm = yanfm.
READ TABLE xanlc INTO anlc INDEX 1.
CALL FUNCTION ‘FI_AA_VALUES_CALCULATE’
EXPORTING
i_anlc = anlc
IMPORTING
e_anlcv = anlcv.