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
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