1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 &SCOP VALID-FIELDS "Budget,Revised,Actual,BudgetVariance,RevisedVariance,Actual2"
9 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
10 DEF VAR project-1
LIKE Project.ProjectCode
NO-UNDO.
11 DEF VAR project-n
LIKE Project.ProjectCode
NO-UNDO.
12 DEF VAR hierarchy-1
AS INT NO-UNDO.
13 DEF VAR hierarchy-n
AS INT NO-UNDO.
14 DEF VAR field-name
AS CHAR NO-UNDO.
15 DEF VAR sort-by
AS CHAR NO-UNDO INITIAL "Code".
16 DEF VAR include-awaiting
AS LOGI
NO-UNDO INITIAL No.
17 DEF VAR as-at-month
AS INT NO-UNDO.
18 DEF VAR first-month
AS INT NO-UNDO INITIAL ?.
21 DEF VAR no-months
AS INT NO-UNDO.
22 DEF VAR current-row
AS INT NO-UNDO INITIAL 0.
23 DEF VAR delim
AS CHAR NO-UNDO INIT "|".
25 /* each total line for a hierarchy level is a new total-row
*/
26 DEF VAR grand-rows
AS CHAR INITIAL "".
27 DEF VAR total-rows
AS CHAR INITIAL "".
28 DEF VAR entity-rows
AS CHAR INITIAL "".
29 DEF VAR hierarchy-depth
AS INT NO-UNDO INITIAL 0.
31 DEF TEMP-TABLE MonthAccount
NO-UNDO
32 FIELD MonthCode
LIKE Month.MonthCode
33 FIELD AccountCode
LIKE ChartOfAccount.AccountCode
36 INDEX MonthAccount
IS UNIQUE PRIMARY
40 DEF TEMP-TABLE MonthBucket
NO-UNDO
41 FIELD MonthCode
LIKE Month.MonthCode
42 FIELD MonthName
LIKE Month.MonthName
43 FIELD MonthStart
AS DATE
44 FIELD MonthEnd
AS DATE
46 INDEX MonthCode
IS UNIQUE PRIMARY
49 DEF TEMP-TABLE AccountBucket
NO-UNDO
50 FIELD AccountCode
LIKE ChartOfAccount.AccountCode
51 FIELD AccountName
LIKE ChartOfAccount.Name
54 INDEX AccountCode
IS UNIQUE PRIMARY
57 /* _UIB-CODE-BLOCK-END
*/
61 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
63 /* ******************** Preprocessor Definitions
******************** */
65 &Scoped-define PROCEDURE-TYPE Procedure
66 &Scoped-define DB-AWARE no
70 /* _UIB-PREPROCESSOR-BLOCK-END
*/
74 /* ************************ Function Prototypes
********************** */
76 &IF DEFINED(EXCLUDE-get-amount) = 0 &THEN
78 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-amount Procedure
79 FUNCTION get-amount
RETURNS DECIMAL
80 ( /* parameter-definitions
*/ ) FORWARD.
82 /* _UIB-CODE-BLOCK-END
*/
87 &IF DEFINED(EXCLUDE-get-earliest-month) = 0 &THEN
89 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD get-earliest-month Procedure
90 FUNCTION get-earliest-month
RETURNS INTEGER
91 ( /* parameter-definitions
*/ ) FORWARD.
93 /* _UIB-CODE-BLOCK-END
*/
99 /* *********************** Procedure Settings
************************ */
101 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
102 /* Settings for
THIS-PROCEDURE
106 Add Fields to
: Neither
107 Other Settings
: CODE-ONLY
COMPILE
109 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
111 /* ************************* Create Window
************************** */
113 &ANALYZE-SUSPEND _CREATE-WINDOW
114 /* DESIGN Window definition
(used by the UIB
)
115 CREATE WINDOW Procedure
ASSIGN
118 /* END WINDOW DEFINITION
*/
122 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
123 /* ************************* Included-Libraries
*********************** */
125 {inc
/method
/m-excel.i
}
127 /* _UIB-CODE-BLOCK-END
*/
134 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
137 /* *************************** Main Block
*************************** */
139 RUN begin-spreadsheet.
140 IF RETURN-VALUE = "FAIL" THEN DO:
144 RUN cash-flow-report.
148 /* _UIB-CODE-BLOCK-END
*/
152 /* ********************** Internal Procedures
*********************** */
154 &IF DEFINED(EXCLUDE-begin-spreadsheet) = 0 &THEN
156 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE begin-spreadsheet Procedure
157 PROCEDURE begin-spreadsheet
:
158 /*------------------------------------------------------------------------------
160 ------------------------------------------------------------------------------*/
164 IF NOT VALID-HANDLE( chExcelApplication
) THEN DO:
174 chWorkSheet
:Columns
("A"):ColumnWidth
= 8.
175 chWorkSheet
:Columns
("B"):ColumnWidth
= 30.
176 chWorkSheet
:Columns
("C:AZ"):ColumnWidth
= 14.
179 chWorkSheet
:Columns
("C:AZ"):HorizontalAlignment
= {&xlAlignRight}.
182 chWorkSheet
:Range
("A:A"):NumberFormat
= "0000.00" .
183 chWorkSheet
:Range
("C:AZ"):NumberFormat
= "#,##0.00;[Red]-#,##0.00" .
185 set-excel-visible
(Yes
).
190 /* _UIB-CODE-BLOCK-END
*/
195 &IF DEFINED(EXCLUDE-cash-flow-report) = 0 &THEN
197 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cash-flow-report Procedure
198 PROCEDURE cash-flow-report
:
199 /*------------------------------------------------------------------------------
201 ------------------------------------------------------------------------------*/
202 DEF VAR month-list
AS CHAR NO-UNDO.
206 FOR EACH Month
WHERE Month.MonthCode
>= first-month
AND Month.MonthCode
<= as-at-month
NO-LOCK:
207 month-list
= month-list
+ delim
+ "'" + Month.MonthName
+ " " + SUBSTR( STRING( YEAR( Month.EndDate
) ), 3 ).
208 no-months
= no-months
+ 1.
210 RUN output-line
( "Account" + delim
+ "Name" + delim
+ "Total" + month-list
).
211 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Name
= "Arial".
212 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Size
= 9.
215 DEF BUFFER pj
FOR Project.
217 IF sort-by
= 'Type'
THEN DO:
218 FOR EACH ProjectType
NO-LOCK:
219 FOR EACH pj
NO-LOCK WHERE pj.ProjectCode
>= project-1
220 AND pj.ProjectCode
<= project-n
221 AND pj.ProjectType
= ProjectType.ProjectType
:
222 RUN each-project
( pj.ProjectCode
).
224 RUN totals-line
( grand-rows
, "Total of " + ProjectType.Description
+ " Projects").
228 ELSE IF sort-by
= 'Parent'
THEN DO:
229 DEF VAR last-entity
AS CHAR NO-UNDO INITIAL "".
230 FOR EACH pj
NO-LOCK WHERE pj.ProjectCode
>= project-1
231 AND pj.ProjectCode
<= project-n
232 BY pj.EntityType
BY pj.EntityCode
BY pj.EntityAccount
:
233 IF pj.EntityType
+ STRING(pj.EntityCode
) <> last-entity
THEN DO:
234 IF last-entity
<> "" THEN DO:
235 RUN totals-line
( entity-rows
, "Total For " + last-entity
).
238 last-entity
= pj.EntityType
+ STRING(pj.EntityCode
) .
240 RUN each-project
( pj.ProjectCode
).
242 RUN totals-line
( entity-rows
, "Total For " + last-entity
).
243 RUN totals-line
( grand-rows
, "Total of Project Range" ).
246 FOR EACH pj
NO-LOCK WHERE pj.ProjectCode
>= project-1
247 AND pj.ProjectCode
<= project-n
:
248 RUN each-project
( pj.ProjectCode
).
251 RUN totals-line
( grand-rows
, "Total of Project Range" ).
256 /* _UIB-CODE-BLOCK-END
*/
261 &IF DEFINED(EXCLUDE-clear-buckets) = 0 &THEN
263 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE clear-buckets Procedure
264 PROCEDURE clear-buckets
:
265 /*------------------------------------------------------------------------------
267 ------------------------------------------------------------------------------*/
268 FOR EACH AccountBucket
:
269 DELETE AccountBucket.
271 FOR EACH MonthAccount
:
276 /* _UIB-CODE-BLOCK-END
*/
281 &IF DEFINED(EXCLUDE-each-project) = 0 &THEN
283 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-project Procedure
284 PROCEDURE each-project
:
285 /*------------------------------------------------------------------------------
287 ------------------------------------------------------------------------------*/
288 DEF INPUT PARAMETER pj-code
AS INT NO-UNDO.
289 DEF VAR this-amount
AS DEC NO-UNDO.
290 DEF BUFFER pj
FOR Project.
292 DEF VAR save-totals
AS CHAR NO-UNDO.
294 IF hierarchy-depth
>= hierarchy-1
AND hierarchy-depth
<= hierarchy-n
THEN DO:
296 FIND Project
WHERE Project.ProjectCode
= pj-code
NO-LOCK.
297 FOR EACH ProjectBudget
OF Project
NO-LOCK:
298 RUN get-account-bucket.
299 FOR EACH AccountBalance
WHERE AccountBalance.EntityType
= "J"
300 AND AccountBalance.EntityCode
= Project.ProjectCode
301 AND AccountBalance.AccountCode
= ProjectBudget.AccountCode
302 AND AccountBalance.MonthCode
>= first-month
303 AND AccountBalance.MonthCode
<= as-at-month
304 AND (AccountBalance.Balance
<> 0.0
305 OR AccountBalance.Budget
<> 0.0
306 OR AccountBalance.RevisedBudget
<> 0.0 ) :
307 this-amount
= get-amount
().
308 IF this-amount
= 0 THEN NEXT.
310 RUN get-month-bucket.
311 RUN get-month-account.
312 RUN update-month-account
( this-amount
).
316 IF CAN-FIND( FIRST MonthAccount
) THEN RUN send-to-spreadsheet.
319 save-totals
= total-rows.
321 hierarchy-depth
= hierarchy-depth
+ 1.
322 FOR EACH pj
NO-LOCK WHERE pj.EntityType
= "J"
323 AND pj.EntityCode
= pj-code
:
324 RUN each-project
( pj.ProjectCode
).
326 RUN totals-line
( total-rows
, "Sub-projects of Project " + STRING(pj-code
,"99999") ).
327 total-rows
= save-totals.
328 hierarchy-depth
= hierarchy-depth
- 1.
332 /* _UIB-CODE-BLOCK-END
*/
337 &IF DEFINED(EXCLUDE-end-spreadsheet) = 0 &THEN
339 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE end-spreadsheet Procedure
340 PROCEDURE end-spreadsheet
:
341 /*------------------------------------------------------------------------------
343 ------------------------------------------------------------------------------*/
349 /* _UIB-CODE-BLOCK-END
*/
354 &IF DEFINED(EXCLUDE-get-account-bucket) = 0 &THEN
356 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-account-bucket Procedure
357 PROCEDURE get-account-bucket
:
358 /*------------------------------------------------------------------------------
362 ------------------------------------------------------------------------------*/
364 FIND FIRST AccountBucket
WHERE AccountBucket.AccountCode
= ProjectBudget.AccountCode
367 IF NOT AVAILABLE AccountBucket
THEN
369 CREATE AccountBucket.
370 AccountBucket.AccountCode
= ProjectBudget.AccountCode.
371 AccountBucket.AccountName
= ProjectBudget.Description.
376 /* _UIB-CODE-BLOCK-END
*/
381 &IF DEFINED(EXCLUDE-get-actual) = 0 &THEN
383 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-actual Procedure
384 PROCEDURE get-actual
:
385 /*------------------------------------------------------------------------------
387 ------------------------------------------------------------------------------*/
388 DEF OUTPUT PARAMETER actual
AS DEC NO-UNDO.
390 actual
= AccountBalance.Balance.
391 IF NOT include-awaiting
THEN RETURN.
393 FOR EACH Order
NO-LOCK WHERE
394 Order.ProjectCode
= ProjectBudget.ProjectCode
AND
395 Order.AccountCode
= ProjectBudget.AccountCode
AND
396 Order.OrderDate
>= MonthBucket.MonthStart
AND
397 Order.OrderDate
<= MonthBucket.MonthEnd
:
399 FIND FIRST Voucher
WHERE
400 Voucher.ProjectCode
= ProjectBudget.ProjectCode
AND
401 Voucher.OrderCode
= Order.OrderCode
404 IF AVAILABLE Voucher
AND LOOKUP( Voucher.VoucherStatus
, "U,H" ) <> 0 THEN
405 actual
= actual
+ ( Voucher.GoodsValue
+ Voucher.TaxValue
).
411 /* _UIB-CODE-BLOCK-END
*/
416 &IF DEFINED(EXCLUDE-get-month-account) = 0 &THEN
418 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-month-account Procedure
419 PROCEDURE get-month-account
:
420 /*------------------------------------------------------------------------------
424 ------------------------------------------------------------------------------*/
426 FIND FIRST MonthAccount
WHERE
427 MonthAccount.MonthCode
= MonthBucket.MonthCode
AND
428 MonthAccount.AccountCode
= AccountBalance.AccountCode
431 IF NOT AVAILABLE MonthAccount
THEN
435 MonthAccount.MonthCode
= MonthBucket.MonthCode
436 MonthAccount.AccountCode
= AccountBalance.AccountCode.
441 /* _UIB-CODE-BLOCK-END
*/
446 &IF DEFINED(EXCLUDE-get-month-bucket) = 0 &THEN
448 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-month-bucket Procedure
449 PROCEDURE get-month-bucket
:
450 /*------------------------------------------------------------------------------
452 ------------------------------------------------------------------------------*/
454 FIND FIRST MonthBucket
WHERE MonthBucket.MonthCode
= AccountBalance.MonthCode
457 IF NOT AVAILABLE MonthBucket
THEN DO:
458 FIND FIRST Month
WHERE Month.MonthCode
= AccountBalance.MonthCode
NO-LOCK NO-ERROR.
459 IF NOT AVAILABLE(Month
) THEN DO:
460 MESSAGE "Cannot find month" AccountBalance.MonthCode
"for account " + AccountBalance.EntityType
+ STRING(AccountBalance.EntityCode
,"99999") + "/" + STRING(AccountBalance.AccountCode
,"9999.99").
464 MonthBucket.MonthCode
= AccountBalance.MonthCode.
466 IF AVAILABLE(Month
) THEN ASSIGN
467 MonthBucket.MonthStart
= Month.StartDate
468 MonthBucket.MonthEnd
= Month.EndDate.
473 /* _UIB-CODE-BLOCK-END
*/
478 &IF DEFINED(EXCLUDE-output-line) = 0 &THEN
480 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE output-line Procedure
481 PROCEDURE output-line
:
482 /*------------------------------------------------------------------------------
484 ------------------------------------------------------------------------------*/
485 DEF INPUT PARAMETER detail
AS CHAR NO-UNDO.
487 DEF VAR i
AS INT NO-UNDO.
489 current-row
= current-row
+ 1.
490 DO i
= 1 TO NUM-ENTRIES( detail
, delim
):
491 chWorkSheet
:Cells
(current-row
,i
):Value
= ENTRY( i
, detail
, delim
).
496 /* _UIB-CODE-BLOCK-END
*/
501 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
503 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
504 PROCEDURE parse-parameters
:
505 /*------------------------------------------------------------------------------
507 ------------------------------------------------------------------------------*/
508 DEF VAR i
AS INT NO-UNDO.
509 DEF VAR token
AS CHAR NO-UNDO.
511 {inc
/showopts.i
"report-options"}
513 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
514 token
= ENTRY( i
, report-options
, "~n" ).
516 CASE( ENTRY( 1, token
) ):
517 WHEN "ProjectRange" THEN ASSIGN
518 project-1
= INT( ENTRY(2,token
) )
519 project-n
= INT( ENTRY(3,token
) ).
521 WHEN "ReportOn" THEN field-name
= ENTRY(2,token
).
522 WHEN "HierarchyLevels" THEN ASSIGN
523 hierarchy-1
= INT( ENTRY(2,token
) )
524 hierarchy-n
= INT( ENTRY(3,token
) ).
525 WHEN "AwaitingApproval" THEN include-awaiting
= Yes.
526 WHEN "MonthTo" THEN as-at-month
= INT(ENTRY(2,token
)).
527 WHEN "MonthFrom" THEN first-month
= INT(ENTRY(2,token
)).
528 WHEN "Sort" THEN sort-by
= ENTRY(2,token
).
532 IF project-n
< project-1
THEN project-n
= project-1.
534 IF first-month
= ?
THEN first-month
= get-earliest-month
().
538 /* _UIB-CODE-BLOCK-END
*/
543 &IF DEFINED(EXCLUDE-send-to-spreadsheet) = 0 &THEN
545 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-to-spreadsheet Procedure
546 PROCEDURE send-to-spreadsheet
:
547 /*------------------------------------------------------------------------------
549 ------------------------------------------------------------------------------*/
550 DEF VAR non-zero
AS LOGI
NO-UNDO.
551 DEF VAR top-row
AS INT NO-UNDO.
552 DEF VAR dtl
AS CHAR NO-UNDO.
553 DEF VAR c1
AS CHAR NO-UNDO.
554 DEF VAR c2
AS CHAR NO-UNDO.
555 DEF VAR r1
AS CHAR NO-UNDO.
556 DEF VAR r2
AS CHAR NO-UNDO.
557 DEF VAR i
AS INT NO-UNDO.
559 current-row
= current-row
+ 1.
560 IF sort-by
= 'Parent'
THEN DO:
561 chWorkSheet
:Cells
(current-row
,1):Value
= Project.EntityType
+ TRIM(STRING(Project.EntityCode
,">>>>>>9")).
562 chWorkSheet
:Cells
(current-row
,2):Value
= STRING(Project.ProjectCode
,"99999") + " - " + Project.Name .
565 chWorkSheet
:Cells
(current-row
,1):Value
= STRING(Project.ProjectCode
,"99999") + " - " + Project.Name .
567 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Name
= "Arial".
568 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Size
= 11.
569 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):Font
:Bold
= Yes.
570 chWorkSheet
:Range
(STRING(current-row
) + ":" + STRING(current-row
)):HorizontalAlignment
= {&xlAlignLeft}.
573 r1
= STRING( current-row
+ 1 ).
574 top-row
= current-row.
575 FOR EACH AccountBucket
NO-LOCK:
577 dtl
= STRING(AccountBucket.AccountCode
) + delim
+ AccountBucket.AccountName.
578 r2
= STRING(current-row
+ 1).
580 c2
= int-to-column
( no-months
+ 3 ).
581 dtl
= dtl
+ delim
+ "=SUM(" + c1
+ r2
+ ":" + c2
+ r2
+ ")".
583 FOR EACH Month
WHERE Month.MonthCode
>= first-month
AND Month.MonthCode
<= as-at-month
NO-LOCK:
584 FIND FIRST MonthAccount
WHERE
585 MonthAccount.AccountCode
= AccountBucket.AccountCode
AND
586 MonthAccount.MonthCode
= Month.MonthCode
NO-LOCK NO-ERROR.
589 IF AVAILABLE MonthAccount
THEN DO:
590 dtl
= dtl
+ STRING( MonthAccount.Amount
).
591 IF MonthAccount.Amount
<> 0 THEN non-zero
= Yes.
597 IF non-zero
THEN RUN output-line
( dtl
).
600 IF top-row
<> current-row
THEN DO:
602 r2
= STRING( current-row
).
603 dtl
= delim
+ "Totals".
604 DO i
= 0 TO no-months
:
605 c2
= int-to-column
( i
+ 3 ).
606 dtl
= dtl
+ delim
+ "=SUM(" + c2
+ r1
+ ":" + c2
+ r2
+ ")".
608 RUN output-line
( dtl
).
609 r2
= STRING(current-row
).
610 IF hierarchy-depth
> 0 THEN DO:
611 total-rows
= total-rows
+ "+X" + r2.
614 entity-rows
= entity-rows
+ "+X" + r2.
615 grand-rows
= grand-rows
+ "+X" + r2.
617 chWorkSheet
:Range
(c1
+ r2
+ ":" + c2
+ r2
):Borders
({&xlEdgeTop}):LineStyle = {&xlContinuous} .
620 current-row
= current-row
+ 2.
624 /* _UIB-CODE-BLOCK-END
*/
629 &IF DEFINED(EXCLUDE-setup-workbook) = 0 &THEN
631 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE setup-workbook Procedure
632 PROCEDURE setup-workbook
:
633 /*------------------------------------------------------------------------------
635 ------------------------------------------------------------------------------*/
636 chWorkSheet
:PageSetup
:Orientation
= {&xlLandscape}.
637 chWorkSheet
:PageSetup
:LeftMargin
= 24.
638 chWorkSheet
:PageSetup
:RightMargin
= 24.
639 chWorkSheet
:PageSetup
:TopMargin
= 60.
640 chWorkSheet
:PageSetup
:BottomMargin
= 28.
641 chWorkSheet
:PageSetup
:FooterMargin
= 20.
642 chWorkSheet
:PageSetup
:PrintTitleColumns
= "A:B".
643 chWorkSheet
:PageSetup
:PrintTitleRows
= "1:1".
645 chWorkSheet
:PageSetup
:CenterHeader
= "&12&B" + field-name
+ " Project Cashflows".
646 chWorkSheet
:PageSetup
:LeftFooter
= "".
647 chWorkSheet
:PageSetup
:CenterFooter
= "&07Page &P".
648 chWorkSheet
:PageSetup
:RightFooter
= "&07Generated at " + STRING( TIME, "HH:MM:SS") + " on " + STRING( TODAY, "99/99/9999").
650 chWorkBook
:Styles
("Normal"):Font
:Size
= 8.
651 chWorkBook
:Styles
("Normal"):Font
:Name
= "Times New Roman".
653 chWorkBook
:Styles
:Add
("Heading-1").
654 chWorkBook
:Styles
("Heading-1"):Font
:Size
= 11.
655 chWorkBook
:Styles
("Heading-1"):Font
:Name
= "Arial".
656 chWorkBook
:Styles
("Heading-1"):Font
:Bold
= True.
658 chWorkBook
:Styles
:Add
("Heading-2").
659 chWorkBook
:Styles
("Heading-2"):Font
:Name
= "Arial".
660 chWorkBook
:Styles
("Heading-2"):Font
:Bold
= True.
662 chWorkBook
:Styles
:Add
("Prop-Total").
663 chWorkBook
:Styles
("Prop-Total"):Font
:Name
= "Arial".
664 chWorkBook
:Styles
("Prop-Total"):Font
:Bold
= True.
668 /* _UIB-CODE-BLOCK-END
*/
673 &IF DEFINED(EXCLUDE-totals-line) = 0 &THEN
675 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE totals-line Procedure
676 PROCEDURE totals-line
:
677 /*------------------------------------------------------------------------------
679 ------------------------------------------------------------------------------*/
680 DEF INPUT PARAMETER sum-lines
AS CHAR NO-UNDO.
681 DEF INPUT PARAMETER description
AS CHAR NO-UNDO.
683 DEF VAR dtl
AS CHAR NO-UNDO.
684 DEF VAR c1
AS CHAR NO-UNDO.
685 DEF VAR c2
AS CHAR NO-UNDO.
686 DEF VAR r1
AS CHAR NO-UNDO.
687 DEF VAR i
AS INT NO-UNDO.
689 sum-lines
= SUBSTRING( sum-lines
, 2).
690 IF sum-lines
= "" THEN RETURN.
692 r1
= STRING(current-row
).
693 current-row
= current-row
- 1.
695 dtl
= delim
+ description.
696 DO i
= 0 TO no-months
:
697 c2
= int-to-column
( i
+ 3 ).
698 dtl
= dtl
+ delim
+ "=" + REPLACE( sum-lines
, "X", c2
).
700 RUN output-line
( dtl
).
701 chWorkSheet
:Range
(c1
+ r1
+ ":" + c2
+ r1
):Borders
({&xlEdgeTop}):LineStyle = {&xlContinuous} .
703 current-row
= current-row
+ 1.
707 /* _UIB-CODE-BLOCK-END
*/
712 &IF DEFINED(EXCLUDE-update-month-account) = 0 &THEN
714 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE update-month-account Procedure
715 PROCEDURE update-month-account
:
716 /*------------------------------------------------------------------------------
718 ------------------------------------------------------------------------------*/
719 DEF INPUT PARAMETER amount
AS DEC NO-UNDO.
721 MonthAccount.Amount
= MonthAccount.Amount
+ amount.
725 /* _UIB-CODE-BLOCK-END
*/
730 /* ************************ Function Implementations
***************** */
732 &IF DEFINED(EXCLUDE-get-amount) = 0 &THEN
734 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-amount Procedure
735 FUNCTION get-amount
RETURNS DECIMAL
736 ( /* parameter-definitions
*/ ) :
737 /*------------------------------------------------------------------------------
740 ------------------------------------------------------------------------------*/
741 DEF VAR amount
AS DEC NO-UNDO.
745 WHEN "Budget" THEN amount
= AccountBalance.Budget.
746 WHEN "Revised" THEN amount
= AccountBalance.Revised.
748 DEF VAR actual
AS DEC NO-UNDO.
749 RUN get-actual
( OUTPUT actual
).
751 WHEN "Actual" THEN amount
= actual.
752 WHEN "BudgetVariance" THEN amount
= AccountBalance.Budget
- actual.
753 WHEN "RevisedVariance" THEN amount
= AccountBalance.Revised
- actual.
763 /* _UIB-CODE-BLOCK-END
*/
768 &IF DEFINED(EXCLUDE-get-earliest-month) = 0 &THEN
770 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION get-earliest-month Procedure
771 FUNCTION get-earliest-month
RETURNS INTEGER
772 ( /* parameter-definitions
*/ ) :
773 /*------------------------------------------------------------------------------
776 ------------------------------------------------------------------------------*/
777 DEF VAR earliest-date
AS DATE NO-UNDO INITIAL TODAY.
779 FOR EACH Project
NO-LOCK WHERE Project.ProjectCode
>= project-1
780 AND Project.ProjectCode
<= project-n
:
781 IF Project.StartDate
< earliest-date
THEN earliest-date
= Project.StartDate .
784 FIND Month
WHERE Month.StartDate
<= earliest-date
AND Month.EndDate
>= earliest-date
NO-LOCK NO-ERROR.
785 IF NOT AVAILABLE(Month
) THEN FIND FIRST Month
NO-LOCK.
786 RETURN Month.MonthCode .
790 /* _UIB-CODE-BLOCK-END
*/