d-aktpreis.w 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI ADM2
  2. &ANALYZE-RESUME
  3. /* Connected Databases
  4. anadat PROGRESS
  5. */
  6. &Scoped-define WINDOW-NAME CURRENT-WINDOW
  7. {adecomm/appserv.i}
  8. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS dTables
  9. /*------------------------------------------------------------------------
  10. File:
  11. Description: from DATA.W - Template For SmartData objects in the ADM
  12. Input Parameters:
  13. <none>
  14. Output Parameters:
  15. <none>
  16. Modified: February 24, 1999
  17. ------------------------------------------------------------------------*/
  18. /* This .W file was created with the Progress AppBuilder. */
  19. /*----------------------------------------------------------------------*/
  20. /* Create an unnamed pool to store all the widgets created
  21. by this procedure. This is a good default which assures
  22. that this procedure's triggers and internal procedures
  23. will execute in this procedure's storage, and that proper
  24. cleanup will occur on deletion of the procedure. */
  25. CREATE WIDGET-POOL.
  26. /* *************************** Definitions ************************** */
  27. /* Parameters Definitions --- */
  28. /* Local Variable Definitions --- */
  29. DEF VAR SteuAkt AS INT NO-UNDO.
  30. DEF VAR AktGrp AS INT NO-UNDO.
  31. &SCOPED-DEFINE Tabelle AktPreis
  32. &SCOPED-DEFINE TabWhere /* USE-INDEX Benutzer-k1 ~
  33. WHERE {&Tabelle}.Benutzer = tRowObject.Benutzer
  34. */
  35. { incl/datdefinition.i }
  36. /* _UIB-CODE-BLOCK-END */
  37. &ANALYZE-RESUME
  38. &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
  39. /* ******************** Preprocessor Definitions ******************** */
  40. &Global-define DATA-LOGIC-PROCEDURE .p
  41. &Scoped-define PROCEDURE-TYPE SmartDataObject
  42. &Scoped-define DB-AWARE yes
  43. &Scoped-define ADM-SUPPORTED-LINKS Data-Source,Data-Target,Navigation-Target,Update-Target,Commit-Target,Filter-Target
  44. /* Db-Required definitions. */
  45. &IF DEFINED(DB-REQUIRED) = 0 &THEN
  46. &GLOBAL-DEFINE DB-REQUIRED TRUE
  47. &ENDIF
  48. &GLOBAL-DEFINE DB-REQUIRED-START &IF {&DB-REQUIRED} &THEN
  49. &GLOBAL-DEFINE DB-REQUIRED-END &ENDIF
  50. &Scoped-define QUERY-NAME Query-Main
  51. /* Internal Tables (found by Frame, Query & Browse Queries) */
  52. &Scoped-define INTERNAL-TABLES AktPreis
  53. /* Definitions for QUERY Query-Main */
  54. &Scoped-Define ENABLED-FIELDS Firma Artnr Inhalt Jahr Grp Ab_Datum Bis_Datum Art Wert Aktion Bemerkung~
  55. Gruppe VK_Netto VK_Brutto Marge VK_Normal
  56. &Scoped-define ENABLED-FIELDS-IN-AktPreis Firma Artnr Inhalt Jahr Grp ~
  57. Ab_Datum Bis_Datum Art Wert Aktion Bemerkung
  58. &Scoped-Define DATA-FIELDS Firma Artnr Inhalt Jahr Grp Ab_Datum Bis_Datum Art Wert Aktion Bemerkung~
  59. Gruppe VK_Netto VK_Brutto Marge VK_Normal
  60. &Scoped-define DATA-FIELDS-IN-AktPreis Firma Artnr Inhalt Jahr Grp Ab_Datum ~
  61. Bis_Datum Art Wert Aktion Bemerkung
  62. &Scoped-Define MANDATORY-FIELDS Firma
  63. &Scoped-Define APPLICATION-SERVICE
  64. &Scoped-Define ASSIGN-LIST
  65. &Scoped-Define DATA-FIELD-DEFS "d-aktpreis.i"
  66. &Scoped-Define DATA-TABLE-NO-UNDO NO-UNDO
  67. &Scoped-define QUERY-STRING-Query-Main FOR EACH AktPreis NO-LOCK INDEXED-REPOSITION
  68. {&DB-REQUIRED-START}
  69. &Scoped-define OPEN-QUERY-Query-Main OPEN QUERY Query-Main FOR EACH AktPreis NO-LOCK INDEXED-REPOSITION.
  70. {&DB-REQUIRED-END}
  71. &Scoped-define TABLES-IN-QUERY-Query-Main AktPreis
  72. &Scoped-define FIRST-TABLE-IN-QUERY-Query-Main AktPreis
  73. /* Custom List Definitions */
  74. /* List-1,List-2,List-3,List-4,List-5,List-6 */
  75. /* _UIB-PREPROCESSOR-BLOCK-END */
  76. &ANALYZE-RESUME
  77. /* ************************ Function Prototypes ********************** */
  78. {&DB-REQUIRED-START}
  79. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getPreise dTables _DB-REQUIRED
  80. FUNCTION getPreise RETURNS DECIMAL
  81. ( ipArtnr AS INT, ipInhalt AS INT,
  82. ipJahr AS INT, ipAktGrp AS INT,
  83. ipDatum AS DATE ) FORWARD.
  84. /* _UIB-CODE-BLOCK-END */
  85. &ANALYZE-RESUME
  86. {&DB-REQUIRED-END}
  87. {&DB-REQUIRED-START}
  88. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getQueryBuffer dTables _DB-REQUIRED
  89. FUNCTION getQueryBuffer RETURNS HANDLE
  90. ( /* parameter-definitions */ ) FORWARD.
  91. /* _UIB-CODE-BLOCK-END */
  92. &ANALYZE-RESUME
  93. {&DB-REQUIRED-END}
  94. {&DB-REQUIRED-START}
  95. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD openQuery dTables _DB-REQUIRED
  96. FUNCTION openQuery RETURNS LOGICAL
  97. ( /* parameter-definitions */ ) FORWARD.
  98. /* _UIB-CODE-BLOCK-END */
  99. &ANALYZE-RESUME
  100. {&DB-REQUIRED-END}
  101. /* *********************** Control Definitions ********************** */
  102. {&DB-REQUIRED-START}
  103. /* Query definitions */
  104. &ANALYZE-SUSPEND
  105. DEFINE QUERY Query-Main FOR
  106. AktPreis SCROLLING.
  107. &ANALYZE-RESUME
  108. {&DB-REQUIRED-END}
  109. /* ************************ Frame Definitions *********************** */
  110. /* *********************** Procedure Settings ************************ */
  111. &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
  112. /* Settings for THIS-PROCEDURE
  113. Type: SmartDataObject
  114. Allow: Query
  115. Frames: 0
  116. Add Fields to: Neither
  117. Other Settings: PERSISTENT-ONLY COMPILE APPSERVER DB-AWARE
  118. */
  119. /* This procedure should always be RUN PERSISTENT. Report the error, */
  120. /* then cleanup and return. */
  121. IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
  122. MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT.":U
  123. VIEW-AS ALERT-BOX ERROR BUTTONS OK.
  124. RETURN.
  125. END.
  126. &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
  127. /* ************************* Create Window ************************** */
  128. &ANALYZE-SUSPEND _CREATE-WINDOW
  129. /* DESIGN Window definition (used by the UIB)
  130. CREATE WINDOW dTables ASSIGN
  131. HEIGHT = 1.62
  132. WIDTH = 46.6.
  133. /* END WINDOW DEFINITION */
  134. */
  135. &ANALYZE-RESUME
  136. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB dTables
  137. /* ************************* Included-Libraries *********************** */
  138. {src/adm2/data.i}
  139. /* _UIB-CODE-BLOCK-END */
  140. &ANALYZE-RESUME
  141. /* *********** Runtime Attributes and AppBuilder Settings *********** */
  142. &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
  143. /* SETTINGS FOR WINDOW dTables
  144. VISIBLE,,RUN-PERSISTENT */
  145. /* _RUN-TIME-ATTRIBUTES-END */
  146. &ANALYZE-RESUME
  147. /* Setting information for Queries and Browse Widgets fields */
  148. &ANALYZE-SUSPEND _QUERY-BLOCK QUERY Query-Main
  149. /* Query rebuild information for SmartDataObject Query-Main
  150. _TblList = "AnaDat.AktPreis"
  151. _Options = "NO-LOCK INDEXED-REPOSITION"
  152. _FldNameList[1] > AnaDat.AktPreis.Firma
  153. "Firma" "Firma" ? ? "character" ? ? ? ? ? ? yes ? yes 8 yes ?
  154. _FldNameList[2] > AnaDat.AktPreis.Artnr
  155. "Artnr" "Artnr" ? ? "integer" ? ? ? ? ? ? yes ? no 7.2 yes ?
  156. _FldNameList[3] > AnaDat.AktPreis.Inhalt
  157. "Inhalt" "Inhalt" ? ? "integer" ? ? ? ? ? ? yes ? no 5.2 yes ?
  158. _FldNameList[4] > AnaDat.AktPreis.Jahr
  159. "Jahr" "Jahr" ? ? "integer" ? ? ? ? ? ? yes ? no 4.8 yes ?
  160. _FldNameList[5] > AnaDat.AktPreis.Grp
  161. "Grp" "Grp" ? ? "integer" ? ? ? ? ? ? yes ? no 3.4 yes ?
  162. _FldNameList[6] > AnaDat.AktPreis.Ab_Datum
  163. "Ab_Datum" "Ab_Datum" ? ? "date" ? ? ? ? ? ? yes ? no 10.8 yes ?
  164. _FldNameList[7] > AnaDat.AktPreis.Bis_Datum
  165. "Bis_Datum" "Bis_Datum" ? ? "date" ? ? ? ? ? ? yes ? no 10.8 yes ?
  166. _FldNameList[8] > AnaDat.AktPreis.Art
  167. "Art" "Art" ? ? "integer" ? ? ? ? ? ? yes ? no 2.6 yes ?
  168. _FldNameList[9] > AnaDat.AktPreis.Wert
  169. "Wert" "Wert" ? ? "decimal" ? ? ? ? ? ? yes ? no 9.2 yes ?
  170. _FldNameList[10] > AnaDat.AktPreis.Aktion
  171. "Aktion" "Aktion" ? ? "character" ? ? ? ? ? ? yes ? no 20 yes ?
  172. _FldNameList[11] > AnaDat.AktPreis.Bemerkung
  173. "Bemerkung" "Bemerkung" ? ? "character" ? ? ? ? ? ? yes ? no 30 yes ?
  174. _FldNameList[12] > "_<CALC>"
  175. "DYNAMIC-FUNCTION('getAktPreisGruppe':U, RowObject.Grp)" "Gruppe" "Gruppe" "x(30)" "character" ? ? ? ? ? ? yes ? no 30 no ?
  176. _FldNameList[13] > "_<CALC>"
  177. "0" "VK_Netto" "Netto (exkl)" "->>,>>9.9999" "Decimal" ? ? ? ? ? ? yes ? no 12.6 no ?
  178. _FldNameList[14] > "_<CALC>"
  179. "0" "VK_Brutto" "Brutto (inkl)" "->>,>>9.9999" "Decimal" ? ? ? ? ? ? yes ? no 12.6 no ?
  180. _FldNameList[15] > "_<CALC>"
  181. "0" "Marge" "Marge" "->>,>>9.9999" "Decimal" ? ? ? ? ? ? yes ? no 12.6 no ?
  182. _FldNameList[16] > "_<CALC>"
  183. "DYNAMIC-FUNCTION('getPreise':U IN THIS-PROCEDURE, RowObject.Artnr, RowObject.Inhalt,RowObject.Jahr, RowObject.Grp, RowObject.Ab_Datum )" "VK_Normal" "Normalpreis" "->>,>>9.9999" "Decimal" ? ? ? ? ? ? yes ? no 12.6 no ?
  184. _Design-Parent is WINDOW dTables @ ( 1.14 , 2.6 )
  185. */ /* QUERY Query-Main */
  186. &ANALYZE-RESUME
  187. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK dTables
  188. /* *************************** Main Block *************************** */
  189. { incl/datmainblock.i }
  190. FIND Steuer NO-LOCK USE-INDEX Steuer-k1
  191. WHERE Steuer.Firma = Firma NO-ERROR.
  192. IF AVAILABLE Steuer THEN SteuAkt = Steuer.Aktionspreise.
  193. &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
  194. RUN initializeObject.
  195. &ENDIF
  196. /* _UIB-CODE-BLOCK-END */
  197. &ANALYZE-RESUME
  198. /* ********************** Internal Procedures *********************** */
  199. {&DB-REQUIRED-START}
  200. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE DATA.CALCULATE dTables DATA.CALCULATE _DB-REQUIRED
  201. PROCEDURE DATA.CALCULATE :
  202. /*------------------------------------------------------------------------------
  203. Purpose: Calculate all the Calculated Expressions found in the
  204. SmartDataObject.
  205. Parameters: <none>
  206. ------------------------------------------------------------------------------*/
  207. ASSIGN
  208. rowObject.Gruppe = (DYNAMIC-FUNCTION('getAktPreisGruppe':U, RowObject.Grp))
  209. rowObject.Marge = (0)
  210. rowObject.VK_Brutto = (0)
  211. rowObject.VK_Netto = (0)
  212. rowObject.VK_Normal = (DYNAMIC-FUNCTION('getPreise':U IN THIS-PROCEDURE, RowObject.Artnr, RowObject.Inhalt,RowObject.Jahr, RowObject.Grp, RowObject.Ab_Datum ))
  213. .
  214. END PROCEDURE.
  215. /* _UIB-CODE-BLOCK-END */
  216. &ANALYZE-RESUME
  217. {&DB-REQUIRED-END}
  218. {&DB-REQUIRED-START}
  219. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE dataAvailable dTables _DB-REQUIRED
  220. PROCEDURE dataAvailable :
  221. /*------------------------------------------------------------------------------
  222. Purpose: Super Override
  223. Parameters:
  224. Notes:
  225. ------------------------------------------------------------------------------*/
  226. { incl/datdataavailable.i }
  227. END PROCEDURE.
  228. /* _UIB-CODE-BLOCK-END */
  229. &ANALYZE-RESUME
  230. {&DB-REQUIRED-END}
  231. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI dTables _DEFAULT-DISABLE
  232. PROCEDURE disable_UI :
  233. /*------------------------------------------------------------------------------
  234. Purpose: DISABLE the User Interface
  235. Parameters: <none>
  236. Notes: Here we clean-up the user-interface by deleting
  237. dynamic widgets we have created and/or hide
  238. frames. This procedure is usually called when
  239. we are ready to "clean-up" after running.
  240. ------------------------------------------------------------------------------*/
  241. /* Hide all frames. */
  242. IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
  243. END PROCEDURE.
  244. /* _UIB-CODE-BLOCK-END */
  245. &ANALYZE-RESUME
  246. {&DB-REQUIRED-START}
  247. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE INAKTIVIEREN dTables _DB-REQUIRED
  248. PROCEDURE INAKTIVIEREN :
  249. /*------------------------------------------------------------------------------
  250. Purpose:
  251. Parameters: <none>
  252. Notes:
  253. ------------------------------------------------------------------------------*/
  254. { incl/datinaktivieren.i }
  255. END PROCEDURE.
  256. /* _UIB-CODE-BLOCK-END */
  257. &ANALYZE-RESUME
  258. {&DB-REQUIRED-END}
  259. {&DB-REQUIRED-START}
  260. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initializeObject dTables _DB-REQUIRED
  261. PROCEDURE initializeObject :
  262. /*------------------------------------------------------------------------------
  263. Purpose: Super Override
  264. Parameters:
  265. Notes:
  266. ------------------------------------------------------------------------------*/
  267. { incl/datinitialize.i }
  268. END PROCEDURE.
  269. /* _UIB-CODE-BLOCK-END */
  270. &ANALYZE-RESUME
  271. {&DB-REQUIRED-END}
  272. {&DB-REQUIRED-START}
  273. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE REAKTIVIEREN dTables _DB-REQUIRED
  274. PROCEDURE REAKTIVIEREN :
  275. /*------------------------------------------------------------------------------
  276. Purpose:
  277. Parameters: <none>
  278. Notes:
  279. ------------------------------------------------------------------------------*/
  280. { incl/datreaktivieren.i }
  281. END PROCEDURE.
  282. /* _UIB-CODE-BLOCK-END */
  283. &ANALYZE-RESUME
  284. {&DB-REQUIRED-END}
  285. {&DB-REQUIRED-START}
  286. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE REPOS_TABELLE dTables _DB-REQUIRED
  287. PROCEDURE REPOS_TABELLE :
  288. /*------------------------------------------------------------------------------
  289. Purpose:
  290. Parameters: <none>
  291. Notes:
  292. ------------------------------------------------------------------------------*/
  293. { incl/datrepos.i }
  294. END PROCEDURE.
  295. /* _UIB-CODE-BLOCK-END */
  296. &ANALYZE-RESUME
  297. {&DB-REQUIRED-END}
  298. {&DB-REQUIRED-START}
  299. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_FILTER dTables _DB-REQUIRED
  300. PROCEDURE SET_FILTER :
  301. /*------------------------------------------------------------------------------
  302. Purpose:
  303. Parameters: <none>
  304. Notes:
  305. ------------------------------------------------------------------------------*/
  306. { incl/datsetfilter.i }
  307. END PROCEDURE.
  308. /* _UIB-CODE-BLOCK-END */
  309. &ANALYZE-RESUME
  310. {&DB-REQUIRED-END}
  311. {&DB-REQUIRED-START}
  312. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_OPENFLAG dTables _DB-REQUIRED
  313. PROCEDURE SET_OPENFLAG :
  314. /*------------------------------------------------------------------------------
  315. Purpose:
  316. Parameters: <none>
  317. Notes:
  318. ------------------------------------------------------------------------------*/
  319. { incl/datsetopenflag.i }
  320. END PROCEDURE.
  321. /* _UIB-CODE-BLOCK-END */
  322. &ANALYZE-RESUME
  323. {&DB-REQUIRED-END}
  324. {&DB-REQUIRED-START}
  325. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_SORT dTables _DB-REQUIRED
  326. PROCEDURE SET_SORT :
  327. /*------------------------------------------------------------------------------
  328. Purpose:
  329. Parameters: <none>
  330. Notes:
  331. ------------------------------------------------------------------------------*/
  332. { incl/datsetsort.i }
  333. END PROCEDURE.
  334. /* _UIB-CODE-BLOCK-END */
  335. &ANALYZE-RESUME
  336. {&DB-REQUIRED-END}
  337. /* ************************ Function Implementations ***************** */
  338. {&DB-REQUIRED-START}
  339. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getPreise dTables _DB-REQUIRED
  340. FUNCTION getPreise RETURNS DECIMAL
  341. ( ipArtnr AS INT, ipInhalt AS INT,
  342. ipJahr AS INT, ipAktGrp AS INT,
  343. ipDatum AS DATE ) :
  344. /*------------------------------------------------------------------------------
  345. Purpose:
  346. Notes:
  347. ------------------------------------------------------------------------------*/
  348. DEF VAR cString AS CHAR NO-UNDO.
  349. DEF VAR lBrutto AS LOG NO-UNDO.
  350. DEF VAR VK_Normal AS DEC DECIMALS 4 NO-UNDO.
  351. DEF VAR VK_Netto AS DEC DECIMALS 4 NO-UNDO.
  352. DEF VAR VK_Brutto AS DEC DECIMALS 4 NO-UNDO.
  353. DEF VAR Ansatz AS DEC DECIMALS 4 NO-UNDO.
  354. DEF VAR Marge AS DEC DECIMALS 4 NO-UNDO.
  355. DEF VAR EP AS DEC DECIMALS 4 NO-UNDO.
  356. IF SteuAkt = 0 THEN AktGrp = ipAktGrp.
  357. ELSE DO:
  358. RUN FIND_KUNDENGRUPPE ( INPUT ipAktGrp, OUTPUT cString ).
  359. IF cString <> '' THEN AktGrp = INTEGER(ENTRY(3, cString, CHR(01))).
  360. END.
  361. RUN FIND_PREISGRUPPE ( INPUT AktGrp, OUTPUT cString ).
  362. IF INTEGER(ENTRY(3, cString, CHR(01))) = 1 THEN lBrutto = TRUE.
  363. ELSE lBrutto = FALSE.
  364. FIND LAST ArtPreis NO-LOCK USE-INDEX ArtPreis-k1
  365. WHERE ArtPreis.Firma = Firma
  366. AND ArtPreis.Artnr = ipArtnr
  367. AND ArtPreis.Inhalt = ipInhalt
  368. AND ArtPreis.Jahr = ipJahr
  369. AND ArtPreis.Preis_Grp = ipAktGrp
  370. AND ArtPreis.Aktion = FALSE
  371. AND ArtPreis.Ab_Datum <= ipDatum NO-ERROR.
  372. DO WHILE TRUE:
  373. IF NOT AVAILABLE ArtPreis THEN LEAVE.
  374. Ansatz = (ArtPreis.VK_Brutto * 100 / ArtPreis.VK_Netto) - 100.
  375. IF lBrutto THEN VK_Normal = Artpreis.VK_Brutto.
  376. ELSE VK_Normal = Artpreis.VK_Netto.
  377. CASE rowObject.Art:
  378. WHEN 0 THEN DO:
  379. IF lBrutto THEN DO:
  380. VK_Brutto = ArtPreis.VK_Brutto - rowObject.Wert.
  381. RUN RUNDEN ( INPUT 1, INPUT-OUTPUT VK_Brutto ).
  382. VK_Netto = VK_Brutto / (100 + Ansatz) * 100.
  383. END.
  384. ELSE DO:
  385. VK_Netto = ArtPreis.VK_Netto - rowObject.Wert.
  386. VK_Brutto = VK_Netto * (100 + Ansatz) / 100.
  387. END.
  388. END.
  389. WHEN 1 THEN DO:
  390. IF lBrutto THEN DO:
  391. VK_Brutto = ArtPreis.VK_Brutto * (100 - rowObject.Wert) / 100.
  392. RUN RUNDEN ( INPUT 1, INPUT-OUTPUT VK_Brutto ).
  393. VK_Netto = VK_Brutto / (100 + Ansatz) * 100.
  394. END.
  395. ELSE DO:
  396. VK_Netto = ArtPreis.VK_Netto * (100 - rowObject.Wert) / 100.
  397. VK_Brutto = VK_Netto * (100 + Ansatz) / 100.
  398. END.
  399. END.
  400. END CASE.
  401. LEAVE.
  402. END.
  403. EP = 0.
  404. Marge = 0.
  405. FIND Artst NO-LOCK USE-INDEX Artst-k1
  406. WHERE Artst.Firma = Firma
  407. AND Artst.Artnr = ipArtnr
  408. AND Artst.Inhalt = ipInhalt
  409. AND Artst.Jahr = ipJahr NO-ERROR.
  410. EP = Artst.Listen_EP.
  411. IF EP = 0 THEN EP = Artst.LEP.
  412. IF EP = 0 THEN EP = Artst.DEP.
  413. IF EP <> 0 AND
  414. VK_Netto <> 0 THEN Marge = 100 - (EP * 100 / VK_Netto).
  415. rowObject.VK_Brutto = VK_Brutto.
  416. rowObject.VK_Netto = VK_Netto .
  417. rowObject.Marge = Marge.
  418. RETURN VK_Normal.
  419. END FUNCTION.
  420. /* _UIB-CODE-BLOCK-END */
  421. &ANALYZE-RESUME
  422. {&DB-REQUIRED-END}
  423. {&DB-REQUIRED-START}
  424. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getQueryBuffer dTables _DB-REQUIRED
  425. FUNCTION getQueryBuffer RETURNS HANDLE
  426. ( /* parameter-definitions */ ) :
  427. /*------------------------------------------------------------------------------
  428. Purpose:
  429. Notes:
  430. ------------------------------------------------------------------------------*/
  431. RETURN BUFFER rowObject:HANDLE.
  432. END FUNCTION.
  433. /* _UIB-CODE-BLOCK-END */
  434. &ANALYZE-RESUME
  435. {&DB-REQUIRED-END}
  436. {&DB-REQUIRED-START}
  437. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION openQuery dTables _DB-REQUIRED
  438. FUNCTION openQuery RETURNS LOGICAL
  439. ( /* parameter-definitions */ ) :
  440. /*------------------------------------------------------------------------------
  441. Purpose: Super Override
  442. Notes:
  443. ------------------------------------------------------------------------------*/
  444. DEF VAR Felder AS CHAR NO-UNDO.
  445. DEF VAR Inhalt AS CHAR NO-UNDO.
  446. DEF VAR ix AS INT NO-UNDO.
  447. DEF VAR cFeld AS CHAR NO-UNDO.
  448. /* IF NOT fOpen THEN RETURN FALSE. */
  449. xWhere = ''.
  450. xSort = ''.
  451. xString = ''.
  452. Felder = DYNAMIC-FUNCTION('getForeignFields':U) NO-ERROR.
  453. Inhalt = DYNAMIC-FUNCTION('getForeignValues':U) NO-ERROR.
  454. /* ix = LOOKUP('Feld', Felder, ',') / 2. */
  455. /* cFeld = ENTRY (ix , Inhalt, CHR(01)). */
  456. /* xWhere = 'Aufko.Firma = ' + QUOTER(Firma) + ' AND ' */
  457. /* + 'Aufko.Auf_Sta = ' + STRING(Auf_Sta) + ' '. */
  458. /* xString = 'FOR EACH Debop ' + xSort + 'WHERE ' */
  459. /* + 'Debop.Firma = "' + Firma + '" AND ' */
  460. /* + 'Debop.Knr = ' + STRING(Knr) + ' ' */
  461. /* + 'NO-LOCK BY Debop.FakDat DESCENDING INDEXED-REPOSITION '. */
  462. { incl/datopenquery.i }
  463. IF xWhere <> '' THEN DYNAMIC-FUNCTION('setQueryWhere':U , INPUT xWhere ).
  464. IF xString <> '' THEN DYNAMIC-FUNCTION('setQueryString':U, INPUT xString).
  465. IF xSort <> '' THEN DYNAMIC-FUNCTION('setQuerySort':U , INPUT xSort ).
  466. RETURN SUPER( ).
  467. END FUNCTION.
  468. /* _UIB-CODE-BLOCK-END */
  469. &ANALYZE-RESUME
  470. {&DB-REQUIRED-END}