tx2_det has a unique index of tx2d_ref_nbr which has the following structure:
pu tx2d_ref_nbr 8 6 + tx2d_ref
+ tx2d_nbr
+ tx2d_line
+ tx2d_trl
+ tx2d_tr_type
+ tx2d_tax_code
So, you cannot have 2 records with the same information in all the above fields.
** tx2d_det already exists with Reference "10018924" Number "0016764" Line 2 Trailer "" Transaction Type "22" Tax Code "6". (132)
You probably already have a record in the system with this informaiton:
tx2d_ref = "10018924"
tx2d_nbr = "0016764"
tx2d_line = 2
tx2d_trl = ""
tx2d_tr_type = "22"
tx2d_tax_code = "6"
Since the Trailer is "", I would guess that you need to put a value into Trailer and it should work.