1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS B-table-Win
8 /*------------------------------------------------------------------------
11 ------------------------------------------------------------------------*/
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
*/
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 ~
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
*/
72 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
73 /* Actions
: ? adm
/support
/keyedit.w ? ? ?
*/
79 CollisionID||y|ttpl.ReplCollisionLog.CollisionID
82 **************************
83 * Set attributes related to FOREIGN
KEYS
85 RUN set-attribute-list
(
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 /**************************
93 /* _UIB-CODE-BLOCK-END
*/
96 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
97 /* Actions
: ? adm
/support
/advqedit.w ? ? ?
*/
105 ************************
106 * Set attributes related to SORTBY-OPTIONS
*/
107 RUN set-attribute-list
(
108 'SortBy-Options
= ""'
:U
).
109 /************************
112 </FILTER-ATTRIBUTES
> */
114 /* _UIB-CODE-BLOCK-END
*/
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
*/
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
*/
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
143 /* Query definitions
*/
145 DEFINE QUERY br_table
FOR
146 ReplCollisionLog
SCROLLING.
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
*/
164 WITH NO-ASSIGN NO-ROW-MARKERS SEPARATORS SIZE 92 BY 9.2
168 /* ************************ Frame Definitions
*********************** */
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
179 /* *********************** Procedure Settings
************************ */
181 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
182 /* Settings for
THIS-PROCEDURE
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.
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
207 /* END WINDOW DEFINITION
*/
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
*/
221 FRAME F-Main
:SCROLLABLE = FALSE
222 FRAME F-Main
:HIDDEN = TRUE.
224 /* _RUN-TIME-ATTRIBUTES-END
*/
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 ?
248 */ /* BROWSE br_table
*/
251 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
252 /* Query rebuild information for
FRAME F-Main
255 */ /* FRAME F-Main
*/
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
*/
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
}
284 /* _UIB-CODE-BLOCK-END
*/
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
}
296 /* _UIB-CODE-BLOCK-END
*/
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
).
311 /* _UIB-CODE-BLOCK-END
*/
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'
323 ------------------------------------------------------------------------------*/
325 /* No Foreign keys are accepted by this SmartObject.
*/
327 {&OPEN-QUERY-{&BROWSE-NAME}}
331 /* _UIB-CODE-BLOCK-END
*/
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.
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
}
354 /* _UIB-CODE-BLOCK-END
*/
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
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.
*/
370 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
373 /* _UIB-CODE-BLOCK-END
*/
377 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-value-changed B-table-Win
378 PROCEDURE inst-value-changed
:
379 /*------------------------------------------------------------------------------
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".
396 RUN VALUE(disp-program
) ( ReplCollisionLog.ReplBI
, OUTPUT before-value
).
398 IF ReplCollisionLog.ReplEvent
= "D" THEN
399 after-value
= "Record deleted".
401 RUN VALUE(disp-program
) ( ReplCollisionLog.ReplAI
, OUTPUT after-value
).
403 IF ReplCollisionLog.ReplEvent
= "M" THEN
404 get-differences
( before-value
, after-value
).
407 edt_record
:SCREEN-VALUE = before-value
+ "~n" + after-value.
413 /* _UIB-CODE-BLOCK-END
*/
417 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE purge-log B-table-Win
418 PROCEDURE purge-log
:
419 /*------------------------------------------------------------------------------
421 ------------------------------------------------------------------------------*/
423 FOR EACH ReplCollisionLog
:
424 DELETE ReplCollisionLog.
427 RUN dispatch
( 'open-query'
:U
).
431 /* _UIB-CODE-BLOCK-END
*/
435 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
437 /*------------------------------------------------------------------------------
438 Purpose
: Sends a requested
KEY value back to the calling
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
}
454 /* _UIB-CODE-BLOCK-END
*/
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
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
}
477 /* _UIB-CODE-BLOCK-END
*/
481 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
482 PROCEDURE state-changed
:
483 /* -----------------------------------------------------------
487 -------------------------------------------------------------*/
488 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
489 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
492 /* Object instance CASEs can go here to replace standard behavior
494 {src
/adm
/template
/bstates.i
}
498 /* _UIB-CODE-BLOCK-END
*/
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 /*------------------------------------------------------------------------------
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.
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").
528 s2
= TRIM(s2a
, "~n").
530 RETURN s1
<> "" AND s2
<> "".
534 /* _UIB-CODE-BLOCK-END
*/
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.
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.
564 /* _UIB-CODE-BLOCK-END
*/