1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
15 ------------------------------------------------------------------------*/
16 /* This .W file was created with the Progress UIB.
*/
17 /*----------------------------------------------------------------------*/
19 /* *************************** Definitions
************************** */
21 DEF INPUT PARAMETER report-options
AS CHAR NO-UNDO.
22 DEF INPUT PARAMETER entity-code
LIKE AcctTran.EntityCode
NO-UNDO.
23 DEF INPUT PARAMETER type-list
AS CHAR NO-UNDO.
24 DEF OUTPUT PARAMETER address
AS CHAR NO-UNDO.
26 /* _UIB-CODE-BLOCK-END
*/
30 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
32 /* ******************** Preprocessor Definitions
******************** */
34 &Scoped-define PROCEDURE-TYPE Procedure
38 /* _UIB-PREPROCESSOR-BLOCK-END
*/
43 /* *********************** Procedure Settings
************************ */
45 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
46 /* Settings for
THIS-PROCEDURE
50 Add Fields to
: Neither
51 Other Settings
: CODE-ONLY
COMPILE
53 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
55 /* ************************* Create Window
************************** */
57 &ANALYZE-SUSPEND _CREATE-WINDOW
58 /* DESIGN Window definition
(used by the UIB
)
59 CREATE WINDOW Procedure
ASSIGN
62 /* END WINDOW DEFINITION
*/
69 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
72 /* *************************** Main Block
*************************** */
74 DEF VAR person-code
LIKE Person.PersonCode
NO-UNDO.
75 DEF VAR entity-type
AS CHAR NO-UNDO.
76 DEF VAR address-type
AS CHAR NO-UNDO.
77 DEF VAR other-options
AS CHAR NO-UNDO.
78 /* DEF VAR opt-person-name
AS LOGICAL NO-UNDO.
*/
79 DEF VAR opt-person-name
AS CHAR INIT "" NO-UNDO.
/* Stolen for attn line
*/
80 DEF VAR entity-name
AS CHAR NO-UNDO.
81 DEF VAR state-line
AS CHAR NO-UNDO.
82 DEF VAR country-line
AS CHAR NO-UNDO.
83 DEF VAR i
AS INT NO-UNDO.
84 DEF BUFFER pd
FOR PostalDetail.
87 {inc
/ofc-set.i
"Country" "office-country"}
88 {inc
/ofc-set.i
"Address-Attention" "address-attention"}
89 {inc
/ofc-set.i
"Address-Priority" "priority-list"}
90 IF type-list
= ?
OR type-list
= "" THEN type-list
= priority-list.
92 entity-type
= ENTRY( 1, report-options
).
93 IF NUM-ENTRIES( report-options
) > 1 THEN DO:
94 opt-person-name
= ENTRY( 2, report-options
).
95 /* other-options
= ENTRY( 2, report-options
).
96 opt-person-name
= INDEX( other-options
, "N" ) <> 0.
*/
102 FIND Tenant
WHERE Tenant.TenantCode
= entity-code
NO-LOCK NO-ERROR.
103 IF AVAILABLE Tenant
THEN ASSIGN
104 entity-name
= Tenant.Name
105 person-code
= Tenant.BillingContact.
109 FIND Creditor
WHERE Creditor.CreditorCode
= entity-code
NO-LOCK NO-ERROR.
110 IF AVAILABLE Creditor
THEN ASSIGN
111 entity-name
= Creditor.Name
112 person-code
= Creditor.PaymentContact.
115 WHEN "PERSON" THEN DO:
117 person-code
= entity-code.
120 IF entity-name
= ?
THEN entity-name
= "".
122 DO WHILE NOT AVAILABLE PD
AND i
< NUM-ENTRIES( type-list
).
126 PD.PersonCode
= person-code
AND
127 PD.PostalType
= ENTRY( i
, type-list
) NO-LOCK NO-ERROR.
131 IF NOT AVAILABLE PD
THEN
132 FIND FIRST PD
WHERE PD.PersonCode
= person-code
NO-LOCK NO-ERROR.
135 RUN cat-non-null
( entity-name
).
137 /* Inject the user entered attn line if it exists. Dont know what the
138 lookup is for but two attns will appear if I dont check it
*/
139 IF LOOKUP( address-type
, address-attention
) = 0 AND opt-person-name
<> "" THEN
140 RUN cat-non-null
( "~nAttn: " + opt-person-name
).
142 IF AVAILABLE(PD
) THEN DO:
144 state-line
= IF PD.State
= ?
THEN "" ELSE PD.State.
145 state-line
= IF PD.Zip
= ?
THEN state-line
146 ELSE state-line
+ " " + PD.Zip.
148 RUN cat-non-null
( "~n" + TRIM(PD.Address
) ).
149 RUN cat-non-null
( "~n" + TRIM(PD.City
) ).
150 IF TRIM(state-line
) <> "" THEN RUN cat-non-null
( ", " + TRIM(state-line
) ).
153 IF PD.Country
<> office-country
THEN country-line
= PD.Country.
155 RUN cat-non-null
( "~n" + TRIM(country-line
) ).
157 address-type
= PD.PostalType.
158 IF LOOKUP( address-type
, address-attention
) > 0 THEN DO:
159 FIND Person
WHERE Person.PersonCode
= person-code
NO-LOCK.
160 IF entity-name
<> (Person.FirstName
+ " " + Person.LastName
)
161 AND TRIM(Person.FirstName
+ Person.LastName
) <> "" THEN DO:
162 RUN cat-non-null
( "~nAttn: ").
163 RUN cat-non-null
( Person.PersonTitle
+ " ").
164 RUN cat-non-null
( Person.FirstName
+ " " ).
165 RUN cat-non-null
( Person.LastName
).
170 address
= TRIM(REPLACE(address
, "~r", "")).
171 DO WHILE INDEX( address
, ",~n") > 0:
172 address
= REPLACE( address
, ",~n", "~n").
174 DO WHILE INDEX( address
, "~n ") > 0:
175 address
= REPLACE( address
, "~n ", "~n").
177 DO WHILE INDEX( address
, " ~n") > 0:
178 address
= REPLACE( address
, " ~n", "~n").
180 DO WHILE INDEX( address
, "~n~n") > 0:
181 address
= REPLACE( address
, "~n~n", "~n").
184 /* _UIB-CODE-BLOCK-END
*/
188 /* ********************** Internal Procedures
*********************** */
190 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE cat-non-null Procedure
191 PROCEDURE cat-non-null
:
192 /*------------------------------------------------------------------------------
193 Purpose
: concatenate the string onto address only if it is non-null
194 ------------------------------------------------------------------------------*/
195 DEF INPUT PARAMETER s2
AS CHAR NO-UNDO.
197 IF s2
= ?
OR TRIM(s2
) = "" THEN RETURN.
198 address
= address
+ s2.
201 /* _UIB-CODE-BLOCK-END
*/