Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating A/P payment entry (version 5.6)

Status
Not open for further replies.

Pierreski

Programmer
Aug 20, 2010
6
CA
Hi all,
I've managed to create and post an invoice batch and also created a new payment batch, but now that I'm trying to add payment entries to this new payment batch, I'm completely stuck!

The issue is that the macro code tells me nothing about selecting the individual line items for a vendor (when I click on the blue ">>" arrow).
When I actually add the line item to the batch, the macro code just seems to reference the sequential number of each grid item (from the above action), but gives me no detail about the entry itself and no indication of what it does behind the scenes to add it. It doesn't even detail where I applied the document to the line.

Here's a snippet of macro code generated as I described - I won't waste space with the view composition code, but please let me know if you need this.

Any ideas / pointers gratefully accepted.

Many thanks

Pete


Code Snippet:

APPAYMENT3batch.RecordClear

APPAYMENT3batchFields("PAYMTYPE").PutWithoutVerification ("PY") ' Batch Selector

APPAYMENT3headerFields("BTCHTYPE").PutWithoutVerification ("PY") ' Batch Type
APPAYMENT3detail3Fields("BATCHTYPE").PutWithoutVerification ("PY") ' Batch Type
APPAYMENT3detail1Fields("BATCHTYPE").PutWithoutVerification ("PY") ' Batch Type
APPAYMENT3detail2Fields("BATCHTYPE").PutWithoutVerification ("PY") ' Batch Type
APPAYMENT3batchFields("CNTBTCH").PutWithoutVerification ("91") ' Batch Number
APPAYMENT3batch.Read

APPAYMENT3batchFields("PROCESSCMD").PutWithoutVerification ("1") ' Process Command Code

APPAYMENT3batch.Process

APPAYMENT3batchFields("PROCESSCMD").PutWithoutVerification ("1") ' Process Command Code

APPAYMENT3batch.Process
APPAYMENT3header.RecordCreate 2
APPAYMENT3batch.Browse "((PAYMTYPE = ""PY"") AND ((BATCHSTAT = 1) OR (BATCHSTAT = 7) OR (BATCHSTAT = 8)))", 1
APPAYMENT3headerFields("IDVEND").Value = "100208" ' Vendor Number
APPAYMENT3detail1.Cancel

APPAYMENT3headerFields("TXTRMITREF").Value = "Ref #3" ' Entry Reference

APPAYMENT3header.Insert
APPAYMENT3header.Insert
APPAYMENT3batch.Read
APPAYMENT3headerFields("CNTENTR").PutWithoutVerification ("0") ' Entry Number
APPAYMENT3header.RecordCreate 2

 
Clicking the blue arrow ("Go") button will create an internal list of invoices. You can then navigate through that list.

I pulled the following code from an existing macro. It should point you in the right direction:
Code:
    With APPAYMENT1detail1
        .RecordClear
        .RecordCreate VIEW_RECORD_CREATE_DELAYKEY
        .Fields("IDINVC").Value = InvNo
        
        .Insert
        .Fields("AMTPAYM").Value = ds.Fields("AMOUNT").Value
        .Fields("PROCESSCMD").PutWithoutVerification 1
        .Process
        
    End With
 
Thanks for that, with a bit of fiddling about I've written some code that's 99% working.
The other 1%...well, even though I've included the IDINVC field, as per your example, I get an error telling me that the "Invoice Number cannot be blank".
I've done some searching and can find no invoice number (or similar) in any of the header or detail view fields. I've tried setting up a few potential fields, but to no avail.
Any ideas what field it might actually be erroring on?

Here's the relevant code if that helps. It actually errors on the last line APheader.insert

Thanks again.


' Create payment batch with bank code
APbatch.Fields.FieldByName("PAYMTYPE").SetValue("PY", False) ' Batch Selector
APbatch.Fields.FieldByName("CNTBTCH").SetValue("0", False) ' Batch Number
APbatch.RecordCreate(1)
APbatch.Fields.FieldByName("BATCHDESC").SetValue("Pete Payment Batch #2", False) ' Description
APbatch.Fields.FieldByName("DATEBTCH").SetValue(DateSerial(2010, 8, 30), False) ' Batch Date
APbatch.Fields.FieldByName("IDBANK").SetValue("COMOP", False) ' Bank Code
APbatch.Update()

' Create payment header (vendor specific, can contain multiple invoices)
APheader.RecordCreate(0)
APheader.Fields.FieldByName("TEXTRMIT").SetValue("Batch entry 1", False) ' Entry Description
APheader.Fields.FieldByName("RMITTYPE").SetValue("4", False) ' Payment Trans. Type
APheader.Fields.FieldByName("PROCESSCMD").SetValue("0", False) ' Process Command Code
APheader.Fields.FieldByName("IDVEND").SetValue("100035", False) ' Vendor Number
APheader.Fields.FieldByName("PROCESSCMD").SetValue("0", False) ' Process Command Code
APheader.Fields.FieldByName("SWPRNTRMIT").SetValue("0", False) ' Check Print Required
APheader.Fields.FieldByName("IDRMIT").SetValue("000000123456", False) ' Check Number
APheader.Fields.FieldByName("TXTRMITREF").SetValue("Reference 1", False) ' Entry Reference
APheader.Fields.FieldByName("DOCNBR").SetValue("PY000005017", False) ' Header Doc Number
APheader.Process()

' and add the details - each unpaid invoice for the chosen vendor
APdetail1.RecordCreate(0)
APdetail1.Fields.FieldByName("IDINVC").SetValue("INV-PCE-19", False) ' Document number (invoice)
APdetail1.Fields.FieldByName("CNTRMIT").SetValue("1", False) ' entry number
APdetail1.Fields.FieldByName("AMTPAYM").SetValue("900.00", False) ' Dist. Amount
APdetail1.Insert()

APheader.Insert()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top