1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS V-table-Win
8 /*------------------------------------------------------------------------
11 ------------------------------------------------------------------------*/
13 /* *************************** Definitions
************************** */
15 DEF VAR user-name
AS CHAR INITIAL "Andrew" NO-UNDO.
16 {inc
/username.i
"user-name"}
17 &GLOB REPORT-ID "portfolio-expiry"
19 /* _UIB-CODE-BLOCK-END
*/
23 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
25 /* ******************** Preprocessor Definitions
******************** */
27 &Scoped-define PROCEDURE-TYPE SmartViewer
29 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
31 /* Name of first Frame and
/or Browse and
/or first Query
*/
32 &Scoped-define FRAME-NAME F-Main
35 &Scoped-define EXTERNAL-TABLES RP
36 &Scoped-define FIRST-EXTERNAL-TABLE RP
39 /* Need to scope the external tables to this procedure
*/
40 DEFINE QUERY external_tables
FOR RP.
41 /* Standard List Definitions
*/
42 &Scoped-Define ENABLED-FIELDS RP.Int1 RP.Int2 RP.Char2
43 &Scoped-define FIELD-PAIRS~
44 ~
{&FP1}Int1 ~{&FP2}Int1 ~{&FP3}~
45 ~
{&FP1}Int2 ~{&FP2}Int2 ~{&FP3}~
46 ~
{&FP1}Char2 ~{&FP2}Char2 ~{&FP3}
47 &Scoped-define ENABLED-TABLES RP
48 &Scoped-define FIRST-ENABLED-TABLE RP
49 &Scoped-Define ENABLED-OBJECTS RECT-1 btn_Browse Btn_OK
50 &Scoped-Define DISPLAYED-FIELDS RP.Int1 RP.Int2 RP.Char2
52 /* Custom List Definitions
*/
53 /* ADM-CREATE-FIELDS
,ADM-ASSIGN-FIELDS
,List-3
,List-4
,List-5
,List-6
*/
55 /* _UIB-PREPROCESSOR-BLOCK-END
*/
60 /* *********************** Control Definitions
********************** */
63 /* Definitions of the field level widgets
*/
64 DEFINE BUTTON btn_Browse
68 DEFINE BUTTON Btn_OK
AUTO-GO DEFAULT
73 DEFINE RECTANGLE RECT-1
74 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
78 /* ************************ Frame Definitions
*********************** */
81 RP.Int1
AT ROW 1.8 COL 16.14 COLON-ALIGNED
85 RP.Int2
AT ROW 2.8 COL 16.14 COLON-ALIGNED
86 LABEL "Months Per Period"
89 RP.Char2
AT ROW 5.4 COL 5.86 COLON-ALIGNED
93 btn_Browse
AT ROW 5.4 COL 52.43
94 Btn_OK
AT ROW 7.8 COL 50.14
96 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
97 SIDE-LABELS NO-UNDERLINE THREE-D
98 AT COL 1 ROW 1 SCROLLABLE
100 DEFAULT-BUTTON Btn_OK.
103 /* *********************** Procedure Settings
************************ */
105 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
106 /* Settings for
THIS-PROCEDURE
108 External Tables
: ttpl.RP
109 Allow
: Basic
,DB-Fields
111 Add Fields to
: EXTERNAL-TABLES
112 Other Settings
: PERSISTENT-ONLY
COMPILE
115 /* This procedure should always be
RUN PERSISTENT. Report the error
, */
116 /* then cleanup and return.
*/
117 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
118 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
119 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
123 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
125 /* ************************* Create Window
************************** */
127 &ANALYZE-SUSPEND _CREATE-WINDOW
128 /* DESIGN Window definition
(used by the UIB
)
129 CREATE WINDOW V-table-Win
ASSIGN
132 /* END WINDOW DEFINITION
*/
137 /* *************** Runtime Attributes and UIB Settings
************** */
139 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
140 /* SETTINGS
FOR WINDOW V-table-Win
141 VISIBLE,,RUN-PERSISTENT
*/
142 /* SETTINGS
FOR FRAME F-Main
143 NOT-VISIBLE Size-to-Fit
*/
145 FRAME F-Main
:SCROLLABLE = FALSE
146 FRAME F-Main
:HIDDEN = TRUE.
148 /* SETTINGS
FOR FILL-IN RP.Char2
IN FRAME F-Main
150 /* SETTINGS
FOR FILL-IN RP.Int1
IN FRAME F-Main
152 /* SETTINGS
FOR FILL-IN RP.Int2
IN FRAME F-Main
154 /* _RUN-TIME-ATTRIBUTES-END
*/
158 /* Setting information for Queries and Browse Widgets fields
*/
160 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
161 /* Query rebuild information for
FRAME F-Main
164 */ /* FRAME F-Main
*/
170 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB V-table-Win
171 /* ************************* Included-Libraries
*********************** */
173 {src
/adm
/method
/viewer.i
}
174 {inc
/method
/m-mntvwr.i
}
176 /* _UIB-CODE-BLOCK-END
*/
182 /* ************************ Control Triggers
************************ */
184 &Scoped-define SELF-NAME btn_Browse
185 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_Browse V-table-Win
186 ON CHOOSE OF btn_Browse
IN FRAME F-Main
/* Browse
*/
188 RUN select-file-dialog.
191 /* _UIB-CODE-BLOCK-END
*/
195 &Scoped-define SELF-NAME Btn_OK
196 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL Btn_OK V-table-Win
197 ON CHOOSE OF Btn_OK
IN FRAME F-Main
/* OK */
199 DISABLE {&SELF-NAME}.
204 /* _UIB-CODE-BLOCK-END
*/
210 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK V-table-Win
213 /* *************************** Main Block
*************************** */
215 &IF DEFINED(UIB_IS_RUNNING) <> 0 &THEN
216 RUN dispatch
IN THIS-PROCEDURE ('initialize'
:U
).
219 /************************ INTERNAL PROCEDURES
********************/
221 /* _UIB-CODE-BLOCK-END
*/
225 /* ********************** Internal Procedures
*********************** */
227 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available V-table-Win _ADM-ROW-AVAILABLE
228 PROCEDURE adm-row-available
:
229 /*------------------------------------------------------------------------------
230 Purpose
: Dispatched to this procedure when the Record-
231 Source has a new row available. This procedure
232 tries to get the new row
(or foriegn keys
) from
233 the Record-Source and process it.
235 ------------------------------------------------------------------------------*/
237 /* Define variables needed by this internal procedure.
*/
238 {src
/adm
/template
/row-head.i
}
240 /* Create a list of all the tables that we need to get.
*/
241 {src
/adm
/template
/row-list.i
"RP"}
243 /* Get the record
ROWID's from the RECORD-SOURCE.
*/
244 {src
/adm
/template
/row-get.i
}
246 /* FIND each record specified by the RECORD-SOURCE.
*/
247 {src
/adm
/template
/row-find.i
"RP"}
249 /* Process the newly available records
(i.e. display fields
,
250 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
251 {src
/adm
/template
/row-end.i
}
255 /* _UIB-CODE-BLOCK-END
*/
259 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI V-table-Win _DEFAULT-DISABLE
260 PROCEDURE disable_UI
:
261 /*------------------------------------------------------------------------------
262 Purpose
: DISABLE the User Interface
264 Notes
: Here we clean-up the user-interface by deleting
265 dynamic widgets we have created and
/or hide
266 frames. This procedure is usually called when
267 we are ready to
"clean-up" after running.
268 ------------------------------------------------------------------------------*/
269 /* Hide all frames.
*/
271 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
274 /* _UIB-CODE-BLOCK-END
*/
278 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable-appropriate-fields V-table-Win
279 PROCEDURE enable-appropriate-fields
:
280 /*------------------------------------------------------------------------------
281 Purpose
: As its name
!
282 ------------------------------------------------------------------------------*/
284 DO WITH FRAME {&FRAME-NAME}:
290 /* _UIB-CODE-BLOCK-END
*/
294 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-initialize V-table-Win
295 PROCEDURE inst-initialize
:
296 /*------------------------------------------------------------------------------
297 Purpose
: Initialise the necessary bits and pieces
298 ------------------------------------------------------------------------------*/
300 FIND RP
WHERE RP.ReportID
= {&REPORT-ID}
301 AND RP.UserName
= user-name
304 IF NOT AVAILABLE( RP
) THEN DO:
307 RP.ReportID
= {&REPORT-ID}
308 RP.UserName
= user-name
312 RUN dispatch
( 'display-fields'
:U
).
313 RUN dispatch
( 'enable-fields'
:U
).
314 RUN enable-appropriate-fields.
318 /* _UIB-CODE-BLOCK-END
*/
322 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pre-destroy V-table-Win
323 PROCEDURE pre-destroy
:
324 /*------------------------------------------------------------------------------
326 ------------------------------------------------------------------------------*/
327 RUN check-modified
( 'clear'
:U
).
330 /* _UIB-CODE-BLOCK-END
*/
334 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE run-report V-table-Win
335 PROCEDURE run-report
:
336 /*------------------------------------------------------------------------------
337 Purpose
: Actually run the report program.
338 ------------------------------------------------------------------------------*/
339 DEF VAR report-options
AS CHAR NO-UNDO.
341 RUN dispatch
IN THIS-PROCEDURE ('update-record'
:U
).
343 report-options
= "File," + RP.Char2
344 + "~nPeriods," + STRING(RP.Int1
)
345 + "~nPeriodMonths," + STRING(RP.Int2
).
347 RUN notify
( 'set-busy
,container-source'
:U
).
348 RUN process
/export
/portfolio-expiry.p
( report-options
).
349 RUN notify
( 'set-idle
,container-source'
:U
).
353 /* _UIB-CODE-BLOCK-END
*/
357 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE select-file-dialog V-table-Win
358 PROCEDURE select-file-dialog
:
359 /*------------------------------------------------------------------------------
361 ------------------------------------------------------------------------------*/
362 DEF VAR select-ok
AS LOGICAL INITIAL Yes
NO-UNDO.
363 DEF VAR file-name
AS CHAR NO-UNDO.
364 DEF VAR start-dir
AS CHAR NO-UNDO.
366 file-name
= INPUT FRAME {&FRAME-NAME} RP.Char2 .
367 start-dir
= SUBSTRING( file-name
, 1, R-INDEX(file-name
, "\" ) ).
369 SYSTEM-DIALOG GET-FILE file-name
FILTERS "Comma-separated values" "*.CSV"
370 SAVE-AS ASK-OVERWRITE CREATE-TEST-FILE DEFAULT-EXTENSION ".CSV"
371 INITIAL-DIR start-dir
RETURN-TO-START-DIR
372 TITLE "" USE-FILENAME UPDATE select-ok.
374 IF select-ok
THEN DO:
375 IF SUBSTRING( file-name
, R-INDEX( file-name
, ".") ) <> ".CSV" THEN DO:
376 IF (LENGTH( file-name
) - R-INDEX( file-name
, "." )) < 4 THEN
377 file-name
= SUBSTRING( file-name
, 1, R-INDEX( file-name
, ".")) + "CSV" .
379 RP.Char2
:SCREEN-VALUE IN FRAME {&FRAME-NAME} = file-name.
384 /* _UIB-CODE-BLOCK-END
*/
388 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records V-table-Win _ADM-SEND-RECORDS
389 PROCEDURE send-records
:
390 /*------------------------------------------------------------------------------
391 Purpose
: Send record
ROWID's for all tables used by
393 Parameters
: see template
/snd-head.i
394 ------------------------------------------------------------------------------*/
396 /* Define variables needed by this internal procedure.
*/
397 {src
/adm
/template
/snd-head.i
}
399 /* For each requested table
, put it's
ROWID in the output list.
*/
400 {src
/adm
/template
/snd-list.i
"RP"}
402 /* Deal with any unexpected table requests before closing.
*/
403 {src
/adm
/template
/snd-end.i
}
407 /* _UIB-CODE-BLOCK-END
*/
411 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed V-table-Win
412 PROCEDURE state-changed
:
413 /* -----------------------------------------------------------
417 -------------------------------------------------------------*/
418 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
419 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
422 /* Object instance CASEs can go here to replace standard behavior
424 {src
/adm
/template
/vstates.i
}
428 /* _UIB-CODE-BLOCK-END
*/