1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 &IF DEFINED(UIB_IS_RUNNING) &THEN
8 DEF VAR report-options
AS CHAR NO-UNDO INITIAL "".
10 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
13 DEF VAR ctype-list
AS CHAR NO-UNDO.
14 DEF VAR ptype-list
AS CHAR NO-UNDO.
15 DEF VAR include-types
AS LOGI
NO-UNDO INIT Yes.
16 DEF VAR merge-list
AS LOGI
NO-UNDO INIT No.
18 DEF VAR preview
AS LOGI
NO-UNDO INIT No.
19 DEF VAR user-name
AS CHAR NO-UNDO.
20 {inc
/username.i
"user-name"}
21 DEF VAR timeStamp
AS CHAR FORMAT "X(44)" NO-UNDO.
22 timeStamp
= STRING( TODAY, "99/99/9999") + ", " + STRING( TIME, "HH:MM:SS") + " for " + user-name.
24 DEF TEMP-TABLE ListContact
NO-UNDO
25 FIELD PersonCode
AS INT
27 FIELD LastName
AS CHAR
28 INDEX XPKListContact
IS UNIQUE PRIMARY PersonCode
29 INDEX XAK1ListContact Company Lastname.
31 /* _UIB-CODE-BLOCK-END
*/
35 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
37 /* ******************** Preprocessor Definitions
******************** */
39 &Scoped-define PROCEDURE-TYPE Procedure
43 /* _UIB-PREPROCESSOR-BLOCK-END
*/
48 /* *********************** Procedure Settings
************************ */
50 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
51 /* Settings for
THIS-PROCEDURE
55 Add Fields to
: Neither
56 Other Settings
: CODE-ONLY
COMPILE
58 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
60 /* ************************* Create Window
************************** */
62 &ANALYZE-SUSPEND _CREATE-WINDOW
63 /* DESIGN Window definition
(used by the UIB
)
64 CREATE WINDOW Procedure
ASSIGN
67 /* END WINDOW DEFINITION
*/
73 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Procedure
74 /* ************************* Included-Libraries
*********************** */
76 {inc
/method
/m-txtrep.i
}
80 /* _UIB-CODE-BLOCK-END
*/
85 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
88 /* *************************** Main Block
*************************** */
92 OUTPUT TO VALUE(txtrep-print-file
) KEEP-MESSAGES PAGE-SIZE 0.
94 RUN pclrep-start
( preview
, "reset,landscape,tm,2,a4,lm,6,courier,cpi,18,lpi,9").
105 /* _UIB-CODE-BLOCK-END
*/
109 /* ********************** Internal Procedures
*********************** */
111 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE contact-listing Procedure
112 PROCEDURE contact-listing
:
113 /*------------------------------------------------------------------------------
115 ------------------------------------------------------------------------------*/
116 DEF VAR use-contact-type
AS LOGI
NO-UNDO.
118 FOR EACH ContactType
NO-LOCK:
120 use-contact-type
= LOOKUP( ContactType.ContactType
, ctype-list
) <> 0.
121 IF NOT include-types
THEN use-contact-type
= NOT use-contact-type.
122 IF NOT use-contact-type
THEN NEXT.
123 RUN each-contact-type.
129 /* _UIB-CODE-BLOCK-END
*/
133 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE each-contact-type Procedure
134 PROCEDURE each-contact-type
:
135 /*------------------------------------------------------------------------------
137 ------------------------------------------------------------------------------*/
138 DEF VAR person-address
AS CHAR NO-UNDO.
139 DEF VAR last-address
AS CHAR NO-UNDO.
140 DEF VAR phone-no
AS CHAR EXTENT 3 NO-UNDO.
141 DEF VAR phtype-list
AS CHAR NO-UNDO INIT "BUS,FAX,MOB".
142 DEF VAR i
AS INT NO-UNDO.
144 RUN pclrep-line
( "Helvetica,Point,12,Bold,Proportional", ContactType.Description
+ " (" + ContactType.ContactType
+ ")" ).
145 RUN pclrep-line
( ?
, "" ).
147 FOR EACH Contact
OF ContactType
NO-LOCK,
148 FIRST Person
OF Contact
NO-LOCK
149 BREAK BY Person.Company
/* BY Person.City
BY Person.Address
*/:
151 IF FIRST-OF( Person.Company
) THEN DO:
152 RUN process
/getaddr.p
( "PERSON", Person.PersonCode
, ptype-list
, OUTPUT person-address
).
153 person-address
= TRIM( TRIM( REPLACE( REPLACE( person-address
, "~r", ""), "~n", "," ), "," ) ).
154 IF person-address
<> "" THEN person-address
= ", " + person-address.
155 RUN pclrep-line
( "Helvetica,Point,8,Normal,Proportional", null-str
(Person.Company
,"?") + null-str
(person-address
,"?") ).
156 last-address
= person-address.
159 RUN process
/getaddr.p
( "PERSON", Person.PersonCode
, ptype-list
, OUTPUT person-address
).
160 person-address
= TRIM( TRIM( REPLACE( REPLACE( person-address
, "~r", ""), "~n", "," ), "," ) ).
161 IF person-address
<> "" THEN person-address
= ", " + person-address.
162 IF person-address
<> last-address
THEN
163 RUN pclrep-line
( "Helvetica,Point,8,Normal,Proportional", null-str
(Person.Company
,"?") + null-str
(person-address
,"?") ).
165 DO i
= 1 TO NUM-ENTRIES( phtype-list
):
166 FIND PhoneDetail
WHERE PhoneDetail.PersonCode
= Person.PersonCode
167 AND PhoneDetail.PhoneType
= ENTRY( i
, phtype-list
)
171 IF AVAILABLE PhoneDetail
THEN
172 RUN combine-phone
( PhoneDetail.cCountryCode
, PhoneDetail.cSTDCode
, PhoneDetail.Number
,
173 OUTPUT phone-no
[i
] ).
176 RUN pclrep-line
( "courier,Fixed,cpi,18,lpi,9,Normal",
178 STRING( null-str
(Person.FirstName
, "?"), "X(15)" ) + SPC
( 3 ) +
179 STRING( null-str
(Person.LastName
, "?"), "X(15)" ) + SPC
( 3 ) +
180 STRING( null-str
(phone-no
[1], "?"), "X(20)" ) + SPC
( 1 ) +
181 STRING( null-str
(phone-no
[2], "?"), "X(20)" ) + SPC
( 1 ) +
182 STRING( null-str
(phone-no
[3], "?"), "X(20)" ) + SPC
( 1 ) +
183 STRING( null-str
(Person.JobTitle
, "?"), "X(40)" ) + SPC
( 1 ) +
184 STRING( null-str
(Person.Department
, "?"), "X(40)" )
187 IF LAST-OF( Person.Company
) THEN RUN pclrep-line
( ?
, "" ).
193 /* _UIB-CODE-BLOCK-END
*/
197 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-footer Procedure
198 PROCEDURE inst-page-footer
:
199 /*------------------------------------------------------------------------------
200 Purpose
: Print any page footer
201 ------------------------------------------------------------------------------*/
205 /* _UIB-CODE-BLOCK-END
*/
209 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-page-header Procedure
210 PROCEDURE inst-page-header
:
211 /*------------------------------------------------------------------------------
212 Purpose
: Print any page header
213 ------------------------------------------------------------------------------*/
215 RUN pclrep-line
( "univers,Point,7,bold,proportional", TimeStamp
).
216 RUN pclrep-line
( "univers,Point,12,bold,proportional", FILL( " ", 45) + "Contact Listing").
218 IF merge-list
THEN DO:
219 RUN pclrep-line
( "", "").
220 RUN pclrep-line
( "courier,Fixed,cpi,18,lpi,9,Bold", "Contact Types: " + ctype-list
).
223 RUN pclrep-line
( "", "").
224 RUN pclrep-line
( "courier,Fixed,cpi,18,lpi,9,Bold",
226 STRING( "First Name", "X(15)" ) + SPC
( 3 ) +
227 STRING( "Last Name", "X(15)" ) + SPC
( 3 ) +
228 STRING( "Business", "X(20)" ) + SPC
( 1 ) +
229 STRING( "Facsimile", "X(20)" ) + SPC
( 1 ) +
230 STRING( "Mobile", "X(20)" ) + SPC
( 1 ) +
231 STRING( "Position title", "X(41)" ) + "Department~n"
236 /* _UIB-CODE-BLOCK-END
*/
240 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE merge-contacts Procedure
241 PROCEDURE merge-contacts
:
242 /*------------------------------------------------------------------------------
244 ------------------------------------------------------------------------------*/
245 DEF VAR use-contact-type
AS LOGI
NO-UNDO.
247 DEF VAR person-address
AS CHAR NO-UNDO.
248 DEF VAR phone-no
AS CHAR EXTENT 3 NO-UNDO.
249 DEF VAR phtype-list
AS CHAR NO-UNDO INIT "BUS,FAX,MOB".
250 DEF VAR i
AS INT NO-UNDO.
252 FOR EACH Contact
NO-LOCK:
253 IF CAN-FIND(FIRST ListContact
WHERE ListContact.PersonCode
= Contact.PersonCode
) THEN NEXT.
254 use-contact-type
= LOOKUP( Contact.ContactType
, ctype-list
) <> 0.
255 IF NOT include-types
THEN use-contact-type
= NOT use-contact-type.
256 IF NOT use-contact-type
THEN NEXT.
257 FIND FIRST Person
OF Contact
NO-LOCK NO-ERROR.
258 IF AVAILABLE(Person
) THEN DO:
260 ListContact.PersonCode
= Person.PersonCode.
261 ListContact.Company
= Person.Company.
262 ListContact.LastName
= Person.LastName.
266 FOR EACH ListContact
, FIRST Person
OF ListContact
267 BREAK BY ListContact.Company
BY ListContact.LastName
:
269 IF FIRST-OF( ListContact.Company
) THEN DO:
270 RUN process
/getaddr.p
( "PERSON", Person.PersonCode
, ptype-list
, OUTPUT person-address
).
271 person-address
= TRIM( TRIM( REPLACE( REPLACE( person-address
, CHR(13), ""), "~n", "," ), "," ) ).
272 IF person-address
<> "" THEN person-address
= ", " + person-address.
273 RUN pclrep-line
( "Helvetica,Point,8,Normal,Proportional", Person.Company
+ person-address
).
276 DO i
= 1 TO NUM-ENTRIES( phtype-list
):
277 FIND PhoneDetail
WHERE
278 PhoneDetail.PersonCode
= Person.PersonCode
AND
279 PhoneDetail.PhoneType
= ENTRY( i
, phtype-list
)
283 IF AVAILABLE PhoneDetail
THEN
284 RUN combine-phone
( PhoneDetail.cCountryCode
, PhoneDetail.cSTDCode
, PhoneDetail.Number
,
285 OUTPUT phone-no
[i
] ).
288 RUN pclrep-line
( "courier,Fixed,cpi,18,lpi,9,Normal",
290 STRING( null-str
(Person.FirstName
, "?"), "X(15)" ) + SPC
( 3 ) +
291 STRING( null-str
(Person.LastName
, "?"), "X(15)" ) + SPC
( 3 ) +
292 STRING( null-str
(phone-no
[1], "?"), "X(20)" ) + SPC
( 1 ) +
293 STRING( null-str
(phone-no
[2], "?"), "X(20)" ) + SPC
( 1 ) +
294 STRING( null-str
(phone-no
[3], "?"), "X(20)" ) + SPC
( 1 ) +
295 STRING( null-str
(Person.JobTitle
, "?"), "X(40)" ) + SPC
( 1 ) +
296 STRING( null-str
(Person.Department
, "?"), "X(40)" )
299 IF LAST-OF( ListContact.Company
) THEN
300 RUN pclrep-line
( ?
, "" ).
306 /* _UIB-CODE-BLOCK-END
*/
310 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE parse-parameters Procedure
311 PROCEDURE parse-parameters
:
312 /*------------------------------------------------------------------------------
316 ------------------------------------------------------------------------------*/
318 DEF VAR i
AS INT NO-UNDO.
319 DEF VAR token
AS CHAR NO-UNDO.
321 DO i
= 1 TO NUM-ENTRIES( report-options
, "~n" ):
322 token
= ENTRY( i
, report-options
, "~n" ).
324 CASE ENTRY( 1, token
):
325 WHEN "ContactTypes" THEN ctype-list
= SUBSTR( token
, INDEX( token
, "," ) + 1 ).
326 WHEN "PostalTypes" THEN ptype-list
= SUBSTR( token
, INDEX( token
, "," ) + 1 ).
327 WHEN "Exclude" THEN include-types
= ENTRY( 2, token
) <> "Yes".
328 WHEN "Preview" THEN preview
= Yes.
329 WHEN "Merge" THEN merge-list
= Yes.
336 /* _UIB-CODE-BLOCK-END
*/