Спасибо, добавила  в код #define ComponentVersion  , исключение исчезло 

 все равно ничего не считает и пишет предупреждение о рекурсивном рел. отношении таблицы basedoc
#define ComponentVersion
#include Dolg_BD.vih
Interface workskidka2 'Расчет предоставления скидки' EscClose, cyan;
show(,, 65, 10);
Create view
var
d1,d2,d3:date;
tipDO : word;
bDolg: boolean;
DolgBDR: CalcDolgBD;
dEndDateCalc: date;
SumOtgDO: double;
SumDolgOnlyOtgrDO: double;
_cRecBD: comp;
dBegDateCalc: date;
SumReklDO:double;
DolgOtgrDOWihtRekl: double;
as select *
FROM
  KatOrg
, synonym    Katorg KAtorg1
, Sgoods
, Acprmspkat
, Basedoc
where
((
      Sgoods.corg   == KatOrg.nrec
  and Sgoods.cpluse == Acprmspkat.nrec
  and basedoc.corg  == Katorg1.nrec
  and d2  >>= basedoc.ddoc(noindex)
  and word(201) == basedoc.viddoc
  and word(2)   == basedoc.status
));
screen ButtonList('Расчет скидки');
  show(,, 64, 9);
  buttons
    cmRGod;
    cmRMes;
    cmDel;
    cmDelM;
 <<
     <.Расчет скидки(год).>     <.Расчет скидки месяц.>
     <.Отмена скидки(год).>     <.Отмена скидки(месяц).>
 >>
end;
HandleEvent
cmInit:
{
  d1:=Cur_Date;
  d2:=Sub_Months(d2,1);
  tipDO :=201;
  d3:=dEndDateCalc;
}
 cmRGod:
{
   if (RunDialog('C_Common::GetFormNa',d1)=cmCancel)
   {
    abort;
    exit;
   }
  _loop Sgoods where (( 31h == sgoods.cpluse (NoIndex) ))
  {
   if (year(sub_date(d1, sgoods.duse)) >= 10 )
    {
     KatOrg.kbk :=double('5');
    }
   if (year(sub_date(d1, sgoods.duse)) < 10 and year(sub_date(d1, sgoods.duse)) >= 5)
    {
     KatOrg.kbk :=double('4');
    }
   if (year(sub_date(d1, sgoods.duse)) < 5  and year(sub_date(d1, sgoods.duse)) >= 3)
    {
     KatOrg.kbk := double('3');
    }
  update current KatOrg;
  }
  message('Произведен расчет скидка(год)!')
}
 cmDel:
{
  _Loop Sgoods
  {
    KatOrg.KBK := doubletostr(KatOrg.KBK,'');
    update current KatOrg;
  }
  message('Перерасчет скидки(год) произведен!Запустите расчет! ')
}
cmDelM:
{
  _Loop Sgoods
  {
    KatOrg.OGRN := doubletostr(KatOrg.OGRN,'');
    update current KatOrg;
  }
  message('Перерасчет скидки(месяц) произведен!Запустите расчет! ')
}
cmRMes:
{
   if (RunDialog('C_Common::GetFormNa',d3)=cmCancel)
   {
    abort;
    exit;
   }
_loop KatOrg where (( '' << katorg.kbk  (NoIndex) ))
 {
    bDolg := FALSE;
_loop BaseDoc where ((word(201) == BaseDoc.VidDoc and KatOrg1.nRec == BaseDoc.cOrg and d2 >>= basedoc.ddoc))
   {
     DolgBDR.GetAllSumOtgrDO(_cRecBD,0,d3, SumOtgDO,SumReklDO, SumDolgOnlyOtgrDO,DolgOtgrDOWihtRekl);          
    if SumDolgOnlyOtgrDO>0
      {
       bDOlg := TRUE;
       break;
      }
    if  SumDolgOnlyOtgrDO<=0
     {
      bDolg := FALSE;
      katorg.ogrn:= katorg.kbk;
     }
   }
  update current KatOrg;
 }
  message('Перерасчет скидки(месяц) произведен!')
}
end;
#undef ComponentVersion
End.
 
