Gawk would be better, with it's specific support for fixed width fields. (Look up the FIELDWIDTHS variable.)
It's also easy to write the simple rules to filter out the garbage you will get.
Here's a simple script that just gives you the "important" lines and the variable mappings from that report you linked to:
BEGIN {
FIELDWIDTHS="4 4 7 5 1 7 1 1 23 4 10 2 1 2 8 1 6 1 4 1 6 1 2 1 2 1 2 1 4 2 10 1"
}
function cvt_amt(a) {
gsub(",", "", a);
amt = a * 1;
return amt;
}
function empty(s) {
gsub(" ", "", s);
return s == "";
}
/* skip garbage lines */
/----/ { next; }
/CASH RECEIPTS REPORT/ { next;}
/PERIOD ENTERED/ { next; }
/^ *$/ { next; }
($2 == "CUST") { next; }
($2 == "NO. ") { next; }
/CUSTOMER TOTALS/ { next; }
/GRAND TOTALS/ { next; }
/SUMMARY BY STATUS/ { nextfile; } /* end of stuff we care about */
/* Identify user */
(!empty($2)) {
user_no = $2;
user_name = substr($0, 10, 30);
}
{
/* variable mapping */
cust_no = $2;
vchr_no = $4;
inv_no = $6;
inv_no_sign = $7;
inv_desc = $9;
recv_amt = cvt_amt($11);
st = $13;
recv_date = $15;
check_no = $17;
period = $19;
batch = $21;
bank = $23;
cc = $25;
dp = $27;
acct = $29;
amt_recv = cvt_amt($31);
sign = $32;
if (sign == "-") {
amt_recv = amt_recv * -1;
}
print;
}
Frankly, I think this is pretty clean, but I'm a (g)awk fanboi.
Edit -- I added some code to pull out the user number and name. User number is field 2 from the fixed fields, but the user name had to substr() out, since it overlaps many of the detail fields.