1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 Expense Variance Report
6 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
12 DEF VAR preview
AS LOGI
NO-UNDO INIT No.
13 DEF VAR exporting
AS LOGI
NO-UNDO INIT No.
14 DEF VAR file-name
AS CHAR NO-UNDO INIT "".
15 DEF VAR by-account
AS LOGI
NO-UNDO INIT No.
16 DEF VAR consolidate-subs
AS LOGI
NO-UNDO INIT No.
17 DEF VAR show-vacant-space
AS LOGI
NO-UNDO INIT Yes.
18 DEF VAR detailed
AS LOGI
NO-UNDO INIT No.
19 DEF VAR client-code
AS CHAR NO-UNDO INIT ?.
20 DEF VAR company-list
AS CHAR NO-UNDO INIT ?.
21 DEF VAR group-list
AS CHAR NO-UNDO INIT ?.
22 DEF VAR revised
AS LOGI
NO-UNDO INIT No.
23 DEF VAR manager-code
AS INT NO-UNDO INIT ?.
24 DEF VAR region-code
AS CHAR NO-UNDO INIT ?.
25 DEF VAR entity-type
AS CHAR NO-UNDO INIT ?.
26 DEF VAR property-1
AS INT NO-UNDO INIT 0.
27 DEF VAR property-n
AS INT NO-UNDO INIT {&MAX-KEY}.
28 DEF VAR account-1
AS DEC NO-UNDO INIT 0.
29 DEF VAR account-n
AS DEC NO-UNDO INIT {&MAX-KEY}.
30 DEF VAR company-1
AS INT NO-UNDO INIT 0.
31 DEF VAR company-n
AS INT NO-UNDO INIT {&MAX-KEY}.
32 DEF VAR month-1
AS INT NO-UNDO INIT ?.
33 DEF VAR month-n
AS INT NO-UNDO INIT ?.
34 DEF VAR multiplier
AS INT NO-UNDO INIT 1.
35 DEF VAR page-title-1
AS CHAR NO-UNDO.
36 DEF VAR page-title-2
AS CHAR NO-UNDO.
39 DEF VAR user-name
AS CHAR NO-UNDO.
40 {inc
/username.i
"user-name"}
41 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
42 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
44 DEF VAR major-key
AS DEC NO-UNDO INITIAL ?.
45 DEF VAR report-key
AS DEC NO-UNDO.
46 DEF VAR pr-line
AS CHAR INIT "" NO-UNDO.
/* used everywhere to hold print line
*/
48 DEF VAR title-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
49 DEF VAR time-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,6,normal".
50 DEF VAR break1-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,12,bold".
51 DEF VAR break2-font
AS CHAR NO-UNDO INITIAL "proportional,helv,point,8,bold".
52 DEF VAR line1-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,18,lpi,9,bold".
53 DEF VAR line2-font
AS CHAR NO-UNDO INITIAL "fixed,courier,cpi,18,lpi,9,normal".
54 DEF VAR amt-fmt
AS CHAR INIT "(>>,>>>,>>9.99)" NO-UNDO.
55 IF exporting
THEN amt-fmt
= "->>>>>>>>>>9.99".
56 DEF VAR i
AS INT NO-UNDO.
60 DEF TEMP-TABLE RepLine
NO-UNDO
63 FIELD Description
AS CHAR
64 FIELD Balance
LIKE AccountBalance.Balance
65 FIELD Budget
LIKE AccountBalance.Budget
66 FIELD Variance
LIKE AccountBalance.Budget
67 FIELD Month
LIKE AccountBalance.Balance
68 INDEX XPKPseudo
IS UNIQUE PRIMARY Key Key2.
70 DEF BUFFER MajorLine
FOR RepLine.
72 /* _UIB-CODE-BLOCK-END
*/
76 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
78 /* ******************** Preprocessor Definitions
******************** */
80 &Scoped-define PROCEDURE-TYPE Procedure
81 &Scoped-define DB-AWARE no
85 /* _UIB-PREPROCESSOR-BLOCK-END
*/
89 /* ************************ Function Prototypes
********************** */
91 &IF DEFINED(EXCLUDE-include-company) = 0 &THEN
93 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-company Procedure
94 FUNCTION include-company
RETURNS LOGICAL
95 ( /* parameter-definitions
*/ ) FORWARD.
97 /* _UIB-CODE-BLOCK-END
*/
102 &IF DEFINED(EXCLUDE-include-property) = 0 &THEN
104 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-property Procedure
105 FUNCTION include-property
RETURNS LOGICAL
106 ( /* parameter-definitions
*/ ) FORWARD.
108 /* _UIB-CODE-BLOCK-END
*/
113 &IF DEFINED(EXCLUDE-include-tenant) = 0 &THEN
115 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD include-tenant Procedure
116 FUNCTION include-tenant
RETURNS LOGICAL
117 ( /* parameter-definitions
*/ ) FORWARD.
119 /* _UIB-CODE-BLOCK-END
*/
125 /* *********************** Procedure Settings
************************ */
127 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
128 /* Settings for
THIS-PROCEDURE
132 Add Fields to
: Neither
133 Other Settings
: CODE-ONLY
COMPILE
135 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
137 /* ************************* Create Window
************************** */
139 &ANALYZE-SUSPEND _CREATE-WINDOW
140 /* DESIGN Window definition
(used by the UIB
)
141 CREATE WINDOW Procedure
ASSIGN
144 /* END WINDOW DEFINITION
*/
148 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
149 /* ************************* Included-Libraries
*********************** */
151 {inc
/method
/m-txtrep.i
}
153 /* _UIB-CODE-BLOCK-END
*/
160 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
163 /* *************************** Main Block
*************************** */
165 OUTPUT TO VALUE( IF exporting
THEN file-name
ELSE txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
166 RUN pclrep-start
( preview
OR exporting
,
167 "reset,portrait,tm,2,a4,lm,6," + line1-font
).
169 RUN build-variance-info.
175 MESSAGE "Export Complete" VIEW-AS ALERT-BOX INFORMATION TITLE "Finished".
179 /* _UIB-CODE-BLOCK-END
*/
183 /* ********************** Internal Procedures
*********************** */
185 &IF DEFINED(EXCLUDE-add-one-account) = 0 &THEN
187 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE add-one-account Procedure
188 PROCEDURE add-one-account
:
189 /*------------------------------------------------------------------------------
191 ------------------------------------------------------------------------------*/
192 DEF INPUT PARAMETER et
AS CHAR NO-UNDO.
193 DEF INPUT PARAMETER ec
AS INT NO-UNDO.
194 DEF INPUT PARAMETER ac
AS DEC NO-UNDO.
196 DEF VAR delta-bal
AS DEC NO-UNDO INITIAL 0.0 .
197 DEF VAR delta-bud
AS DEC NO-UNDO INITIAL 0.0 .
198 DEF VAR delta-mth
AS DEC NO-UNDO INITIAL 0.0 .
200 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= et
201 AND AccountBalance.EntityCode
= ec
202 AND AccountBalance.AccountCode
= ac
203 AND AccountBalance.MonthCode
>= month-1
204 AND AccountBalance.MonthCode
<= month-n
NO-LOCK:
205 delta-bal
= delta-bal
+ (AccountBalance.Balance
* multiplier
).
206 delta-bud
= delta-bud
+ ((IF revised
THEN AccountBalance.RevisedBudget
ELSE AccountBalance.Budget
) * multiplier
).
207 IF AccountBalance.MonthCode
= month-n
THEN
208 delta-mth
= ((IF revised
THEN AccountBalance.RevisedBudget
ELSE AccountBalance.Budget
) * multiplier
)
209 - (AccountBalance.Balance
* multiplier
) .
213 RepLine.Balance
= RepLine.Balance
+ delta-bal.
214 RepLine.Budget
= RepLine.Budget
+ delta-bud.
215 RepLine.Variance
= (RepLine.Budget
- RepLine.Balance
) * multiplier.
216 RepLine.Month
= RepLine.Month
+ delta-mth.
218 IF AVAILABLE(MajorLine
) THEN DO:
219 MajorLine.Balance
= MajorLine.Balance
+ delta-bal.
220 MajorLine.Budget
= MajorLine.Budget
+ delta-bud.
221 MajorLine.Variance
= (MajorLine.Budget
- MajorLine.Balance
) * multiplier.
222 MajorLine.Month
= MajorLine.Month
+ delta-mth.
227 /* _UIB-CODE-BLOCK-END
*/
232 &IF DEFINED(EXCLUDE-build-each-account) = 0 &THEN
234 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-each-account Procedure
235 PROCEDURE build-each-account
:
236 /*------------------------------------------------------------------------------
238 ------------------------------------------------------------------------------*/
239 DEF VAR ac
AS DEC NO-UNDO.
241 FOR EACH ChartOfAccount
WHERE ChartOfAccount.AccountCode
>= account-1
242 AND ChartOfAccount.AccountCode
<= account-n
243 AND LOOKUP( ChartOfAccount.AccountGroupCode
, group-list
) > 0 NO-LOCK:
244 ac
= ChartOfAccount.AccountCode.
245 IF consolidate-subs
THEN ac
= TRUNC( ac
, 0 ).
247 FIND RepLine
WHERE RepLine.Key
= major-key
AND RepLine.Key2
= report-key
NO-ERROR.
248 IF NOT AVAILABLE(RepLine
) THEN DO:
250 RepLine.Key
= major-key.
251 RepLine.Key2
= report-key.
252 RepLine.Description
= STRING( ChartOfAccount.AccountCode
, (IF consolidate-subs
THEN (IF exporting
THEN "9999" ELSE " 9999 ") ELSE "9999.99"))
253 + (IF exporting
THEN '
","'
ELSE " ") + ChartOfAccount.Name .
255 RUN build-one-account
(ChartOfAccount.AccountCode
).
260 /* _UIB-CODE-BLOCK-END
*/
265 &IF DEFINED(EXCLUDE-build-each-entity) = 0 &THEN
267 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-each-entity Procedure
268 PROCEDURE build-each-entity
:
269 /*------------------------------------------------------------------------------
271 ------------------------------------------------------------------------------*/
272 DEF VAR sep
AS CHAR INITIAL " " NO-UNDO.
274 IF exporting
THEN sep
= '
","'.
277 FOR EACH Property
NO-LOCK:
278 IF NOT include-property
() THEN NEXT.
279 report-key
= Property.PropertyCode.
281 RepLine.Key
= major-key.
282 RepLine.Key2
= report-key.
283 RepLine.Description
= STRING( Property.PropertyCode
, "99999") + sep
+ Property.Name .
284 RUN build-one-entity
( entity-type
, Property.PropertyCode
).
288 FOR EACH Company
NO-LOCK:
289 IF NOT include-company
() THEN NEXT.
290 report-key
= Company.CompanyCode.
292 RepLine.Key
= major-key.
293 RepLine.Key2
= report-key.
294 RepLine.Description
= STRING( Company.CompanyCode
, "99999") + sep
+ Company.LegalName .
295 RUN build-one-entity
( entity-type
, Company.CompanyCode
).
299 FOR EACH Property
NO-LOCK:
300 IF NOT include-property
() THEN NEXT.
301 FOR EACH Tenant
WHERE Tenant.EntityType
= "P" AND Tenant.EntityCode
= Property.PropertyCode
NO-LOCK:
302 IF NOT include-tenant
() THEN NEXT.
303 report-key
= Property.PropertyCode.
304 FIND RepLine
WHERE RepLine.Key
= major-key
AND RepLine.Key2
= report-key
NO-ERROR.
305 IF NOT AVAILABLE(RepLine
) THEN DO:
307 RepLine.Key
= major-key.
308 RepLine.Key2
= report-key.
309 RepLine.Description
= STRING( Property.PropertyCode
, "99999") + sep
+ Property.Name .
311 RUN build-one-entity
( entity-type
, Tenant.TenantCode
).
314 report-key
= Property.PropertyCode.
315 FIND RepLine
WHERE RepLine.Key
= major-key
AND RepLine.Key2
= report-key
NO-ERROR.
316 IF NOT AVAILABLE(RepLine
) THEN DO:
318 RepLine.Key
= major-key.
319 RepLine.Key2
= report-key.
320 RepLine.Description
= STRING( Property.PropertyCode
, "99999") + sep
+ Property.Name .
322 RUN build-vacant-entity
( Property.PropertyCode
).
330 /* _UIB-CODE-BLOCK-END
*/
335 &IF DEFINED(EXCLUDE-build-one-account) = 0 &THEN
337 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-one-account Procedure
338 PROCEDURE build-one-account
:
339 /*------------------------------------------------------------------------------
341 ------------------------------------------------------------------------------*/
342 DEF INPUT PARAMETER ac
AS DEC NO-UNDO.
346 FOR EACH Property
NO-LOCK:
347 IF NOT include-property
() THEN NEXT.
348 RUN add-one-account
( entity-type
, Property.PropertyCode
, ac
).
352 FOR EACH Company
NO-LOCK:
353 IF NOT include-company
() THEN NEXT.
354 RUN add-one-account
( entity-type
, Company.CompanyCode
, ac
).
358 FOR EACH Property
NO-LOCK:
359 IF NOT include-property
() THEN NEXT.
360 FOR EACH Tenant
WHERE Tenant.EntityType
= "P" AND Tenant.EntityCode
= Property.PropertyCode
NO-LOCK:
361 IF NOT include-tenant
() THEN NEXT.
362 RUN add-one-account
( entity-type
, Tenant.TenantCode
, ac
).
368 IF AVAILABLE(RepLine
) AND RepLine.Balance
= 0 AND RepLine.Budget
= 0 THEN DELETE RepLine.
372 /* _UIB-CODE-BLOCK-END
*/
377 &IF DEFINED(EXCLUDE-build-one-entity) = 0 &THEN
379 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-one-entity Procedure
380 PROCEDURE build-one-entity
:
381 /*------------------------------------------------------------------------------
383 ------------------------------------------------------------------------------*/
384 DEF INPUT PARAMETER et
AS CHAR NO-UNDO.
385 DEF INPUT PARAMETER ec
AS INT NO-UNDO.
387 DEF VAR ac
AS DEC NO-UNDO.
389 FOR EACH ChartOfAccount
WHERE ChartOfAccount.AccountCode
>= account-1
390 AND ChartOfAccount.AccountCode
<= account-n
391 AND LOOKUP( ChartOfAccount.AccountGroupCode
, group-list
) > 0 NO-LOCK:
393 ac
= ChartOfAccount.AccountCode.
394 IF consolidate-subs
THEN ac
= TRUNC( ac
, 0 ).
396 FIND RepLine
WHERE RepLine.Key
= major-key
AND RepLine.Key2
= report-key
NO-ERROR.
397 IF NOT AVAILABLE(RepLine
) THEN DO:
399 RepLine.Key
= major-key.
400 RepLine.Key2
= report-key.
401 RepLine.Description
= STRING( ChartOfAccount.AccountCode
, (IF consolidate-subs
THEN (IF exporting
THEN "9999" ELSE " 9999 ") ELSE "9999.99"))
402 + (IF exporting
THEN '
","'
ELSE " ") + ChartOfAccount.Name .
405 RUN add-one-account
( et
, ec
, ChartOfAccount.AccountCode
).
406 IF detailed
AND RepLine.Balance
= 0 AND RepLine.Budget
= 0 THEN DELETE RepLine.
409 IF AVAILABLE(MajorLine
) AND MajorLine.Balance
= 0 AND MajorLine.Budget
= 0 THEN DELETE MajorLine.
411 ELSE IF RepLine.Balance
= 0 AND RepLine.Budget
= 0 THEN DELETE RepLine.
415 /* _UIB-CODE-BLOCK-END
*/
420 &IF DEFINED(EXCLUDE-build-vacant-entity) = 0 &THEN
422 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-vacant-entity Procedure
423 PROCEDURE build-vacant-entity
:
424 /*------------------------------------------------------------------------------
426 ------------------------------------------------------------------------------*/
427 DEF INPUT PARAMETER property-code
AS INT NO-UNDO.
429 DEF VAR bal
AS DEC NO-UNDO.
430 DEF VAR bud
AS DEC NO-UNDO.
432 FOR EACH ChartOfAccount
WHERE ChartOfAccount.AccountCode
>= account-1
433 AND ChartOfAccount.AccountCode
<= account-n
434 AND LOOKUP( ChartOfAccount.AccountGroupCode
, group-list
) > 0 NO-LOCK:
435 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= "P"
436 AND AccountBalance.EntityCode
= property-code
437 AND AccountBalance.AccountCode
= ChartOfAccount.AccountCode
438 AND AccountBalance.MonthCode
>= month-1
439 AND AccountBalance.MonthCode
<= month-n
NO-LOCK:
440 bal
= bal
+ (AccountBalance.Balance
* multiplier
).
441 bud
= bud
+ ((IF revised
THEN AccountBalance.RevisedBudget
ELSE AccountBalance.Budget
) * multiplier
).
445 /* the vacant space is the difference between the property amount and the sum
448 IF AVAILABLE(MajorLine
) THEN ASSIGN
449 RepLine.Balance
= bal
- MajorLine.Balance
450 RepLine.Budget
= bud
- MajorLine.Budget.
452 RepLine.Balance
= bal
453 RepLine.Budget
= bud.
455 IF RepLine.Balance
= 0 AND RepLine.Budget
= 0 THEN DO:
460 RepLine.Variance
= (RepLine.Budget
- RepLine.Balance
) * multiplier.
462 IF NOT AVAILABLE(MajorLine
) THEN RETURN.
463 MajorLine.Balance
= MajorLine.Balance
+ RepLine.Balance.
464 MajorLine.Budget
= MajorLine.Budget
+ RepLine.Budget.
465 MajorLine.Variance
= (MajorLine.Budget
- MajorLine.Balance
) * multiplier.
469 /* _UIB-CODE-BLOCK-END
*/
474 &IF DEFINED(EXCLUDE-build-variance-info) = 0 &THEN
476 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE build-variance-info Procedure
477 PROCEDURE build-variance-info
:
478 /*------------------------------------------------------------------------------
480 ------------------------------------------------------------------------------*/
482 IF detailed
THEN RUN detailed-each-entity.
483 ELSE IF by-account
THEN RUN build-each-account.
484 ELSE RUN build-each-entity.
488 /* _UIB-CODE-BLOCK-END
*/
493 &IF DEFINED(EXCLUDE-detailed-each-entity) = 0 &THEN
495 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE detailed-each-entity Procedure
496 PROCEDURE detailed-each-entity
:
497 /*------------------------------------------------------------------------------
499 ------------------------------------------------------------------------------*/
500 DEF VAR sep
AS CHAR INITIAL " " NO-UNDO.
502 IF exporting
THEN sep
= '
","'.
505 FOR EACH Property
NO-LOCK:
506 IF NOT include-property
() THEN NEXT.
507 major-key
= Property.PropertyCode.
509 MajorLine.Key
= major-key.
510 MajorLine.Key2
= {&MIN-KEY}.
511 MajorLine.Description
= STRING( Property.PropertyCode
, "99999") + sep
+ Property.Name .
513 MajorLine.Key
= major-key.
514 MajorLine.Key2
= {&MAX-KEY}.
515 MajorLine.Description
= STRING( Property.PropertyCode
, "99999") + sep
+ Property.Name .
516 RUN build-one-entity
( "P", Property.PropertyCode
).
520 FOR EACH Company
NO-LOCK:
521 IF NOT include-company
() THEN NEXT.
522 major-key
= Company.CompanyCode.
524 MajorLine.Key
= major-key.
525 MajorLine.Key2
= {&MIN-KEY}.
526 MajorLine.Description
= STRING( Company.CompanyCode
, "99999") + sep
+ Company.LegalName .
528 MajorLine.Key
= major-key.
529 MajorLine.Key2
= {&MAX-KEY}.
530 MajorLine.Description
= STRING( Company.CompanyCode
, "99999") + sep
+ Company.LegalName .
531 RUN build-one-entity
( "L", Company.CompanyCode
).
536 FOR EACH Property
NO-LOCK:
537 IF NOT include-property
() THEN NEXT.
538 major-key
= Property.PropertyCode.
540 MajorLine.Key
= major-key.
541 MajorLine.Key2
= {&MIN-KEY}.
542 MajorLine.Description
= STRING( Property.PropertyCode
, "99999") + sep
+ Property.Name .
544 MajorLine.Key
= major-key.
545 MajorLine.Key2
= {&MAX-KEY}.
546 MajorLine.Description
= STRING( Property.PropertyCode
, "99999") + sep
+ Property.Name .
547 FOR EACH Tenant
WHERE Tenant.EntityType
= "P" AND Tenant.EntityCode
= Property.PropertyCode
NO-LOCK:
548 IF NOT include-tenant
() THEN NEXT.
549 report-key
= Tenant.TenantCode.
551 RepLine.Key
= major-key.
552 RepLine.Key2
= report-key.
553 RepLine.Description
= STRING( Tenant.TenantCode
, "99999") + sep
+ Tenant.Name .
554 RUN build-one-entity
( entity-type
, Tenant.TenantCode
).
556 IF show-vacant-space
THEN DO:
559 RepLine.Key
= major-key.
560 RepLine.Key2
= report-key.
561 RepLine.Description
= " Vacant Areas" .
562 RUN build-vacant-entity
( Property.PropertyCode
).
564 IF MajorLine.Balance
= 0 AND MajorLine.Budget
= 0 THEN DELETE MajorLine.
568 FOR EACH Property
NO-LOCK:
569 IF NOT include-property
() THEN NEXT.
570 FOR EACH Tenant
WHERE Tenant.EntityType
= "P"
571 AND Tenant.EntityCode
= Property.PropertyCode
NO-LOCK:
572 IF NOT include-tenant
() THEN NEXT.
573 major-key
= Tenant.TenantCode.
575 MajorLine.Key
= major-key.
576 MajorLine.Key2
= {&MIN-KEY}.
577 MajorLine.Description
= STRING( Tenant.TenantCode
, "99999") + sep
+ Tenant.Name .
579 MajorLine.Key
= major-key.
580 MajorLine.Key2
= {&MAX-KEY}.
581 MajorLine.Description
= STRING( Tenant.TenantCode
, "99999") + sep
+ Tenant.Name .
582 RUN build-one-entity
( "T", Tenant.TenantCode
).
590 /* _UIB-CODE-BLOCK-END
*/
595 &IF DEFINED(EXCLUDE-inst-page-footer) = 0 &THEN
597 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
598 PROCEDURE inst-page-footer
:
599 /*------------------------------------------------------------------------------
601 ------------------------------------------------------------------------------*/
605 /* _UIB-CODE-BLOCK-END
*/
610 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
612 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
613 PROCEDURE inst-page-header
:
614 /*------------------------------------------------------------------------------
616 ------------------------------------------------------------------------------*/
619 IF NOT exporting
THEN DO:
620 pr-line
= pr-line
+ (IF preview
THEN SPC
(65) ELSE CHR(13) + SPC
(275)) + "Page: " + STRING( pclrep-page-number
).
622 RUN pclrep-line
( time-font
, '
"' + pr-line + '"'
).
624 RUN pclrep-line
( ?
, "").
625 IF exporting
THEN DO:
626 RUN pclrep-line
( ?
, '
"' + page-title-1 + ", " + page-title-2 + '"'
).
627 RUN pclrep-line
( ?
, "Account,Name,Actual,Budget,Variance,Month").
630 RUN pclrep-line
( ?
, "").
631 RUN pclrep-line
( title-font
, SPC
(45 - INT( LENGTH(page-title-1
) / 2)) + page-title-1
).
632 RUN pclrep-line
( time-font
, "").
633 RUN pclrep-line
( title-font
, SPC
(45 - INT( LENGTH(page-title-2
) / 2)) + page-title-2
).
634 RUN pclrep-line
( time-font
, "").
635 RUN pclrep-line
( line1-font
, SPC
(70) + "Actual Budget Variance Month").
636 RUN pclrep-line
( time-font
, "").
641 /* _UIB-CODE-BLOCK-END
*/
646 &IF DEFINED(EXCLUDE-output-report) = 0 &THEN
648 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-report Procedure
649 PROCEDURE output-report
:
650 /*------------------------------------------------------------------------------
652 ------------------------------------------------------------------------------*/
653 DEF VAR line
AS CHAR NO-UNDO.
654 DEF VAR balance-total
AS DEC NO-UNDO.
655 DEF VAR budget-total
AS DEC NO-UNDO.
656 DEF VAR variance-total
AS DEC NO-UNDO.
657 DEF VAR month-total
AS DEC NO-UNDO.
659 DEF BUFFER RepLine2
FOR RepLine.
663 line
= '
"' + RepLine.Description + '",'
664 + TRIM(STRING( RepLine.Balance
, amt-fmt
)) + ","
665 + TRIM(STRING( RepLine.Budget
, amt-fmt
)) + ","
666 + TRIM(STRING( RepLine.Variance
, amt-fmt
)) + ","
667 + TRIM(STRING( RepLine.Month
, amt-fmt
)).
669 line
= STRING( RepLine.Description
, "X(65)")
670 + STRING( RepLine.Balance
, amt-fmt
) + " "
671 + STRING( RepLine.Budget
, amt-fmt
) + " "
672 + STRING( RepLine.Variance
, amt-fmt
) + " "
673 + STRING( RepLine.Month
, amt-fmt
).
674 IF RepLine.Key2
= {&MIN-KEY} THEN DO:
675 IF CAN-FIND( FIRST RepLine2
WHERE RepLine2.Key
= RepLine.Key
AND RepLine2.Key2
= {&MAX-KEY} ) THEN DO:
677 RUN pclrep-line
( ?
, '
"' + RepLine.Description + '"'
).
679 RUN pclrep-line
( line1-font
, RepLine.Description
).
680 RUN pclrep-line
( ?
, ?
).
683 ELSE IF RepLine.Key2
= {&MAX-KEY} THEN DO:
685 RUN pclrep-line
( ?
, "," + FILL( ",--------------", 4) ).
687 RUN pclrep-line
( line1-font
, SPC
(63) + FILL( " --------------", 4) ).
688 RUN pclrep-line
( ?
, line
).
689 RUN pclrep-line
( ?
, ?
).
690 RUN pclrep-line
( ?
, ?
).
693 RUN pclrep-line
( (IF exporting
THEN ?
ELSE line2-font
), line
).
694 balance-total
= balance-total
+ RepLine.Balance .
695 budget-total
= budget-total
+ RepLine.Budget .
696 variance-total
= variance-total
+ RepLine.Variance .
697 month-total
= month-total
+ RepLine.Month .
702 line
= "," + FILL( ",==============", 4).
704 line
= SPC
(63) + FILL( " ==============", 4).
706 RUN pclrep-line
( line1-font
, line
).
709 + TRIM(STRING( balance-total
, amt-fmt
)) + ","
710 + TRIM(STRING( budget-total
, amt-fmt
)) + ","
711 + TRIM(STRING( variance-total
, amt-fmt
)) + ","
712 + TRIM(STRING( month-total
, amt-fmt
)).
714 line
= STRING( "Totals", "X(65)")
715 + STRING( balance-total
, amt-fmt
) + " "
716 + STRING( budget-total
, amt-fmt
) + " "
717 + STRING( variance-total
, amt-fmt
) + " "
718 + STRING( month-total
, amt-fmt
).
720 RUN pclrep-line
( line1-font
, line
).
724 /* _UIB-CODE-BLOCK-END
*/
729 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
731 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
732 PROCEDURE parse-parameters
:
733 /*------------------------------------------------------------------------------
735 ------------------------------------------------------------------------------*/
736 DEF VAR token
AS CHAR NO-UNDO.
737 DEF VAR i
AS INT NO-UNDO.
739 {inc
/showopts.i
"report-options"}
741 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
742 token
= ENTRY( i
, report-options
, "~n" ).
744 CASE ENTRY( 1, token
):
745 WHEN "Preview" THEN preview
= Yes.
746 WHEN "ConsolidateSubs" THEN consolidate-subs
= Yes.
747 WHEN "NoVacantSpace" THEN show-vacant-space
= No.
748 WHEN "AccountGroups" THEN group-list
= SUBSTRING( token
, INDEX( token
, ",") + 1).
749 WHEN "File" THEN ASSIGN
751 file-name
= SUBSTRING( token
, INDEX( token
, ",") + 1).
753 WHEN "Month" THEN ASSIGN
754 month-1
= INT(ENTRY(2,token
))
755 month-n
= INT(ENTRY(3,token
)).
757 WHEN "Style" THEN DO:
758 CASE ENTRY( 2, token
):
759 WHEN "Detailed" THEN detailed
= Yes.
760 WHEN "Account" THEN by-account
= Yes.
764 WHEN "AccountRange" THEN ASSIGN
765 account-1
= DEC(ENTRY(2,token
))
766 account-n
= DEC(ENTRY(3,token
)).
768 WHEN "Company" THEN DO:
770 WHEN "Company" THEN ASSIGN
771 company-1
= INT(ENTRY(3,token
))
772 company-n
= INT(ENTRY(4,token
))
774 page-title-1
= "Company " + ENTRY(3,token
) + " to " + ENTRY(4,token
).
776 company-list
= ENTRY(3,token
).
777 FIND ConsolidationList
WHERE ConsolidationList.Name
= company-list
NO-LOCK.
778 company-list
= ConsolidationList.CompanyList.
780 page-title-1
= ConsolidationList.Description.
782 WHEN "Client" THEN ASSIGN
783 client-code
= ENTRY(3,token
)
784 page-title-1
= "Client/Owner: " + client-code.
788 WHEN "Tenant" THEN DO:
790 WHEN "Tenant" THEN ASSIGN
791 property-1
= INT(ENTRY(3,token
))
792 property-n
= INT(ENTRY(4,token
))
794 page-title-1
= "Tenants of Properties " + ENTRY(3,token
) + " to " + ENTRY(4,token
).
798 WHEN "Property" THEN DO:
800 WHEN "Property" THEN ASSIGN
801 property-1
= INT(ENTRY(3,token
))
802 property-n
= INT(ENTRY(4,token
))
804 page-title-1
= "Property " + ENTRY(3,token
) + " to " + ENTRY(4,token
).
805 WHEN "Region" THEN ASSIGN
806 region-code
= ENTRY(3,token
)
808 page-title-1
= "Region " + ENTRY(3,token
).
809 WHEN "Manager" THEN DO:
810 manager-code
= INT(ENTRY(3,token
)).
812 FIND Person
WHERE Person.PersonCode
= manager-code
NO-LOCK NO-ERROR.
813 page-title-1
= "Managed by " + (IF AVAILABLE(Person
) THEN Person.FirstName
+ " " + Person.LastName
ELSE "Unknown Manager").
821 DO ON ERROR UNDO, RETURN ERROR:
822 FIND Month
WHERE Month.MonthCode
= month-n
NO-LOCK.
823 page-title-1
= " to " + STRING( Month.EndDate
, "99/99/9999" ) + " - " + page-title-1.
824 FIND Month
WHERE Month.MonthCode
= month-1
NO-LOCK.
825 page-title-1
= "Variances from "
826 + STRING( Month.StartDate
, "99/99/9999" )
829 IF NUM-ENTRIES( group-list
) = 1 THEN DO:
830 FIND AccountGroup
WHERE AccountGroup.AccountGroupCode
= group-list
NO-LOCK.
831 page-title-2
= AccountGroup.Name
+ " (" + AccountGroup.AccountGroupCode
+ ")".
832 IF AccountGroup.CreditGroup
THEN multiplier
= -1.
835 page-title-2
= "Account groups " + group-list.
841 /* _UIB-CODE-BLOCK-END
*/
846 /* ************************ Function Implementations
***************** */
848 &IF DEFINED(EXCLUDE-include-company) = 0 &THEN
850 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-company Procedure
851 FUNCTION include-company
RETURNS LOGICAL
852 ( /* parameter-definitions
*/ ) :
853 /*------------------------------------------------------------------------------
854 Purpose
: Decide whether the current company should be in the report
856 ------------------------------------------------------------------------------*/
857 IF Company.CompanyCode
< company-1
THEN RETURN No.
858 IF Company.CompanyCode
> company-n
THEN RETURN No.
860 IF client-code
<> ?
THEN DO:
861 IF Company.ClientCode
<> client-code
THEN RETURN No.
864 IF company-list
<> ?
THEN DO:
865 IF LOOKUP( STRING(Company.CompanyCode
), company-list
) = 0 THEN RETURN No.
868 FIND FIRST AccountBalance
WHERE AccountBalance.EntityType
= "L"
869 AND AccountBalance.EntityCode
= Company.CompanyCode
870 AND (AccountBalance.Balance
<> 0
871 OR AccountBalance.Budget
<> 0 ) NO-LOCK NO-ERROR.
872 IF NOT AVAILABLE(AccountBalance
) THEN RETURN No.
878 /* _UIB-CODE-BLOCK-END
*/
883 &IF DEFINED(EXCLUDE-include-property) = 0 &THEN
885 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-property Procedure
886 FUNCTION include-property
RETURNS LOGICAL
887 ( /* parameter-definitions
*/ ) :
888 /*------------------------------------------------------------------------------
889 Purpose
: Decide whether the current property should be in the report
891 ------------------------------------------------------------------------------*/
892 IF Property.PropertyCode
< property-1
THEN RETURN No.
893 IF Property.PropertyCode
> property-n
THEN RETURN No.
895 IF manager-code
<> ?
THEN DO:
896 IF Property.Manager
<> manager-code
THEN RETURN No.
899 IF region-code
<> ?
THEN DO:
900 IF NOT(Property.Region
BEGINS region-code
) THEN RETURN No.
903 FIND FIRST AccountBalance
WHERE AccountBalance.EntityType
= "P"
904 AND AccountBalance.EntityCode
= Property.PropertyCode
905 AND (AccountBalance.Balance
<> 0
906 OR AccountBalance.Budget
<> 0 ) NO-LOCK NO-ERROR.
907 RETURN AVAILABLE(AccountBalance
).
911 /* _UIB-CODE-BLOCK-END
*/
916 &IF DEFINED(EXCLUDE-include-tenant) = 0 &THEN
918 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION include-tenant Procedure
919 FUNCTION include-tenant
RETURNS LOGICAL
920 ( /* parameter-definitions
*/ ) :
921 /*------------------------------------------------------------------------------
922 Purpose
: Decide whether the current tenant should be in the report
924 ------------------------------------------------------------------------------*/
925 FIND FIRST AccountBalance
WHERE AccountBalance.EntityType
= "T"
926 AND AccountBalance.EntityCode
= Tenant.TenantCode
927 AND (AccountBalance.Balance
<> 0
928 OR AccountBalance.Budget
<> 0 ) NO-LOCK NO-ERROR.
929 RETURN AVAILABLE(AccountBalance
).
933 /* _UIB-CODE-BLOCK-END
*/