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

New to accpac 1

Status
Not open for further replies.

verify01

Programmer
Jan 15, 2008
2
CZ
Hi,
I'm new to this so I would very much appreciate any help getting started. I need to send invoices to Accpac using the xapi. I am running the sample program included with the sdk and it shows how to open a view and get data from the accpac database. I need an example of how to add data to the database. I have read the xapi documentation and it looks like I need to call xapiViewInsert followed by xapiBlkPut and xapiViewUpdate. Does that sound right? Does anyone have a very simple example adding any record to the Accpac database using the xapi?

Thanks in advance!
 
Hi there,
Thanks a lot for the reply. I have written a function based on code posted on this forum. It uses the com api and it works to a point. It opens a session, connects to a database and adds a new invoice batch. After this I am trying to add an invoice header and details but thats where it fails. I get an "Unspecified error". I thought that it was because I am using the view id of the batch view when I init the session, but I read on another post here that it doesn't actually matter what you pass in the parameters here. Do you have any idea what I am doing wrong? Here is the code:

Code:
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink

Dim ARbatch As AccpacCOMAPI.AccpacView

Dim ARheader As AccpacCOMAPI.AccpacView

Dim ARdetail1 As AccpacCOMAPI.AccpacView

Dim ARdetail2 As AccpacCOMAPI.AccpacView

Dim ARdetail3 As AccpacCOMAPI.AccpacView

Dim ARdetail4 As AccpacCOMAPI.AccpacView


On Error GoTo Errorhandler
Dim AccSession As New AccpacCOMAPI.AccpacSession

If AccSession.IsOpened Then
       mDBLinkCmpRW.Close
       AccSession.Close
    End If
    AccSession.Init "", "ZX", "ZX1000", "54A"   'Prog ID Location Details
    AccSession.EnforceAppVersion = False
    AccSession.Open "ADMIN", "ADMIN", "SAMINC", Date, 0, ""

'Open DB

Set mDBLinkCmpRW = AccSession.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)


'Open views

mDBLinkCmpRW.OpenView "AR0031", ARbatch

mDBLinkCmpRW.OpenView "AR0032", ARheader

mDBLinkCmpRW.OpenView "AR0033", ARdetail1

mDBLinkCmpRW.OpenView "AR0034", ARdetail2

mDBLinkCmpRW.OpenView "AR0402", ARdetail3

mDBLinkCmpRW.OpenView "AR0401", ARdetail4



'Compose views

ARbatch.Compose Array(ARheader)

ARheader.Compose Array(ARbatch, ARdetail1, ARdetail2, ARdetail3, Nothing)

ARdetail1.Compose Array(ARheader, ARbatch, ARdetail4)

ARdetail2.Compose Array(ARheader)

ARdetail3.Compose Array(ARheader)

ARdetail4.Compose Array(ARdetail1)



'Create batch

ARbatch.RecordCreate 1

ARbatch.Fields("BTCHDESC").PutWithoutVerification BTCHDESC

ARbatch.Update



ARheader.RecordCreate 0

ARheader.Fields("IDCUST").Value = IDCUST

ARheader.Fields("IDINVC").Value = "IN123"


Dim i As Integer
For i = 0 To UBound(aItemNames)
    
    ARdetail1.RecordCreate 0

    ARdetail1.Fields("IDITEM").Value = aItemNames(i)
    ARdetail1.Fields("QTYINVC").Value = aItemQtys(i)
  
    
    ARdetail1.Insert

Next i


ARheader.Insert

It fails on the insert calls for the detail and header. It also doesn't like this line:
Code:
ARdetail1.Fields("IDITEM").Value = aItemNames(i)
Thanks again for the help
 
Add an Accpac error handler, that will give you a meaningful message.
Make sure that you set your batch type (or entry type) to "Item".
Record a macro while you enter an AR invoice and see how they do that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top