1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
9 DEF VAR project-from
LIKE Project.ProjectCode
NO-UNDO.
10 DEF VAR project-to
LIKE Project.ProjectCode
NO-UNDO.
11 DEF VAR upto-month
AS INT NO-UNDO.
12 DEF VAR upto-date
AS DATE NO-UNDO.
13 DEF VAR from-month
AS INT NO-UNDO INITIAL 0.
14 DEF VAR from-date
AS DATE NO-UNDO.
15 DEF VAR preview
AS LOGICAL NO-UNDO INITIAL No.
16 DEF VAR summarise
AS LOGI
NO-UNDO INITIAL No.
19 DEF VAR pending-headers
AS CHAR NO-UNDO INITIAL "".
20 DEF VAR ptot
AS DEC NO-UNDO INITIAL 0.
21 DEF VAR gtot
AS DEC NO-UNDO INITIAL 0.
24 DEF VAR ln
AS DEC INIT 0.00 NO-UNDO.
25 DEF VAR lines-per-page
AS INT NO-UNDO.
27 /* Line definitions
*/
29 DEF VAR page-no
AS INT INIT 1 NO-UNDO.
30 DEF VAR reset-page
AS CHAR NO-UNDO.
31 DEF VAR half-line
AS CHAR NO-UNDO.
32 DEF VAR title-font
AS CHAR NO-UNDO.
33 DEF VAR time-font
AS CHAR NO-UNDO.
34 DEF VAR project-font
AS CHAR EXTENT 3 NO-UNDO.
35 DEF VAR line-font
AS CHAR NO-UNDO.
36 DEF VAR i
AS INT NO-UNDO.
37 DEF VAR money-fmt
AS CHAR NO-UNDO INITIAL ">>>,>>>,>>9.99CR".
39 DEF VAR money-width
AS INT NO-UNDO.
40 money-width
= LENGTH(STRING(0,money-fmt
)).
42 DEF VAR now
AS CHAR NO-UNDO.
43 now
= STRING( TODAY, "99/99/9999" ) + " " + STRING( TIME, "HH:MM:SS" ).
44 DEF VAR user-name
AS CHAR NO-UNDO.
45 {inc
/username.i
"user-name"}
47 RUN get-control-strings.
49 /* _UIB-CODE-BLOCK-END
*/
53 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
55 /* ******************** Preprocessor Definitions
******************** */
57 &Scoped-define PROCEDURE-TYPE Procedure
61 /* _UIB-PREPROCESSOR-BLOCK-END
*/
65 /* ************************ Function Prototypes
********************** */
67 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD sum-project-orders Procedure
68 FUNCTION sum-project-orders
RETURNS DECIMAL
69 ( INPUT project-code
AS INT ) FORWARD.
71 /* _UIB-CODE-BLOCK-END
*/
75 /* *********************** Procedure Settings
************************ */
77 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
78 /* Settings for
THIS-PROCEDURE
82 Add Fields to
: Neither
83 Other Settings
: CODE-ONLY
COMPILE
85 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
87 /* ************************* Create Window
************************** */
89 &ANALYZE-SUSPEND _CREATE-WINDOW
90 /* DESIGN Window definition
(used by the UIB
)
91 CREATE WINDOW Procedure
ASSIGN
94 /* END WINDOW DEFINITION
*/
100 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
101 /* ************************* Included-Libraries
*********************** */
103 {inc
/method
/m-txtrep.i
}
105 /* _UIB-CODE-BLOCK-END
*/
110 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
113 /* *************************** Main Block
*************************** */
115 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
121 RUN view-output-file
( preview
).
123 /* _UIB-CODE-BLOCK-END
*/
127 /* ********************** Internal Procedures
*********************** */
129 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE column-header Procedure
130 PROCEDURE column-header
:
131 /*------------------------------------------------------------------------------
133 ------------------------------------------------------------------------------*/
134 DEF VAR line-1
AS CHAR NO-UNDO.
135 DEF VAR line-2
AS CHAR NO-UNDO.
137 line-1
= " Order" + FILL(" ", 84) + "1st".
138 line-2
= " Date Reference Amount Description" + FILL(" ", 41) + "Appvr Supplier".
140 RUN print-line
( line-1
).
141 RUN print-line
( line-2
).
142 RUN skip-line
( 1.5 ).
146 /* _UIB-CODE-BLOCK-END
*/
150 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE detail-sub-projects Procedure
151 PROCEDURE detail-sub-projects
:
152 /*------------------------------------------------------------------------------
154 ------------------------------------------------------------------------------*/
155 DEF INPUT PARAMETER project-code
LIKE Project.ProjectCode
NO-UNDO.
157 DEF BUFFER SubProj
FOR Project.
159 FOR EACH SubProj
WHERE SubProj.EntityType
= "J"
160 AND SubProj.EntityCode
= project-code
NO-LOCK:
161 FOR EACH Order
WHERE Order.ProjectCode
= SubProj.ProjectCode
NO-LOCK:
164 RUN detail-sub-projects
( SubProj.ProjectCode
).
169 /* _UIB-CODE-BLOCK-END
*/
173 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-order Procedure
174 PROCEDURE each-order
:
175 /*------------------------------------------------------------------------------
177 ------------------------------------------------------------------------------*/
178 DEF VAR var-text
AS CHAR NO-UNDO.
179 DEF VAR cred-name
AS CHAR NO-UNDO.
181 DEF VAR detail-line
AS CHAR NO-UNDO.
183 IF Order.OrderDate
< from-date
OR Order.OrderDate
> upto-date
THEN RETURN.
185 var-text
= WRAP
( Order.Description
, 50).
186 FIND Creditor
OF Order
NO-LOCK NO-ERROR.
187 IF AVAILABLE(Creditor
) THEN
188 cred-name
= Creditor.Name.
190 cred-name
= "Creditor not on file!".
192 detail-line
= (IF Order.OrderDate
= ?
THEN "??/??/????" ELSE STRING( Order.OrderDate
, "99/99/9999" )) + " "
193 + STRING( STRING( Order.ProjectCode
) + "/" + STRING( Order.OrderCode
), "X(10)")
194 + STRING( Order.OrderAmount
, money-fmt
) + " "
195 + STRING( ENTRY( 1, var-text
, "~n"), "X(52)" )
196 + STRING( Order.FirstApprover
, "X(6)" )
197 + STRING( Order.CreditorCode
, "99999" ) + " "
202 RUN print-line
( detail-line
).
204 ptot
= ptot
+ Order.OrderAmount .
208 /* _UIB-CODE-BLOCK-END
*/
212 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-project Procedure
213 PROCEDURE each-project
:
214 /*------------------------------------------------------------------------------
218 ------------------------------------------------------------------------------*/
219 DEF INPUT PARAMETER project-code
LIKE Project.ProjectCode
NO-UNDO.
221 DEF VAR project-name
AS CHAR NO-UNDO.
222 DEF VAR save-gtot
AS DEC NO-UNDO.
223 DEF BUFFER SubProj
FOR Project.
225 FIND Project
WHERE Project.ProjectCode
= project-code
NO-LOCK.
226 project-name
= Project.Name.
227 RUN pending-project-header
( project-code
).
230 FOR EACH Order
WHERE Order.ProjectCode
= project-code
NO-LOCK:
234 RUN summarise-sub-projects
( project-code
).
236 RUN detail-sub-projects
( project-code
).
238 IF pending-headers
= "" THEN DO:
239 RUN print-totals
( "Total", ptot
).
246 /* _UIB-CODE-BLOCK-END
*/
250 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-control-strings Procedure
251 PROCEDURE get-control-strings
:
252 /*------------------------------------------------------------------------------
253 Purpose
: Get all control strings for this report
256 ------------------------------------------------------------------------------*/
257 DEF VAR rows
AS DEC NO-UNDO.
258 DEF VAR cols
AS DEC NO-UNDO.
260 RUN make-control-string
( "PCL", "reset,portrait,a4,tm,0,lm,0,Fixed,Courier,cpi,18,lpi,9.54",
261 OUTPUT reset-page
, OUTPUT lines-per-page
, OUTPUT cols
).
263 IF preview
THEN RETURN.
264 half-line
= CHR(27) + "=".
266 RUN make-control-string
( "PCL", "Fixed,Courier,cpi,18,lpi,9.54",
267 OUTPUT line-font
, OUTPUT rows
, OUTPUT cols
).
269 RUN make-control-string
( "PCL", "Proportional,Helvetica,Bold,Point,12",
270 OUTPUT title-font
, OUTPUT rows
, OUTPUT cols
).
272 RUN make-control-string
( "PCL", "Proportional,Helvetica,Bold,Point,6",
273 OUTPUT time-font
, OUTPUT rows
, OUTPUT cols
).
275 RUN make-control-string
( "PCL", "Proportional,Helvetica,Bold,Point,10",
276 OUTPUT project-font
[1], OUTPUT rows
, OUTPUT cols
).
278 RUN make-control-string
( "PCL", "Proportional,Helvetica,Bold,Point,10",
279 OUTPUT project-font
[2], OUTPUT rows
, OUTPUT cols
).
281 RUN make-control-string
( "PCL", "Proportional,Helvetica,Bold,Point,10",
282 OUTPUT project-font
[3], OUTPUT rows
, OUTPUT cols
).
286 /* _UIB-CODE-BLOCK-END
*/
290 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE get-entity-name Procedure
291 PROCEDURE get-entity-name
:
292 /*------------------------------------------------------------------------------
296 ------------------------------------------------------------------------------*/
297 DEF INPUT PARAMETER entity-type
AS CHAR NO-UNDO.
298 DEF INPUT PARAMETER entity-code
AS INT NO-UNDO.
299 DEF OUTPUT PARAMETER entity-name
AS CHAR NO-UNDO.
301 DEF BUFFER OtherProject
FOR Project.
305 FIND FIRST Property
WHERE Property.PropertyCode
= entity-code
307 IF AVAILABLE Property
THEN entity-name
= Property.Name.
311 FIND FIRST Company
WHERE Company.CompanyCode
= entity-code
313 IF AVAILABLE Company
THEN entity-name
= Company.LegalName.
317 FIND FIRST Tenant
WHERE Tenant.TenantCode
= entity-code
319 IF AVAILABLE Tenant
THEN entity-name
= Tenant.Name.
323 FIND FIRST Creditor
WHERE Creditor.CreditorCode
= entity-code
325 IF AVAILABLE Creditor
THEN entity-name
= Creditor.Name.
329 FIND FIRST OtherProject
WHERE OtherProject.ProjectCode
= entity-code
331 IF AVAILABLE OtherProject
THEN entity-name
= OtherProject.Name.
338 /* _UIB-CODE-BLOCK-END
*/
342 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE order-tracking Procedure
343 PROCEDURE order-tracking
:
344 /*------------------------------------------------------------------------------
346 ------------------------------------------------------------------------------*/
350 FOR EACH Project
NO-LOCK WHERE Project.ProjectCode
>= project-from
351 AND Project.ProjectCode
<= project-to
:
352 RUN each-project
( Project.ProjectCode
).
355 IF project-from
< project-to
THEN DO:
357 RUN print-totals
( "Grand total", gtot
).
364 /* _UIB-CODE-BLOCK-END
*/
368 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-feed Procedure
369 PROCEDURE page-feed
:
370 /*------------------------------------------------------------------------------
374 ------------------------------------------------------------------------------*/
376 page-no
= page-no
+ 1.
381 /* _UIB-CODE-BLOCK-END
*/
385 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE page-header Procedure
386 PROCEDURE page-header
:
387 /*------------------------------------------------------------------------------
391 ------------------------------------------------------------------------------*/
399 /* _UIB-CODE-BLOCK-END
*/
403 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
404 PROCEDURE parse-parameters
:
405 /*------------------------------------------------------------------------------
407 ------------------------------------------------------------------------------*/
408 DEF VAR i
AS INT NO-UNDO.
409 DEF VAR token
AS CHAR NO-UNDO.
411 FIND FIRST Month
NO-LOCK. from-month
= Month.MonthCode.
412 FIND LAST Month
NO-LOCK. upto-month
= Month.MonthCode.
414 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
415 token
= ENTRY( i
, report-options
, "~n" ).
416 CASE( ENTRY( 1, token
) ):
417 WHEN "Range" THEN ASSIGN
418 project-from
= INT( ENTRY(2,token
) )
419 project-to
= INT( ENTRY(3,token
) ).
421 WHEN "Summarise" THEN summarise
= Yes.
422 WHEN "upto" THEN upto-month
= INT( ENTRY(2,token
)).
423 WHEN "From" THEN from-month
= INT( ENTRY(2,token
)).
424 WHEN "Preview" THEN preview
= Yes.
427 IF project-to
< project-from
THEN project-to
= project-from.
429 FIND Month
WHERE Month.MonthCode
= from-month
NO-LOCK.
430 from-date
= Month.StartDate.
432 FIND Month
WHERE Month.MonthCode
= upto-month
NO-LOCK.
433 upto-date
= Month.EndDate.
437 /* _UIB-CODE-BLOCK-END
*/
441 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pending-project-header Procedure
442 PROCEDURE pending-project-header
:
443 /*------------------------------------------------------------------------------
445 ------------------------------------------------------------------------------*/
446 DEF INPUT PARAMETER project-code
LIKE Project.ProjectCode
NO-UNDO.
448 FIND Project
WHERE Project.ProjectCode
= project-code
NO-LOCK NO-ERROR.
449 IF NOT AVAILABLE Project
THEN RETURN.
451 DEF VAR entity-name
AS CHAR NO-UNDO.
452 RUN get-entity-name
( Project.EntityType
, Project.EntityCode
, OUTPUT entity-name
).
454 pending-headers
= project-font
[1]
455 + "(" + STRING( Project.ProjectCode
, "99999" ) + ") - "
456 + Project.Name
+ ", " + entity-name
461 /* _UIB-CODE-BLOCK-END
*/
465 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-line Procedure
466 PROCEDURE print-line
:
467 /*------------------------------------------------------------------------------
469 ------------------------------------------------------------------------------*/
470 DEF INPUT PARAMETER out-line
AS CHAR NO-UNDO.
472 PUT UNFORMATTED out-line.
477 /* _UIB-CODE-BLOCK-END
*/
481 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-title Procedure
482 PROCEDURE print-title
:
483 /*------------------------------------------------------------------------------
487 ------------------------------------------------------------------------------*/
490 PUT CONTROL time-font.
492 STRING( "Printed: " + now
+ " for " + user-name
, "X(100)" ) SPACE(120)
493 STRING( "Page: " + STRING( page-no
), "X(20)" ).
495 PUT CONTROL title-font.
496 PUT UNFORMATTED "Project Orders/Commitments Tracking Report".
498 FIND FIRST Month
NO-LOCK.
499 IF from-month
> Month.MonthCode
THEN
500 PUT UNFORMATTED ", from " STRING( from-date
, "99/99/9999").
501 FIND LAST Month
NO-LOCK.
502 IF upto-month
< Month.MonthCode
THEN
503 PUT UNFORMATTED ", up to " STRING( upto-date
, "99/99/9999").
506 PUT CONTROL line-font.
510 /* _UIB-CODE-BLOCK-END
*/
514 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-totals Procedure
515 PROCEDURE print-totals
:
516 /*------------------------------------------------------------------------------
518 ------------------------------------------------------------------------------*/
519 DEF INPUT PARAMETER title-str
AS CHAR NO-UNDO.
520 DEF INPUT PARAMETER this-total
AS DEC NO-UNDO.
522 RUN print-line
( FILL(" ",22) + FILL("-", money-width
) ).
523 RUN print-line
( STRING( title-str
, "X(22)") + STRING(this-total
, money-fmt
) ).
527 /* _UIB-CODE-BLOCK-END
*/
531 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE project-header Procedure
532 PROCEDURE project-header
:
533 /*------------------------------------------------------------------------------
535 ------------------------------------------------------------------------------*/
536 IF pending-headers
= "" THEN RETURN.
538 DEF VAR i
AS INT NO-UNDO.
539 DEF VAR hdr-line
AS CHAR NO-UNDO.
541 DO WHILE ENTRY( 1, pending-headers
, "~n") <> "":
542 hdr-line
= ENTRY( 1, pending-headers
, "~n").
543 pending-headers
= SUBSTRING( pending-headers
, INDEX( pending-headers
, "~n") + 1).
544 IF hdr-line
= ?
THEN NEXT.
545 PUT CONTROL hdr-line.
549 pending-headers
= "".
553 /* _UIB-CODE-BLOCK-END
*/
557 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE reset-page Procedure
558 PROCEDURE reset-page
:
559 /*------------------------------------------------------------------------------
563 ------------------------------------------------------------------------------*/
565 PUT CONTROL reset-page.
570 /* _UIB-CODE-BLOCK-END
*/
574 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-line Procedure
575 PROCEDURE skip-line
:
576 /*------------------------------------------------------------------------------
578 ------------------------------------------------------------------------------*/
579 DEF INPUT PARAMETER n
AS DEC NO-UNDO.
581 IF ln
+ n
>= lines-per-page
THEN
588 DEF VAR int-part
AS INT NO-UNDO.
589 DEF VAR dec-part
AS DEC NO-UNDO.
591 int-part
= TRUNCATE( n
, 0 ).
592 IF int-part
< 0 THEN RETURN.
593 dec-part
= n
- int-part.
594 IF int-part
= 0 AND dec-part
= 0 THEN RETURN.
596 IF dec-part
<> 0 THEN PUT CONTROL half-line.
598 IF int-part
= 1 THEN PUT UNFORMATTED " " SKIP.
599 ELSE IF int-part
> 1 THEN PUT SKIP(int-part
).
605 /* _UIB-CODE-BLOCK-END
*/
609 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE skip-to-line Procedure
610 PROCEDURE skip-to-line
:
611 /*------------------------------------------------------------------------------
615 ------------------------------------------------------------------------------*/
616 DEF INPUT PARAMETER line-no
AS DEC NO-UNDO.
618 DEF VAR int-part
AS INT NO-UNDO.
619 DEF VAR dec-part
AS DEC NO-UNDO.
621 int-part
= TRUNCATE( line-no
- ln
, 0 ).
622 IF int-part
< 0 THEN RETURN.
623 dec-part
= ( line-no
- ln
) - int-part.
624 IF int-part
= 0 AND dec-part
= 0 THEN RETURN.
626 IF dec-part
<> 0 THEN PUT CONTROL half-line.
628 IF int-part
= 1 THEN PUT " " SKIP.
629 ELSE IF int-part
> 1 THEN PUT SKIP( int-part
).
635 /* _UIB-CODE-BLOCK-END
*/
639 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE summarise-sub-projects Procedure
640 PROCEDURE summarise-sub-projects
:
641 /*------------------------------------------------------------------------------
643 ------------------------------------------------------------------------------*/
644 DEF INPUT PARAMETER project-code
LIKE Project.ProjectCode
NO-UNDO.
646 DEF VAR orders
AS DEC NO-UNDO.
647 DEF VAR var-text
AS CHAR NO-UNDO.
649 DEF VAR detail-line
AS CHAR NO-UNDO.
650 DEF BUFFER SubProj
FOR Project.
652 FOR EACH SubProj
WHERE SubProj.EntityType
= "J"
653 AND SubProj.EntityCode
= project-code
NO-LOCK:
654 var-text
= "Orders for " + SubProj.Name.
655 orders
= sum-project-orders
( SubProj.ProjectCode
).
657 detail-line
= FILL( " ", 12)
658 + STRING( STRING(SubProj.ProjectCode
) + "/sub" , "X(10)")
659 + STRING( orders
, money-fmt
) + " "
660 + STRING( ENTRY( 1, var-text
, "~n"), "X(62)" ) .
662 IF orders
<> 0 THEN DO:
664 RUN print-line
( detail-line
).
666 ptot
= ptot
+ orders.
671 /* _UIB-CODE-BLOCK-END
*/
675 /* ************************ Function Implementations
***************** */
677 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION sum-project-orders Procedure
678 FUNCTION sum-project-orders
RETURNS DECIMAL
679 ( INPUT project-code
AS INT ) :
680 /*------------------------------------------------------------------------------
681 Purpose
: Sum orders
(or adjustments
) up to the upto-date
682 ------------------------------------------------------------------------------*/
683 DEF VAR order-total
AS DEC NO-UNDO INITIAL 0.
685 DEF BUFFER SubProj
FOR Project.
687 FOR EACH Order
NO-LOCK WHERE Order.ProjectCode
= project-code
688 AND Order.OrderDate
>= from-date
689 AND Order.OrderDate
<= upto-date
:
690 order-total
= order-total
+ Order.OrderAmount .
693 FOR EACH SubProj
WHERE SubProj.EntityType
= "J"
694 AND SubProj.EntityCode
= project-code
NO-LOCK:
695 order-total
= order-total
+ sum-project-orders
( SubProj.ProjectCode
).
702 /* _UIB-CODE-BLOCK-END
*/