KorrBesze.p 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. DISABLE TRIGGERS FOR LOAD OF artlager.
  2. DISABLE TRIGGERS FOR LOAD OF artlief.
  3. DISABLE TRIGGERS FOR LOAD OF besze.
  4. DISABLE TRIGGERS FOR LOAD OF besko.
  5. DISABLE TRIGGERS FOR LOAD OF Artst.
  6. DEF VAR irest AS INT.
  7. DEF VAR fuellung AS DEC.
  8. DEF VAR ianzbest AS INT.
  9. DEF VAR ianztage AS INT.
  10. DEF VAR ianzinter AS INT.
  11. DEF VAR dbestdatum AS DATE.
  12. DEF VAR nRueckstand AS DEC .
  13. DEF VAR nbestellt AS DEC .
  14. FIND Steuer NO-LOCK
  15. WHERE Steuer.Firma = '1000'.
  16. FOR EACH Artst:
  17. ASSIGN Artst.Bestellt = 0.
  18. END.
  19. FOR EACH ArtLager:
  20. ASSIGN ArtLager.Bestellt = 0
  21. Artlager.offen = 0.
  22. END.
  23. FOR EACH Besze
  24. WHERE besze.firma = '1000'
  25. AND besze.artnr > 0,
  26. FIRST Besko NO-LOCK OF Besze,
  27. FIRST artst OF besze:
  28. ASSIGN besze.GGeb_EG = 0
  29. besze.VGeb_EG = 0
  30. besze.KGeb_EG = 0
  31. besze.Eingang = 0
  32. besze.mgeli = 0
  33. besze.mruek = 0.
  34. FOR EACH Artbw NO-LOCK
  35. WHERE Artbw.Firma = Besze.Firma
  36. AND Artbw.Artnr = Besze.Artnr
  37. AND Artbw.Inhalt = besze.inhalt
  38. AND artbw.jahr = besze.jahr
  39. AND artbw.aufnr = besze.besnr
  40. AND artbw.datum >= TODAY - 365
  41. AND artbw.tr_art = 11:
  42. ASSIGN besze.mgeli = besze.mgeli + artbw.menge.
  43. END.
  44. IF besze.mgeli > besze.mbest THEN besze.mbest = besze.mgeli.
  45. IF besko.Best_datum < (TODAY - 365) OR
  46. Besko.Best_Sta > 2 THEN Besze.Mgel = Besze.mbest.
  47. /* IF besze.mgeli = Besze.mbest THEN NEXT. */
  48. FIND ggebinde NO-LOCK
  49. WHERE ggebinde.firma = besze.firma
  50. AND ggebinde.geb_cd = artst.ggeb_cd NO-ERROR.
  51. FIND vgebinde NO-LOCK
  52. WHERE vgebinde.firma = besze.firma
  53. AND vgebinde.geb_cd = artst.vgeb_cd NO-ERROR.
  54. FIND kgebinde NO-LOCK
  55. WHERE kgebinde.firma = besze.firma
  56. AND kgebinde.geb_cd = artst.kgeb_cd NO-ERROR.
  57. ASSIGN besze.kgeb_EG = besze.mgel.
  58. IF AVAILABLE vgebinde AND vgebinde.inhalt > 0 THEN DO:
  59. besze.vgeb_eg = (besze.mgel - (besze.mgel MOD vgebinde.inhalt)) / vgebinde.inhalt.
  60. END.
  61. IF besze.vgeb_eg > 0 AND
  62. AVAILABLE ggebinde AND
  63. ggebinde.inhalt > 0 THEN DO:
  64. irest = besze.vgeb_eg MOD ggebinde.inhalt.
  65. besze.ggeb_eg = (besze.vgeb_eg - irest) / ggebinde.inhalt.
  66. fuellung = irest * 100 / ggebinde.inhalt.
  67. IF irest > 50 THEN besze.ggeb_eg = besze.ggeb_eg + 1.
  68. END.
  69. END.
  70. FOR EACH BesEing WHERE BesEing.Eingang > 0:
  71. FIND besze OF beseing NO-ERROR.
  72. IF NOT AVAILABLE besze THEN DO:
  73. DELETE BesEing.
  74. NEXT.
  75. END.
  76. besze.eingang = besze.eingang + beseing.eingang.
  77. besze.mruek = besze.mbest - besze.mgeli - besze.eingang.
  78. END.
  79. FOR EACH Besze WHERE Besze.Artnr > 0,
  80. FIRST Besko OF Besze,
  81. FIRST Artst OF Besze,
  82. FIRST ArtLager OF Besze
  83. BREAK BY Besze.Artnr
  84. BY Besze.Inhalt
  85. BY Besze.Jahr:
  86. IF FIRST-OF(Besze.Jahr) THEN ASSIGN nRueckstand = 0.0
  87. nBestellt = 0.0.
  88. ASSIGN Besze.Best_Sta = Besko.Best_Sta.
  89. FIND GGebinde NO-LOCK
  90. WHERE GGebinde.Firma = Besze.Firma
  91. AND GGebinde.Geb_Cd = Besze.GGeb_Cd NO-ERROR.
  92. FIND VGebinde NO-LOCK
  93. WHERE VGebinde.Firma = Besze.Firma
  94. AND VGebinde.Geb_Cd = Besze.VGeb_Cd NO-ERROR.
  95. FIND KGebinde NO-LOCK
  96. WHERE KGebinde.Firma = Besze.Firma
  97. AND KGebinde.Geb_Cd = Besze.KGeb_Cd NO-ERROR.
  98. IF Besze.GGebKto = '' AND
  99. AVAILABLE GGebinde THEN Besze.GGebKto = GGebinde.Geb_Kto.
  100. IF Besze.VGebKto = '' AND
  101. AVAILABLE VGebinde THEN Besze.VGebKto = VGebinde.Geb_Kto.
  102. IF Besze.KGebKto = '' AND
  103. AVAILABLE KGebinde THEN Besze.KGebKto = KGebinde.Geb_Kto.
  104. nRueckstand = nRueckstand + Besze.mRuek.
  105. nbestellt = nbestellt + Besze.mBest.
  106. IF NOT LAST-OF ( Besze.Jahr ) THEN NEXT.
  107. ASSIGN Artst.Bestellt = nbestellt
  108. ArtLager.Bestellt = nbestellt
  109. Artlager.offen = nrueckstand.
  110. /* IF Steuer.St09 = 1 THEN DO: */
  111. /* IF Artst.Mind_Bestand > 0 THEN Artst.Mind_Bestand = Artst.Mind_Bestand / VGebinde.Inhalt. */
  112. /* IF Artst.Soll_Bestand > 0 THEN Artst.Soll_Bestand = Artst.Soll_Bestand / VGebinde.Inhalt. */
  113. /* END. */
  114. END.
  115. FOR EACH Artst:
  116. IF Artst.Mind_Bestand = 0 AND
  117. Artst.Soll_Bestand = 0 THEN NEXT.
  118. FIND FIRST ArtLager OF Artst.
  119. ASSIGN ArtLager.Mind_Bestand = Artst.Mind_Bestand
  120. ArtLager.Soll_Bestand = Artst.Soll_Bestand.
  121. END.
  122. FIND Steuer NO-LOCK
  123. WHERE Steuer.Firma = '1000'.
  124. /*
  125. FOR EACH Artlief,
  126. FIRST Artst OF Artlief NO-LOCK,
  127. FIRST VGebinde NO-LOCK
  128. WHERE VGebinde.Firma = ArtLief.Firma
  129. AND VGebinde.Geb_Cd = Artst.VGeb_Cd:
  130. IF Steuer.St09 = 1 THEN ASSIGN ArtLief.Min_VGebinde = Min_Menge
  131. ArtLief.Min_KGebinde = Min_Menge * VGebinde.Inhalt.
  132. ELSE ArtLief.Min_KGebinde = Min_Menge.
  133. END.
  134. */
  135. /*
  136. FOR EACH Besko
  137. WHERE Besko.Firma = '1000'
  138. AND Besko.Best_Dat >= 01/01/2018
  139. AND Besko.Best_Dat <= 12/31/2019
  140. AND Besko.Best_Sta >= 3
  141. BREAK BY Besko.Knr
  142. BY Besko.Best_Dat:
  143. IF FIRST-OF(Besko.Knr) THEN DO:
  144. ASSIGN iAnzBest = 0
  145. iAnzInter = 0
  146. iAnzTage = 0
  147. dBestDatum = Besko.Best_Dat.
  148. NEXT.
  149. END.
  150. iAnzBest = iAnzBest + 1.
  151. iAnzInter = iAnzInter + (Besko.Best_Dat - dBestDatum).
  152. FOR EACH Artbw NO-LOCK
  153. WHERE Artbw.Firma = Besko.Firma
  154. AND artbw.aufnr = besko.besnr
  155. AND artbw.tr_art = 11:
  156. iAnzTage = iAnzTage + (Artbw.Datum - Besko.Best_Dat).
  157. LEAVE.
  158. END.
  159. dBestDatum = Besko.Best_Dat.
  160. IF NOT LAST-OF ( Besko.Knr) THEN NEXT.
  161. IF iAnzBest < 3 THEN NEXT.
  162. FIND Liefst OF Besko.
  163. ASSIGN Liefst.Bestell_Intervall = iAnzInter / iAnzBest
  164. Liefst.Lieferzeit = iAnzTage / iAnzBest.
  165. RELEASE Liefst.
  166. END.
  167. */