Да, расчет правильный. Сумма налога и суммы остаточной стоимости формируются корректно. Причем я пока формирую все за 1 квартал, так что заполняются только суммы NBV01, NBV02, NBV03, NBV04. Мне не понятно почему в декларации за 1 квартал при расчете средней происходит деление на 12:
Code:
lv_month = 0.
lv_month2 = 0.
DO 12 TIMES VARYING lv_monthvalue FROM ls_asset_tax-tax01 NEXT ls_asset_tax-tax02
VARYING lv_monthvalue2 FROM ls_temp_asset-tax01 NEXT ls_temp_asset-tax02
VARYING lv_netvalue FROM ls_temp_asset-nbv01 NEXT ls_temp_asset-nbv02
VARYING lv_netvalue2 FROM ls_asset_tax-nbv01 NEXT ls_asset_tax-nbv02.
ADD 1 TO lv_month.
CONCATENATE p_gjahr lv_month '01' INTO lv_month_beg.
" generate date with the current month - first date of the month
IF lv_month_beg BETWEEN ls_td-adatu AND ls_td-bdatu. " if the actual month fits the actual time-dependent interval
ADD 1 TO lv_month2.
ADD lv_monthvalue TO ls_temp_asset-ptax_year.
" set the month tax value of the actual month if it fits the actual time dependent interval
lv_monthvalue2 = lv_monthvalue.
" set the monthly net book value of the actual month
lv_netvalue = lv_netvalue2.
ADD lv_netvalue TO ls_temp_asset-avgnbv.
" select the declaration number regarding the (bukrs, okato)
READ TABLE lt_declnums WITH TABLE KEY
bukrs = ls_temp_asset-grkey4-gr_bukrs
okato = ls_temp_asset-grkey4-gr_okato
INTO ls_declnums.
IF sy-subrc = 0.
ls_temp_asset-decl_num = ls_declnums-decl_num.
ls_temp_asset-corr_num = ls_declnums-corr_num.
ENDIF.
ENDIF.
ENDDO.
ls_temp_asset-nbv13 = ls_asset_tax-nbv13.
ADD ls_temp_asset-nbv13 TO ls_temp_asset-avgnbv.
" calculate average net book value of the given interval
ls_temp_asset-avgnbv = ls_temp_asset-avgnbv / lv_month2.
" copy number of the valid months to the table
ls_temp_asset-valid_month = lv_month2.
Цикл идет 12 раз и в переменной lv_month2 значение 12 после цикла. Поэтому и делится на 12.