Add %age area column to vacancies section.
[capital-apms-progress.git] / rplctn / b-repcol.w
blobf05fd86f437ac896f93b344d482a871377178549
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
2 &ANALYZE-RESUME
3 /* Connected Databases
4 ttpl PROGRESS
5 */
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS B-table-Win
8 /*------------------------------------------------------------------------
9 File:
10 Description:
11 ------------------------------------------------------------------------*/
13 CREATE WIDGET-POOL.
15 /* *************************** Definitions ************************** */
17 /* Local Variable Definitions --- */
19 DEF VAR repl-date AS CHAR NO-UNDO FORMAT "X(12)" LABEL "Repl Date".
20 DEF VAR repl-time AS CHAR NO-UNDO FORMAT "X(12)" LABEL "Repl Time".
22 /* _UIB-CODE-BLOCK-END */
23 &ANALYZE-RESUME
26 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
28 /* ******************** Preprocessor Definitions ******************** */
30 &Scoped-define PROCEDURE-TYPE SmartBrowser
32 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
34 /* Name of first Frame and/or Browse and/or first Query */
35 &Scoped-define FRAME-NAME F-Main
36 &Scoped-define BROWSE-NAME br_table
38 /* Internal Tables (found by Frame, Query & Browse Queries) */
39 &Scoped-define INTERNAL-TABLES ReplCollisionLog
41 /* Define KEY-PHRASE in case it is used by any query. */
42 &Scoped-define KEY-PHRASE TRUE
44 /* Definitions for BROWSE br_table */
45 &Scoped-define FIELDS-IN-QUERY-br_table ReplCollisionLog.LoadFile ~
46 ReplCollisionLog.TableToRepl ReplCollisionLog.ReplDate ~
47 STRING( ReplCollisionLog.ReplTime, 'HH:MM:SS') @ repl-time ~
48 ReplCollisionLog.ReplEvent ReplCollisionLog.TransActID ~
49 ReplCollisionLog.ReplId ReplCollisionLog.CollisionID ~
50 ReplCollisionLog.Collided
51 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_table
52 &Scoped-define FIELD-PAIRS-IN-QUERY-br_table
53 &Scoped-define OPEN-QUERY-br_table OPEN QUERY br_table FOR EACH ReplCollisionLog WHERE ~{&KEY-PHRASE} NO-LOCK ~
54 ~{&SORTBY-PHRASE}.
55 &Scoped-define TABLES-IN-QUERY-br_table ReplCollisionLog
56 &Scoped-define FIRST-TABLE-IN-QUERY-br_table ReplCollisionLog
59 /* Definitions for FRAME F-Main */
61 /* Standard List Definitions */
62 &Scoped-Define ENABLED-OBJECTS br_table edt_record
63 &Scoped-Define DISPLAYED-OBJECTS edt_record
65 /* Custom List Definitions */
66 /* List-1,List-2,List-3,List-4,List-5,List-6 */
68 /* _UIB-PREPROCESSOR-BLOCK-END */
69 &ANALYZE-RESUME
72 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
73 /* Actions: ? adm/support/keyedit.w ? ? ? */
74 /* STRUCTURED-DATA
75 <KEY-OBJECT>
76 &BROWSE-NAME
77 </KEY-OBJECT>
78 <FOREIGN-KEYS>
79 CollisionID||y|ttpl.ReplCollisionLog.CollisionID
80 </FOREIGN-KEYS>
81 <EXECUTING-CODE>
82 **************************
83 * Set attributes related to FOREIGN KEYS
85 RUN set-attribute-list (
86 'Keys-Accepted = ,
87 Keys-Supplied = "CollisionID"':U).
89 /* Tell the ADM to use the OPEN-QUERY-CASES. */
90 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
91 /**************************
92 </EXECUTING-CODE> */
93 /* _UIB-CODE-BLOCK-END */
94 &ANALYZE-RESUME
96 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
97 /* Actions: ? adm/support/advqedit.w ? ? ? */
98 /* STRUCTURED-DATA
99 <KEY-OBJECT>
100 &BROWSE-NAME
101 </KEY-OBJECT>
102 <SORTBY-OPTIONS>
103 </SORTBY-OPTIONS>
104 <SORTBY-RUN-CODE>
105 ************************
106 * Set attributes related to SORTBY-OPTIONS */
107 RUN set-attribute-list (
108 'SortBy-Options = ""':U).
109 /************************
110 </SORTBY-RUN-CODE>
111 <FILTER-ATTRIBUTES>
112 </FILTER-ATTRIBUTES> */
114 /* _UIB-CODE-BLOCK-END */
115 &ANALYZE-RESUME
117 /* ************************ Function Prototypes ********************** */
119 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-differences B-table-Win
120 FUNCTION get-differences RETURNS LOGICAL
121 ( INPUT-OUTPUT s1 AS CHAR, INPUT-OUTPUT s2 AS CHAR ) FORWARD.
123 /* _UIB-CODE-BLOCK-END */
124 &ANALYZE-RESUME
126 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-disp-program B-table-Win
127 FUNCTION get-disp-program RETURNS CHARACTER
128 ( INPUT table-name AS CHAR ) FORWARD.
130 /* _UIB-CODE-BLOCK-END */
131 &ANALYZE-RESUME
134 /* *********************** Control Definitions ********************** */
137 /* Definitions of the field level widgets */
138 DEFINE VARIABLE edt_record AS CHARACTER
139 VIEW-AS EDITOR NO-WORD-WRAP SCROLLBAR-HORIZONTAL SCROLLBAR-VERTICAL
140 SIZE 92 BY 16.4
141 FONT 8 NO-UNDO.
143 /* Query definitions */
144 &ANALYZE-SUSPEND
145 DEFINE QUERY br_table FOR
146 ReplCollisionLog SCROLLING.
147 &ANALYZE-RESUME
149 /* Browse definitions */
150 DEFINE BROWSE br_table
151 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table B-table-Win _STRUCTURED
152 QUERY br_table NO-LOCK DISPLAY
153 ReplCollisionLog.LoadFile COLUMN-LABEL "Load File"
154 ReplCollisionLog.TableToRepl
155 ReplCollisionLog.ReplDate COLUMN-LABEL "Repl Date"
156 STRING( ReplCollisionLog.ReplTime, 'HH:MM:SS') @ repl-time COLUMN-LABEL "Repl Time" FORMAT "X(10)"
157 ReplCollisionLog.ReplEvent
158 ReplCollisionLog.TransActID
159 ReplCollisionLog.ReplId
160 ReplCollisionLog.CollisionID
161 ReplCollisionLog.Collided FORMAT "Yes/No"
162 /* _UIB-CODE-BLOCK-END */
163 &ANALYZE-RESUME
164 WITH NO-ASSIGN NO-ROW-MARKERS SEPARATORS SIZE 92 BY 9.2
165 BGCOLOR 15 FONT 10.
168 /* ************************ Frame Definitions *********************** */
170 DEFINE FRAME F-Main
171 br_table AT ROW 1 COL 1
172 edt_record AT ROW 10.4 COL 1 NO-LABEL
173 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
174 SIDE-LABELS NO-UNDERLINE THREE-D
175 AT COL 1 ROW 1 SCROLLABLE
176 FONT 10.
179 /* *********************** Procedure Settings ************************ */
181 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
182 /* Settings for THIS-PROCEDURE
183 Type: SmartBrowser
184 Allow: Basic,Browse
185 Frames: 1
186 Add Fields to: EXTERNAL-TABLES
187 Other Settings: PERSISTENT-ONLY COMPILE
190 /* This procedure should always be RUN PERSISTENT. Report the error, */
191 /* then cleanup and return. */
192 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
193 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
194 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
195 RETURN.
196 END.
198 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
200 /* ************************* Create Window ************************** */
202 &ANALYZE-SUSPEND _CREATE-WINDOW
203 /* DESIGN Window definition (used by the UIB)
204 CREATE WINDOW B-table-Win ASSIGN
205 HEIGHT = 29.15
206 WIDTH = 106.57.
207 /* END WINDOW DEFINITION */
209 &ANALYZE-RESUME
212 /* *************** Runtime Attributes and UIB Settings ************** */
214 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
215 /* SETTINGS FOR WINDOW B-table-Win
216 NOT-VISIBLE,,RUN-PERSISTENT */
217 /* SETTINGS FOR FRAME F-Main
218 NOT-VISIBLE Size-to-Fit */
219 /* BROWSE-TAB br_table 1 F-Main */
220 ASSIGN
221 FRAME F-Main:SCROLLABLE = FALSE
222 FRAME F-Main:HIDDEN = TRUE.
224 /* _RUN-TIME-ATTRIBUTES-END */
225 &ANALYZE-RESUME
228 /* Setting information for Queries and Browse Widgets fields */
230 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_table
231 /* Query rebuild information for BROWSE br_table
232 _TblList = "ttpl.ReplCollisionLog"
233 _Options = "NO-LOCK KEY-PHRASE SORTBY-PHRASE"
234 _FldNameList[1] > ttpl.ReplCollisionLog.LoadFile
235 "ReplCollisionLog.LoadFile" "Load File" ? "character" ? ? ? ? ? ? no ?
236 _FldNameList[2] = ttpl.ReplCollisionLog.TableToRepl
237 _FldNameList[3] > ttpl.ReplCollisionLog.ReplDate
238 "ReplCollisionLog.ReplDate" "Repl Date" ? "date" ? ? ? ? ? ? no ?
239 _FldNameList[4] > "_<CALC>"
240 "STRING( ReplCollisionLog.ReplTime, 'HH:MM:SS') @ repl-time" "Repl Time" "X(10)" ? ? ? ? ? ? ? no ?
241 _FldNameList[5] = ttpl.ReplCollisionLog.ReplEvent
242 _FldNameList[6] = ttpl.ReplCollisionLog.TransActID
243 _FldNameList[7] = ttpl.ReplCollisionLog.ReplId
244 _FldNameList[8] = ttpl.ReplCollisionLog.CollisionID
245 _FldNameList[9] > ttpl.ReplCollisionLog.Collided
246 "ReplCollisionLog.Collided" ? "Yes/No" "logical" ? ? ? ? ? ? no ?
247 _Query is NOT OPENED
248 */ /* BROWSE br_table */
249 &ANALYZE-RESUME
251 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
252 /* Query rebuild information for FRAME F-Main
253 _Options = "NO-LOCK"
254 _Query is NOT OPENED
255 */ /* FRAME F-Main */
256 &ANALYZE-RESUME
261 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB B-table-Win
262 /* ************************* Included-Libraries *********************** */
264 {src/adm/method/browser.i}
265 {inc/method/m-drlvwr.i}
267 /* _UIB-CODE-BLOCK-END */
268 &ANALYZE-RESUME
273 /* ************************ Control Triggers ************************ */
275 &Scoped-define BROWSE-NAME br_table
276 &Scoped-define SELF-NAME br_table
277 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
278 ON ROW-ENTRY OF br_table IN FRAME F-Main
280 /* This code displays initial values for newly added or copied rows. */
281 {src/adm/template/brsentry.i}
282 END.
284 /* _UIB-CODE-BLOCK-END */
285 &ANALYZE-RESUME
288 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
289 ON ROW-LEAVE OF br_table IN FRAME F-Main
291 /* Do not disable this code or no updates will take place except
292 by pressing the Save button on an Update SmartPanel. */
293 {src/adm/template/brsleave.i}
294 END.
296 /* _UIB-CODE-BLOCK-END */
297 &ANALYZE-RESUME
300 &UNDEFINE SELF-NAME
302 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK B-table-Win
305 /* *************************** Main Block *************************** */
307 &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
308 RUN dispatch IN THIS-PROCEDURE ('initialize':U).
309 &ENDIF
311 /* _UIB-CODE-BLOCK-END */
312 &ANALYZE-RESUME
315 /* ********************** Internal Procedures *********************** */
317 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-open-query-cases B-table-Win adm/support/_adm-opn.p
318 PROCEDURE adm-open-query-cases :
319 /*------------------------------------------------------------------------------
320 Purpose: Opens different cases of the query based on attributes
321 such as the 'Key-Name', or 'SortBy-Case'
322 Parameters: <none>
323 ------------------------------------------------------------------------------*/
325 /* No Foreign keys are accepted by this SmartObject. */
327 {&OPEN-QUERY-{&BROWSE-NAME}}
329 END PROCEDURE.
331 /* _UIB-CODE-BLOCK-END */
332 &ANALYZE-RESUME
335 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available B-table-Win _ADM-ROW-AVAILABLE
336 PROCEDURE adm-row-available :
337 /*------------------------------------------------------------------------------
338 Purpose: Dispatched to this procedure when the Record-
339 Source has a new row available. This procedure
340 tries to get the new row (or foriegn keys) from
341 the Record-Source and process it.
342 Parameters: <none>
343 ------------------------------------------------------------------------------*/
345 /* Define variables needed by this internal procedure. */
346 {src/adm/template/row-head.i}
348 /* Process the newly available records (i.e. display fields,
349 open queries, and/or pass records on to any RECORD-TARGETS). */
350 {src/adm/template/row-end.i}
352 END PROCEDURE.
354 /* _UIB-CODE-BLOCK-END */
355 &ANALYZE-RESUME
358 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI B-table-Win _DEFAULT-DISABLE
359 PROCEDURE disable_UI :
360 /*------------------------------------------------------------------------------
361 Purpose: DISABLE the User Interface
362 Parameters: <none>
363 Notes: Here we clean-up the user-interface by deleting
364 dynamic widgets we have created and/or hide
365 frames. This procedure is usually called when
366 we are ready to "clean-up" after running.
367 ------------------------------------------------------------------------------*/
368 /* Hide all frames. */
369 HIDE FRAME F-Main.
370 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
371 END PROCEDURE.
373 /* _UIB-CODE-BLOCK-END */
374 &ANALYZE-RESUME
377 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-value-changed B-table-Win
378 PROCEDURE inst-value-changed :
379 /*------------------------------------------------------------------------------
380 Purpose:
381 Parameters: <none>
382 Notes:
383 ------------------------------------------------------------------------------*/
385 DO WITH FRAME {&FRAME-NAME}:
387 DEF VAR disp-program AS CHAR NO-UNDO.
388 DEF VAR before-value AS CHAR NO-UNDO.
389 DEF VAR after-value AS CHAR NO-UNDO.
391 IF AVAILABLE ReplCollisionLog THEN DO:
392 disp-program = get-disp-program( ReplCollisionLog.TableToRepl ).
393 IF ReplCollisionLog.ReplEvent = "C" THEN
394 before-value = "Record created:~n".
395 ELSE
396 RUN VALUE(disp-program) ( ReplCollisionLog.ReplBI, OUTPUT before-value ).
398 IF ReplCollisionLog.ReplEvent = "D" THEN
399 after-value = "Record deleted".
400 ELSE
401 RUN VALUE(disp-program) ( ReplCollisionLog.ReplAI, OUTPUT after-value ).
403 IF ReplCollisionLog.ReplEvent = "M" THEN
404 get-differences( before-value, after-value ).
405 END.
407 edt_record:SCREEN-VALUE = before-value + "~n" + after-value.
409 END.
411 END PROCEDURE.
413 /* _UIB-CODE-BLOCK-END */
414 &ANALYZE-RESUME
417 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE purge-log B-table-Win
418 PROCEDURE purge-log :
419 /*------------------------------------------------------------------------------
420 Purpose:
421 ------------------------------------------------------------------------------*/
423 FOR EACH ReplCollisionLog:
424 DELETE ReplCollisionLog.
425 END.
427 RUN dispatch( 'open-query':U ).
429 END PROCEDURE.
431 /* _UIB-CODE-BLOCK-END */
432 &ANALYZE-RESUME
435 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
436 PROCEDURE send-key :
437 /*------------------------------------------------------------------------------
438 Purpose: Sends a requested KEY value back to the calling
439 SmartObject.
440 Parameters: <see adm/template/sndkytop.i>
441 ------------------------------------------------------------------------------*/
443 /* Define variables needed by this internal procedure. */
444 {src/adm/template/sndkytop.i}
446 /* Return the key value associated with each key case. */
447 {src/adm/template/sndkycas.i "CollisionID" "ReplCollisionLog" "CollisionID"}
449 /* Close the CASE statement and end the procedure. */
450 {src/adm/template/sndkyend.i}
452 END PROCEDURE.
454 /* _UIB-CODE-BLOCK-END */
455 &ANALYZE-RESUME
458 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records B-table-Win _ADM-SEND-RECORDS
459 PROCEDURE send-records :
460 /*------------------------------------------------------------------------------
461 Purpose: Send record ROWID's for all tables used by
462 this file.
463 Parameters: see template/snd-head.i
464 ------------------------------------------------------------------------------*/
466 /* Define variables needed by this internal procedure. */
467 {src/adm/template/snd-head.i}
469 /* For each requested table, put it's ROWID in the output list. */
470 {src/adm/template/snd-list.i "ReplCollisionLog"}
472 /* Deal with any unexpected table requests before closing. */
473 {src/adm/template/snd-end.i}
475 END PROCEDURE.
477 /* _UIB-CODE-BLOCK-END */
478 &ANALYZE-RESUME
481 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
482 PROCEDURE state-changed :
483 /* -----------------------------------------------------------
484 Purpose:
485 Parameters: <none>
486 Notes:
487 -------------------------------------------------------------*/
488 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
489 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
491 CASE p-state:
492 /* Object instance CASEs can go here to replace standard behavior
493 or add new cases. */
494 {src/adm/template/bstates.i}
495 END CASE.
496 END PROCEDURE.
498 /* _UIB-CODE-BLOCK-END */
499 &ANALYZE-RESUME
502 /* ************************ Function Implementations ***************** */
504 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-differences B-table-Win
505 FUNCTION get-differences RETURNS LOGICAL
506 ( INPUT-OUTPUT s1 AS CHAR, INPUT-OUTPUT s2 AS CHAR ) :
507 /*------------------------------------------------------------------------------
508 Purpose:
509 Notes:
510 ------------------------------------------------------------------------------*/
511 DEF VAR i AS INT NO-UNDO.
512 DEF VAR n AS INT NO-UNDO.
513 DEF VAR s1a AS CHAR NO-UNDO.
514 DEF VAR s2a AS CHAR NO-UNDO.
516 n = NUM-ENTRIES( s1, "~n").
517 IF NUM-ENTRIES( s2, "~n") <> n THEN RETURN FALSE.
519 DO i = 1 TO n:
520 IF ENTRY(i, s1, "~n") <> ENTRY(i, s2, "~n") THEN
521 s2a = s2a + (IF s2a = "" THEN "After: " ELSE " ")
522 + ENTRY(i, s2, "~n") + "~n".
523 ENTRY( i, s1, "~n") = (IF i = 1 THEN "Before: " ELSE " ")
524 + ENTRY(i, s1, "~n").
526 END.
528 s2 = TRIM(s2a, "~n").
530 RETURN s1 <> "" AND s2 <> "".
532 END FUNCTION.
534 /* _UIB-CODE-BLOCK-END */
535 &ANALYZE-RESUME
538 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-disp-program B-table-Win
539 FUNCTION get-disp-program RETURNS CHARACTER
540 ( INPUT table-name AS CHAR ) :
541 /*------------------------------------------------------------------------------
542 Purpose: Get the name of the generic record display program for the
543 given table. If it does not exist then generate the code for the
544 program and compile it.
545 Notes:
546 ------------------------------------------------------------------------------*/
548 DEF VAR disp-program AS CHAR NO-UNDO.
550 FIND _File WHERE _File._File-Name = table-name NO-LOCK.
552 OS-CREATE-DIR VALUE( "rplctn/disp" ).
553 disp-program = "rplctn/disp/" + _File._Dump-Name + ".p".
555 IF SEARCH( disp-program ) = ? THEN DO:
556 RUN rplctn/mkrecstr.p( table-name, disp-program ).
557 IF RETURN-VALUE = "FAIL" THEN RETURN RETURN-VALUE.
558 END.
560 RETURN disp-program.
562 END FUNCTION.
564 /* _UIB-CODE-BLOCK-END */
565 &ANALYZE-RESUME