Add blank column, rename column.
[capital-apms-progress.git] / process / report / batch-compare.p
blob4a3c0e06c69642b8101f90e2e7b898450d05e21d
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 DEF INPUT PARAMETER report-options AS CHAR NO-UNDO.
9 DEF VAR preview AS LOGI NO-UNDO INIT No.
10 DEF VAR posted-batch AS INT NO-UNDO INIT ?.
11 DEF VAR unposted-batch AS INT NO-UNDO INIT ?.
12 DEF VAR reverse AS LOGI NO-UNDO INITIAL No.
13 RUN parse-parameters.
16 DEF VAR user-name AS CHAR NO-UNDO.
17 {inc/username.i "user-name"}
18 DEF VAR timeStamp AS CHAR FORMAT "X(44)" NO-UNDO.
19 timeStamp = STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
21 DEF VAR line AS CHAR NO-UNDO.
23 DEF VAR time-font AS CHAR NO-UNDO INITIAL "helvetica,proportional,point,6,normal".
24 DEF VAR base-font AS CHAR NO-UNDO INITIAL "courier,fixed,cpi,16,lpi,9,normal".
25 DEF VAR header-font AS CHAR NO-UNDO INITIAL "Times,Point,11,lpi,6,Proportional,Normal".
28 DEFINE TEMP-TABLE MyTran LIKE NewAcctTran
29 INDEX XPKMyTran IS PRIMARY EntityType EntityCode AccountCode Amount.
31 /* _UIB-CODE-BLOCK-END */
32 &ANALYZE-RESUME
35 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
37 /* ******************** Preprocessor Definitions ******************** */
39 &Scoped-define PROCEDURE-TYPE Procedure
40 &Scoped-define DB-AWARE no
44 /* _UIB-PREPROCESSOR-BLOCK-END */
45 &ANALYZE-RESUME
49 /* *********************** Procedure Settings ************************ */
51 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
52 /* Settings for THIS-PROCEDURE
53 Type: Procedure
54 Allow:
55 Frames: 0
56 Add Fields to: Neither
57 Other Settings: CODE-ONLY COMPILE
59 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
61 /* ************************* Create Window ************************** */
63 &ANALYZE-SUSPEND _CREATE-WINDOW
64 /* DESIGN Window definition (used by the UIB)
65 CREATE WINDOW Procedure ASSIGN
66 HEIGHT = 18.25
67 WIDTH = 51.14.
68 /* END WINDOW DEFINITION */
70 &ANALYZE-RESUME
72 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
73 /* ************************* Included-Libraries *********************** */
75 {inc/method/m-txtrep.i}
76 {inc/date.i}
77 {inc/null.i}
78 {inc/convert.i}
80 /* _UIB-CODE-BLOCK-END */
81 &ANALYZE-RESUME
87 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
90 /* *************************** Main Block *************************** */
92 OUTPUT TO VALUE(txtrep-print-file) KEEP-MESSAGES PAGE-SIZE 0.
94 RUN pclrep-start( preview, "reset,portrait,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
96 RUN compare-batches.
98 OUTPUT CLOSE.
100 RUN pclrep-finish.
102 /* _UIB-CODE-BLOCK-END */
103 &ANALYZE-RESUME
106 /* ********************** Internal Procedures *********************** */
108 &IF DEFINED(EXCLUDE-compare-batches) = 0 &THEN
110 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE compare-batches Procedure
111 PROCEDURE compare-batches :
112 /*------------------------------------------------------------------------------
113 Purpose:
114 ------------------------------------------------------------------------------*/
115 RUN load-posted-batch.
116 RUN remove-unposted-equal.
117 RUN print-differences.
118 END PROCEDURE.
120 /* _UIB-CODE-BLOCK-END */
121 &ANALYZE-RESUME
123 &ENDIF
125 &IF DEFINED(EXCLUDE-inst-page-footer) = 0 &THEN
127 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
128 PROCEDURE inst-page-footer :
129 /*------------------------------------------------------------------------------
130 Purpose: Print any page footer
131 ------------------------------------------------------------------------------*/
133 END PROCEDURE.
135 /* _UIB-CODE-BLOCK-END */
136 &ANALYZE-RESUME
138 &ENDIF
140 &IF DEFINED(EXCLUDE-inst-page-header) = 0 &THEN
142 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
143 PROCEDURE inst-page-header :
144 /*------------------------------------------------------------------------------
145 Purpose:
146 ------------------------------------------------------------------------------*/
148 line = timeStamp.
149 line = line + CHR(13) + SPC(275) + "Page: " + STRING( pclrep-page-number ).
150 RUN pclrep-line( time-font, line).
152 RUN pclrep-down-by(2).
153 RUN pclrep-line( header-font, SPC(35) + "Comparing posted batch " + STRING(posted-batch) + " with unposted batch " + STRING(unposted-batch) ).
154 RUN pclrep-down-by(1).
156 END PROCEDURE.
158 /* _UIB-CODE-BLOCK-END */
159 &ANALYZE-RESUME
161 &ENDIF
163 &IF DEFINED(EXCLUDE-load-posted-batch) = 0 &THEN
165 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE load-posted-batch Procedure
166 PROCEDURE load-posted-batch :
167 /*------------------------------------------------------------------------------
168 Purpose:
169 ------------------------------------------------------------------------------*/
170 FOR EACH AcctTran WHERE BatchCode = posted-batch,
171 FIRST Document OF AcctTran NO-LOCK:
172 IF AcctTran.ConsequenceOf > 0 THEN NEXT.
173 IF Document.DocumentType = 'INTC' THEN NEXT.
174 CREATE MyTran.
175 BUFFER-COPY AcctTran TO MyTran.
176 END.
177 END PROCEDURE.
179 /* _UIB-CODE-BLOCK-END */
180 &ANALYZE-RESUME
182 &ENDIF
184 &IF DEFINED(EXCLUDE-parse-parameters) = 0 &THEN
186 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
187 PROCEDURE parse-parameters :
188 /*------------------------------------------------------------------------------
189 Purpose:
190 ------------------------------------------------------------------------------*/
191 {inc/showopts.i "report-options"}
193 DEF VAR token AS CHAR NO-UNDO.
194 DEF VAR i AS INT NO-UNDO.
196 DO i = 1 TO NUM-ENTRIES( report-options, "~n" ):
197 token = ENTRY( i, report-options, "~n" ).
199 CASE ENTRY( 1, token ):
200 WHEN "Preview" THEN preview = Yes.
201 WHEN "Reverse" THEN reverse = Yes.
202 WHEN "PostedBatch" THEN posted-batch = INT( ENTRY(2,token ) ).
203 WHEN "UnpostedBatch" THEN unposted-batch = INT( ENTRY(2,token ) ).
204 END CASE.
206 END.
208 END PROCEDURE.
210 /* _UIB-CODE-BLOCK-END */
211 &ANALYZE-RESUME
213 &ENDIF
215 &IF DEFINED(EXCLUDE-print-differences) = 0 &THEN
217 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE print-differences Procedure
218 PROCEDURE print-differences :
219 /*------------------------------------------------------------------------------
220 Purpose:
221 ------------------------------------------------------------------------------*/
222 FOR EACH MyTran BY EntityType BY EntityCode BY AccountCode BY Amount:
223 line = MyTran.EntityType + " "
224 + STRING( MyTran.EntityCode, "99999") + " "
225 + STRING( MyTran.AccountCode, "9999.99") + " "
226 + STRING( MyTran.Amount, "->>,>>>,>>9.99" ) + " "
227 + STRING( MyTran.BatchCode, ">>9999").
228 RUN pclrep-line( base-font, line ).
229 END.
230 END PROCEDURE.
232 /* _UIB-CODE-BLOCK-END */
233 &ANALYZE-RESUME
235 &ENDIF
237 &IF DEFINED(EXCLUDE-remove-unposted-equal) = 0 &THEN
239 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE remove-unposted-equal Procedure
240 PROCEDURE remove-unposted-equal :
241 /*------------------------------------------------------------------------------
242 Purpose:
243 ------------------------------------------------------------------------------*/
244 FOR EACH NewAcctTran WHERE BatchCode = unposted-batch NO-LOCK:
245 FIND FIRST MyTran WHERE MyTran.EntityType = NewAcctTran.EntityType
246 AND MyTran.EntityCode = NewAcctTran.EntityCode
247 AND MyTran.AccountCode = NewAcctTran.AccountCode
248 AND MyTran.Amount = NewAcctTran.Amount NO-ERROR.
249 IF AVAILABLE(MyTran) THEN
250 DELETE MyTran.
251 ELSE DO:
252 CREATE MyTran.
253 BUFFER-COPY NewAcctTran TO MyTran.
254 END.
255 END.
257 END PROCEDURE.
259 /* _UIB-CODE-BLOCK-END */
260 &ANALYZE-RESUME
262 &ENDIF