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!

Accpac 5.5A COMAPI Invoice Creation C# .Net 1

Status
Not open for further replies.

blahlazer

Programmer
Jan 14, 2009
7
US
I really need help. I created an Accpac integration in C# using the Accpac 5.4 Interop.AccpacCOMAPI.dll. The system worked great until I moved it over to Accpac 5.5. Unfortunately, my company's live Accpac system just got upgraded to 5.5 a few weeks back, so I don't have the option of sticking with 5.4.

The upgrade didn't break the entire integration, I am able to use the 5.4 API to create customer records in Accpac but the invoices fail on the header insert.

Since I was originally using the 5.4 Interop.AccpacCOMAPI.dll, I thought I might be able to just switch over to the 5.5 Interop.AccpacCOMAPI.dll, but that made matters worse. The 5.5 dll is missing the RecordCreate function on the AccpacView object. If I generate a macro for invoice creation in Accpac, the RecordCreate function is still used, so I don't see why it's not in the API.

If anything I mentioned reveals something I'm doing wrong please let me know. Below I will be inserting the code I am using when trying to create an invoice. I have created a wrapper to the API so some of my functions are not standard, but they call the standard functions. I have simplified my code in an attempt to remove any unnecessary code that would be breaking the system.


DateTime startDate = actStartDate;
EzAccpacModule invBatch = new EzAccpacModule(ref ezAcSession.acDBLink, "AR0031");
EzAccpacModule invHeader = new EzAccpacModule(ref ezAcSession.acDBLink, "AR0032");
EzAccpacModule invDetail1 = new EzAccpacModule(ref ezAcSession.acDBLink, "AR0033");
EzAccpacModule invDetail2 = new EzAccpacModule(ref ezAcSession.acDBLink, "AR0034");
EzAccpacModule invDetail3 = new EzAccpacModule(ref ezAcSession.acDBLink, "AR0402");
EzAccpacModule invDetail4 = new EzAccpacModule(ref ezAcSession.acDBLink, "AR0401");
Object obj = new Object();
invBatch.Compose(ref obj, (Object)(new AccpacView[1] { invHeader.module }));
invHeader.Compose(ref obj, (Object)(new AccpacView[5] { invBatch.module, invDetail1.module, invDetail2.module, invDetail3.module, null }));
invDetail1.Compose(ref obj, (Object)(new AccpacView[3] { invHeader.module, invBatch.module, invDetail4.module }));
invDetail2.Compose(ref obj, (Object)(new AccpacView[1] { invHeader.module }));
invDetail3.Compose(ref obj, (Object)(new AccpacView[1] { invHeader.module }));
invDetail4.Compose(ref obj, (Object)(new AccpacView[1] { invDetail1.module }));
invBatch.Browse("((BTCHSTTS = 1) OR (BTCHSTTS = 7))", true);
invBatch.RecordCreate(tagViewRecordCreateEnum.VIEW_RECORD_CREATE_INSERT);
invBatch.setNoValiFieldValue("PROCESSCMD", "1");
invBatch.Process();
invBatch.Read();
invHeader.RecordCreate(tagViewRecordCreateEnum.VIEW_RECORD_CREATE_NOINSERT);
invDetail1.Cancel();
invBatch.setNoValiFieldValue("BTCHDESC", actName + " 1st Invoice");
invBatch.Update();
invHeader.setFieldValue("IDCUST", actId);
invDetail1.RecordClear();
invDetail1.RecordCreate(tagViewRecordCreateEnum.VIEW_RECORD_CREATE_DELAYKEY);
invDetail1.setFieldValue("IDDIST", "L");
invDetail1.Insert();
 
Thanks for the fast response. Sorry I didn't include it to begin with, but the error is completely useless to me:

+ $exception {"Error HRESULT E_FAIL has been returned from a call to a COM component."} System.Exception {System.Runtime.InteropServices.COMException}

errorCode: -2147467259
 
Yeah, that's pretty useless. The only time I've ever see E_FAIL is when you try to import from an Excel spreadsheet that's still open in Excel. Your code looks fine.
 
I talked to a Sage tech today and he said that the RecordCreate function has been removed and the RecordGenerate function should be used instead. Unfortunately, I can't get it to work either and since the macros doesn't use the RecordGenerate function, I have no examples to go by. If anyone has an example or if their macros use the RecordGenerate function (supposedly they're supposed to), please help me out.
 
It appears that .recordCreate is missing from Interop 5.5 for no reason other than maybe an oversight by Accpac.
 
I use RecordGenerate almost exclusively in my macros. It's simply

.RecordGenerate True

to make the record now, like a New Batch, and

.RecordGenerate False

to delay until .Insert, like a header or detail line.

 
We tried .RecordGenerate, but for some reason that kept failing - but .Init worked in the end. Go figure.
 
.Init? That was supposed to be deprecated a couple years ago. Looks like somebody at Sage screwed up...
 
I *think* that .recordgenerate is used by the data sources primarily and .recordcreate is used by views. There are times when I'm creating detail lines and trying to maintain the order and I have to use .recordgenerate - otherwise the CNTLINE value is ignored and my lines come in backwards.
 
Hm.... It seems that the problem I was having is not a problem with the API. It's a problem with the API I was using. I didn't know that Accpac installs the .NET libraries under "C:\Program Files\Common Files\Sage\Sage Accpac". The only API file I could find was located in the "C:\Program Files\Sage Software\Sage Accpac\AccpacWebService\bin" directory and that is what I've been using. I just happened to be reinstalling Accpac today when I noticed the "install .NET libraries" option in the installer. I loaded up the Interop COMAPI file and the RecordCreate function is present like it should be.

I hope this helps anyone who makes the same stupid mistake.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top