DISABLE TRIGGERS FOR LOAD OF artlager. DISABLE TRIGGERS FOR LOAD OF artlief. DISABLE TRIGGERS FOR LOAD OF besze. DISABLE TRIGGERS FOR LOAD OF besko. DISABLE TRIGGERS FOR LOAD OF Artst. DEF VAR irest AS INT. DEF VAR fuellung AS DEC. DEF VAR ianzbest AS INT. DEF VAR ianztage AS INT. DEF VAR ianzinter AS INT. DEF VAR dbestdatum AS DATE. DEF VAR nRueckstand AS DEC . DEF VAR nbestellt AS DEC . FIND Steuer NO-LOCK WHERE Steuer.Firma = '1000'. FOR EACH Artst: ASSIGN Artst.Bestellt = 0. END. FOR EACH ArtLager: ASSIGN ArtLager.Bestellt = 0 Artlager.offen = 0. END. FOR EACH Besze WHERE besze.firma = '1000' AND besze.artnr > 0, FIRST Besko NO-LOCK OF Besze, FIRST artst OF besze: ASSIGN besze.GGeb_EG = 0 besze.VGeb_EG = 0 besze.KGeb_EG = 0 besze.Eingang = 0 besze.mgeli = 0 besze.mruek = 0. FOR EACH Artbw NO-LOCK WHERE Artbw.Firma = Besze.Firma AND Artbw.Artnr = Besze.Artnr AND Artbw.Inhalt = besze.inhalt AND artbw.jahr = besze.jahr AND artbw.aufnr = besze.besnr AND artbw.datum >= TODAY - 365 AND artbw.tr_art = 11: ASSIGN besze.mgeli = besze.mgeli + artbw.menge. END. IF besze.mgeli > besze.mbest THEN besze.mbest = besze.mgeli. IF besko.Best_datum < (TODAY - 365) OR Besko.Best_Sta > 2 THEN Besze.Mgel = Besze.mbest. /* IF besze.mgeli = Besze.mbest THEN NEXT. */ FIND ggebinde NO-LOCK WHERE ggebinde.firma = besze.firma AND ggebinde.geb_cd = artst.ggeb_cd NO-ERROR. FIND vgebinde NO-LOCK WHERE vgebinde.firma = besze.firma AND vgebinde.geb_cd = artst.vgeb_cd NO-ERROR. FIND kgebinde NO-LOCK WHERE kgebinde.firma = besze.firma AND kgebinde.geb_cd = artst.kgeb_cd NO-ERROR. ASSIGN besze.kgeb_EG = besze.mgel. IF AVAILABLE vgebinde AND vgebinde.inhalt > 0 THEN DO: besze.vgeb_eg = (besze.mgel - (besze.mgel MOD vgebinde.inhalt)) / vgebinde.inhalt. END. IF besze.vgeb_eg > 0 AND AVAILABLE ggebinde AND ggebinde.inhalt > 0 THEN DO: irest = besze.vgeb_eg MOD ggebinde.inhalt. besze.ggeb_eg = (besze.vgeb_eg - irest) / ggebinde.inhalt. fuellung = irest * 100 / ggebinde.inhalt. IF irest > 50 THEN besze.ggeb_eg = besze.ggeb_eg + 1. END. END. FOR EACH BesEing WHERE BesEing.Eingang > 0: FIND besze OF beseing NO-ERROR. IF NOT AVAILABLE besze THEN DO: DELETE BesEing. NEXT. END. besze.eingang = besze.eingang + beseing.eingang. besze.mruek = besze.mbest - besze.mgeli - besze.eingang. END. FOR EACH Besze WHERE Besze.Artnr > 0, FIRST Besko OF Besze, FIRST Artst OF Besze, FIRST ArtLager OF Besze BREAK BY Besze.Artnr BY Besze.Inhalt BY Besze.Jahr: IF FIRST-OF(Besze.Jahr) THEN ASSIGN nRueckstand = 0.0 nBestellt = 0.0. ASSIGN Besze.Best_Sta = Besko.Best_Sta. FIND GGebinde NO-LOCK WHERE GGebinde.Firma = Besze.Firma AND GGebinde.Geb_Cd = Besze.GGeb_Cd NO-ERROR. FIND VGebinde NO-LOCK WHERE VGebinde.Firma = Besze.Firma AND VGebinde.Geb_Cd = Besze.VGeb_Cd NO-ERROR. FIND KGebinde NO-LOCK WHERE KGebinde.Firma = Besze.Firma AND KGebinde.Geb_Cd = Besze.KGeb_Cd NO-ERROR. IF Besze.GGebKto = '' AND AVAILABLE GGebinde THEN Besze.GGebKto = GGebinde.Geb_Kto. IF Besze.VGebKto = '' AND AVAILABLE VGebinde THEN Besze.VGebKto = VGebinde.Geb_Kto. IF Besze.KGebKto = '' AND AVAILABLE KGebinde THEN Besze.KGebKto = KGebinde.Geb_Kto. nRueckstand = nRueckstand + Besze.mRuek. nbestellt = nbestellt + Besze.mBest. IF NOT LAST-OF ( Besze.Jahr ) THEN NEXT. ASSIGN Artst.Bestellt = nbestellt ArtLager.Bestellt = nbestellt Artlager.offen = nrueckstand. /* IF Steuer.St09 = 1 THEN DO: */ /* IF Artst.Mind_Bestand > 0 THEN Artst.Mind_Bestand = Artst.Mind_Bestand / VGebinde.Inhalt. */ /* IF Artst.Soll_Bestand > 0 THEN Artst.Soll_Bestand = Artst.Soll_Bestand / VGebinde.Inhalt. */ /* END. */ END. FOR EACH Artst: IF Artst.Mind_Bestand = 0 AND Artst.Soll_Bestand = 0 THEN NEXT. FIND FIRST ArtLager OF Artst. ASSIGN ArtLager.Mind_Bestand = Artst.Mind_Bestand ArtLager.Soll_Bestand = Artst.Soll_Bestand. END. FIND Steuer NO-LOCK WHERE Steuer.Firma = '1000'. /* FOR EACH Artlief, FIRST Artst OF Artlief NO-LOCK, FIRST VGebinde NO-LOCK WHERE VGebinde.Firma = ArtLief.Firma AND VGebinde.Geb_Cd = Artst.VGeb_Cd: IF Steuer.St09 = 1 THEN ASSIGN ArtLief.Min_VGebinde = Min_Menge ArtLief.Min_KGebinde = Min_Menge * VGebinde.Inhalt. ELSE ArtLief.Min_KGebinde = Min_Menge. END. */ /* FOR EACH Besko WHERE Besko.Firma = '1000' AND Besko.Best_Dat >= 01/01/2018 AND Besko.Best_Dat <= 12/31/2019 AND Besko.Best_Sta >= 3 BREAK BY Besko.Knr BY Besko.Best_Dat: IF FIRST-OF(Besko.Knr) THEN DO: ASSIGN iAnzBest = 0 iAnzInter = 0 iAnzTage = 0 dBestDatum = Besko.Best_Dat. NEXT. END. iAnzBest = iAnzBest + 1. iAnzInter = iAnzInter + (Besko.Best_Dat - dBestDatum). FOR EACH Artbw NO-LOCK WHERE Artbw.Firma = Besko.Firma AND artbw.aufnr = besko.besnr AND artbw.tr_art = 11: iAnzTage = iAnzTage + (Artbw.Datum - Besko.Best_Dat). LEAVE. END. dBestDatum = Besko.Best_Dat. IF NOT LAST-OF ( Besko.Knr) THEN NEXT. IF iAnzBest < 3 THEN NEXT. FIND Liefst OF Besko. ASSIGN Liefst.Bestell_Intervall = iAnzInter / iAnzBest Liefst.Lieferzeit = iAnzTage / iAnzBest. RELEASE Liefst. END. */