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

Delphi Accpac comapi create batch invoice problem 1

Status
Not open for further replies.

EricComnut

Programmer
Mar 21, 2014
19
IE
Hi, we migrated our dll that connect to accpac from XAPI to COMAPI... Few things had change like the way we create view , open session.. change string and integer to olevariant but nothing major..
We can update and create customer, vendor in Accpac no problem

Now I just start testing the other options we have and see if the work and unfortunately I have a problem when I create an AR batch invoice list or an AP batch invoice list.
And the error is only an access violation. I spend a lot of time trying to figure out what it could be..
I recorded the macro in accpac to validate my code was not the same so I changed it.. even that didn't work out.
Checked with RVSPY and nothing is raised.
Here's what I have and my access violation happen on the PutWithoutVerification.
This code was working fine with XAPI
arrAccpacBatchAR0031[y].view.Browse ( '', False);
tmpValue := '1';
arrAccpacBatchAR0031[y].CNTBTCH.PutWithoutVerification(tmpValue);
arrAccpacBatchAR0031[y].View.Init;
Here is the macro
ARINVOICE3batch.Browse "((BTCHSTTS = 1) OR (BTCHSTTS = 7))", 1
ARINVOICE3batch.RecordCreate 1

ARINVOICE3batchFields("PROCESSCMD").PutWithoutVerification ("1") ' Process Command


They don't show the batch number and use the recordcreate.. so I did... And with this code I still have an access violation when I use the putwithoutverification.
Other places in the code we use the putwithoutverification and there is no problem...

Anybody would have an idea about what happen?
Thanks a million
 
Try showing the .Name:

Code:
showmessage(arrAccpacBatchAR0031[i].CNTBTCH.Name);

If that doesn't work then I would suggest that
Code:
arrAccpacBatchAR0031[i].CNTBTCH;

isn't pointing to the field that you're expecting it to be pointed at.
 
I did as u said before I try to set the value...
Same name and same pointer.. really this is some weird behavior.
now at least the customers will be able to work with it.. but just for personal knowledge I'd like to understand why this give me an access violation
As reading the code it should work as it did and also the name and the pointer are the same so why would it not work for that but for other like update customer and vendor it does work.

Been very long time since I'm stuck on a problem that long without finding the solution
 
Wait... this morning I did it again and now for some reason the field name is same ...
but in my 3nd test...
the pointer is different
arrAccpacBatchAR0031[y].cntbtch
Pointer($8BC03D0) as IAccpacViewField
arrAccpacBatchAR0031[y].View.Fields.Fieldbyname['CNTbtch']
Pointer($8BF94F8) as IAccpacViewField
arrAccpacBatchAR0031[y].Fields.Fieldbyname['CNTbtch']
Pointer($8BF95F8) as IAccpacViewField

Now I'm confuse but at least it make sense...

Ok could it be possible that when I compose the view.. it change something about the fields ??? if yes why with AR and AP only not with customer and vendor view???

Any thoughts?
 
tmpValue : Olevariant;

But now I'd say something change as my pointer are not the same before I do the set value...
 
Django,

There is something weird this morning..
the field CNTBTCH has a different pointer if I use CNTbtch or CNTBTCH...
in delphi since when the lower or uppercase change something??

Again thanks a million for your help !!! :)
 
The COMApi shouldn't be case sensitive when dealing with the views.

Can you send me your units?
 
Hi Django,

I found where the problem is...Have same pointer for the view.fields.fieldbyname[''] until I compose the view
TmpViews := VarArrayCreate([0,0],varVariant);
TmpViews[0] := arrAccpacInvoiceAR0032.View;
arrAccpacBatchAR0031.View.Compose(TmpViews);

then the pointer to arrAccpacBatchAR0031[0].view.fields.fieldbyname['CNTBTCH'] change... Why I don't really know as before was working but for my assignment of the arrAccpacBatchAR0031[0].CNTBTCH now I do it after the view.compose and the pointer are now the same and all the code works fine.

My best guess would be for some view and the compose function. between XAPI and COMAPI there is a little change... anyway now all works perfect as before :)
Thanks a million for all your help :)
 
Excellent news!

As an aside, from one Delphi developer to another, if your company is planning to move to .Net, have a look at Oxygene. It can be described as Delphi for .Net.
 
Thanks as I maintain the delphi version of our product but for the last 3 years they are developping the web version of it :)
I really appreciate all the help and hints you gave me :)
Slainte
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top