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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply Documents Automation

Status
Not open for further replies.

easyzone

Programmer
Jun 30, 2006
8
US
Accpac 5.3b

I am working on an apply documents routine in vb6 using COM API. I have the routine creating the batch I need but it is wanting to apply to the wrong documents. The field ARPOOP.CNTKEY has to be populated with a negative number. I originally thought that it was the order in which it shows in the AR Receipt Enty form when you click the >> button after you enter the unapplied cash document. So I ran an RVSPY on the click of the >> button to see how accpac queries the data. I implemented the query into my program but I am still applying to wrong documents. Can anyone tell me how to derive the CNTKEY field value or how I can apply documents by document number instead of using the CNTKEY. Below is my current code.



For Detail = 1 To lbatch.Batches.RecordCount

ARRECMAC1headerFields("RMITTYPE").Value = "4" ' Receipt Trans. Type
ARRECMAC1detail1.Cancel
ARRECMAC1headerFields("PROCESSCMD").PutWithoutVerification ("0") ' Process Command Code
ARRECMAC1header.Process
ARRECMAC1detail4.Cancel
ARRECMAC1headerFields("IDCUST").Value = Trim(lbatch.IDCUST) ' Customer Number
ARRECMAC1detail1.Cancel
ARRECMAC1headerFields("PROCESSCMD").PutWithoutVerification ("0") ' Process Command Code
ARRECMAC1header.Process
ARRECMAC1detail4.Cancel

ARRECMAC1headerFields("DOCNBR").Value = Trim(lbatch.APPLYFROM) ' Document Number
ARRECMAC1detail4Fields("PAYMTYPE").Value = "CA" ' Batch Type

ARRECMAC1detail4Fields("CNTBTCH").Value = lbatch.AccpacBatch ' Batch Number
ARRECMAC1detail4Fields("CNTITEM").Value = lbatch.GetItemNumber ' Entry Number
ARRECMAC1detail4Fields("IDCUST").Value = Trim(lbatch.IDCUST) ' ID Customer
ARRECMAC1detail4Fields("AMTRMIT").Value = "0.000" ' Receipt Amount
ARRECMAC1detail4Fields("PROTYPE").PutWithoutVerification ("1") ' Process Type
ARRECMAC1detail4.Process
ARRECMAC1detail4Fields("CNTITEM").PutWithoutVerification (lbatch.GetItemNumber) ' Entry Number
ARRECMAC1detail4Fields("CNTKEY").PutWithoutVerification (lbatch.GetKeycodeValue(lbatch.APPLYFROM, lbatch.APPLYTO)) ' Count key
ARRECMAC1detail4.Read
ARRECMAC1detail4Fields("APPLY").Value = "Y" ' Apply
temp = ARRECMAC1detail4.Exists
ARRECMAC1detail4.Update
ARRECMAC1detail4Fields("CNTITEM").PutWithoutVerification (lbatch.GetItemNumber) ' Entry Number
ARRECMAC1detail4Fields("CNTKEY").PutWithoutVerification (lbatch.GetKeycodeValue(lbatch.APPLYFROM, lbatch.APPLYTO)) ' Count key
ARRECMAC1detail4.Read
ARRECMAC1header.Insert
ARRECMAC1detail4.Cancel
temp = ARRECMAC1header.Exists
ARRECMAC1detail4Fields("PAYMTYPE").Value = "CA" ' Batch Type
ARRECMAC1detail4Fields("CNTBTCH").Value = lbatch.AccpacBatch ' Batch Number
ARRECMAC1detail4Fields("CNTITEM").Value = lbatch.GetItemNumber ' Entry Number
ARRECMAC1detail4Fields("IDCUST").Value = Trim(lbatch.IDCUST) ' ID Customer
ARRECMAC1detail4Fields("AMTRMIT").Value = "0.000" ' Receipt Amount
ARRECMAC1detail4Fields("PROTYPE").PutWithoutVerification ("1") ' Process Type
ARRECMAC1detail4.Process
ARRECMAC1headerFields("CNTITEM").PutWithoutVerification ("0") ' Entry Number
temp = ARRECMAC1header.Exists
ARRECMAC1header.RecordGenerate False
ARRECMAC1detail4.Cancel
temp = ARRECMAC1header.Exists

ARRECMAC1headerFields("PROCESSCMD").PutWithoutVerification ("0") ' Process Command Code

ARRECMAC1header.Process

lbatch.MoveNextApplyDocumentBatchRecord

Next Detail
 
Forget about CNTKEY, that will be generated.
You need to apply to IDCUST, IDINVC, CNTPAYM in ARTCP (AR0044).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top