d-kunbw.w 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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 iKnr AS INT NO-UNDO.
  30. &SCOPED-DEFINE Tabelle Artbw
  31. &SCOPED-DEFINE TabWhere /* USE-INDEX Benutzer-k1 ~
  32. WHERE {&Tabelle}.Benutzer = tRowObject.Benutzer
  33. */
  34. { incl/datdefinition.i }
  35. /* _UIB-CODE-BLOCK-END */
  36. &ANALYZE-RESUME
  37. &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
  38. /* ******************** Preprocessor Definitions ******************** */
  39. &Scoped-define PROCEDURE-TYPE SmartDataObject
  40. &Scoped-define DB-AWARE yes
  41. &Scoped-define ADM-SUPPORTED-LINKS Data-Source,Data-Target,Navigation-Target,Update-Target,Commit-Target,Filter-Target
  42. /* Db-Required definitions. */
  43. &IF DEFINED(DB-REQUIRED) = 0 &THEN
  44. &GLOBAL-DEFINE DB-REQUIRED TRUE
  45. &ENDIF
  46. &GLOBAL-DEFINE DB-REQUIRED-START &IF {&DB-REQUIRED} &THEN
  47. &GLOBAL-DEFINE DB-REQUIRED-END &ENDIF
  48. &Scoped-define QUERY-NAME Query-Main
  49. /* Internal Tables (found by Frame, Query & Browse Queries) */
  50. &Scoped-define INTERNAL-TABLES Artbw
  51. /* Definitions for QUERY Query-Main */
  52. &Scoped-Define ENABLED-FIELDS Artnr Inhalt Jahr Bez1 Datum Menge VGeb_Me GGeb_Me Rab_Art Rab_Wert Aktion~
  53. Preis Net_Betr Aufnr Faknr Fak_Dat DokNr Lag_Buch
  54. &Scoped-define ENABLED-FIELDS-IN-Artbw Artnr Inhalt Jahr Bez1 Datum Menge ~
  55. VGeb_Me GGeb_Me Rab_Art Rab_Wert Aktion Preis Net_Betr Aufnr Faknr Fak_Dat ~
  56. Lag_Buch
  57. &Scoped-Define DATA-FIELDS Artnr Inhalt Jahr Bez1 Datum Menge VGeb_Me GGeb_Me Rab_Art Rab_Wert Aktion~
  58. Preis Net_Betr Aufnr Faknr Fak_Dat DokNr Lag_Buch
  59. &Scoped-define DATA-FIELDS-IN-Artbw Artnr Inhalt Jahr Bez1 Datum Menge ~
  60. VGeb_Me GGeb_Me Rab_Art Rab_Wert Aktion Preis Net_Betr Aufnr Faknr Fak_Dat ~
  61. Lag_Buch
  62. &Scoped-Define MANDATORY-FIELDS
  63. &Scoped-Define APPLICATION-SERVICE
  64. &Scoped-Define ASSIGN-LIST
  65. &Scoped-Define DATA-FIELD-DEFS "d-kunbw.i"
  66. &Scoped-define QUERY-STRING-Query-Main FOR EACH Artbw NO-LOCK INDEXED-REPOSITION
  67. {&DB-REQUIRED-START}
  68. &Scoped-define OPEN-QUERY-Query-Main OPEN QUERY Query-Main FOR EACH Artbw NO-LOCK INDEXED-REPOSITION.
  69. {&DB-REQUIRED-END}
  70. &Scoped-define TABLES-IN-QUERY-Query-Main Artbw
  71. &Scoped-define FIRST-TABLE-IN-QUERY-Query-Main Artbw
  72. /* Custom List Definitions */
  73. /* List-1,List-2,List-3,List-4,List-5,List-6 */
  74. /* _UIB-PREPROCESSOR-BLOCK-END */
  75. &ANALYZE-RESUME
  76. /* ************************ Function Prototypes ********************** */
  77. {&DB-REQUIRED-START}
  78. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD openQuery dTables _DB-REQUIRED
  79. FUNCTION openQuery RETURNS LOGICAL
  80. ( /* parameter-definitions */ ) FORWARD.
  81. /* _UIB-CODE-BLOCK-END */
  82. &ANALYZE-RESUME
  83. {&DB-REQUIRED-END}
  84. /* *********************** Control Definitions ********************** */
  85. {&DB-REQUIRED-START}
  86. /* Query definitions */
  87. &ANALYZE-SUSPEND
  88. DEFINE QUERY Query-Main FOR
  89. Artbw SCROLLING.
  90. &ANALYZE-RESUME
  91. {&DB-REQUIRED-END}
  92. /* ************************ Frame Definitions *********************** */
  93. /* *********************** Procedure Settings ************************ */
  94. &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
  95. /* Settings for THIS-PROCEDURE
  96. Type: SmartDataObject
  97. Allow: Query
  98. Frames: 0
  99. Add Fields to: Neither
  100. Other Settings: PERSISTENT-ONLY COMPILE APPSERVER DB-AWARE
  101. */
  102. /* This procedure should always be RUN PERSISTENT. Report the error, */
  103. /* then cleanup and return. */
  104. IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
  105. MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT.":U
  106. VIEW-AS ALERT-BOX ERROR BUTTONS OK.
  107. RETURN.
  108. END.
  109. &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
  110. /* ************************* Create Window ************************** */
  111. &ANALYZE-SUSPEND _CREATE-WINDOW
  112. /* DESIGN Window definition (used by the UIB)
  113. CREATE WINDOW dTables ASSIGN
  114. HEIGHT = 1.62
  115. WIDTH = 56.4.
  116. /* END WINDOW DEFINITION */
  117. */
  118. &ANALYZE-RESUME
  119. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB dTables
  120. /* ************************* Included-Libraries *********************** */
  121. {src/adm2/data.i}
  122. /* _UIB-CODE-BLOCK-END */
  123. &ANALYZE-RESUME
  124. /* *********** Runtime Attributes and AppBuilder Settings *********** */
  125. &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
  126. /* SETTINGS FOR WINDOW dTables
  127. VISIBLE,,RUN-PERSISTENT */
  128. /* _RUN-TIME-ATTRIBUTES-END */
  129. &ANALYZE-RESUME
  130. /* Setting information for Queries and Browse Widgets fields */
  131. &ANALYZE-SUSPEND _QUERY-BLOCK QUERY Query-Main
  132. /* Query rebuild information for SmartDataObject Query-Main
  133. _TblList = "AnaDat.Artbw"
  134. _Options = "NO-LOCK INDEXED-REPOSITION"
  135. _FldNameList[1] > AnaDat.Artbw.Artnr
  136. "Artnr" "Artnr" ? ? "integer" ? ? ? ? ? ? yes ? no 7.2 yes ""
  137. _FldNameList[2] > AnaDat.Artbw.Inhalt
  138. "Inhalt" "Inhalt" ? ? "integer" ? ? ? ? ? ? yes ? no 5.2 yes ""
  139. _FldNameList[3] > AnaDat.Artbw.Jahr
  140. "Jahr" "Jahr" ? ? "integer" ? ? ? ? ? ? yes ? no 4.8 yes ""
  141. _FldNameList[4] > AnaDat.Artbw.Bez1
  142. "Bez1" "Bez1" ? ? "character" ? ? ? ? ? ? yes ? no 30 yes ""
  143. _FldNameList[5] > AnaDat.Artbw.Datum
  144. "Datum" "Datum" ? ? "date" ? ? ? ? ? ? yes ? no 10.8 yes ""
  145. _FldNameList[6] > AnaDat.Artbw.Menge
  146. "Menge" "Menge" ? ? "decimal" ? ? ? ? ? ? yes ? no 8.8 yes ""
  147. _FldNameList[7] > AnaDat.Artbw.VGeb_Me
  148. "VGeb_Me" "VGeb_Me" ? "zzz9.99-" "decimal" ? ? ? ? ? ? yes ? no 9.6 yes ""
  149. _FldNameList[8] > AnaDat.Artbw.GGeb_Me
  150. "GGeb_Me" "GGeb_Me" ? "zz9.99-" "decimal" ? ? ? ? ? ? yes ? no 9.8 yes ""
  151. _FldNameList[9] > AnaDat.Artbw.Rab_Art
  152. "Rab_Art" "Rab_Art" ? ? "integer" ? ? ? ? ? ? yes ? no 7.8 yes ""
  153. _FldNameList[10] > AnaDat.Artbw.Rab_Wert
  154. "Rab_Wert" "Rab_Wert" ? "zz9.999-" "decimal" ? ? ? ? ? ? yes ? no 9.8 yes ""
  155. _FldNameList[11] > AnaDat.Artbw.Aktion
  156. "Aktion" "Aktion" ? "J/N" "logical" ? ? ? ? ? ? yes ? no 6 yes ""
  157. _FldNameList[12] > AnaDat.Artbw.Preis
  158. "Preis" "Preis" ? "zzz9.999" "decimal" ? ? ? ? ? ? yes ? no 8.4 yes ""
  159. _FldNameList[13] > AnaDat.Artbw.Net_Betr
  160. "Net_Betr" "Net_Betr" ? "zzz,zz9.999-" "decimal" ? ? ? ? ? ? yes ? no 11.6 yes ""
  161. _FldNameList[14] > AnaDat.Artbw.Aufnr
  162. "Aufnr" "Aufnr" ? ? "integer" ? ? ? ? ? ? yes ? no 7.2 yes ""
  163. _FldNameList[15] > AnaDat.Artbw.Faknr
  164. "Faknr" "Faknr" ? ? "integer" ? ? ? ? ? ? yes ? no 7.2 yes ""
  165. _FldNameList[16] > AnaDat.Artbw.Fak_Dat
  166. "Fak_Dat" "Fak_Dat" ? ? "date" ? ? ? ? ? ? yes ? no 10.8 yes ""
  167. _FldNameList[17] > "_<CALC>"
  168. "IF (RowObject.Faknr > 0) THEN ('F' + TRIM(STRING(RowObject.Faknr,'zzzz999999'))) ELSE ('A' + TRIM(STRING(RowObject.Aufnr,'zzzz999999')))" "DokNr" "DokNr" "x(8)" "character" ? ? ? ? ? ? yes ? no 8 no ?
  169. _FldNameList[18] > AnaDat.Artbw.Lag_Buch
  170. "Lag_Buch" "Lag_Buch" ? ? "logical" ? ? ? ? ? ? yes ? no 9.8 yes ?
  171. _Design-Parent is WINDOW dTables @ ( 1.14 , 2.6 )
  172. */ /* QUERY Query-Main */
  173. &ANALYZE-RESUME
  174. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK dTables
  175. /* *************************** Main Block *************************** */
  176. { incl/datmainblock.i }
  177. fOpen = FALSE.
  178. &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
  179. RUN initializeObject.
  180. &ENDIF
  181. /* _UIB-CODE-BLOCK-END */
  182. &ANALYZE-RESUME
  183. /* ********************** Internal Procedures *********************** */
  184. {&DB-REQUIRED-START}
  185. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE DATA.CALCULATE dTables DATA.CALCULATE _DB-REQUIRED
  186. PROCEDURE DATA.CALCULATE :
  187. /*------------------------------------------------------------------------------
  188. Purpose: Calculate all the Calculated Expressions found in the
  189. SmartDataObject.
  190. Parameters: <none>
  191. ------------------------------------------------------------------------------*/
  192. ASSIGN
  193. rowObject.DokNr = (IF (RowObject.Faknr > 0) THEN ('F' + TRIM(STRING(RowObject.Faknr,'zzzz999999'))) ELSE ('A' + TRIM(STRING(RowObject.Aufnr,'zzzz999999'))))
  194. .
  195. END PROCEDURE.
  196. /* _UIB-CODE-BLOCK-END */
  197. &ANALYZE-RESUME
  198. {&DB-REQUIRED-END}
  199. {&DB-REQUIRED-START}
  200. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE dataAvailable dTables _DB-REQUIRED
  201. PROCEDURE dataAvailable :
  202. /*------------------------------------------------------------------------------
  203. Purpose: Super Override
  204. Parameters:
  205. Notes:
  206. ------------------------------------------------------------------------------*/
  207. { incl/datdataavailable.i }
  208. END PROCEDURE.
  209. /* _UIB-CODE-BLOCK-END */
  210. &ANALYZE-RESUME
  211. {&DB-REQUIRED-END}
  212. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI dTables _DEFAULT-DISABLE
  213. PROCEDURE disable_UI :
  214. /*------------------------------------------------------------------------------
  215. Purpose: DISABLE the User Interface
  216. Parameters: <none>
  217. Notes: Here we clean-up the user-interface by deleting
  218. dynamic widgets we have created and/or hide
  219. frames. This procedure is usually called when
  220. we are ready to "clean-up" after running.
  221. ------------------------------------------------------------------------------*/
  222. /* Hide all frames. */
  223. IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
  224. END PROCEDURE.
  225. /* _UIB-CODE-BLOCK-END */
  226. &ANALYZE-RESUME
  227. {&DB-REQUIRED-START}
  228. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE initializeObject dTables _DB-REQUIRED
  229. PROCEDURE initializeObject :
  230. /*------------------------------------------------------------------------------
  231. Purpose: Super Override
  232. Parameters:
  233. Notes:
  234. ------------------------------------------------------------------------------*/
  235. { incl/datinitialize.i }
  236. END PROCEDURE.
  237. /* _UIB-CODE-BLOCK-END */
  238. &ANALYZE-RESUME
  239. {&DB-REQUIRED-END}
  240. {&DB-REQUIRED-START}
  241. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE REPOS dTables _DB-REQUIRED
  242. PROCEDURE REPOS :
  243. /*------------------------------------------------------------------------------
  244. Purpose:
  245. Parameters: <none>
  246. Notes:
  247. ------------------------------------------------------------------------------*/
  248. DEF INPUT PARAMETER ipRecid AS RECID NO-UNDO.
  249. FIND Artbw WHERE RECID(Artbw) = ipRecid NO-LOCK NO-ERROR.
  250. IF NOT AVAILABLE Artbw THEN RETURN.
  251. DYNAMIC-FUNCTION('fetchRowIdent':U, INPUT STRING(ROWID(Artbw)), INPUT ? ).
  252. END PROCEDURE.
  253. /* _UIB-CODE-BLOCK-END */
  254. &ANALYZE-RESUME
  255. {&DB-REQUIRED-END}
  256. {&DB-REQUIRED-START}
  257. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE REPOS_TABELLE dTables _DB-REQUIRED
  258. PROCEDURE REPOS_TABELLE :
  259. /*------------------------------------------------------------------------------
  260. Purpose:
  261. Parameters: <none>
  262. Notes:
  263. ------------------------------------------------------------------------------*/
  264. { incl/datrepos.i }
  265. END PROCEDURE.
  266. /* _UIB-CODE-BLOCK-END */
  267. &ANALYZE-RESUME
  268. {&DB-REQUIRED-END}
  269. {&DB-REQUIRED-START}
  270. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_FILTER dTables _DB-REQUIRED
  271. PROCEDURE SET_FILTER :
  272. /*------------------------------------------------------------------------------
  273. Purpose:
  274. Parameters: <none>
  275. Notes:
  276. ------------------------------------------------------------------------------*/
  277. { incl/datsetfilter.i }
  278. END PROCEDURE.
  279. /* _UIB-CODE-BLOCK-END */
  280. &ANALYZE-RESUME
  281. {&DB-REQUIRED-END}
  282. {&DB-REQUIRED-START}
  283. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_OPENFLAG dTables _DB-REQUIRED
  284. PROCEDURE SET_OPENFLAG :
  285. /*------------------------------------------------------------------------------
  286. Purpose:
  287. Parameters: <none>
  288. Notes:
  289. ------------------------------------------------------------------------------*/
  290. { incl/datsetopenflag.i }
  291. END PROCEDURE.
  292. /* _UIB-CODE-BLOCK-END */
  293. &ANALYZE-RESUME
  294. {&DB-REQUIRED-END}
  295. {&DB-REQUIRED-START}
  296. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE SET_SORT dTables _DB-REQUIRED
  297. PROCEDURE SET_SORT :
  298. /*------------------------------------------------------------------------------
  299. Purpose:
  300. Parameters: <none>
  301. Notes:
  302. ------------------------------------------------------------------------------*/
  303. { incl/datsetsort.i }
  304. END PROCEDURE.
  305. /* _UIB-CODE-BLOCK-END */
  306. &ANALYZE-RESUME
  307. {&DB-REQUIRED-END}
  308. /* ************************ Function Implementations ***************** */
  309. {&DB-REQUIRED-START}
  310. &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION openQuery dTables _DB-REQUIRED
  311. FUNCTION openQuery RETURNS LOGICAL
  312. ( /* parameter-definitions */ ) :
  313. /*------------------------------------------------------------------------------
  314. Purpose: Super Override
  315. Notes:
  316. ------------------------------------------------------------------------------*/
  317. DEF VAR Felder AS CHAR NO-UNDO.
  318. DEF VAR Inhalt AS CHAR NO-UNDO.
  319. DEF VAR ix AS INT NO-UNDO.
  320. DEF VAR cFeld AS CHAR NO-UNDO.
  321. DEF VAR lVerkauf AS LOG NO-UNDO.
  322. DEF VAR lEinkauf AS LOG NO-UNDO.
  323. DEF VAR iVonArt AS INT NO-UNDO.
  324. DEF VAR iBisArt AS INT NO-UNDO.
  325. IF NOT fOpen THEN RETURN FALSE.
  326. xWhere = ''.
  327. xSort = ''.
  328. xString = ''.
  329. Felder = DYNAMIC-FUNCTION('getForeignFields':U) NO-ERROR.
  330. Inhalt = DYNAMIC-FUNCTION('getForeignValues':U) NO-ERROR.
  331. iVonArt = 1.
  332. iBisArt = 20.
  333. lVerkauf = DYNAMIC-FUNCTION('getHistorieVerkaeufe':U) NO-ERROR.
  334. lEinkauf = DYNAMIC-FUNCTION('getHistorieEinkaeufe':U) NO-ERROR.
  335. IF NOT lEinkauf THEN iBisArt = 10.
  336. IF NOT lVerkauf THEN iVonArt = 11.
  337. ix = LOOKUP('Knr', Felder, ',') / 2.
  338. iKnr = INTEGER(ENTRY (ix, Inhalt, CHR(01))).
  339. /* xWhere = 'Aufko.Firma = ' + QUOTER(Firma) + ' AND ' */
  340. /* + 'Aufko.Auf_Sta = ' + STRING(Auf_Sta) + ' '. */
  341. xString = 'FOR EACH Artbw WHERE Artbw.Firma = "&1" '
  342. + 'AND Artbw.Knr = &2 '
  343. + 'AND Artbw.Tr_Art >= &3 '
  344. + 'AND Artbw.Tr_Art <= &4 '.
  345. xString = SUBSTITUTE(xString, Firma, iKnr, iVonArt, iBisArt ).
  346. xString = xString + ' NO-LOCK INDEXED-REPOSITION '.
  347. IF cSort = '' THEN DO:
  348. cSort = 'Datum'.
  349. fDesc = TRUE.
  350. END.
  351. { incl/datopenquery.i }
  352. IF xWhere <> '' THEN DYNAMIC-FUNCTION('setQueryWhere':U , INPUT xWhere ).
  353. IF xString <> '' THEN DYNAMIC-FUNCTION('setQueryString':U, INPUT xString).
  354. IF LOOKUP('Datum', xSort, ',') = 0 THEN DO:
  355. xSort = xSort + ' BY Datum DESCENDING '.
  356. END.
  357. IF xSort <> '' THEN DYNAMIC-FUNCTION('setQuerySort':U , INPUT xSort ).
  358. RETURN SUPER( ).
  359. END FUNCTION.
  360. /* _UIB-CODE-BLOCK-END */
  361. &ANALYZE-RESUME
  362. {&DB-REQUIRED-END}