Friday, 5 December 2008

Stopping CACI Anabase creating .finish file

Anabase will not run if the path to the nnn.finish file is too long. To workaround this problem, stop Anabase creating the file by editing file /opt/caci/cf/sort-it.cf (replace /opt/caci with the correct path if necessary). Comment out lines, as shown in red below:
**********************************************************************
* *
* Author: Pete *
* Dated: July 2002 *
* *
* Purpose: - *
* Main control process that validates input *
* parameters and uses systemcalls to execute *
* the required Mailsort processes. *
* *
* June 2006 - PW *
* - Pricing in Proportion Changes *
* *
* Amended - Sept 2006 - PW *
* - Populate walkid field with 'UK' or 'FRG' *
* dependent on record type. *
* *
* Amended: - July 2008 *
* Punctuation Processing *
* *
**********************************************************************
**
** Parameters passed into this control file are: -
**
** 1 - work directory
** 2 - job id
**
control
job = sort-it
report = %1/sort-it.rep
licence file = $licence
cd = %1

work
name = allowed
length = 10
initial value = >20

record
w-go-wsort = 1 / 1 / u / / Y
w-go-700 = 2 / 1 / u / / Y
w-go-1400 = 3 / 1 / u / / Y
w-go-120 = 4 / 1 / u / / Y
w-go-pcode = 5 / 1 / u / / Y

work
name = general
length = 550
initial value = >20

record
w-tag = 1 / 30
w-action = 31 / 3
w-start = 41 / 2 / b / / 0
w-end = 51 / 2 / b / / 0
w-current = 61 / 4 / b / / 0
w-quote = 71 / 1 / / / >22
w-where = 81 / 10
w-tag2 = 101 / 30
w-error = 131 / 4

w-innumn = 141 / 8 / n
w-innum = 151 / 8
w-readnum = 161 / 8

w-split = 171 / 1 / / / N
w-continue = 172 / 1 / / / N

w-serlvl = 173 / 1

w-flags = 201 / 12 / / / NNNNNNNNNNNN
w-whatsort = 201 / 1
w-numenv = 202 / 1
w-avgwgt = 203 / 1
w-mixwgt = 204 / 1
w-filesplt = 205 / 1
w-fileord = 206 / 1
w-geoseq = 207 / 1
w-bundle = 208 / 1
w-addbar = 209 / 1
w-mpt = 210 / 1
w-perend = 211 / 1
w-accum = 212 / 1

w-sorts = 221 / 4 / / / NNNN
w-wsort = 221 / 1 / u
w-700 = 222 / 1 / u
w-1400 = 223 / 1 / u
w-120 = 224 / 1 / u

w-nonsort = 241 / 1 / / / N

w-dispnumx = 301 / 10
w-caciuser = 320 / 4 / / / $CACI_User
w-lastused = 340 / 4
w-fulllog = 350 / 1 / u / / $FullLog
w-bypassad = 351 / 1 / u / / $ByPassAdd
w-keeptmpf = 352 / 1 / u / / $KeepTmpFile
w-dumpadds = 353 / 1 / u / / $DumpAddress
w-newpcode = 354 / 1 / u / / $NewPostcode
w-reportit = 355 / 1 / u / / $ReportIt

w-noPAF = 356 / 1 / u / / $noPAF

w-onefile = 357 / 1 / u / / $OneFile

w-punctopt = 359 / 5 * 072008
w-uPAFadd = 359 / 1 / u / / $UsePAFAdd * 072008
w-uPAFpun = 360 / 1 / u / / N *$UseAllowedPAFPunct * 072008
w-rallpun = 361 / 1 / u / / $RemoveAllPunct * 072008
w-runwpun = 362 / 1 / u / / N *$RemoveUnwantedPunct * 072008
w-punrep = 363 / 1 / u / / $PunctuationReport * 072008

w-rmpunout = 364 / 1 / u / / N *$RemovePunctAtOutput * 072008

w-walknopu = 365 / 1 / u / / N *$NoPunctWalksort * 072008
w-700nopu = 366 / 1 / u / / N *$NoPunct700 * 072008
w-120nopu = 367 / 1 / u / / N *$NoPunct120 * 072008
w-1400nopu = 368 / 1 / u / / N *$NoPunct1400 * 072008
w-cmnopu = 369 / 1 / u / / N *$NoPunctCleanM * 072008

w-genpos = 375 / 2 / b / / 0

w-format = 380 / 12

w-date = 401 / 20 / d / 4
w-datex = 401 / 20
w-time = 421 / 10

w-inwgt = 431 / 4 / n

wkmwgt = 451 / 4 / n / / $MaxWgtWalksort
wkmwgtx = 451 / 4
1400mwgt = 455 / 4 / n / / $MaxWgt1400
1400mwgtx = 455 / 4
700mwgt = 459 / 4 / n / / $MaxWgt700
700mwgtx = 459 / 4
120mwgt = 463 / 4 / n / / $MaxWgt120
120mwgtx = 463 / 4

w-walkbc = 481 / 4 / b / / 0
w-walknbc = 485 / 4 / b / / 0
w-700bc = 489 / 4 / b / / 0
w-700nbc = 493 / 4 / b / / 0
w-1400bc = 497 / 4 / b / / 0
w-1400nbc = 501 / 4 / b / / 0
w-120bc = 505 / 4 / b / / 0
w-120nbc = 509 / 4 / b / / 0

w-perc = 520 / 4 / b / 2 / 0

work
name = for-vsf
length = 10
initial value = >20

record
wv-iosize = 1 / 2 / b
wv-curpos = 3 / 4 / b / / 0

file
name = whathappen
pathname = %1/whathappen
file type = variable
access = both
current position = wv-curpos
item length = 250
block length = 250
i-o size = wv-iosize
open action = add

record
wh-key = 1 / 4
wh-walked = 5 / 4 / b
wh-700ed = 9 / 4 / b
wh-1400ed = 13 / 4 / b
wh-120ed = 17 / 4 / b
wh-remain = 21 / 4 / b
wh-seqno = 25 / 4 / b
wh-errors = 29 / 4 / b
wh-UKre = 33 / 4 / b
wh-nonUKre = 37 / 4 / b
wh-cleanm = 41 / 4 / b
wh-noclean = 45 / 4 / b
wh-totalin = 49 / 4 / b
wh-except = 53 / 4 / b
wh-totexc = 57 / 4 / b
wh-totbc = 61 / 4 / b
wh-totnbc = 65 / 4 / b
wh-mess1 = 71 / 80
wh-mess2 = 151 / 80

file
name = parameters
file type = text
pathname = %2.par
access = read
open action = add
item length = 80

record
p-rec = 1 / 80
p-char1 = 1 / 1

work
name = known-tags
length = 1000
initial value = >20

record
k-goodtags = 1 / 900
unused = 1 / 30 ///
unused = 31 / 30 ///
unused = 61 / 30 ///
unused = 91 / 30 ///
unused = 121 / 30 ///
unused = 151 / 30 ///
unused = 181 / 30 ///
unused = 211 / 30 ///
unused = 241 / 30 ///
unused = 271 / 30 ///
unused = 301 / 30 ///
unused = 331 / 30 ///
unused = 361 / 30 /// * 072008
unused = 391 / 30 /// * 072008
unused = 421 / 30 /// * 072008
unused = 451 / 30 /// * 072008
unused = 481 / 30 ///
unused = 511 / 30 ///
unused = 541 / 30 ///
unused = 571 / 30 ///
unused = 601 / 30 ///
unused = 631 / 30 ///
unused = 661 / 30 ///
unused = 691 / 30 ///
unused = 721 / 30 ///
unused = 751 / 30 ///
unused = 781 / 30 /// * 072008
unused = 811 / 30 /// * 072008

k-tag = 901 / 30
k-current = 931 / 4 / b / / 0
k-currend = 935 / 4 / b / / 28
k-action = 941 / 3

table
name = good-tags
item length = 30
key position = 1
allow duplicate key values = no
table area = k-goodtags
fill character = >20
action = k-action
key value = k-tag
current position = k-current
current end position = k-currend

record
good-tag = 1 / 30

work
name = geo-region
length = 100
initial value = >20

record
g-regions = 1 / 51
unused = 1 / 36
unused = 37 / 15

g-region = 61 / 1
g-current = 71 / 4 / b / / 0
g-currend = 75 / 4 / b / / 0
g-action = 79 / 3

table
name = region-tab
item length = 3
key position = 1
allow duplicate key values = no
table area = g-regions
fill character = >20
action = g-action
key value = g-region
current position = g-current
current end position = g-currend

record
g-geoseq = 1 / 1
g-geoseqn = 2 / 2 / n

table
name = parm-tab
item length = 42
key position = 1
allow duplicate key values = no
fill character = >20
action = w-action
key value = w-tag
current position = w-current

record
pt-tag = 1 / 30 / u
pt-serv = 1 / 8

pt-value = 31 / 12 / u
pt-yesno = 31 / 1
pt-serlev = 31 / 1
pt-order = 31 / 1
pt-qtyx = 31 / 8
pt-qty = 31 / 8 / n
pt-weightx = 31 / 4
pt-weight = 31 / 4 / n
pt-geoseq = 31 / 1
pt-bundlex = 31 / 3
pt-bundle = 31 / 3 / n
pt-mpt = 31 / 12

file
name = audit
pathname = %2.log
file type = text
access = write
open action = add
item length = 200
immediate write = yes

record
a-rec = 1 / 200
a-mess = 3 / 30
a-total = 33 / 12

file
name = inform
pathname = %2.inf
file type = text
access = write
open action = replace
item length = 100
immediate write = yes

record
if-rec = 1 / 100

work
name = err-parm
length = 500
initial value = >20

record
er-parm = 1 / 500
unused = 1 / 5 / / / -21 "
er-path = 6 / 200
unused = 207 / 5 / / / -22 "
er-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
er-mess1 = 238 / 81
unused = 321 / 5 / / / -24 "
er-mess2 = 326 / 81

systemcall
name = call-error
command = $bu -c $ClientCode
options = er-parm
arguments = $caci_cf/errors.cf
action in edit = no
stop on error = no
error = w-error

work
name = add-parm
length = 325
initial value = >20

record
ad-parm = 1 / 325
unused = 1 / 5 / / / -21 "
ad-path = 6 / 200
unused = 207 / 5 / / / -22 "
ad-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
ad-report = 238 / 1
unused = 239 / 7 / / / " -24 "
ad-amendpc = 246 / 1
unused = 247 / 7 / / / " -25 "
ad-addbar = 254 / 1
unused = 255 / 7 / / / " -26 "
ad-repONLY = 262 / 1
unused = 263 / 7 / / / " -27 "
ad-serlvl = 270 / 1
unused = 271 / 7 / / / " -28 "
ad-accum = 278 / 1
unused = 279 / 7 / / / " -29 " * 072008
ad-uPAFadd = 286 / 1 * 072008
unused = 287 / 7 / / / " -30 " * 072008
ad-uPAFpun = 294 / 1 * 072008
unused = 295 / 7 / / / " -31 " * 072008
ad-rallpun = 302 / 1 * 072008
unused = 303 / 7 / / / " -32 " * 072008
ad-runwpun = 310 / 1 * 072008
unused = 311 / 7 / / / " -33 " * 072008
ad-punrep = 318 / 1 * 072008
unused = 319 / 1 / / / >22 * 072008

systemcall
name = call-addit
command = $bu -c $ClientCode
options = ad-parm
arguments = $caci_cf/address-it.cf
action in edit = no
stop on error = no
error = w-error

*** 072008
work
name = pun-parm
length = 700
initial value = >20

record
po-parm = 1 / 700
unused = 1 / 5 / / / -21 "
po-path = 6 / 200
unused = 207 / 5 / / / -22 "
po-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
po-uPAFadd = 238 / 1
unused = 239 / 7 / / / " -24 "
po-uPAFpun = 246 / 1
unused = 247 / 7 / / / " -25 "
po-rallpun = 254 / 1
unused = 255 / 7 / / / " -26 "
po-runwpun = 262 / 1
unused = 263 / 7 / / / " -27 "
po-punrep = 270 / 1
unused = 271 / 7 / / / " -28 "
po-infile = 278 / 200
unused = 480 / 5 / / / -29 "
po-rpfile = 485 / 200
unused = 686 / 4 / / / -30
po-scheme = 690 / 4

systemcall
name = call-punit
command = $bu -c $ClientCode
options = po-parm
arguments = $caci_cf/punct-it.cf
action in edit = no
stop on error = no
error = w-error
*** 072008

work
name = cm-parm
length = 250
initial value = >20

record
cm-parm = 1 / 250
unused = 1 / 5 / / / -21 "
cm-path = 6 / 200
unused = 207 / 5 / / / -22 "
cm-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
cm-split = 238 / 1
unused = 239 / 1 / / / "

systemcall
name = call-clean
command = $bu -c $ClientCode
options = cm-parm
arguments = $caci_cf/bcodeonly.cf
action in edit = no
stop on error = no
error = w-error

work
name = wsort-parm
length = 360
initial value = >20

record
ws-parm = 1 / 360
unused = 1 / 5 / / / -21 "
ws-path = 6 / 200
unused = 207 / 5 / / / -22 "
ws-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
ws-serlev = 238 / 1
unused = 239 / 7 / / / " -24 "
ws-split = 246 / 1
unused = 247 / 7 / / / " -25 "
ws-unspec = 248 / 8
ws-mixwgt = 254 / 1
unused = 255 / 7 / / / " -26 "
ws-avgwgt = 262 / 4
ws-avgwgtn = 262 / 4 / n
unused = 266 / 7 / / / " -27 "
ws-onepass = 273 / 1
unused = 274 / 7 / / / " -28 "
ws-oneschm = 281 / 1
unused = 282 / 7 / / / " -29 "
ws-geoseq = 289 / 2
ws-geoseqn = 289 / 2 / n
unused = 291 / 7 / / / " -30 "
ws-bundle = 298 / 3
ws-bundlen = 298 / 3 / n
unused = 301 / 7 / / / " -31 "
ws-order = 308 / 1
unused = 309 / 7 / / / " -32 "
ws-mselqty = 316 / 4
unused = 320 / 7 / / / " -33 "
ws-mmsqty = 327 / 4
unused = 331 / 7 / / / " -34 "
ws-format = 338 / 12
unused = 350 / 1 / / / "

systemcall
name = call-wsort
command = $bu -c $ClientCode
options = ws-parm
arguments = $caci_cf/walksort.cf
action in edit = no
stop on error = no
error = w-error

work
name = wpr-work
length = 500
initial value = >20

record
wpr-parms = 1 / 500

systemcall
name = wpr
command = $bu -c $ClientCode
options = wpr-parms
arguments = $caci_cf/wpr.cf
action in edit = no
stop on error = no
error = w-error

work
name = wll-work
length = 500
initial value = >20

record
wll-parms = 1 / 500

systemcall
name = wll
command = $bu -c $ClientCode
options = wll-parms
arguments = $caci_cf/wll.cf
action in edit = no
stop on error = no
error = w-error

work
name = wsdb-parm
length = 500
initial value = >20

record
wb-parm = 1 / 500
unused = 1 / 5 / / / -21 "
wb-path = 6 / 200
unused = 207 / 5 / / / -22 "
wb-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
wb-infile = 238 / 200

systemcall
name = wsdb-chk
command = $bu -c $ClientCode
options = wb-parm
arguments = $caci_cf/wsdb-chk.cf
action in edit = no
stop on error = no
error = w-error

work
name = cbc-parm
length = 540
initial value = >20

record
cs-parm = 1 / 540
unused = 1 / 5 / / / -21 "
cs-path = 6 / 200
unused = 207 / 5 / / / -22 "
cs-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
cs-serlev = 238 / 1
unused = 239 / 7 / / / " -24 "
cs-split = 246 / 1
unused = 247 / 7 / / / " -25 "
cs-unspec = 248 / 8
cs-mixwgt = 254 / 1
unused = 255 / 7 / / / " -26 "
cs-avgwgt = 262 / 4
cs-avgwgtn = 262 / 4 / n
unused = 266 / 7 / / / " -27 "
cs-onepass = 273 / 1
unused = 274 / 7 / / / " -28 "
cs-oneschm = 281 / 1
unused = 282 / 7 / / / " -29 "
cs-geoseq = 289 / 2
cs-geoseqn = 289 / 2 / n
unused = 291 / 7 / / / " -30 "
cs-bundle = 298 / 3
cs-bundlen = 298 / 3 / n
unused = 301 / 7 / / / " -31 "
cs-order = 308 / 1
unused = 309 / 7 / / / " -32 "
cs-format = 316 / 12
unused = 328 / 7 / / / " -33 "
cs-infile = 335 / 200

systemcall
name = call-csort
command = $bu -c $ClientCode
options = cs-parm
arguments = $caci_cf/msort700.cf
action in edit = no
stop on error = no
error = w-error

work
name = 1400-parm
length = 565
initial value = >20

record
ms-parm = 1 / 565
unused = 1 / 5 / / / -21 "
ms-path = 6 / 200
unused = 207 / 5 / / / -22 "
ms-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
ms-serlev = 238 / 1
unused = 239 / 7 / / / " -24 "
ms-split = 246 / 1
unused = 247 / 7 / / / " -25 "
ms-unspec = 248 / 8
ms-mixwgt = 254 / 1
unused = 255 / 7 / / / " -26 "
ms-avgwgt = 262 / 4
ms-avgwgtn = 262 / 4 / n
unused = 266 / 7 / / / " -27 "
ms-onepass = 273 / 1
unused = 274 / 7 / / / " -28 "
ms-oneschm = 281 / 1
unused = 282 / 7 / / / " -29 "
ms-geoseq = 289 / 2
ms-geoseqn = 289 / 2 / n
unused = 291 / 7 / / / " -30 "
ms-bundle = 298 / 3
ms-bundlen = 298 / 3 / n
unused = 301 / 7 / / / " -31 "
ms-order = 308 / 1
unused = 309 / 7 / / / " -32 "
ms-mselqty = 316 / 4
unused = 320 / 7 / / / " -33 "
ms-mmsqty = 327 / 4
unused = 331 / 7 / / / " -34 "
ms-format = 338 / 12
unused = 350 / 7 / / / " -35 "
ms-infile = 357 / 200

systemcall
name = call-1400
command = $bu -c $ClientCode
options = ms-parm
arguments = $caci_cf/msort1400.cf
action in edit = no
stop on error = no
error = w-error

work
name = 120-parm
length = 560
initial value = >20

record
mr-parm = 1 / 560
unused = 1 / 5 / / / -21 "
mr-path = 6 / 200
unused = 207 / 5 / / / -22 "
mr-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
mr-serlev = 238 / 1
unused = 239 / 7 / / / " -24 "
mr-split = 246 / 1
unused = 247 / 7 / / / " -25 "
mr-unspec = 248 / 8
mr-mixwgt = 254 / 1
unused = 255 / 7 / / / " -26 "
mr-avgwgt = 262 / 4
mr-avgwgtn = 262 / 4 / n
unused = 266 / 7 / / / " -27 "
mr-onepass = 273 / 1
unused = 274 / 7 / / / " -28 "
mr-oneschm = 281 / 1
unused = 282 / 7 / / / " -29 "
mr-geoseq = 289 / 2
mr-geoseqn = 289 / 2 / n
unused = 291 / 7 / / / " -30 "
mr-bundle = 298 / 3
mr-bundlen = 298 / 3 / n
unused = 301 / 7 / / / " -31 "
mr-order = 308 / 1
unused = 309 / 7 / / / " -32 "
mr-format = 316 / 12
unused = 328 / 7 / / / " -33 "
mr-mmq = 335 / 5
mr-mmqn = 335 / 5 / n
unused = 340 / 7 / / / " -34 "
mr-accum = 347 / 1
unused = 348 / 7 / / / " -35 "
mr-infile = 355 / 200

systemcall
name = call-120
command = $bu -c $ClientCode
options = mr-parm
arguments = $caci_cf/msort120.cf
action in edit = no
stop on error = no
error = w-error

systemcall
name = call-120A
command = $bu -c $ClientCode
options = mr-parm
arguments = $caci_cf/msort120A.cf
action in edit = no
stop on error = no
error = w-error

work
name = mpr-parm
length = 600
initial value = >20

record
mp-parms = 1 / 600
unused = 1 / 4 / / / -1 "
mp-in = 5 / 121
unused = 127 / 4 / / / -2 "
mp-out = 131 / 121
unused = 253 / 3 / / / -3
mp-rtype = 256 / 1
unused = 258 / 3 / / / -4
mp-batch = 261 / 1
unused = 263 / 3 / / / -5
mp-rev = 266 / 1
unused = 268 / 3 / / / -6
mp-m-code = 271 / 2
unused = 274 / 3 / / / -7
mp-ocr = 277 / 1
unused = 279 / 3 / / / -8
mp-1pm = 282 / 1
unused = 284 / 3 / / / -9
mp-mps = 287 / 1
unused = 289 / 4 / / / -10
mp-i-wgt = 293 / 5
unused = 299 / 5 / / / -21 "
mp-dir = 304 / 200

systemcall
name = mpr
command = $bu -c $ClientCode
options = mp-parms
arguments = $caci_cf/mpr.cf
action in edit = no
stop on error = no
error = w-error

work
name = mll-parm
length = 500
initial value = >20

record
mll-parms = 1 / 500

systemcall
name = mll
command = $bu -c $ClientCode
options = mll-parms
arguments = $caci_cf/mll.cf
action in edit = no
stop on error = no
error = w-error

** 05/09 **
work
name = 1file-parm
length = 300
initial value = >20

record
1f-parms = 1 / 300
unused = 1 / 5 / / / -21 "
1f-path = 6 / 200
unused = 207 / 5 / / / -22 "
1f-jobid = 212 / 20
unused = 233 / 5 / / / -23 "
1f-file = 238 / 40

systemcall
name = one-file
command = $bu -c $ClientCode
options = 1f-parms
arguments = $caci_cf/onefile.cf
action in edit = no
stop on error = no
error = w-error
** 05/09 **

work
name = wsort-tidy
length = 500
initial value = >20

record
wtidy-up = 1 / 500

systemcall
name = rm-out
command = rm -f
arguments = wtidy-up
action in edit = no
stop on error = no
error = w-error

work
name = joinfiles
length = 500
initial value = >20

record
file-join = 1 / 500

systemcall
name = join-files
command = cat
arguments = file-join
action in edit = no
stop on error = no
error = w-error

work
name = renamefs
length = 500
initial value = >20

record
rename-fs = 1 / 500

systemcall
name = rename
command = mv
arguments = rename-fs
action in edit = no
stop on error = no
error = w-error

*systemcall
* name = job-done
* command = echo "" > %1/%2.finish
* action in edit = no
* stop on error = no
* error = w-error

select
name = YorN
field = pt-yesno
ranges = no
select matches = yes
values = (Y,N)

select
name = 1or2or3
field = pt-serlev
ranges = no
select matches = yes
values = (1,2,3)

select
name = SorEorTorP
field = pt-order
ranges = no
select matches = yes
values = (E,P,S,T)

select
name = GeoSeq
field = pt-geoseq
ranges = no
select matches = yes
values = (>20,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P)

select
name = MailPiece
field = pt-mpt
ranges = no
select matches = yes
values = (LETTER,PACKET,LARGE LETTER,A3 PACKET)

work
name = mcf-file
length = 2048
initial value = >00

record
wf-err = 1 / 4 * error code
wf-fct = 5 / 4 * file control
wf-iad = 9 / 4 * item address

wf-oct = 101 / 1024 * open control table
unused = 101 / 40
unused = 141 / 1 / / / T * file type (seq)
wf-act = 142 / 1 / / / R * action (read/write)
unused = 143 / 4 / b / / 0 * restart number
unused = 147 / 2 / b / / 0 * fraction m
unused = 149 / 2 / b / / 0 * fraction n
unused = 151 / 4 / b / / 0 * limit
wf-isz = 155 / 2 / b / / 577 * item size
wf-prl = 157 / 2 / b / / 0 * phys. rec. length
unused = 159 / 1 / / / X * fast read flag
unused = 160 / 1 * use std in/out
unused = 161 / 4 / b / / 0 * byte skip count
unused = 165 / 2 * spare
unused = 167 / 1 / / / N * temporary file?
unused = 168 / 1 / / / Y * immediate write?
unused = 169 / 1 / / / N * blank suppress
unused = 170 / 1 * spare
wf-oact = 171 / 1 / / / A * open action
unused = 172 / 1 * kif logging
unused = 173 / 2 / b * key number
unused = 175 / 2 / b
unused = 177 / 4
unused = 181 / 4 / b
unused = 185 / 16
wf-pname = 301 / 824 / / / %1/120/%2.mcf

work
name = mcf-item
length = 600
initial value = >20

record
mcf-item = 1 / 577
mcf-ident = 1 / 3
mcf-perc = 66 / 6

mcf-count = 580 / 2 / b / / 0

work
name = act-file
length = 2048
initial value = >00

record
at-err = 1 / 4 * error code
at-fct = 5 / 4 * file control
at-iad = 9 / 4 * item address

at-oct = 101 / 1024 * open control table
unused = 101 / 40
unused = 141 / 1 / / / T * file type (seq)
at-act = 142 / 1 / / / R * action (read/write)
unused = 143 / 4 / b / / 0 * restart number
unused = 147 / 2 / b / / 0 * fraction m
unused = 149 / 2 / b / / 0 * fraction n
unused = 151 / 4 / b / / 0 * limit
at-isz = 155 / 2 / b / / 800 * item size
at-prl = 157 / 2 / b / / 0 * phys. rec. length
unused = 159 / 1 / / / X * fast read flag
unused = 160 / 1 * use std in/out
unused = 161 / 4 / b / / 0 * byte skip count
unused = 165 / 2 * spare
unused = 167 / 1 / / / N * temporary file?
unused = 168 / 1 / / / Y * immediate write?
unused = 169 / 1 / / / N * blank suppress
unused = 170 / 1 * spare
at-oact = 171 / 1 / / / A * open action
unused = 172 / 1 * kif logging
unused = 173 / 2 / b * key number
unused = 175 / 2 / b
unused = 177 / 4
unused = 181 / 4 / b
unused = 185 / 16
at-pname = 301 / 824 / / / $TMPDIR/%2.ACT

work
name = act-item
length = 800
initial value = >20

record
act-item = 1 / 800

work
name = err-mess
length = 3800
initial value = >20

record
* 1 2 3 4 5 6
* 123456789012345678901234567890123456789012345678901234567890
em-001 = 1 / 60 ///Un-recognised Tag encountered - Job Aborted!
em-002 = 61 / 60 ///Invalid Tag Value encountered - Job Aborted!
em-003 = 121 / 60 ///Number of Envelopes is Zero - Nothing to Sort!
em-004 = 181 / 60 ///Mailsort Scheme Not Specified - Job Aborted!
em-005 = 241 / 60 ///Number of Envelopes Not Specified - Job Aborted!
em-006 = 301 / 60 ///Average Weight Not Specified - Job Aborted!
em-007 = 361 / 60 ///Mixed Weight Switch Not Specified - Job Aborted!
em-008 = 421 / 60 ///File Splitting Switch Not Specified - Defaulted to "N"!
em-009 = 481 / 60 ///File Order Switch Not Specified - Job Aborted!
em-010 = 541 / 60 ///Geographical Sequence Not Specified - Job Aborted!
em-011 = 601 / 60 ///Walksort Specified but No Service Level - Job Aborted!
em-012 = 661 / 60 ///Mailsort 700 Specified but No Service Level - Job Aborted!
em-013 = 721 / 60 ///Mailsort 1400 Specified but No Service Level - Job Aborted!
em-014 = 781 / 60 ///Mailsort 120 Specified but No Service Level - Job Aborted!
em-015 = 841 / 60 ///Processing Address Details Failed - Job Aborted!
em-016 = 901 / 60 ///Less than 1000 Envelopes - Does not qualify for sorting!
em-017 = 961 / 60 ///Walksort Process Failed - Job Aborted!
em-018 = 1021 / 60 ///Production of Walksort Processing Report Failed-Job Aborted!
em-019 = 1081 / 60 ///Production of Walksort Line Listing Failed - Job Aborted!
em-020 = 1141 / 60 ///Production of Mailsort Costing Report Failed - Job Aborted!
em-021 = 1201 / 60 ///Production of Mailsort Line Listing Failed - Job Aborted!
em-022 = 1261 / 60 ///Mailsort 700 Process Failed - Job Aborted!
em-023 = 1321 / 60 ///Less than 10000 Envelopes -Does not qualify for Mailsort700!
em-024 = 1381 / 60 ///Mailsort 1400 Process Failed - Job Aborted!
em-025 = 1441 / 60 ///Mailsort 120 Process Failed - Job Aborted!
em-026 = 1501 / 60 ///Bundle Size Not Specified - Job Aborted!
em-027 = 1561 / 60 ///Service Level 3 not allowed for Walksort - Job Aborted!
em-028 = 1621 / 60 ///Service Level 3 not allowed for Mailsort 120 - Job Aborted!
em-029 = 1681 / 60 ///Error removing empty Walksort files - Job Aborted!
em-030 = 1741 / 60 ///Error removing empty Mailsort 700 files - Job Aborted!
em-031 = 1801 / 60 ///Error removing empty Mailsort 1400 files - Job Aborted!
em-032 = 1861 / 60 ///Error removing empty Mailsort 120 files - Job Aborted!
em-033 = 1921 / 60 ///Error joining Walksort files - Job Aborted!
em-034 = 1981 / 60 ///Error joining Mailsort 700 files - Job Aborted!
em-035 = 2041 / 60 ///Error joining Mailsort 1400 files - Job Aborted!
em-036 = 2101 / 60 ///Error joining Mailsort 120 files - Job Aborted!
em-037 = 2161 / 60 ///Error removing Walksort file - Job Aborted!
em-038 = 2221 / 60 ///Error removing Mailsort 700 file - Job Aborted!
em-039 = 2281 / 60 ///Error removing Mailsort 1400 file - Job Aborted!
em-040 = 2341 / 60 ///Error removing Mailsort 120 file - Job Aborted!
em-041 = 2401 / 60 ///Barcode-Only Process Failed - Job Aborted!
em-042 = 2461 / 60 ///Average Weight greater than threshold - Scheme Ignored!
em-043 = 2521 / 60 ///Mail Piece Type Not Specified - Job Aborted!
em-044 = 2581 / 60 ///Walksort Level Specified but No Tag - Job Aborted!
em-045 = 2641 / 60 ///700 Level Specified but No Tag - Job Aborted!
em-046 = 2701 / 60 ///1400 Level Specified but No Tag - Job Aborted!
em-047 = 2761 / 60 ///120 Level Specified but No Tag - Job Aborted!
em-048 = 2821 / 60 ///Mailsort Requested, Enforcing ADD_BARCODE!
em-049 = 2881 / 60 ///Postcode Update Requested, Enforcing ADD_BARCODE!
em-050 = 2941 / 60 ///Walksort Module Not Activated - Scheme Ignored!
em-051 = 3001 / 60 ///Mailsort 700 Module Not Activated - Scheme Ignored!
em-052 = 3061 / 60 ///Mailsort 1400 Module Not Activated - Scheme Ignored!
em-053 = 3121 / 60 ///Mailsort 120 Module Not Activated - Scheme Ignored!
em-054 = 3181 / 60 ///Over 100 grams cannot be LETTER format - Job Aborted!
em-057 = 3361 / 60 ///Checking Walksort DB validity Failed - Job Aborted!
em-058 = 3421 / 60 /// - EMPTY ACCUMULATION FILE OR ACCUMULATION FILE MISSING!

messages
name = debug1
report 1 = (TAG = , pt-tag)

messages
name = debug2
report 1 = (VALUE = , pt-value)

messages
name = debug3
report 1 = (er-parm)

messages
name = debug4
report 1 = (w-error)

messages
name = debug5
report 1 = (,,,,ITEMS WALKSORTED =, wh-walked)
report 2 = (,,,,ITEMS 700 SORTED =, wh-700ed)
report 3 = (,,,ITEMS 1400 SORTED =, wh-1400ed)
report 4 = (,,,,ITEMS 120 SORTED =, wh-120ed)
report 5 = (,,,,,,UNSORTED ITEMS =, wh-remain)
report 6 = (CURRENT SEQUENCE No. =, wh-seqno)
report 7 = (,,,,,POSTCODE ERRORS =, wh-errors)
report 8 = (,,,,,,,,,UK RESIDUES =, wh-UKre)
report 9 = (,,,,,NON-UK RESIDUES =, wh-nonUKre)
report 10 = (,,,,,,,,,CLEANMAILED =, wh-cleanm)
report 11 = (,,,,,NOT CLEANMAILED =, wh-noclean)
report 12 = (,,TOTAL INPUT RECORD =, wh-totalin)
report 13 = (,,,,,,TOTAL EXCEPTED =, wh-except)
report 14 = (,,TOTAL EXCEPTS READ =, wh-totexc)
report 15 = (,,,,,,TOTAL BARCODED =, wh-totbc)
report 16 = (,,TOTAL NON-BARCODED =, wh-totnbc)
report 17 = (,,,,RETURNED MESSAGE =, wh-mess1)
report 18 = (,,,,RETURNED MESSAGE =, wh-mess2)

messages
name = debug6
report 1 = (W_WSORT = , w-wsort)
report 2 = (,,W_700 = , w-700)
report 3 = (,W_1400 = , w-1400)
report 4 = (,,W_120 = , w-120)

messages
name = debug7
report 1 = (WALK_BC = , w-walkbc)
report 2 = (WALK_NC = , w-walknbc)
report 3 = (,700_BC = , w-700bc)
report 4 = (,700_NC = , w-700nbc)
report 5 = (1400_BC = , w-1400bc)
report 6 = (1400_NC = , w-1400nbc)
report 7 = (,120_BC = , w-120bc)
report 8 = (,120_NC = , w-120nbc)

messages
name = debug8
report 1 = (,,,,,,ONE_FILE = , w-onefile)
report 2 = (FILE_SPLITTING = , w-split)
report 3 = (,,,ADD_BARCODE = , w-addbar)
report 4 = (,,,,UK RESIDUE = , wh-Ukre)
report 5 = (,,,,,,,FOREIGN = , wh-nonUkre)

messages
name = debug9
report 1 = (W_WHATSORT = , w-whatsort)
report 2 = (,,,,,W_120 = , w-120)
report 3 = (,,W_PEREND = , w-perend)
report 4 = (,,,W_ACCUM = , w-accum)
report 5 = (,,,,,W_700 = , w-700)
report 6 = (,,,,W_1400 = , w-1400)
report 7 = (,,W_ADDBAR = , w-addbar)
report 8 = (,,,W_SORTS = , w-sorts)

messages
name = why-here
screen 1 = (WHY?)

process
**
** general initialisation
**
move "AAAA" to wh-key
move 0 to wh-walked
move 0 to wh-700ed
move 0 to wh-1400ed
move 0 to wh-120ed
move 0 to wh-remain
move 0 to wh-seqno
move 0 to wh-errors
move 0 to wh-UKre
move 0 to wh-nonUKre
move 0 to wh-cleanm
move 0 to wh-noclean
move 0 to wh-totalin
move 0 to wh-except
move 0 to wh-totexc
move 0 to wh-totbc
move 0 to wh-totnbc
move 1 to wv-curpos
move 250 to wv-iosize
clear wh-mess1 to spaces
clear wh-mess2 to spaces
write whathappen

**
** prepare directory pathnames
**
move "%1" to er-path
append w-quote to er-path
move "%2" to er-jobid
append w-quote to er-jobid
move er-path to ad-path
move er-jobid to ad-jobid
move er-path to ws-path
move er-jobid to ws-jobid
move er-path to cs-path
move er-jobid to cs-jobid
move er-path to ms-path
move er-jobid to ms-jobid
move er-path to mr-path
move er-jobid to mr-jobid
move er-path to cm-path
move er-jobid to cm-jobid
move er-path to 1f-path * 05/09
move er-jobid to 1f-jobid * 05/09
move er-path to wb-path
move er-jobid to wb-jobid
move er-path to po-path * 072008
move er-jobid to po-jobid * 072008

**
** map out mailsort region translation
**
move " 00A01B02C03D04E05F06G07H08I09J10K11L12M13N14O15P16"
to g-regions
move "SBE" to g-action
do region-tab

move "SFE" to k-action
do good-tags
move "RBK" to k-action

**
** set up and write headings to log file
**
clear a-rec to spaces
write audit
accept w-date from date
move "DATE:~" to a-rec
append w-datex to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
accept w-time from time
move "START TIME:~" to a-rec
append w-time to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move "JOB-ID:~" to a-rec
append "%2" to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move "MAILSORT WORK DIRECTORY: -"
to a-rec
write audit
move "%1" to a-rec
write audit
clear a-rec to spaces
write audit

**
** first load sefas parameters into a keyed table and start
** to validate some of the values
**
:LOAD_INTO_TABLE:
move "Loading Parameter File" to a-rec
write audit
clear a-rec to spaces
move "INS" to w-action
loop
:LOAD_INTO_TABLE_EACH_RECORD:
read parameters
until eof
if p-rec = spaces
go LOAD_INTO_TABLE_EACH_RECORD
endif
if p-char1 = "#"
go LOAD_INTO_TABLE_EACH_RECORD
endif
**
** get actual parameter tag
**
scan p-rec forwards into w-start looking for "<"
scan p-rec forwards into w-end looking for ">"
move p-rec (w-start, w-end) to pt-tag on overflow truncate
inc w-end
move p-rec (w-end, 0) to pt-value on overflow truncate
move pt-tag to k-tag
do good-tags ** check if tag is valid
if nonmatch
move em-001 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif

if pt-tag = "" ** check number of envelopes tag
move pt-qtyx to pt-qty
if pt-qty = zeros
move em-003 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif
move pt-qty to w-innum
move pt-qty to w-innumn
move "Y" to w-numenv
go UPDATE_TO_TABLE
endif

if pt-tag = "" ** check average item weight tag
move pt-weightx to pt-weight
if pt-weight = zeros
move em-002 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif
move "Y" to w-avgwgt
move pt-weight to w-inwgt
go UPDATE_TO_TABLE
endif

if pt-tag = "" ** check bundle size tag
move pt-bundlex to pt-bundle
if pt-bundle = zeros
move em-002 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif
move "Y" to w-bundle
go UPDATE_TO_TABLE
endif

if pt-tag = "" ** check residue sequence tag
select SorEorTorP
if nonmatch
move em-002 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif
move "Y" to w-fileord
go UPDATE_TO_TABLE
endif

if pt-tag = "" ** check letter or packets tag
select MailPiece
if nonmatch
move em-002 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif
move "Y" to w-mpt
move pt-value to w-format
go UPDATE_TO_TABLE
endif

if pt-tag = "" ** check mailsort geo-region tag
select GeoSeq
if nonmatch
move em-002 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif
move "Y" to w-geoseq
go UPDATE_TO_TABLE
endif

if pt-serv = "
select 1or2or3
if nonmatch
move em-002 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif
move "Y" to w-whatsort
go UPDATE_TO_TABLE
endif

select YorN ** check 'Y' or 'N' for all others
if nonmatch
move em-002 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif

if pt-tag = ""
move pt-yesno to w-addbar
go UPDATE_TO_TABLE
endif

if pt-tag = ""
move pt-yesno to w-addbar
go UPDATE_TO_TABLE
endif

if pt-tag = ""
move pt-yesno to w-reportit
go UPDATE_TO_TABLE
endif

if pt-tag = ""
move pt-yesno to w-newpcode
go UPDATE_TO_TABLE
endif

if pt-tag = "" * 072008
move pt-yesno to w-punrep * 072008
go UPDATE_TO_TABLE * 072008
endif * 072008

if pt-tag = "" * 072008
move pt-yesno to w-rallpun * 072008
go UPDATE_TO_TABLE * 072008
endif * 072008

if pt-tag = "" * 072008
move pt-yesno to w-runwpun * 072008
go UPDATE_TO_TABLE * 072008
endif * 072008

if pt-tag = "" * 072008
move pt-yesno to w-uPAFadd * 072008
go UPDATE_TO_TABLE * 072008
endif * 072008

if pt-tag = "" * 072008
move pt-yesno to w-uPAFpun * 072008
go UPDATE_TO_TABLE * 072008
endif * 072008

if pt-tag = "" * 072008
move pt-yesno to w-rmpunout * 072008
go UPDATE_TO_TABLE * 072008
endif * 072008

if pt-tag = ""
move "Y" to w-filesplt
move pt-yesno to w-split
go UPDATE_TO_TABLE
endif

if pt-tag = ""
move "Y" to w-fileord
go UPDATE_TO_TABLE
endif

if pt-tag = ""
move "Y" to w-mixwgt
endif

if pt-tag = ""
move pt-yesno to w-perend
if w-perend = "Y"
move "N" to w-accum
endif
endif

if pt-tag = ""
move pt-yesno to w-accum
if w-accum = "Y"
move "N" to w-perend
endif
endif

:UPDATE_TO_TABLE:
**
** tag and value is valid therefore write to our internal table
**
if w-fulllog = "Y"
scan pt-tag backwards into w-genpos looking for ">"
move pt-tag (0,w-genpos) to a-mess fill character is "."
move pt-value to a-total
write audit
endif
do parm-tab
endloop
move "RBK" to w-action

**
** now check that all mandatory tags in the parameters file exist
**
:CHECK_MANDATORY_TAGS:
if w-perend = "Y"
move "Y" to w-split
go CHECK_TAG_COMBOS_120
endif
if w-numenv != "Y" ** number of envelopes must be specified
move em-005 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-addbar = "Y"
move "Y" to w-continue
*!* go CHECK_TAG_COMBOS_DONE ** 061108
go CHECK_TAG_COMBOS_ADD_BARCODE ** 061108
endif
if w-whatsort != "Y" ** no mailsort schemes
if w-addbar != "Y" ** and ADD_BARCODE not specified
if w-reportit != "Y" ** and POSTCODE_REPORT not specified
go CHECK_TAG_COMBOS_ADD_BARCODE ** then default to ADD_BARCODE
else
move "Y" to w-continue
go CHECK_TAG_COMBOS_ADD_BARCODE
endif
endif
endif
if w-filesplt != "Y" ** check file split option
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-008 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move "N" to w-split
endif
if w-whatsort != "Y"
move em-004 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-avgwgt != "Y"
move em-006 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-mixwgt != "Y"
move em-007 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-fileord != "Y"
move em-009 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-geoseq != "Y"
move em-010 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-bundle != "Y"
move em-026 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-mpt != "Y"
move em-043 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif

if w-inwgt > 100
if w-format = "LETTER"
move em-054 to er-mess1
append w-quote to er-mess1
move pt-tag to er-mess2
append pt-value to er-mess2
append w-quote to er-mess2
go HAVE_ERROR
endif
endif

**
** now check tags for valid combinations
** .e.g. if walksort is specified then the walksort service level
** must also be specified
**
:CHECK_TAG_COMBOS:
move "" to w-tag
do parm-tab
if match
if pt-yesno = "N"
go CHECK_TAG_COMBOS_700
endif
if pt-yesno = space
go CHECK_TAG_COMBOS_700
endif
if w-go-wsort != "Y"
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-050 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_700
endif
move "" to w-tag
do parm-tab
if nonmatch
move em-011 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
else
move pt-serlev to w-serlvl
endif
if pt-serlev = "3"
move em-027 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if pt-serlev = space
move em-011 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-format = "PACKET"
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append "Cannot send PACKET by Walksort - Scheme ignored"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_700
endif
if w-inwgt > wkmwgt
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-042 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move >2a2a7e to a-rec
append "Walksort maximum allowed weight is~"
to a-rec
append wkmwgtx to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_700
endif
move "" to w-tag
do parm-tab
move pt-yesno to w-wsort
if w-wsort = "Y"
move "Y" to w-continue
endif
else
move "" to w-tag
do parm-tab
if match
move em-044 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif

:CHECK_TAG_COMBOS_700:
move "" to w-tag
do parm-tab
if match
if pt-yesno = "N"
go CHECK_TAG_COMBOS_1400
endif
if pt-yesno = space
go CHECK_TAG_COMBOS_1400
endif
if w-go-700 != "Y"
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-051 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_1400
endif
move "" to w-tag
do parm-tab
if nonmatch
move em-012 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
else
move pt-serlev to w-serlvl
endif
if pt-serlev = spaces
move em-012 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-format != "LETTER"
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append "Only Letters allowed for Mailsort 700 - Scheme ignored"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_1400
endif
if w-inwgt > 700mwgt
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-042 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move >2a2a7e to a-rec
append "Mailsort 700 maximum allowed weight is~"
to a-rec
append 700mwgtx to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_1400
endif
move "" to w-tag
do parm-tab
move pt-yesno to w-700
if w-700 = "Y"
move "Y" to w-continue
endif
else
move "" to w-tag
do parm-tab
if match
move em-045 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif

:CHECK_TAG_COMBOS_1400:
move "" to w-tag
do parm-tab
if match
if pt-yesno = "N"
go CHECK_TAG_COMBOS_120
endif
if pt-yesno = space
go CHECK_TAG_COMBOS_120
endif
if w-go-1400 != "Y"
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-052 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_120
endif
move "" to w-tag
do parm-tab
if nonmatch
move em-013 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
else
move pt-serlev to w-serlvl
endif
if pt-serlev = spaces
move em-013 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-inwgt > 1400mwgt
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-042 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move >2a2a7e to a-rec
append "Mailsort 1400 maximum allowed weight is~"
to a-rec
append 1400mwgtx to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_120
endif
move "" to w-tag
do parm-tab
move pt-yesno to w-1400
if w-1400 = "Y"
move "Y" to w-continue
endif
else
move "" to w-tag
do parm-tab
if match
move em-046 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif

:CHECK_TAG_COMBOS_120:
move "" to w-tag
do parm-tab
if match
if pt-yesno = "N"
go CHECK_TAG_COMBOS_ADD_BARCODE
endif
if pt-yesno = space
go CHECK_TAG_COMBOS_ADD_BARCODE
endif
if w-go-120 != "Y"
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-053 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_ADD_BARCODE
endif
move "" to w-tag
do parm-tab
if nonmatch
move em-014 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
else
move pt-serlev to w-serlvl
endif
if pt-serlev = spaces
move em-014 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
if w-format != "LETTER"
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append "Only Letters allowed for Mailsort 120 CBC - Scheme ignored"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_ADD_BARCODE
endif
if w-inwgt > 120mwgt
clear a-rec to spaces
write audit
move >2a2a7e to a-rec
append em-042 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move >2a2a7e to a-rec
append "Mailsort 120 maximum allowed weight is~"
to a-rec
append 120mwgtx to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go CHECK_TAG_COMBOS_ADD_BARCODE
endif
move "" to w-tag
do parm-tab
move pt-yesno to w-120
if w-120 = "Y"
move "Y" to w-continue
endif
else
move "" to w-tag
do parm-tab
if match
move em-047 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif

:CHECK_TAG_COMBOS_ADD_BARCODE:
if w-perend = "Y"
go CHECK_TAG_COMBOS_DONE
endif
if w-sorts = "NNNN"
move "N" to w-whatsort
endif
if w-whatsort = "Y"
if w-addbar != "Y"
move "Y" to w-continue
move "Y" to w-addbar
endif
endif
if w-newpcode = "Y"
if w-addbar != "Y"
move "Y" to w-continue
move "Y" to w-addbar
endif
endif

:CHECK_TAG_COMBOS_DONE:
if w-120 != "Y"
move "N" to w-perend
move "N" to w-accum
endif

clear a-rec to spaces
move "Loading Parameter File completed and tags validated"
to a-rec
write audit
clear a-rec to spaces
write audit

*!* do debug9

*!*if w-continue != "Y"

if w-whatsort = "N"
move "Mailsort was not invoked"
to if-rec
move >2a2a7e to a-rec
append "No Mailsort scheme(s) were invoked!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
if w-addbar != "Y" ** 061108
move >2a2a7e to a-rec
append "Enforcing ADD_BARCODE process!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move "Y" to w-addbar
clear a-rec to spaces
write audit
endif ** 061108
endif

**
** all checking on the tags in the parameters file are okay.
** we can now start to actually process the input file.
** The first process is to call the ADDRESS routine
**
:PROCESS_THE_ADDRESSES:
if w-perend = "Y"
move "Producing ACCUMULATED REPORTS"
to a-rec
write audit
go DO_ACTUAL_SORTATIONS
endif

if w-uPAFadd = "Y" * 072008
if w-rallpun = "Y" * 072008
move >2a2a7e to a-rec * 072008
append "Both USE-PAF-ADDRESS and REMOVE-ALL-PUNCTUATION options specified!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
move >2a2a7e to a-rec * 072008
append "REMOVE-ALL-PUNCTUATION has priority, USE-PAF-ADDRESS ignored!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
clear a-rec to spaces * 072008
write audit * 072008
move "N" to w-uPAFadd * 072008
endif * 072008
endif * 072008
if w-uPAFadd != "Y" * 072008
if w-rallpun != "Y"
if w-punrep = "Y" * 072008
move >2a2a7e to a-rec * 072008
append "No Punctuation options specified!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
move >2a2a7e to a-rec * 072008
append "Punctuation Report will also be turned off!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
clear a-rec to spaces * 072008
write audit * 072008
move "N" to w-punrep
endif
endif * 072008
endif * 072008
if w-noPAF = "Y"
move "N" to w-reportit
move "N" to w-newpcode
move "N" to w-uPAFadd * 072008
move "N" to w-uPAFpun * 072008
move "N" to w-runwpun * 072008
*move "N" to w-punrep * 072008
clear a-rec to spaces * 072008
write audit * 072008
move >2a2a7e to a-rec * 072008
append "PAF not used - PAF Punctuation Processing Disabled!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
endif

if w-rallpun = "Y" * 072008
move "N" to w-uPAFadd * 072008
move "N" to w-uPAFpun * 072008
move "N" to w-runwpun * 072008
clear a-rec to spaces * 072008
write audit * 072008
move >2a2a7e to a-rec * 072008
append "Removing All Punctuation!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
endif * 072008

if w-uPAFadd = "Y" * 072008
move "N" to w-rallpun * 072008
move "N" to w-uPAFpun * 072008
move "N" to w-runwpun * 072008
clear a-rec to spaces * 072008
write audit * 072008
move >2a2a7e to a-rec * 072008
append "Replacing Input Address with PAF Address!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
endif * 072008

if w-runwpun = "Y" * 072008
move "N" to w-rallpun * 072008
move "N" to w-uPAFpun * 072008
move "N" to w-uPAFadd * 072008
clear a-rec to spaces * 072008
write audit * 072008
move >2a2a7e to a-rec * 072008
append "Removing Punctuation not on PAF!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
endif * 072008

if w-uPAFpun = "Y" * 072008
move "N" to w-rallpun * 072008
move "N" to w-runwpun * 072008
move "N" to w-uPAFadd * 072008
clear a-rec to spaces * 072008
write audit * 072008
move >2a2a7e to a-rec * 072008
append "Retaining PAF Allowed Punctuation!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
endif * 072008

if w-punctopt = "NNNNN" * 072008
clear a-rec to spaces * 072008
write audit * 072008
move >2a2a7e to a-rec * 072008
append "Punctuation Processing is Turned Off!" * 072008
to a-rec * 072008
move a-rec to a-rec unwanted punctuation is "~" * 072008
write audit * 072008
endif * 072008

if w-go-pcode != "Y"
if w-newpcode = "Y"
move "Postcode Correction function is not Activated!!"
to a-rec
write audit
endif
move "N" to w-reportit
move "N" to w-newpcode
endif

if w-reportit = "N"
move "Processing address details"
to a-rec
write audit
move " - Postcode Quality Report has not been requested"
to a-rec
else
move "Processing address details and produce Postcode report"
to a-rec
endif
write audit
if w-newpcode = "Y"
move " - Postcode correction WILL BE applied!"
to a-rec
write audit
if w-dumpadds = "Y"
move " - Separate report for corrected postcode addresses is produced"
to a-rec
write audit
endif
endif

if w-noPAf = "Y"
move "Using PIF to obtain DPS Codes!"
to a-rec
write audit
endif

if w-bypassad = "Y"
if w-caciuser = "CACI"
move " - No address processing on User Request!"
to a-rec
write audit
move "" to w-tag
do parm-tab
if match
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen
move pt-qty to wh-totalin
move 1 to wv-curpos
move 250 to wv-iosize
write whathappen
endif
go PROCESS_THE_ADDRESSES_DONE
endif
endif

move w-reportit to ad-report
move w-newpcode to ad-amendpc
move w-addbar to ad-addbar

move w-uPAFadd to ad-uPAFadd * 072008
move w-uPAFpun to ad-uPAFpun * 072008
move w-rallpun to ad-rallpun * 072008
move w-runwpun to ad-runwpun * 072008
move w-punrep to ad-punrep * 072008

if w-rmpunout = "Y" * 072008
move "N" to ad-uPAFadd * 072008
move "N" to ad-uPAFpun * 072008
move "N" to ad-rallpun * 072008
move "N" to ad-runwpun * 072008
move "N" to ad-punrep * 072008
endif

move "N" to ad-repONLY
move w-serlvl to ad-serlvl
*!* move w-accum to ad-accum
move "N" to ad-accum
if w-whatsort != "Y"
if w-newpcode != "Y"
if w-addbar != "Y"
if w-go-pcode = "Y"
move "Y" to ad-repONLY
move " - Produce Postcode Report ONLY, nothing else required!"
to a-rec
write audit
else
move " - No Processing can be applied, Job Aborted!"
to a-rec
write audit
go FINISH
endif
endif
endif
endif
do call-addit
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-015 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen
if wh-mess1 != spaces
move wh-mess1 to a-rec
write audit
endif
if wh-mess2 != spaces
move wh-mess2 to a-rec
write audit
endif

if ad-punrep != "Y" * 072008
move "%1/%2-punct.rpt" to wtidy-up * 072008
do rm-out * 072008
endif * 072008

:PROCESS_THE_ADDRESSES_DONE:
if w-reportit = "N"
move "Processing address details completed"
to a-rec
else
move "Processing address details and produce Postcode report completed"
to a-rec
endif
write audit
clear a-rec to spaces
write audit

if w-whatsort != "Y"
if w-reportit = "Y"
if w-addbar != "Y"
go DO_GENERAL_TIDY_UP
endif
endif
endif

:DO_ACTUAL_SORTATIONS:
**
** are we just adding barcodes
**
:DO_BARCODE_ONLY:
if w-whatsort = "Y"
go DO_WALKSORT
endif
if w-addbar != "Y"
go DO_WALKSORT
endif
move "Attempting ADD_BARCODE Only"
to a-rec
write audit
move "Attempting ADD_BARCODE Only.."
to if-rec
move w-split to cm-split
clear w-error to spaces
do call-clean
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-041 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen
if wh-mess1 != spaces
move wh-mess1 to a-rec
write audit
endif
if wh-mess2 != spaces
move wh-mess2 to a-rec
write audit
endif
move "ADD_BARCODE Only Process completed"
to a-rec
write audit

:DO_BARCODE_ONLY_TIDY_UP:
if cm-split = "Y"
move "%1/%2.outA" to wtidy-up
do rm-out
else
move "%1/%2.outU" to wtidy-up
do rm-out
move "%1/%2.outF" to wtidy-up
do rm-out
endif
go DO_GENERAL_TIDY_UP

**
** see if we need to walksort the file
**
:DO_WALKSORT:
if w-wsort != "Y"
go DO_700
endif
move "Attempting to apply Walksort"
to a-rec
write audit
move "Attempting Walksort.." to if-rec
clear w-error to spaces
move "" to w-tag
do parm-tab
if match
move pt-serlev to ws-serlev
endif
move "" to w-tag
do parm-tab
if match
move pt-yesno to ws-split
endif
move "" to w-tag
do parm-tab
if match
if pt-yesno = "Y"
clear ws-unspec to spaces
else
move "N" to ws-mixwgt
endif
endif
move "" to w-tag
do parm-tab
if match
move pt-weight to ws-avgwgtn
endif
if ws-avgwgtn > wkmwgt
move >2a2a7e to a-rec
append em-042 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move >2a2a7e to a-rec
append "Walksort maximum allowed weight is~"
to a-rec
append wkmwgtx to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_700
endif
move "N" to ws-onepass
move "N" to ws-oneschm
if w-sorts = "YNNN"
move "Y" to ws-oneschm
endif
move "" to w-tag
do parm-tab
if match
move "RBK" to g-action
move pt-geoseq to g-region
do region-tab
if match
move g-geoseqn to ws-geoseqn
endif
endif
move "" to w-tag
do parm-tab
if match
move pt-bundle to ws-bundlen
endif
move "" to w-tag
do parm-tab
if match
move pt-order to ws-order
endif
move "25" to ws-mselqty
move "4000" to ws-mmsqty

move w-format to ws-format
if ws-format != "LETTER"
move "5" to ws-mselqty
move "1000" to ws-mmsqty
endif

do call-wsort
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-017 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen
if wh-mess1 != spaces
move wh-mess1 to a-rec
write audit
endif
if wh-mess2 != spaces
move wh-mess2 to a-rec
write audit
endif
move wh-cleanm to w-walkbc
move wh-noclean to w-walknbc

:DO_WALKSORT_REPORTS:
if wh-walked = 0
go DO_WALKSORT_TIDY_UP
endif
if w-fulllog = "Y"
move " - producing Walksort Process Report"
to a-rec
write audit
endif
move "-1~" to wpr-parms
append w-quote to wpr-parms
append "%1/walksort/%2.mcf" to wpr-parms
append w-quote to wpr-parms
append "~" to wpr-parms
append "-2~" to wpr-parms
append w-quote to wpr-parms
append "%1/walksort/%2.mpr" to wpr-parms
append w-quote to wpr-parms
append "~-21~" to wpr-parms
append w-quote to wpr-parms
append "%1" to wpr-parms
append w-quote to wpr-parms
move wpr-parms to wpr-parms unwanted punctuation is "~"
do wpr
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-018 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
if w-fulllog = "Y"
move " - Walksort Process Report produced"
to a-rec
write audit
endif

if w-fulllog = "Y"
move " - producing Walksort Line Listing"
to a-rec
write audit
endif
move "-1~" to wll-parms
append w-quote to wll-parms
append "%1/walksort/%2.wlf" to wll-parms
append w-quote to wll-parms
append "~" to wll-parms
append "-2~" to wll-parms
append w-quote to wll-parms
append "%1/walksort/%2.llr" to wll-parms
append w-quote to wll-parms
append "~-21~" to wll-parms
append w-quote to wll-parms
append "%1" to wll-parms
append w-quote to wll-parms
move wll-parms to wll-parms unwanted punctuation is "~"
do wll
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-019 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
if w-fulllog = "Y"
move " - Walksort Line Listing produced"
to a-rec
write audit
endif

:DO_WALKSORT_TIDY_UP:
**
** removes unwanted left-over files
**

move "%1/walksort/%2.mcf" to wb-infile
append w-quote to wb-infile

do wsdb-chk
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-057 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen
if wh-mess1 != spaces
move wh-mess1 to a-rec
write audit
endif
if wh-mess2 != spaces
move wh-mess2 to a-rec
write audit
endif

if wh-walked = 0
move "%1" to wtidy-up
append "/walksort/" to wtidy-up
append >2a2e2a to wtidy-up
do rm-out
else
move "%1/walksort/%2.mcf" to wtidy-up
do rm-out
move "%1/walksort/%2.wlf" to wtidy-up
do rm-out
endif

move "Walksort Process Completed"
to a-rec
write audit
clear a-rec to spaces
write audit
move "WALK" to w-lastused

**
** see if we need to mailsort 700 the file
**
:DO_700:
if w-700 != "Y"
go DO_1400
endif
if w-wsort = "Y"
if wh-remain = 0
move >2a2a7e to a-rec
append "Mailsort 700 scheme Ignored - No items to sort!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_GENERAL_TIDY_UP
endif
endif
move "Attempting to apply Mailsort 700"
to a-rec
write audit
append "Attempting Mailsort700.."
to if-rec
clear w-error to spaces

move "" to w-tag
do parm-tab
if match
move pt-serlev to cs-serlev
endif
move "" to w-tag
do parm-tab
if match
move pt-yesno to cs-split
endif
move "" to w-tag
do parm-tab
if match
if pt-yesno = "Y"
clear cs-unspec to spaces
else
move "N" to cs-mixwgt
endif
endif
move "" to w-tag
do parm-tab
if match
move pt-weight to cs-avgwgtn
endif
if cs-avgwgtn > 700mwgt
move >2a2a7e to a-rec
append em-042 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move >2a2a7e to a-rec
append "Mailsort 700 maximum allowed weight is~"
to a-rec
append 700mwgtx to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_1400
endif
move "N" to cs-onepass
move "N" to cs-oneschm
if w-120 != "Y"
if w-1400 != "Y"
move "Y" to cs-oneschm
endif
endif
move "" to w-tag
do parm-tab
if match
move "RBK" to g-action
move pt-geoseq to g-region
do region-tab
if match
move g-geoseqn to cs-geoseqn
endif
endif
move "" to w-tag
do parm-tab
if match
move pt-bundle to cs-bundlen
endif
move "" to w-tag
do parm-tab
if match
move pt-order to cs-order
endif

move w-format to cs-format

if w-wsort = "Y"
move "%1/%2.P2" to cs-infile
else
move "%1/%2.TMP" to cs-infile
endif
append w-quote to cs-infile
do call-csort
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-022 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen
if wh-mess1 != spaces
move wh-mess1 to a-rec
write audit
endif
if wh-mess2 != spaces
move wh-mess2 to a-rec
write audit
endif
move wh-cleanm to w-700bc
move wh-noclean to w-700nbc
subtract w-walkbc from w-700bc
subtract w-walknbc from w-700nbc

:DO_700_REPORTS:
if wh-700ed = 0
go DO_700_TIDY_UP
endif

if w-fulllog = "Y"
move " - producing Mailsort 700 Costing Report"
to a-rec
write audit
endif

move "C" to mp-rtype
move "B" to mp-batch
move 0 to mp-rev
move "" to w-tag
do parm-tab
if match
move pt-serlev to mp-m-code
endif
move "N" to mp-ocr
move "N" to mp-1pm
move "N" to mp-mps
move cs-avgwgt to mp-i-wgt
move "%1/700/%2.mcf" to mp-in
if cs-oneschm = "N"
move "%1/700/%2.mcf2" to mp-in
endif
append w-quote to mp-in
move "%1/700/%2.mpr" to mp-out
append w-quote to mp-out
move "%1" to mp-dir
append w-quote to mp-dir
do mpr
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-020 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

if w-fulllog = "Y"
move " - Mailsort 700 Costing Report produced"
to a-rec
write audit
endif

if w-fulllog = "Y"
move " - producing Mailsort 700 Line Listing"
to a-rec
write audit
endif

move "-1~" to mll-parms
append w-quote to mll-parms
if cs-oneschm = "N"
append "%1/700/%2.sgt2" to mll-parms
else
append "%1/700/%2.sgt" to mll-parms
endif
append w-quote to mll-parms
append "~" to mll-parms
append "-2~" to mll-parms
append w-quote to mll-parms
append "%1/700/%2.llr" to mll-parms
append w-quote to mll-parms
append "~-21~" to mll-parms
append w-quote to mll-parms
append "%1" to mll-parms
append w-quote to mll-parms
move mll-parms to mll-parms unwanted punctuation is "~"
do mll
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-021 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

if w-fulllog = "Y"
move " - Mailsort 700 Line Listing produced"
to a-rec
write audit
endif

:DO_700_TIDY_UP:
**
** removes unwanted left-over files
**
if cs-oneschm = "N"
move "%1/700/%2.cfl" to wtidy-up
do rm-out
move "%1/700/%2.cfl2 %1/700/%2.cfl"
to rename-fs
do rename
else
move "%1/700/%2.cfl2" to wtidy-up
do rm-out
endif

if wh-700ed = 0
move "%1" to wtidy-up
append "/700/" to wtidy-up
append >2a2e2a to wtidy-up
do rm-out
else
move "%1/700/%2.mcf" to wtidy-up
do rm-out
move "%1/700/%2.sgt" to wtidy-up
do rm-out
move "%1/700/%2.mcf2" to wtidy-up
do rm-out
move "%1/700/%2.sgt2" to wtidy-up
do rm-out
move "%1/700/%2.mcfA" to wtidy-up
do rm-out
move "%1/700/%2.sgtA" to wtidy-up
do rm-out
endif

move "Mailsort 700 Process Completed"
to a-rec
write audit
clear a-rec to spaces
write audit
move "700 " to w-lastused

**
** see if we need to mailsort 1400 the file
**
:DO_1400:
if w-1400 != "Y"
go DO_120
endif
if w-wsort = "Y"
if wh-remain = 0
move >2a2a7e to a-rec
append "Mailsort 1400 scheme Ignored - No items to sort!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_GENERAL_TIDY_UP
endif
else
if w-700 = "Y"
if wh-remain = 0
move >2a2a7e to a-rec
append "Mailsort 1400 scheme Ignored - No items to sort!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_GENERAL_TIDY_UP
endif
endif
endif

move "Attempting to apply Mailsort 1400"
to a-rec
write audit
append "Attempting Mailsort1400.."
to if-rec
clear w-error to spaces

move "" to w-tag
do parm-tab
if match
move pt-serlev to ms-serlev
endif
move "" to w-tag
do parm-tab
if match
move pt-yesno to ms-split
endif
move "" to w-tag
do parm-tab
if match
if pt-yesno = "Y"
clear ms-unspec to spaces
else
move "N" to ms-mixwgt
endif
endif
move "" to w-tag
do parm-tab
if match
move pt-weight to ms-avgwgtn
endif
if ms-avgwgtn > 1400mwgt
move >2a2a7e to a-rec
append em-042 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move >2a2a7e to a-rec
append "Mailsort 1400 maximum allowed weight is~"
to a-rec
append 1400mwgtx to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_120
endif
move "N" to ms-onepass
move "N" to ms-oneschm
if w-120 != "Y"
move "Y" to ms-oneschm
endif
move "" to w-tag
do parm-tab
if match
move "RBK" to g-action
move pt-geoseq to g-region
do region-tab
if match
move g-geoseqn to ms-geoseqn
endif
endif
move "" to w-tag
do parm-tab
if match
move pt-bundle to ms-bundlen
endif
move "" to w-tag
do parm-tab
if match
move pt-order to ms-order
endif
move "25" to ms-mselqty
move "4000" to ms-mmsqty
move w-format to ms-format
if ms-format != "LETTER"
move "5" to ms-mselqty
move "1000" to ms-mmsqty
endif

if w-700 = "Y"
move "%1/%2.P3" to ms-infile
else
if w-wsort = "Y"
move "%1/%2.P2" to ms-infile
else
move "%1/%2.TMP" to ms-infile
endif
endif
append w-quote to ms-infile
do call-1400
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-024 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen
if wh-mess1 != spaces
move wh-mess1 to a-rec
write audit
endif
if wh-mess2 != spaces
move wh-mess2 to a-rec
write audit
endif
move wh-cleanm to w-1400bc
move wh-noclean to w-1400nbc
subtract w-700bc from w-1400bc
subtract w-700nbc from w-1400nbc

:DO_1400_REPORTS:
if wh-1400ed = 0
go DO_1400_TIDY_UP
endif

if w-fulllog = "Y"
move " - producing Mailsort 1400 Costing Report"
to a-rec
write audit
endif

move "C" to mp-rtype
move "B" to mp-batch
move 0 to mp-rev
move "" to w-tag
do parm-tab
if match
move pt-serlev to mp-m-code
endif
move "N" to mp-ocr
move "N" to mp-1pm
move "N" to mp-mps
move ms-avgwgt to mp-i-wgt
move "%1/1400/%2.mcf" to mp-in
if ms-oneschm = "N"
move "%1/1400/%2.mcf2" to mp-in
endif
append w-quote to mp-in
move "%1/1400/%2.mpr" to mp-out
append w-quote to mp-out
move "%1" to mp-dir
append w-quote to mp-dir
do mpr
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-020 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

if w-fulllog = "Y"
move " - Mailsort 1400 Costing Report produced"
to a-rec
write audit
endif

if w-fulllog = "Y"
move " - producing Mailsort 1400 Line Listing"
to a-rec
write audit
endif

move "-1~" to mll-parms
append w-quote to mll-parms
if ms-oneschm = "N"
append "%1/1400/%2.sgt2" to mll-parms
else
append "%1/1400/%2.sgt" to mll-parms
endif
append w-quote to mll-parms
append "~" to mll-parms
append "-2~" to mll-parms
append w-quote to mll-parms
append "%1/1400/%2.llr" to mll-parms
append w-quote to mll-parms
append "~-21~" to mll-parms
append w-quote to mll-parms
append "%1" to mll-parms
append w-quote to mll-parms
move mll-parms to mll-parms unwanted punctuation is "~"
do mll
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-021 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

if w-fulllog = "Y"
move " - Mailsort 1400 Line Listing produced"
to a-rec
write audit
endif

:DO_1400_TIDY_UP:
**
** removes unwanted left-over files
**
if ms-oneschm = "N"
move "%1/1400/%2.cfl" to wtidy-up
do rm-out
move "%1/1400/%2.cfl2 %1/1400/%2.cfl"
to rename-fs
do rename
else
move "%1/1400/%2.cfl2" to wtidy-up
do rm-out
endif

if wh-1400ed = 0
move "%1" to wtidy-up
append "/1400/" to wtidy-up
append >2a2e2a to wtidy-up
do rm-out
else
move "%1/1400/%2.mcf" to wtidy-up
do rm-out
move "%1/1400/%2.sgt" to wtidy-up
do rm-out
move "%1/1400/%2.mcf2" to wtidy-up
do rm-out
move "%1/1400/%2.sgt2" to wtidy-up
do rm-out
move "%1/1400/%2.mcfA" to wtidy-up
do rm-out
move "%1/1400/%2.sgtA" to wtidy-up
do rm-out
endif

move "Mailsort 1400 Process Completed"
to a-rec
write audit
clear a-rec to spaces
write audit
move "1400" to w-lastused

**
** if no items are 1400'ed AND there are no other schemes to follow AND items have
** been 700'ed, then we need to force ALL items back to 700
**
if w-120 = "Y"
go DO_120
endif
if wh-700ed = 0
go DO_120
endif
if wh-1400ed > 0
go DO_120
endif

if w-fulllog = "Y"
move >2a2a7e to a-rec
append "No items qualified for last selected scheme,"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
clear a-rec to spaces
move >2a2a7e to a-rec
append "enforcing all items to previous sorted (700) scheme!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
endif

subtract w-700bc from wh-cleanm
subtract w-700nbc from wh-noclean
subtract w-1400bc from wh-cleanm
subtract w-1400nbc from wh-noclean

subtract wh-700ed from wh-seqno

move 1 to wv-curpos
move 250 to wv-iosize
write whathappen

move "Y" to cs-oneschm
do call-csort
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-022 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "C" to mp-rtype
move "B" to mp-batch
move 0 to mp-rev
move "" to w-tag
do parm-tab
if match
move pt-serlev to mp-m-code
endif
move "N" to mp-ocr
move "N" to mp-1pm
move "N" to mp-mps
move cs-avgwgt to mp-i-wgt
move "%1/700/%2.mcf" to mp-in
append w-quote to mp-in
move "%1/700/%2.mpr" to mp-out
append w-quote to mp-out
move "%1" to mp-dir
append w-quote to mp-dir
do mpr
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-020 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "-1~" to mll-parms
append w-quote to mll-parms
append "%1/700/%2.sgt" to mll-parms
append w-quote to mll-parms
append "~" to mll-parms
append "-2~" to mll-parms
append w-quote to mll-parms
append "%1/700/%2.llr" to mll-parms
append w-quote to mll-parms
append "~-21~" to mll-parms
append w-quote to mll-parms
append "%1" to mll-parms
append w-quote to mll-parms
move mll-parms to mll-parms unwanted punctuation is "~"
do mll
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-021 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "%1/700/%2.mcf" to wtidy-up
do rm-out
move "%1/700/%2.sgt" to wtidy-up
do rm-out
move "%1/700/%2.mcf2" to wtidy-up
do rm-out
move "%1/700/%2.sgt2" to wtidy-up
do rm-out
move "%1/700/%2.cfl2" to wtidy-up
do rm-out
move "%1/700/%2.mcfA" to wtidy-up
do rm-out
move "%1/700/%2.sgtA" to wtidy-up
do rm-out

go DO_GENERAL_TIDY_UP

**
** see if we need to mailsort 120 the file
**
:DO_120:
if w-120 != "Y"
go DO_GENERAL_TIDY_UP
endif
if w-wsort = "Y"
if wh-remain = 0
move >2a2a7e to a-rec
append "Mailsort 120 scheme Ignored - No items to sort!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_GENERAL_TIDY_UP
endif
else
if w-700 = "Y"
if wh-remain = 0
move >2a2a7e to a-rec
append "Mailsort 120 scheme Ignored - No items to sort!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_GENERAL_TIDY_UP
endif
else
if w-1400 = "Y"
if wh-remain = 0
move >2a2a7e to a-rec
append "Mailsort 120 scheme Ignored - No items to sort!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_GENERAL_TIDY_UP
endif
endif
endif
endif

if w-perend = "Y"
call fsopen arguments are (at-err, at-oct, at-fct, at-iad)
if at-err != "0000"
move em-058 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
call fsclos arguments are (at-err, at-fct)
endif

move "Attempting to apply Mailsort 120"
to a-rec
write audit
if w-perend = "Y"
append "Attempting Accumulation"
to if-rec
else
append "Attempting Mailsort120.."
to if-rec
endif
clear w-error to spaces

move "" to w-tag
do parm-tab
if match
move pt-serlev to mr-serlev
endif
move "" to w-tag
do parm-tab
if match
move pt-yesno to mr-split
endif
move "" to w-tag
do parm-tab
if match
if pt-yesno = "Y"
clear mr-unspec to spaces
else
move "N" to mr-mixwgt
endif
endif
move "" to w-tag
do parm-tab
if match
move pt-weight to mr-avgwgtn
endif
if mr-avgwgtn > 120mwgt
move >2a2a7e to a-rec
append em-042 to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
move >2a2a7e to a-rec
append "Mailsort 120 maximum allowed weight is~"
to a-rec
append 120mwgtx to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
go DO_GENERAL_TIDY_UP
endif
move "N" to mr-onepass
move "Y" to mr-oneschm
move "" to w-tag
do parm-tab
if match
move "RBK" to g-action
move pt-geoseq to g-region
do region-tab
if match
move g-geoseqn to mr-geoseqn
endif
endif
move "" to w-tag
do parm-tab
if match
move pt-bundle to mr-bundlen
endif
move "" to w-tag
do parm-tab
if match
move pt-order to mr-order
endif

move 4000 to mr-mmqn
if w-accum = "Y"
move 1 to mr-mmqn
endif
move w-accum to mr-accum

move w-format to mr-format
if w-1400 = "Y"
move "%1/%2.P4" to mr-infile
else
if w-700 = "Y"
move "%1/%2.P3" to mr-infile
else
if w-wsort = "Y"
move "%1/%2.P2" to mr-infile
else
move "%1/%2.TMP" to mr-infile
endif
endif
endif
if w-perend = "Y"
move "$TMPDIR/%2.ACT" to mr-infile
endif
append w-quote to mr-infile
if w-perend = "Y"
do call-120A
else
do call-120
endif
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-025 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen
if wh-mess1 != spaces
move wh-mess1 to a-rec
write audit
endif
if wh-mess2 != spaces
move wh-mess2 to a-rec
write audit
endif
move wh-cleanm to w-120bc
move wh-noclean to w-120nbc
subtract w-1400bc from w-120bc
subtract w-1400nbc from w-120nbc

:DO_120_REPORTS:
if wh-120ed = 0
go DO_120_TIDY_UP
endif

if w-accum = "Y"
go DO_120_REPORTS_LINE_LISTING
endif

if w-fulllog = "Y"
move " - producing Mailsort 120 Costing Report"
to a-rec
write audit
endif

move "C" to mp-rtype
move "B" to mp-batch
move 0 to mp-rev
move "" to w-tag
do parm-tab
if match
move pt-serlev to mp-m-code
endif
move "N" to mp-ocr
move "N" to mp-1pm
move "N" to mp-mps
move mr-avgwgt to mp-i-wgt
move "%1/120/%2.mcf" to mp-in
append w-quote to mp-in
move "%1/120/%2.mpr" to mp-out
append w-quote to mp-out
move "%1" to mp-dir
append w-quote to mp-dir
do mpr
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-020 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

if w-fulllog = "Y"
move " - Mailsort 120 Costing Report produced"
to a-rec
write audit
endif

if w-perend = "Y"
call fsopen arguments are (wf-err, wf-oct, wf-fct, wf-iad)
loop
call fsget arguments are (wf-err, wf-fct, wf-iad, wf-isz, mcf-item)
until mcf-ident = "409"
until wf-iad = high-values
endloop
if mcf-ident = "409"
move mcf-perc to w-perc numeric only
if w-perc <>
move >2a2a7e to a-rec
append "LESS THAN 90 PERCENT FULL POSTCODE IN ACCUMULATED RUN!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
clear a-rec to spaces
move >2a2a7e to a-rec
append "POSTAGE DISCOUNTS SHOULD NOT BE CLAIMED!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
endif
endif
call fsclos arguments are (wf-err, wf-fct)
endif

:DO_120_REPORTS_LINE_LISTING:
if w-fulllog = "Y"
move " - producing Mailsort 120 Line Listing"
to a-rec
write audit
endif

move "-1~" to mll-parms
append w-quote to mll-parms
append "%1/120/%2.sgt" to mll-parms
append w-quote to mll-parms
append "~" to mll-parms
append "-2~" to mll-parms
append w-quote to mll-parms
append "%1/120/%2.llr" to mll-parms
append w-quote to mll-parms
append "~-21~" to mll-parms
append w-quote to mll-parms
append "%1" to mll-parms
append w-quote to mll-parms
move mll-parms to mll-parms unwanted punctuation is "~"
do mll
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-021 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

if w-fulllog = "Y"
move " - Mailsort 120 Line Listing produced"
to a-rec
write audit
endif

:DO_120_TIDY_UP:
**
** removes unwanted left-over files
**
if wh-120ed = 0
move "%1" to wtidy-up
append "/120/" to wtidy-up
append >2a2e2a to wtidy-up
do rm-out
else
move "%1/120/%2.mcf" to wtidy-up
do rm-out
move "%1/120/%2.sgt" to wtidy-up
do rm-out
endif
move "Mailsort 120 Process Completed"
to a-rec
write audit
clear a-rec to spaces
write audit
move "120 " to w-lastused

**
** if no items are 120'ed AND items have 700'ed or 1400'ed,
** then we need to force ALL items back to 700 or 1400
**
if wh-700ed = 0
if wh-1400ed = 0
go DO_GENERAL_TIDY_UP
endif
endif
if wh-120ed > 0
go DO_GENERAL_TIDY_UP
endif
if wh-1400ed > 0
go REDO_1400
endif

:REDO_700:
if w-fulllog = "Y"
move >2a2a7e to a-rec
append "No items qualified for last selected scheme,"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
clear a-rec to spaces
move >2a2a7e to a-rec
append "enforcing all items to previous sorted (700) scheme!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
endif

subtract w-1400bc from wh-cleanm
subtract w-1400nbc from wh-noclean
subtract w-120bc from wh-cleanm
subtract w-120nbc from wh-noclean

subtract wh-700ed from wh-seqno

move 1 to wv-curpos
move 250 to wv-iosize
write whathappen

move "Y" to cs-oneschm
do call-csort
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-022 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "C" to mp-rtype
move "B" to mp-batch
move 0 to mp-rev
move "" to w-tag
do parm-tab
if match
move pt-serlev to mp-m-code
endif
move "N" to mp-ocr
move "N" to mp-1pm
move "N" to mp-mps
move cs-avgwgt to mp-i-wgt
move "%1/700/%2.mcf" to mp-in
append w-quote to mp-in
move "%1/700/%2.mpr" to mp-out
append w-quote to mp-out
move "%1" to mp-dir
append w-quote to mp-dir
do mpr
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-020 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "-1~" to mll-parms
append w-quote to mll-parms
append "%1/700/%2.sgt" to mll-parms
append w-quote to mll-parms
append "~" to mll-parms
append "-2~" to mll-parms
append w-quote to mll-parms
append "%1/700/%2.llr" to mll-parms
append w-quote to mll-parms
append "~-21~" to mll-parms
append w-quote to mll-parms
append "%1" to mll-parms
append w-quote to mll-parms
move mll-parms to mll-parms unwanted punctuation is "~"
do mll
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-021 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "%1/700/%2.mcf" to wtidy-up
do rm-out
move "%1/700/%2.sgt" to wtidy-up
do rm-out
move "%1/700/%2.mcf2" to wtidy-up
do rm-out
move "%1/700/%2.sgt2" to wtidy-up
do rm-out
move "%1/700/%2.cfl2" to wtidy-up
do rm-out
move "%1/700/%2.mcfA" to wtidy-up
do rm-out

move "%1/700/%2.sgtA" to wtidy-up
do rm-out

go DO_GENERAL_TIDY_UP

:REDO_1400:
if w-fulllog = "Y"
move >2a2a7e to a-rec
append "No items qualified for last selected scheme,"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
clear a-rec to spaces
move >2a2a7e to a-rec
append "enforcing all items to previous sorted (1400) scheme!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
endif

subtract w-1400bc from wh-cleanm
subtract w-1400nbc from wh-noclean
subtract w-120bc from wh-cleanm
subtract w-120nbc from wh-noclean

subtract wh-1400ed from wh-seqno

move 1 to wv-curpos
move 250 to wv-iosize
write whathappen

move "Y" to ms-oneschm
do call-1400
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-024 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "C" to mp-rtype
move "B" to mp-batch
move 0 to mp-rev
move "" to w-tag
do parm-tab
if match
move pt-serlev to mp-m-code
endif
move "N" to mp-ocr
move "N" to mp-1pm
move "N" to mp-mps
move ms-avgwgt to mp-i-wgt
move "%1/1400/%2.mcf" to mp-in
append w-quote to mp-in
move "%1/1400/%2.mpr" to mp-out
append w-quote to mp-out
move "%1" to mp-dir
append w-quote to mp-dir
do mpr
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-020 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "-1~" to mll-parms
append w-quote to mll-parms
append "%1/1400/%2.sgt" to mll-parms
append w-quote to mll-parms
append "~" to mll-parms
append "-2~" to mll-parms
append w-quote to mll-parms
append "%1/1400/%2.llr" to mll-parms
append w-quote to mll-parms
append "~-21~" to mll-parms
append w-quote to mll-parms
append "%1" to mll-parms
append w-quote to mll-parms
move mll-parms to mll-parms unwanted punctuation is "~"
do mll
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-021 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif

move "%1/1400/%2.mcf" to wtidy-up
do rm-out
move "%1/1400/%2.sgt" to wtidy-up
do rm-out
move "%1/1400/%2.mcf2" to wtidy-up
do rm-out
move "%1/1400/%2.sgt2" to wtidy-up
do rm-out
move "%1/1400/%2.cfl2" to wtidy-up
do rm-out
move "%1/1400/%2.mcfA" to wtidy-up
do rm-out
move "%1/1400/%2.sgtA" to wtidy-up
do rm-out

:DO_GENERAL_TIDY_UP:
**
** all requested sorts has been carried out, if FILE_SPLITTING
** is not requested then need to join the sorted files together
** and remove any unwanted files.
**
** also write out to the log file totals summary for items sorted
**
** 072008

move 1 to wv-curpos
move 250 to wv-iosize
read whathappen

if w-punctopt = "NNNNN"
go BYPASS_PUNCTING
endif
if w-punctopt = "NNNNY"
go BYPASS_PUNCTING
endif

if w-rmpunout = "Y"
move w-uPAFadd to po-uPAFadd
move w-uPAFpun to po-uPAFpun
move w-rallpun to po-rallpun
move w-runwpun to po-runwpun
move w-punrep to po-punrep

if wh-walked > 0
if w-walknopu = "Y"

clear a-rec to spaces
write audit
move " -- Punctuation Processing for Walksort Records.."
to a-rec
write audit

move "%1/walksort/%2.outW"
to po-infile
append w-quote to po-infile
move "%1/%2-punct.rptWS" to po-rpfile
append w-quote to po-rpfile
move "WS" to po-scheme
do call-punit
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move "Error Removing Punctuation in WS - Job Aborted!"
to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/walksort/%2.outW"
to wtidy-up
do rm-out
move "%1/walksort/%2.outW-X %1/walksort/%2.outW"
to rename-fs
do rename
endif
endif

if wh-700ed > 0
if w-700nopu = "Y"

clear a-rec to spaces
write audit
move " -- Punctuation Processing for Mailsort700 Records.."
to a-rec
write audit

move "%1/700/%2.outM" to po-infile
append w-quote to po-infile
move "%1/%2-punct.rpt700" to po-rpfile
append w-quote to po-rpfile
move "700" to po-scheme
do call-punit
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move "Error Removing Punctuation in 700 - Job Aborted!"
to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/700/%2.outM" to wtidy-up
do rm-out
move "%1/700/%2.outM-X %1/700/%2.outM"
to rename-fs
do rename
endif
endif

if wh-1400ed > 0
if w-1400nopu = "Y"

clear a-rec to spaces
write audit
move " -- Punctuation Processing for Mailsort1400 Records.."
to a-rec
write audit

move "%1/1400/%2.outM" to po-infile
append w-quote to po-infile
move "%1/%2-punct.rpt1400"
to po-rpfile
append w-quote to po-rpfile
move "1400" to po-scheme
do call-punit
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move "Error Removing Punctuation in 1400 - Job Aborted!"
to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/1400/%2.outM" to wtidy-up
do rm-out
move "%1/1400/%2.outM-X %1/1400/%2.outM"
to rename-fs
do rename
endif
endif

if wh-120ed > 0
if w-120nopu = "Y"

clear a-rec to spaces
write audit
move " -- Punctuation Processing for Mailsort120 Records.."
to a-rec
write audit

move "%1/120/%2.outM" to po-infile
append w-quote to po-infile
move "%1/%2-punct.rpt120" to po-rpfile
append w-quote to po-rpfile
move "120" to po-scheme
do call-punit
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move "Error Removing Punctuation in 120 - Job Aborted!"
to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/120/%2.outM" to wtidy-up
do rm-out
move "%1/120/%2.outM-X %1/120/%2.outM"
to rename-fs
do rename
endif
endif

if w-addbar = "Y"
if w-cmnopu = "Y"
clear a-rec to spaces
write audit
move " -- Punctuation Processing for CleanMail Records.."
to a-rec
write audit

if w-split != "Y"
if w-whatsort != "Y"
move "%1/%2.outA" to po-infile
append w-quote to po-infile
move "%1/%2-punct.rptA"
to po-rpfile
append w-quote to po-rpfile
move "A" to po-scheme
do call-punit
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move "Error Removing Punctuation - Job Aborted!"
to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/%2.outA" to wtidy-up
do rm-out
move "%1/%2.outA-X %1/%2.outA"
to rename-fs
do rename
endif
endif

if w-split = "N"
if wh-UKre > 0
move "%1/%2.outU" to po-infile
append w-quote to po-infile
move "%1/%2-punct.rptU"
to po-rpfile
append w-quote to po-rpfile
move "U" to po-scheme
do call-punit
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move "Error Removing Punctuation - Job Aborted!"
to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/%2.outU" to wtidy-up
do rm-out
move "%1/%2.outU-X %1/%2.outU"
to rename-fs
do rename
endif
endif

endif
endif

endif
** 072008

:BYPASS_PUNCTING:
if w-keeptmpf != "Y"
move "%1/%2.TMP" to wtidy-up
do rm-out
if w-perend = "Y"
move "$TMPDIR/%2.ACT" to wtidy-up
do rm-out
endif
endif
move "%1/%2.P2" to wtidy-up
do rm-out
move "%1/%2.P3" to wtidy-up
do rm-out
move "%1/%2.P4" to wtidy-up
do rm-out

clear a-rec to spaces
write audit
clear a-rec to "-"
write audit
move "SUMMARY:- " to a-rec
write audit
clear a-rec to spaces
write audit
if w-perend = "N"
move "Specified number of documents from Parameter file:~"
to a-rec
append w-innum to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit

move " Actual number of documents read from input file:~"
to a-rec
move wh-totalin to w-readnum
append w-readnum to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
if w-innum != w-readnum
move >2a2a7e to a-rec
append "Actual number of documents and parameter value differs!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
endif
else
move " Total number of documents processed in accumulated run:~"
to a-rec
move wh-totalin to w-readnum
append w-readnum to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
endif
clear a-rec to spaces
write audit
move 1 to wv-curpos
move 250 to wv-iosize
read whathappen

if wh-totexc > 0
move "Records in Exception List:"
to a-mess
move wh-totexc to a-total justified right
write audit

move "Total Matched Exceptions:"
to a-mess
move wh-except to a-total justified right
write audit
clear a-rec to spaces
write audit
endif

if wh-errors > 0
move "Total Postcode Errors:"
to a-mess
move wh-errors to a-total justified right
write audit
clear a-rec to spaces
write audit
endif

if ad-repONLY = "Y"
go FINISH
endif

if wh-walked = 0
if wh-700ed = 0
if wh-1400ed = 0
if wh-120ed = 0
if w-whatsort = "Y"
move >2a2a7e to a-rec
append "Mailsort has not applied!"
to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
clear a-rec to spaces
write audit
move "Y" to w-nonsort
endif
endif
endif
endif
endif

if w-wsort = "Y"
move "Total Walksorted:" to a-mess
move wh-walked to a-total justified right
write audit
endif
if w-700 = "Y"
move "Total 700 Mailsorted:"
to a-mess
move wh-700ed to a-total justified right
write audit
endif
if w-1400 = "Y"
move "Total 1400 Mailsorted:"
to a-mess
move wh-1400ed to a-total justified right
write audit
endif
if w-120 = "Y"
move "Total 120 Mailsorted:"
to a-mess
move wh-120ed to a-total justified right
write audit
endif

*!* do debug7

move "Total BarCode data produced:"
to a-mess
move wh-totbc to a-total justified right
write audit
move "Total Non-BarCoded:" to a-mess
move wh-totnbc to a-total justified right
write audit

if w-split = "N"
if w-whatsort != "Y"
go DO_GENERAL_TIDY_UP_REMOVE_FILES
endif
endif

if wh-UKre != 0
move "Total UK Residue:" to a-mess
move wh-UKre to a-total justified right
write audit
else
move >2a2a7e to a-rec
append "No UK Residue" to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
endif
clear a-rec to spaces
if wh-nonUKre != 0
move "Total Foreign Residue:"
to a-mess
move wh-nonUKre to a-total justified right
write audit
else
move >2a2a7e to a-rec
append "No Foreign Residue" to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
endif

:DO_GENERAL_TIDY_UP_REMOVE_FILES:
if wh-Ukre = 0
move "%1/%2.outU" to wtidy-up
do rm-out
endif
if wh-nonUkre = 0
move "%1/%2.outF" to wtidy-up
do rm-out
endif

if w-nonsort = "Y"
*!* go FINISH * 18/09/06
go PROCESS_AMALGAM_FILE * 18/09/06
endif

if w-split = "Y"
go FINISH
endif

if w-whatsort != "Y"
if w-addbar = "Y"
go FINISH
endif
endif

move "%1/%2.outA" to wtidy-up
do rm-out

if wh-walked > 0
move "%1/walksort/%2.outW > %1/%2.outA"
to file-join
do join-files
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-033 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/walksort/%2.outW" to wtidy-up
do rm-out
endif

if wh-700ed > 0
move "%1/700/%2.outM >> %1/%2.outA"
to file-join
do join-files
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-034 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/700/%2.outM" to wtidy-up
do rm-out
endif

if wh-1400ed > 0
move "%1/1400/%2.outM >> %1/%2.outA"
to file-join
do join-files
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-035 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/1400/%2.outM" to wtidy-up
do rm-out
endif

if wh-120ed > 0
move "%1/120/%2.outM >> %1/%2.outA"
to file-join
do join-files
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move em-036 to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/120/%2.outM" to wtidy-up
do rm-out
endif

** 04/09 **
:PROCESS_AMALGAM_FILE:
*!* do debug8

if w-onefile != "Y"
go FINISH
endif
if w-split != "N"
go FINISH
endif
move "N" to w-addbar
move "" to w-tag
do parm-tab
if match
move pt-yesno to w-addbar
endif
move "" to w-tag
do parm-tab
if match
move pt-yesno to w-addbar
endif

if w-addbar = "Y"
go FINISH
endif

if wh-Ukre > 0
clear a-rec to spaces
write audit
move " -- Appending UK Residue records to .outA file.."
to a-rec
write audit
move "%2" to 1f-file
append ".outU" to 1f-file
append w-quote to 1f-file
do one-file
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move "Error joining .outU/.outA files - Job Aborted!"
to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/%2.outU" to wtidy-up
do rm-out
endif
if wh-nonUkre > 0
clear a-rec to spaces
write audit
move " -- Appending Foreign Residue records to .outA file.."
to a-rec
write audit
move "%2" to 1f-file
append ".outF" to 1f-file
append w-quote to 1f-file
do one-file
if w-error != spaces
if w-error != "0000"
if w-error != low-values
move "Error joining .outF/.outA files - Job Aborted!"
to er-mess1
append w-quote to er-mess1
clear er-mess2 to spaces
append w-quote to er-mess2
go HAVE_ERROR
endif
endif
endif
move "%1/%2.outF" to wtidy-up
do rm-out
endif
** 04/09 **

go FINISH

:HAVE_ERROR:
do call-error
move er-mess1 to a-rec unwanted punctuation is "Q"
write audit
move er-mess2 to a-rec unwanted punctuation is "Q"
write audit

:FINISH:
write inform

if w-dumpadds != "Y"
move "%1/%2.dumps" to wtidy-up
do rm-out
endif
if w-reportit = "N"
move "%1/%2.pqr" to wtidy-up
do rm-out
move "%1/pcquality.rpt" to wtidy-up
do rm-out
endif
if wh-except = 0
move "%1/%2.dnt" to wtidy-up
do rm-out
endif

if w-punrep != "Y" * 072008
move "%1/%2-punct.rpt" to wtidy-up * 072008
append >2a to wtidy-up * 072008
do rm-out * 072008
endif

:FINISH_CONTINUE:
clear a-rec to spaces
write audit
accept w-time from time
move "END TIME:~" to a-rec
append w-time to a-rec
move a-rec to a-rec unwanted punctuation is "~"
write audit
clear a-rec to spaces
write audit

*do job-done

run
end