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!

How to import batch of invoices from Access to ACCPAC

Status
Not open for further replies.

POSOL

Programmer
Jul 2, 2004
16
CA
Hello,

I am working on the system which supposely will import batch of invoices from Access DB to ACCPAC A/P. I'm using VB6.0 and COM API (stand alone application)to import new batch to ACCPAC 5.2A.

Here is what works and what not:

It establishes connection with ACCPAC, creates a new batch and grabs NewBatchNumber to write into the Access DB I create (this DB can be imported to ACCPAC manually)

Now The PROBLEM I have:
I have new Batch in ACCPAC and I have Access DB - How to populate(import to) ACCPAC batch with data from Access DB?

Here is the fragment of the code I use:


Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = Session.GetDBLink (DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim APINVCPOST As AccpacCOMAPI.AccpacView

Dim APINVCPOSTFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0039", APINVCPOST
Set APINVCPOSTFields = APINVCPOST.Fields

Dim APINVOICEbatch As AccpacCOMAPI.AccpacView
Dim APINVOICEbatchFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0020", APINVOICEbatch
Set APINVOICEbatchFields = APINVOICEbatch.Fields

Dim APINVOICEheader As AccpacCOMAPI.AccpacView
Dim APINVOICEheaderFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0021", APINVOICEheader
Set APINVOICEheaderFields = APINVOICEheader.Fields

Dim APINVOICEdetail1 As AccpacCOMAPI.AccpacView
Dim APINVOICEdetail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0022", APINVOICEdetail1
Set APINVOICEdetail1Fields = APINVOICEdetail1.Fields

Dim APINVOICEdetail2 As AccpacCOMAPI.AccpacView
Dim APINVOICEdetail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0023", APINVOICEdetail2
Set APINVOICEdetail2Fields = APINVOICEdetail2.Fields

APINVOICEbatch.Compose Array(APINVOICEheader)

APINVOICEheader.Compose Array(APINVOICEbatch, APINVOICEdetail1, APINVOICEdetail2)

APINVOICEdetail1.Compose Array(APINVOICEheader, APINVOICEbatch)

APINVOICEdetail2.Compose Array(APINVOICEheader)


APINVOICEbatch.Browse "((BTCHSTTS = 1) OR (BTCHSTTS = 7))", 1
APINVOICEdetail2.Init
APINVOICEbatchFields("CNTBTCH").PutWithoutVerification ("0") ' Batch Number
APINVOICEbatch.Init

BatchNo = APINVOICEbatchFields("CNTBTCH").Value

'*****DB Convertion

Set conv = New DBConvertion
'MsgBox "DBConnection Object initialized = " & DBConnectionTest, vbOKOnly, "Connection Test"
conv.ConnectTo strSource, strDestination, strTemplate

convertionOK = conv.Convert("tblAllInvoicing", BatchNo)
If Not (convertionOK) Then
MsgBox "Source to Destination DB Convertion Failed!!!", vbOKOnly + vbCritical, "Convertion ERROR"
End If
conv.FinishConvertion

'*****DB Convertion END

'***********************************
'Here I need to Import data from Newly created
'DB into ACCPAC A/P Newly created Batch
'???????????????????????????????????
'***********************************

APINVOICEheaderFields("CNTITEM").PutWithoutVerification ("0") ' Entry Number
APINVOICEheader.Init
APINVOICEdetail1.Init
APINVOICEdetail2.Init
APINVOICEbatchFields("BTCHDESC").PutWithoutVerification (BatchDescription.Text) ' Description
APINVOICEbatch.Update
APINVOICEbatch.Read
APINVOICEheaderFields("CNTITEM").PutWithoutVerification ("-9999999") ' Entry Number
APINVOICEheader.Browse "", 1
APINVOICEheader.Fetch
 
Sorry forgot to say:

Macros Recording will not help!

And, There are two ways as I see:
1. Call api - which imports Access DB.(if it is exists?)

2. Manually fill in the data using views.(which views?)

Thank you for viewing and responding!
 
Macro recording will help!

You're almost done, all the views are ready. All you have to do is put in a loop through the external table, and fill in values in APINVOICEdetail1, then use APINVOICEdetail1.Insert.

Jay Converse
IT Director
Systemlink, Inc.
 
Thanks Jay,

Your post was really helpfull - I've spent a lot of time looking for the view that contains Invoice Info - now I got it.

Thanks again for your post
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top