Really, this should be it, for the passing income.
[capital-apms-progress.git] / forecast / b-prop-fc-param.w
blobc45331a816e67bb36448e103d28cebbf2c163140
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
2 &ANALYZE-RESUME
3 /* Connected Databases
4 */
5 &Scoped-define WINDOW-NAME CURRENT-WINDOW
6 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS B-table-Win
7 /*------------------------------------------------------------------------
9 File:
11 Description:
13 ------------------------------------------------------------------------*/
15 CREATE WIDGET-POOL.
17 /* *************************** Definitions ************************** */
19 DEF VAR key-name AS CHAR NO-UNDO.
20 DEF VAR key-value AS CHAR NO-UNDO.
22 DEF WORK-TABLE SavePFP NO-UNDO LIKE PropForecastParam.
23 CREATE SavePFP.
24 FIND Month WHERE Month.StartDate <= TODAY AND Month.EndDate >= TODAY NO-LOCK NO-ERROR.
25 IF AVAILABLE(Month) THEN DO:
26 SavePFP.MonthCode = Month.MonthCode.
27 FIND FIRST FinancialYear WHERE FinancialYear.FinancialYearCode > Month.FinancialYearCode NO-LOCK NO-ERROR.
28 IF AVAILABLE(FinancialYear) THEN
29 FIND FIRST Month OF FinancialYear NO-LOCK NO-ERROR.
30 IF AVAILABLE(Month) THEN SavePFP.MonthCode = Month.MonthCode.
31 END.
33 DEF VAR line-modified AS LOGI NO-UNDO INITIAL No.
34 DEF VAR last-line AS LOGI NO-UNDO INITIAL No.
35 DEF VAR new-record AS LOGI NO-UNDO INITIAL No.
36 DEF VAR entry-date AS DATE NO-UNDO.
37 DEF BUFFER tmp_Month2 FOR Month.
39 DEFINE TEMP-TABLE tmp_Month NO-UNDO LIKE Month
40 FIELD EnteredDate AS DATE FORMAT "99/99/9999" INITIAL TODAY.
42 ON FIND OF PropForecastParam DO:
43 FIND tmp_Month2 WHERE tmp_Month2.MonthCode = PropForecastParam.MonthCode NO-LOCK NO-ERROR.
44 IF AVAILABLE(tmp_Month2) THEN
45 entry-date = tmp_Month2.StartDate.
46 ELSE
47 entry-date = DATE( MONTH(entry-date), 1, YEAR(entry-date)).
49 FIND tmp_Month WHERE tmp_Month.MonthCode = PropForecastParam.MonthCode NO-ERROR.
50 IF NOT AVAILABLE(tmp_Month) THEN FIND FIRST tmp_Month.
51 tmp_Month.EnteredDate = entry-date.
53 END.
55 /* _UIB-CODE-BLOCK-END */
56 &ANALYZE-RESUME
59 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
61 /* ******************** Preprocessor Definitions ******************** */
63 &Scoped-define PROCEDURE-TYPE SmartBrowser
65 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
67 /* Name of first Frame and/or Browse and/or first Query */
68 &Scoped-define FRAME-NAME f_browser
69 &Scoped-define BROWSE-NAME br_table
71 /* Internal Tables (found by Frame, Query & Browse Queries) */
72 &Scoped-define INTERNAL-TABLES PropForecastParam
74 /* Define KEY-PHRASE in case it is used by any query. */
75 &Scoped-define KEY-PHRASE TRUE
77 /* Definitions for BROWSE br_table */
78 &Scoped-define FIELDS-IN-QUERY-br_table PropForecastParam.PropertyCode tmp_Month.EnteredDate PropForecastParam.ParameterID PropForecastParam.ParameterValue
79 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_table PropForecastParam.PropertyCode ~
80 tmp_Month.EnteredDate ~
81 PropForecastParam.ParameterID ~
82 PropForecastParam.ParameterValue
83 &Scoped-define FIELD-PAIRS-IN-QUERY-br_table~
84 ~{&FP1}PropertyCode ~{&FP2}PropertyCode ~{&FP3}~
85 ~{&FP1}EnteredDate ~{&FP2}EnteredDate ~{&FP3}~
86 ~{&FP1}ParameterID ~{&FP2}ParameterID ~{&FP3}~
87 ~{&FP1}ParameterValue ~{&FP2}ParameterValue ~{&FP3}
88 &Scoped-define ENABLED-TABLES-IN-QUERY-br_table PropForecastParam tmp_Month
89 &Scoped-define FIRST-ENABLED-TABLE-IN-QUERY-br_table PropForecastParam
90 &Scoped-define SECOND-ENABLED-TABLE-IN-QUERY-br_table tmp_Month
91 &Scoped-define SELF-NAME br_table
92 &Scoped-define OPEN-QUERY-br_table OPEN QUERY {&SELF-NAME} FOR EACH PropForecastParam WHERE ~{&KEY-PHRASE} NO-LOCK ~{&SORTBY-PHRASE}.
93 &Scoped-define TABLES-IN-QUERY-br_table PropForecastParam
94 &Scoped-define FIRST-TABLE-IN-QUERY-br_table PropForecastParam
97 /* Definitions for FRAME f_browser */
99 /* Standard List Definitions */
100 &Scoped-Define ENABLED-OBJECTS br_table btn_add-line
102 /* Custom List Definitions */
103 /* List-1,List-2,List-3,List-4,List-5,List-6 */
105 /* _UIB-PREPROCESSOR-BLOCK-END */
106 &ANALYZE-RESUME
109 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
110 /* Actions: ? adm/support/keyedit.w ? ? ? */
111 /* STRUCTURED-DATA
112 <KEY-OBJECT>
113 &BROWSE-NAME
114 </KEY-OBJECT>
115 <FOREIGN-KEYS>
116 MonthCode|y|y|TTPL.PropForecastParam.MonthCode
117 PropertyCode|y|y|TTPL.PropForecastParam.PropertyCode
118 </FOREIGN-KEYS>
119 <EXECUTING-CODE>
120 **************************
121 * Set attributes related to FOREIGN KEYS
123 RUN set-attribute-list (
124 'Keys-Accepted = "MonthCode,PropertyCode",
125 Keys-Supplied = "MonthCode,PropertyCode"':U).
127 /* Tell the ADM to use the OPEN-QUERY-CASES. */
128 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
129 /**************************
130 </EXECUTING-CODE> */
131 /* _UIB-CODE-BLOCK-END */
132 &ANALYZE-RESUME
134 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
135 /* Actions: ? adm/support/advqedit.w ? ? ? */
136 /* STRUCTURED-DATA
137 <KEY-OBJECT>
138 &BROWSE-NAME
139 </KEY-OBJECT>
140 <SORTBY-OPTIONS>
141 </SORTBY-OPTIONS>
142 <SORTBY-RUN-CODE>
143 ************************
144 * Set attributes related to SORTBY-OPTIONS */
145 RUN set-attribute-list (
146 'SortBy-Options = ""':U).
147 /************************
148 </SORTBY-RUN-CODE>
149 <FILTER-ATTRIBUTES>
150 </FILTER-ATTRIBUTES> */
152 /* _UIB-CODE-BLOCK-END */
153 &ANALYZE-RESUME
156 /* *********************** Control Definitions ********************** */
159 /* Definitions of the field level widgets */
160 DEFINE BUTTON btn_add-line
161 LABEL "Button 1"
162 SIZE 15 BY 1.15.
164 /* Query definitions */
165 &ANALYZE-SUSPEND
166 DEFINE QUERY br_table FOR
167 PropForecastParam SCROLLING.
168 &ANALYZE-RESUME
170 /* Browse definitions */
171 DEFINE BROWSE br_table
172 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table B-table-Win _FREEFORM
173 QUERY br_table NO-LOCK DISPLAY
174 PropForecastParam.PropertyCode COLUMN-LABEL "Property" FORMAT "99999":C
175 tmp_Month.EnteredDate COLUMN-LABEL "Starting On" WIDTH 9
176 PropForecastParam.ParameterID FORMAT "X(50)" WIDTH 14
177 PropForecastParam.ParameterValue FORMAT "X(1024)" WIDTH 45
178 ENABLE
179 PropForecastParam.PropertyCode
180 tmp_Month.EnteredDate HELP "The first day of the parameters effects"
181 PropForecastParam.ParameterID
182 PropForecastParam.ParameterValue
183 /* _UIB-CODE-BLOCK-END */
184 &ANALYZE-RESUME
185 WITH NO-ASSIGN SEPARATORS SIZE 82.29 BY 14.2
186 BGCOLOR 15 FONT 10.
189 /* ************************ Frame Definitions *********************** */
191 DEFINE FRAME f_browser
192 br_table AT ROW 1 COL 1
193 btn_add-line AT ROW 2.4 COL 35.29
194 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
195 SIDE-LABELS NO-UNDERLINE THREE-D
196 AT COL 1 ROW 1 SCROLLABLE
197 BGCOLOR 16 FGCOLOR 0 FONT 10.
200 /* *********************** Procedure Settings ************************ */
202 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
203 /* Settings for THIS-PROCEDURE
204 Type: SmartBrowser
205 Allow: Basic,Browse
206 Frames: 1
207 Add Fields to: EXTERNAL-TABLES
208 Other Settings: PERSISTENT-ONLY COMPILE
211 /* This procedure should always be RUN PERSISTENT. Report the error, */
212 /* then cleanup and return. */
213 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
214 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
215 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
216 RETURN.
217 END.
219 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
221 /* ************************* Create Window ************************** */
223 &ANALYZE-SUSPEND _CREATE-WINDOW
224 /* DESIGN Window definition (used by the UIB)
225 CREATE WINDOW B-table-Win ASSIGN
226 HEIGHT = 14.35
227 WIDTH = 106.86.
228 /* END WINDOW DEFINITION */
230 &ANALYZE-RESUME
233 /* *************** Runtime Attributes and UIB Settings ************** */
235 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
236 /* SETTINGS FOR WINDOW B-table-Win
237 NOT-VISIBLE,,RUN-PERSISTENT */
238 /* SETTINGS FOR FRAME f_browser
239 NOT-VISIBLE Size-to-Fit */
240 /* BROWSE-TAB br_table 1 f_browser */
241 ASSIGN
242 FRAME f_browser:SCROLLABLE = FALSE
243 FRAME f_browser:HIDDEN = TRUE.
245 /* _RUN-TIME-ATTRIBUTES-END */
246 &ANALYZE-RESUME
249 /* Setting information for Queries and Browse Widgets fields */
251 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_table
252 /* Query rebuild information for BROWSE br_table
253 _START_FREEFORM
254 OPEN QUERY {&SELF-NAME} FOR EACH PropForecastParam WHERE ~{&KEY-PHRASE} NO-LOCK
255 ~{&SORTBY-PHRASE}.
256 _END_FREEFORM
257 _Options = "NO-LOCK KEY-PHRASE SORTBY-PHRASE"
258 _TblOptList = ", OUTER,"
259 _Query is NOT OPENED
260 */ /* BROWSE br_table */
261 &ANALYZE-RESUME
263 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME f_browser
264 /* Query rebuild information for FRAME f_browser
265 _Options = "NO-LOCK"
266 _Query is NOT OPENED
267 */ /* FRAME f_browser */
268 &ANALYZE-RESUME
273 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB B-table-Win
274 /* ************************* Included-Libraries *********************** */
276 {src/adm/method/browser.i}
277 {inc/method/m-drlvwr.i}
279 /* _UIB-CODE-BLOCK-END */
280 &ANALYZE-RESUME
285 /* ************************ Control Triggers ************************ */
287 &Scoped-define SELF-NAME f_browser
288 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL f_browser B-table-Win
289 ON RETURN OF FRAME f_browser
290 ANYWHERE DO:
291 IF LOOKUP( FOCUS:TYPE, 'FILL-IN,COMBO-BOX,EDITOR' ) <> 0 OR
292 (FOCUS:TYPE = 'BUTTON':U AND FOCUS:DYNAMIC) THEN
294 APPLY 'TAB':U TO FOCUS.
295 RETURN NO-APPLY.
296 END.
297 END.
299 /* _UIB-CODE-BLOCK-END */
300 &ANALYZE-RESUME
303 &Scoped-define BROWSE-NAME br_table
304 &Scoped-define SELF-NAME br_table
305 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
306 ON ENTRY OF br_table IN FRAME f_browser
309 DEF VAR n-results AS INT NO-UNDO.
310 DEF VAR s-focused AS LOGI NO-UNDO INIT ?.
311 DEF VAR n-row AS LOGI NO-UNDO INIT ?.
312 IF LOOKUP( LAST-EVENT:LABEL, 'ENTER,TAB,MOUSE-SELECT-UP':U ) = 0 THEN RETURN.
314 n-row = {&BROWSE-NAME}:NEW-ROW IN FRAME {&FRAME-NAME}.
316 n-results = NUM-RESULTS("{&BROWSE-NAME}":U).
317 IF NOT ( n-results = ? OR n-results = 0 ) THEN
318 s-focused = {&BROWSE-NAME}:SELECT-FOCUSED-ROW().
320 line-modified = No.
321 IF n-row THEN DO:
322 /* Set the default screen-values */
323 RUN set-default-values.
324 line-modified = Yes.
325 END.
326 ELSE IF NOT AVAILABLE PropForecastParam THEN RETURN.
328 IF TRIM(PropForecastParam.ParameterID:SCREEN-VALUE IN BROWSE {&BROWSE-NAME}) = "" THEN
329 APPLY 'ENTRY':U TO PropForecastParam.ParameterID IN BROWSE {&BROWSE-NAME}.
330 ELSE
331 APPLY 'ENTRY':U TO PropForecastParam.PropertyCode IN BROWSE {&BROWSE-NAME}.
333 RETURN NO-APPLY.
335 END.
337 /* _UIB-CODE-BLOCK-END */
338 &ANALYZE-RESUME
341 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
342 ON ROW-ENTRY OF br_table IN FRAME f_browser
344 IF {&BROWSE-NAME}:NEW-ROW IN FRAME {&FRAME-NAME} THEN DO:
345 RUN set-default-values.
346 line-modified = Yes.
347 END.
348 ELSE
349 line-modified = No.
350 END.
352 /* _UIB-CODE-BLOCK-END */
353 &ANALYZE-RESUME
356 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
357 ON ROW-LEAVE OF br_table IN FRAME f_browser
358 OR 'CURSOR-DOWN':U OF {&SELF-NAME}
359 OR 'CURSOR-UP':U OF {&SELF-NAME}
360 OR 'ENTER':U OF PropForecastParam.ParameterValue IN BROWSE {&SELF-NAME}
361 ANYWHERE DO:
363 IF line-modified THEN DO:
364 RUN verify-line. /* and update it */
365 IF RETURN-VALUE = "FAIL" THEN RETURN NO-APPLY.
366 END.
368 RUN save-these-values.
370 END.
372 /* _UIB-CODE-BLOCK-END */
373 &ANALYZE-RESUME
376 &Scoped-define SELF-NAME btn_add-line
377 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_add-line B-table-Win
378 ON CHOOSE OF btn_add-line IN FRAME f_browser /* Button 1 */
380 RUN add-new-line.
381 END.
383 /* _UIB-CODE-BLOCK-END */
384 &ANALYZE-RESUME
387 &UNDEFINE SELF-NAME
389 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK B-table-Win
392 /* *************************** Main Block *************************** */
394 /* create the tmp_Month table from the Month table */
395 FOR EACH Month NO-LOCK:
396 CREATE tmp_Month.
397 BUFFER-COPY Month TO tmp_Month
398 ASSIGN tmp_Month.EnteredDate = Month.StartDate.
399 END.
400 CREATE tmp_Month.
402 HIDE btn_add-line IN FRAME {&FRAME-NAME}.
404 &Scoped-define SELF-NAME PropForecastParam.PropertyCode
405 ON LEAVE OF {&SELF-NAME} IN BROWSE {&BROWSE-NAME}
407 IF line-modified THEN RETURN.
408 IF INPUT BROWSE {&BROWSE-NAME} {&SELF-NAME} <> {&SELF-NAME} THEN
409 line-modified = Yes.
410 END.
413 &SCOP SELF-NAME tmp_Month.EnteredDate
414 ON LEAVE OF {&SELF-NAME} IN BROWSE {&BROWSE-NAME} DO:
415 IF line-modified THEN RETURN.
416 IF (INPUT BROWSE {&BROWSE-NAME} {&SELF-NAME}) <> {&SELF-NAME} THEN
417 line-modified = Yes.
418 END.
420 &SCOP SELF-NAME PropForecastParam.ParameterID
421 ON LEAVE OF {&SELF-NAME} IN BROWSE {&BROWSE-NAME} DO:
422 IF line-modified THEN RETURN.
423 IF (INPUT BROWSE {&BROWSE-NAME} {&SELF-NAME}) <> {&SELF-NAME} THEN
424 line-modified = Yes.
425 END.
427 &SCOP SELF-NAME PropForecastParam.ParameterValue
428 ON LEAVE OF {&SELF-NAME} IN BROWSE {&BROWSE-NAME} DO:
429 IF line-modified THEN RETURN.
430 IF (INPUT BROWSE {&BROWSE-NAME} {&SELF-NAME}) <> {&SELF-NAME} THEN
431 line-modified = Yes.
432 END.
434 &UNDEFINE SELF-NAME
436 /* _UIB-CODE-BLOCK-END */
437 &ANALYZE-RESUME
440 /* ********************** Internal Procedures *********************** */
442 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE add-new-line B-table-Win
443 PROCEDURE add-new-line :
444 /*------------------------------------------------------------------------------
445 Purpose: Inserts a new line at the end of the browse
446 ------------------------------------------------------------------------------*/
447 DO WITH FRAME {&FRAME-NAME}:
448 IF NUM-RESULTS("{&BROWSE-NAME}":U) = ? OR
449 NUM-RESULTS("{&BROWSE-NAME}":U) = 0 THEN
451 DO TRANSACTION:
452 FIND FIRST PropForecastParam WHERE NOT(PropForecastParam.PropertyCode > 0)
453 OR NOT(PropForecastParam.MonthCode > 0)
454 EXCLUSIVE-LOCK NO-ERROR.
455 IF NOT AVAILABLE(PropForecastParam) THEN CREATE PropForecastParam.
456 RUN assign-default-values.
457 END.
458 RUN local-open-query-cases.
459 END.
460 ELSE DO:
461 IF {&BROWSE-NAME}:INSERT-ROW("AFTER") THEN .
462 END.
463 END.
464 END PROCEDURE.
466 /* _UIB-CODE-BLOCK-END */
467 &ANALYZE-RESUME
470 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-open-query-cases B-table-Win adm/support/_adm-opn.p
471 PROCEDURE adm-open-query-cases :
472 /*------------------------------------------------------------------------------
473 Purpose: Opens different cases of the query based on attributes
474 such as the 'Key-Name', or 'SortBy-Case'
475 Parameters: <none>
476 ------------------------------------------------------------------------------*/
477 DEF VAR key-value AS CHAR NO-UNDO.
479 /* Look up the current key-value. */
480 RUN get-attribute ('Key-Value':U).
481 key-value = RETURN-VALUE.
483 /* Find the current record using the current Key-Name. */
484 RUN get-attribute ('Key-Name':U).
485 CASE RETURN-VALUE:
486 WHEN 'MonthCode':U THEN DO:
487 &Scope KEY-PHRASE PropForecastParam.MonthCode eq INTEGER(key-value)
488 {&OPEN-QUERY-{&BROWSE-NAME}}
489 END. /* MonthCode */
490 WHEN 'PropertyCode':U THEN DO:
491 &Scope KEY-PHRASE PropForecastParam.PropertyCode eq INTEGER(key-value)
492 {&OPEN-QUERY-{&BROWSE-NAME}}
493 END. /* PropertyCode */
494 OTHERWISE DO:
495 &Scope KEY-PHRASE TRUE
496 {&OPEN-QUERY-{&BROWSE-NAME}}
497 END. /* OTHERWISE...*/
498 END CASE.
500 END PROCEDURE.
502 /* _UIB-CODE-BLOCK-END */
503 &ANALYZE-RESUME
506 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available B-table-Win _ADM-ROW-AVAILABLE
507 PROCEDURE adm-row-available :
508 /*------------------------------------------------------------------------------
509 Purpose: Dispatched to this procedure when the Record-
510 Source has a new row available. This procedure
511 tries to get the new row (or foriegn keys) from
512 the Record-Source and process it.
513 Parameters: <none>
514 ------------------------------------------------------------------------------*/
516 /* Define variables needed by this internal procedure. */
517 {src/adm/template/row-head.i}
519 /* Process the newly available records (i.e. display fields,
520 open queries, and/or pass records on to any RECORD-TARGETS). */
521 {src/adm/template/row-end.i}
523 END PROCEDURE.
525 /* _UIB-CODE-BLOCK-END */
526 &ANALYZE-RESUME
529 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE assign-default-values B-table-Win
530 PROCEDURE assign-default-values :
531 /*------------------------------------------------------------------------------
532 Purpose:
533 ------------------------------------------------------------------------------*/
534 DEF BUFFER tmp_Prop FOR Property.
535 DEF BUFFER tmp_month2 FOR Month.
536 IF NOT AVAILABLE(PropForecastParam) THEN RETURN.
537 DO WITH FRAME {&FRAME-NAME}:
538 PropForecastParam.ParameterID = SavePFP.ParameterID.
539 PropForecastParam.ParameterValue = SavePFP.ParameterValue.
540 CASE key-name:
541 WHEN 'PropertyCode' THEN DO:
542 PropForecastParam.PropertyCode = INT(key-value).
543 FIND FIRST tmp_month2 WHERE tmp_Month2.MonthCode > SavePFP.MonthCode NO-LOCK NO-ERROR.
544 PropForecastParam.MonthCode = tmp_Month2.MonthCode.
545 END.
546 WHEN 'MonthCode' THEN DO:
547 FIND tmp_month2 WHERE tmp_Month2.MonthCode = INT(key-value) NO-LOCK NO-ERROR.
548 PropForecastParam.MonthCode = tmp_Month2.MonthCode.
549 FIND FIRST tmp_Prop WHERE tmp_Prop.Active AND tmp_Prop.PropertyCode > SavePFP.PropertyCode NO-LOCK NO-ERROR.
550 PropForecastParam.PropertyCode = (IF AVAILABLE(tmp_Prop) THEN tmp_Prop.PropertyCode ELSE 0).
551 END.
552 WHEN 'FinancialYearCode' THEN DO:
553 FIND FIRST tmp_month2 WHERE tmp_Month2.MonthCode > SavePFP.MonthCode NO-LOCK NO-ERROR.
554 PropForecastParam.MonthCode = tmp_Month2.MonthCode.
555 FIND FIRST tmp_Prop WHERE tmp_Prop.Active AND tmp_Prop.PropertyCode > SavePFP.PropertyCode NO-LOCK NO-ERROR.
556 PropForecastParam.PropertyCode = (IF AVAILABLE(tmp_Prop) THEN tmp_Prop.PropertyCode ELSE 0).
557 END.
558 END CASE.
559 FIND tmp_Month OF PropForecastParam NO-ERROR.
560 END.
561 END PROCEDURE.
563 /* _UIB-CODE-BLOCK-END */
564 &ANALYZE-RESUME
567 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE assign-line B-table-Win
568 PROCEDURE assign-line :
569 /*------------------------------------------------------------------------------
570 Purpose:
571 ------------------------------------------------------------------------------*/
572 DEF BUFFER tmp_tmp FOR tmp_Month.
573 DEF BUFFER tmp_Month2 FOR Month.
574 DEF VAR in-date AS DATE NO-UNDO.
576 /* Code placed here will execute PRIOR to standard behavior. */
577 IF NOT AVAILABLE PropForecastParam THEN RETURN.
578 in-date = INPUT BROWSE {&BROWSE-NAME} tmp_Month.EnteredDate .
580 DO TRANSACTION WITH FRAME {&FRAME-NAME}:
582 IF NOT NEW PropForecastParam THEN FIND CURRENT PropForecastParam EXCLUSIVE-LOCK.
584 ASSIGN BROWSE {&BROWSE-NAME}
585 PropForecastParam.PropertyCode
586 PropForecastParam.ParameterID
587 PropForecastParam.ParameterValue.
589 FIND tmp_Month2 WHERE tmp_Month2.StartDate <= in-date
590 AND tmp_Month2.EndDate >= in-date NO-LOCK NO-ERROR.
591 IF NOT AVAILABLE(tmp_Month2) THEN DO:
592 MESSAGE "No financial period (Month) found for the date" in-date
593 VIEW-AS ALERT-BOX ERROR.
594 RETURN ERROR.
595 END.
596 PropForecastParam.MonthCode = tmp_Month2.MonthCode.
597 tmp_Month.EnteredDate = tmp_Month2.StartDate.
598 FIND CURRENT PropForecastParam NO-LOCK.
599 END.
601 RUN display-line.
603 END PROCEDURE.
605 /* _UIB-CODE-BLOCK-END */
606 &ANALYZE-RESUME
609 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI B-table-Win _DEFAULT-DISABLE
610 PROCEDURE disable_UI :
611 /*------------------------------------------------------------------------------
612 Purpose: DISABLE the User Interface
613 Parameters: <none>
614 Notes: Here we clean-up the user-interface by deleting
615 dynamic widgets we have created and/or hide
616 frames. This procedure is usually called when
617 we are ready to "clean-up" after running.
618 ------------------------------------------------------------------------------*/
619 /* Hide all frames. */
620 HIDE FRAME f_browser.
621 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
622 END PROCEDURE.
624 /* _UIB-CODE-BLOCK-END */
625 &ANALYZE-RESUME
628 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE display-line B-table-Win
629 PROCEDURE display-line :
630 /*------------------------------------------------------------------------------
631 Purpose:
632 ------------------------------------------------------------------------------*/
633 IF NOT AVAILABLE PropForecastParam THEN RETURN.
635 IF NUM-RESULTS("{&BROWSE-NAME}":U) > 1 THEN
636 DISPLAY {&ENABLED-FIELDS-IN-QUERY-{&BROWSE-NAME}} WITH BROWSE {&BROWSE-NAME}.
637 ELSE
638 RUN local-open-query-cases.
640 END PROCEDURE.
642 /* _UIB-CODE-BLOCK-END */
643 &ANALYZE-RESUME
646 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-cancel-record B-table-Win
647 PROCEDURE local-cancel-record :
648 /*------------------------------------------------------------------------------
649 Purpose: Override standard ADM method
650 Notes:
651 ------------------------------------------------------------------------------*/
653 /* Code placed here will execute PRIOR to standard behavior. */
654 IF new-record THEN DO TRANSACTION WITH FRAME {&FRAME-NAME}:
655 FIND CURRENT PropForecastParam EXCLUSIVE-LOCK NO-ERROR.
656 IF AVAILABLE(PropForecastParam) THEN DELETE PropForecastParam.
658 IF {&BROWSE-NAME}:DELETE-CURRENT-ROW() THEN .
659 new-record = No.
660 END.
661 ELSE DO TRANSACTION WITH FRAME {&FRAME-NAME}:
662 FIND CURRENT PropForecastParam EXCLUSIVE-LOCK NO-ERROR.
663 IF AVAILABLE(PropForecastParam) THEN
664 BUFFER-COPY SavePFP TO PropForecastParam.
665 END.
667 END PROCEDURE.
669 /* _UIB-CODE-BLOCK-END */
670 &ANALYZE-RESUME
673 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-display-record B-table-Win
674 PROCEDURE local-display-record :
675 /*------------------------------------------------------------------------------
676 Purpose: Override standard ADM method
677 Notes:
678 ------------------------------------------------------------------------------*/
680 RUN display-line.
682 END PROCEDURE.
684 /* _UIB-CODE-BLOCK-END */
685 &ANALYZE-RESUME
688 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-open-query-cases B-table-Win
689 PROCEDURE local-open-query-cases :
690 /*------------------------------------------------------------------------------
691 Purpose: Override standard ADM method
692 Notes:
693 ------------------------------------------------------------------------------*/
694 DEF VAR m-1 AS INT NO-UNDO.
695 DEF VAR m-2 AS INT NO-UNDO.
697 IF key-name = 'MonthCode':U THEN DO:
698 /* Show everything from that month on */
699 &Scope KEY-PHRASE PropForecastParam.MonthCode >= INTEGER(key-value)
700 {&OPEN-QUERY-{&BROWSE-NAME}}
701 RETURN.
702 END.
703 ELSE IF key-name = 'FinancialYearCode':U THEN DO:
704 /* Show everything during that financial year */
705 FIND FIRST Month WHERE Month.FinancialYearCode = INT(key-value) NO-LOCK.
706 FIND LAST Month WHERE Month.FinancialYearCode = INT(key-value) NO-LOCK.
707 &Scope KEY-PHRASE PropForecastParam.MonthCode >= m-1 AND PropForecastParam.MonthCode <= m-2
708 {&OPEN-QUERY-{&BROWSE-NAME}}
709 RETURN.
710 END.
712 /* Dispatch standard ADM method. */
713 RUN dispatch IN THIS-PROCEDURE ( INPUT 'open-query-cases':U ) .
715 /* Code placed here will execute AFTER standard behavior. */
717 END PROCEDURE.
719 /* _UIB-CODE-BLOCK-END */
720 &ANALYZE-RESUME
723 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE save-these-values B-table-Win
724 PROCEDURE save-these-values :
725 /*------------------------------------------------------------------------------
726 Purpose:
727 ------------------------------------------------------------------------------*/
728 IF AVAILABLE(PropForecastParam) THEN DO:
729 BUFFER-COPY PropForecastParam TO SavePFP.
730 new-record = No.
731 END.
732 ELSE
733 new-record = Yes.
734 END PROCEDURE.
736 /* _UIB-CODE-BLOCK-END */
737 &ANALYZE-RESUME
740 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
741 PROCEDURE send-key :
742 /*------------------------------------------------------------------------------
743 Purpose: Sends a requested KEY value back to the calling
744 SmartObject.
745 Parameters: <see adm/template/sndkytop.i>
746 ------------------------------------------------------------------------------*/
748 /* Define variables needed by this internal procedure. */
749 {src/adm/template/sndkytop.i}
751 /* Return the key value associated with each key case. */
752 {src/adm/template/sndkycas.i "MonthCode" "PropForecastParam" "MonthCode"}
753 {src/adm/template/sndkycas.i "PropertyCode" "PropForecastParam" "PropertyCode"}
755 /* Close the CASE statement and end the procedure. */
756 {src/adm/template/sndkyend.i}
758 END PROCEDURE.
760 /* _UIB-CODE-BLOCK-END */
761 &ANALYZE-RESUME
764 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records B-table-Win _ADM-SEND-RECORDS
765 PROCEDURE send-records :
766 /*------------------------------------------------------------------------------
767 Purpose: Send record ROWID's for all tables used by
768 this file.
769 Parameters: see template/snd-head.i
770 ------------------------------------------------------------------------------*/
772 /* Define variables needed by this internal procedure. */
773 {src/adm/template/snd-head.i}
775 /* For each requested table, put it's ROWID in the output list. */
776 {src/adm/template/snd-list.i "PropForecastParam"}
778 /* Deal with any unexpected table requests before closing. */
779 {src/adm/template/snd-end.i}
781 END PROCEDURE.
783 /* _UIB-CODE-BLOCK-END */
784 &ANALYZE-RESUME
787 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-default-values B-table-Win
788 PROCEDURE set-default-values :
789 /*------------------------------------------------------------------------------
790 Purpose:
791 ------------------------------------------------------------------------------*/
792 DEF BUFFER tmp_Prop FOR Property.
793 DEF BUFFER tmp_month2 FOR Month.
794 DO WITH FRAME {&FRAME-NAME}:
795 PropForecastParam.ParameterID:SCREEN-VALUE IN BROWSE {&BROWSE-NAME} = SavePFP.ParameterID.
796 PropForecastParam.ParameterValue:SCREEN-VALUE IN BROWSE {&BROWSE-NAME} = SavePFP.ParameterValue.
797 CASE key-name:
798 WHEN 'PropertyCode' THEN DO:
799 PropForecastParam.PropertyCode:SCREEN-VALUE IN BROWSE {&BROWSE-NAME} = key-value.
800 FIND FIRST tmp_month2 WHERE tmp_Month2.MonthCode > SavePFP.MonthCode NO-LOCK NO-ERROR.
801 tmp_Month.EnteredDate:SCREEN-VALUE IN BROWSE {&BROWSE-NAME} = STRING( tmp_Month2.StartDate, tmp_Month.EnteredDate:FORMAT IN BROWSE {&BROWSE-NAME}).
802 END.
803 WHEN 'MonthCode' THEN DO:
804 FIND tmp_month2 WHERE tmp_Month2.MonthCode = INT(key-value) NO-LOCK NO-ERROR.
805 tmp_Month.EnteredDate:SCREEN-VALUE IN BROWSE {&BROWSE-NAME} = STRING( tmp_Month2.StartDate, tmp_Month.EnteredDate:FORMAT IN BROWSE {&BROWSE-NAME}).
806 FIND FIRST tmp_Prop WHERE tmp_Prop.Active AND tmp_Prop.PropertyCode > SavePFP.PropertyCode NO-LOCK NO-ERROR.
807 PropForecastParam.PropertyCode:SCREEN-VALUE IN BROWSE {&BROWSE-NAME} = STRING( (IF AVAILABLE(tmp_Prop) THEN tmp_Prop.PropertyCode ELSE ?), PropForecastParam.PropertyCode:FORMAT IN BROWSE {&BROWSE-NAME}).
808 END.
809 WHEN 'FinancialYearCode' THEN DO:
810 FIND FIRST tmp_month2 WHERE tmp_Month2.MonthCode > SavePFP.MonthCode NO-LOCK NO-ERROR.
811 tmp_Month.EnteredDate:SCREEN-VALUE IN BROWSE {&BROWSE-NAME} = STRING( tmp_Month2.StartDate, tmp_Month.EnteredDate:FORMAT IN BROWSE {&BROWSE-NAME}).
812 FIND FIRST tmp_Prop WHERE tmp_Prop.Active AND tmp_Prop.PropertyCode > SavePFP.PropertyCode NO-LOCK NO-ERROR.
813 PropForecastParam.PropertyCode:SCREEN-VALUE IN BROWSE {&BROWSE-NAME} = STRING( (IF AVAILABLE(tmp_Prop) THEN tmp_Prop.PropertyCode ELSE ?), PropForecastParam.PropertyCode:FORMAT IN BROWSE {&BROWSE-NAME}).
814 END.
815 END CASE.
816 END.
817 END PROCEDURE.
819 /* _UIB-CODE-BLOCK-END */
820 &ANALYZE-RESUME
823 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
824 PROCEDURE state-changed :
825 /* -----------------------------------------------------------
826 Purpose:
827 Parameters: <none>
828 Notes:
829 -------------------------------------------------------------*/
830 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
831 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
833 CASE p-state:
834 /* Object instance CASEs can go here to replace standard behavior
835 or add new cases. */
836 {src/adm/template/bstates.i}
837 END CASE.
838 END PROCEDURE.
840 /* _UIB-CODE-BLOCK-END */
841 &ANALYZE-RESUME
844 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-line B-table-Win
845 PROCEDURE update-line :
846 /*------------------------------------------------------------------------------
847 Purpose: Update the current invoice line.
848 ------------------------------------------------------------------------------*/
850 /* Create a new line if needed and update the details */
851 IF {&BROWSE-NAME}:NEW-ROW IN FRAME {&FRAME-NAME} THEN DO:
852 FIND FIRST PropForecastParam WHERE NOT(PropForecastParam.PropertyCode > 0)
853 OR NOT(PropForecastParam.MonthCode > 0)
854 EXCLUSIVE-LOCK NO-ERROR.
855 IF NOT AVAILABLE(PropForecastParam) THEN CREATE PropForecastParam.
856 IF {&BROWSE-NAME}:CREATE-RESULT-LIST-ENTRY() THEN.
857 RUN assign-line.
858 END.
859 ELSE
860 RUN assign-line.
862 line-modified = No.
864 END PROCEDURE.
866 /* _UIB-CODE-BLOCK-END */
867 &ANALYZE-RESUME
870 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Key-Name B-table-Win
871 PROCEDURE use-Key-Name :
872 /*------------------------------------------------------------------------------
873 Purpose:
874 ------------------------------------------------------------------------------*/
875 DEF INPUT PARAMETER new-key-name AS CHAR NO-UNDO.
876 key-name = new-key-name.
877 END PROCEDURE.
879 /* _UIB-CODE-BLOCK-END */
880 &ANALYZE-RESUME
883 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE use-Key-Value B-table-Win
884 PROCEDURE use-Key-Value :
885 /*------------------------------------------------------------------------------
886 Purpose:
887 ------------------------------------------------------------------------------*/
888 DEF INPUT PARAMETER new-key-value AS CHAR NO-UNDO.
889 key-value = new-key-value.
891 IF key-name = "PropertyCode" THEN
892 SavePFP.PropertyCode = INT(key-value).
893 ELSE IF key-name = "MonthCode" THEN
894 SavePFP.MonthCode = INT(key-value).
896 END PROCEDURE.
898 /* _UIB-CODE-BLOCK-END */
899 &ANALYZE-RESUME
902 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE verify-line B-table-Win
903 PROCEDURE verify-line :
904 /*------------------------------------------------------------------------------
905 Purpose:
906 ------------------------------------------------------------------------------*/
907 DEF VAR err-field AS HANDLE NO-UNDO.
909 err-field = WIDGET-HANDLE( RETURN-VALUE ).
911 RUN update-line.
913 END PROCEDURE.
915 /* _UIB-CODE-BLOCK-END */
916 &ANALYZE-RESUME