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

Error using comapi

Status
Not open for further replies.

Jo004060

Programmer
Sep 25, 2003
18
0
0
CA
Hello,

I'm trying to add an Order (OE order) with the comapi,

I can open the session,compose the views, process the header, but i can't process the detail.. (I get an unhandled exception)

----
OEORD1headerFields->GetFieldByName("CUSTOMER")->put_Value(&vTemp);
..
OEORD1headerFields->GetFieldByName("SHIPTO")->PutWithoutVerification(&vTemp);
..
OEORD1headerFields->GetFieldByName("PONUMBER")->PutWithoutVerification(&vTemp);
..
OEORD1header->Process();

OEORD1detail1->RecordClear();
OEORD1detail1->RecordGenerate(false);
..
OEORD1detail1Fields->GetFieldByName("ITEM")->put_Value(&vTemp);
OEORD1detail1->Process(); -->exception
----

I based my code on a macro i created in accpac, and everything is there.. (probably not..) any idea how i could fix this problem ? Is ther a way to get more info on an error like this one ?

Thanks in advance,

Jo


 
Are you sure you need to process the detail line? What version of OE are you writing for and show us your compose statements. Having them out of order (which will happen in between versions) will cause problems.

Regards,

Django
 
I noticed i have the same error when inserting the header. Here is what i have in the RVSpy when inserting:

[890] OE0520: OEORDH [10:14:16.84].Insert(view=0x06941ccc)
[890] TX0003: TXGRP [10:14:16.91].Load
[890] TX0003: TXGRP [10:14:17.01].InstanceOpen(PIB=2034, link=39, flags=0x00000040, size=0, buffer='')
[988] --LINK-39: 10:14:17.01 OPEN-TABLE ( table=TXGRP , flags=1 )
[988] --LINK-39: 10:14:17.05 handle <-- 34
[988] --LINK-39: 10:14:17.05 IS-SUPPORTED ( routine=dbGetLE )
[988] --LINK-39: 10:14:17.06
[988] --LINK-39: 10:14:17.06 GET-TABLE-INFO ( table=TXGRP )
[988] --LINK-39: 10:14:17.06
[988] --LINK-39: 10:14:17.07 GET-DRVR-INFO ( )
[988] --LINK-39: 10:14:17.07
[890] 0 <==[10:14:17.07;t=60;ovh=0] {view=0x0ac549cc}
[890] TX0003: TXGRP [10:14:17.11].Name(view=0x0ac549cc, field=999999998 <TITLE_IDX>)
[890] 0 <==[10:14:17.11;t=0;ovh=0] {name=' ', desc='Tax Groups '}
[890] TX0003: TXGRP [10:14:17.11].Put(view=0x0ac549cc, field=1, size=12, verify=0, buffer='\43\41\4c\49\46\20\20\20\20\20\20\20' -> 'CALIF ')
[890] 0 <==[10:14:17.11;t=0;ovh=0] {}
[890] TX0003: TXGRP [10:14:17.11].Put(view=0x0ac549cc, field=2, size=2, verify=0, buffer='\01\00')
[890] 0 <==[10:14:17.11;t=0;ovh=0] {}
[890] TX0003: TXGRP [10:14:17.12].Read(view=0x0ac549cc)
[988] --LINK-39: 10:14:17.12 GET ( handle=34, keyno=0 )
[988] --LINK-39: 10:14:17.13
[890] 0 <==[10:14:17.13;t=10;ovh=0] {}
[890] TX0003: TXGRP [10:14:17.13].Get(view=0x0ac549cc, field=4, size=3)
[890] 0 <==[10:14:17.13;t=0;ovh=0] {buffer='\55\53\44' -> 'USD'}
[890] 6666 <==[10:14:17.13;t=290;ovh=50] {**ERROR**}


Thanks for your help
 
Show us the code that you are using to open and compose. I'm not sure RVSpy is going to tell me something useful until I can compare your code to what is created when Accpac records a macro of the same process.

Regards,

Django
 
OE 5.3

IAccpacViewPtr OEORD1header;
IAccpacViewFieldsPtr OEORD1headerFields;
OEORD1header = AccDBLink->OpenView2(_T("OE0520"), NULL);
HRESULT hRes = OEORD1header->Init();
OEORD1headerFields = OEORD1header->Fields;

IAccpacViewPtr OEORD1detail1;
IAccpacViewFieldsPtr OEORD1detail1Fields;
OEORD1detail1 = AccDBLink->OpenView2(_T("OE0500"), NULL);
hRes = OEORD1detail1->Init();
OEORD1detail1Fields = OEORD1detail1->Fields;

IAccpacViewPtr OEORD1detail2;
IAccpacViewFieldsPtr OEORD1detail2Fields;
OEORD1detail2 = AccDBLink->OpenView2(_T("OE0740"), NULL);
hRes = OEORD1detail2->Init();
OEORD1detail2Fields = OEORD1detail2->Fields;


IAccpacViewPtr OEORD1detail3;
IAccpacViewFieldsPtr OEORD1detail3Fields;
OEORD1detail3 = AccDBLink->OpenView2(_T("OE0180"), NULL);
hRes = OEORD1detail3->Init();
OEORD1detail3Fields = OEORD1detail3->Fields;

IAccpacViewPtr OEORD1detail4;
IAccpacViewFieldsPtr OEORD1detail4Fields;
OEORD1detail4 = AccDBLink->OpenView2(_T("OE0680"), NULL);
hRes = OEORD1detail4->Init();
OEORD1detail4Fields = OEORD1detail4->Fields;

IAccpacViewPtr OEORD1detail5;
IAccpacViewFieldsPtr OEORD1detail5Fields;
OEORD1detail5 = AccDBLink->OpenView2(_T("OE0526"), NULL);
hRes = OEORD1detail5->Init();
OEORD1detail5Fields = OEORD1detail5->Fields;

IAccpacViewPtr OEORD1detail6;
IAccpacViewFieldsPtr OEORD1detail6Fields;
OEORD1detail6 = AccDBLink->OpenView2(_T("OE0522"), NULL);
hRes = OEORD1detail6->Init();
OEORD1detail6Fields = OEORD1detail6->Fields;

IAccpacViewPtr OEORD1detail7;
IAccpacViewFieldsPtr OEORD1detail7Fields;
OEORD1detail7 = AccDBLink->OpenView2(_T("OE0501"), NULL);
hRes = OEORD1detail7->Init();
OEORD1detail7Fields = OEORD1detail7->Fields;

IAccpacViewPtr OEORD1detail8;
IAccpacViewFieldsPtr OEORD1detail8Fields;
OEORD1detail8 = AccDBLink->OpenView2(_T("OE0502"), NULL);
hRes = OEORD1detail8->Init();
OEORD1detail8Fields = OEORD1detail8->Fields;

IAccpacViewPtr OEORD1detail9;
IAccpacViewFieldsPtr OEORD1detail9Fields;
OEORD1detail9 = AccDBLink->OpenView2(_T("OE0504"), NULL);
hRes = OEORD1detail9->Init();
OEORD1detail9Fields = OEORD1detail9->Fields;

IAccpacViewPtr OEORD1detail10;
IAccpacViewFieldsPtr OEORD1detail10Fields;
OEORD1detail10 = AccDBLink->OpenView2(_T("OE0503"), NULL);
hRes = OEORD1detail10->Init();
OEORD1detail10Fields = OEORD1detail10->Fields;

//prepare view array for compose
aDim[0].cElements= 6;
SAFEARRAY FAR * TempArray = SafeArrayCreate(VT_VARIANT,1,aDim);//1D SafeArray VARIANTS

aLong=0;
SafeArrayPutElement(TempArray, &aLong, OEORD1detail1);
aLong++;
SafeArrayPutElement(TempArray, &aLong, OEORD1detail4);
aLong++;
SafeArrayPutElement(TempArray, &aLong, OEORD1detail3);
aLong++;
SafeArrayPutElement(TempArray, &aLong, OEORD1detail2);
aLong++;
SafeArrayPutElement(TempArray, &aLong, OEORD1detail5);
aLong++;
SafeArrayPutElement(TempArray, &aLong, OEORD1detail6);

VARIANT *vTemp = new VARIANT;
vTemp->vt = VT_ARRAY|VT_VARIANT;
vTemp->parray = TempArray;

OEORD1header->Compose(vTemp);

//....
//-- removed the other views composition but it is exactly like this Macro:

OEORD1header.Compose Array(OEORD1detail1, OEORD1detail4, OEORD1detail3, OEORD1detail2, OEORD1detail5, OEORD1detail6)
OEORD1detail1.Compose Array(OEORD1header, OEORD1detail7, OEORD1detail10, OEORD1detail8)
OEORD1detail2.Compose Array(OEORD1header)
OEORD1detail3.Compose Array(OEORD1header, OEORD1detail1)
OEORD1detail4.Compose Array(OEORD1header, OEORD1detail1)
OEORD1detail5.Compose Array(OEORD1header)
OEORD1detail6.Compose Array(OEORD1header)
OEORD1detail7.Compose Array(OEORD1detail1)
OEORD1detail8.Compose Array(OEORD1detail1, OEORD1detail9)
OEORD1detail9.Compose Array(OEORD1detail8)
OEORD1detail10.Compose Array(OEORD1detail1)
//----

vTemp->vt = VT_BSTR;
vTemp->bstrVal = bstrCustomerNumber
OEORD1headerFields->GetFieldByName("CUSTOMER")->PutWithoutVerification(vTemp);
//the PutWithoutVerification crash
//the put_Value returns -2147467259


I compared to the RV spy result with the macro and my code and here is what i get with the PutWithoutVerification :

----------------
[1494] AR0016: ARRTA [15:34:41.46].Load
[1494] AR0016: ARRTA [15:34:41.48].InstanceOpen(PIB=2001, link=177, flags=0x00000040, size=0, buffer='')
[f6c] --LINK-177: 15:34:41.48 OPEN-TABLE ( table=ARRTA , flags=1 )
[f6c] --LINK-177: 15:34:41.50 handle <-- 31
[f6c] --LINK-177: 15:34:41.50 GET-TABLE-INFO ( table=ARRTA )
[f6c] --LINK-177: 15:34:41.50
[f6c] --LINK-177: 15:34:41.50 GET-DRVR-INFO ( )
[f6c] --LINK-177: 15:34:41.51
[1494] 0 <==[15:34:41.51;t=30;ovh=0] {view=0x09a2da74}
[1494] AR0016: ARRTA [15:34:41.51].Name(view=0x09a2da74, field=999999998 <TITLE_IDX>)
[1494] 0 <==[15:34:41.51;t=0;ovh=0] {name=' ', desc='Terms Codes '}

[1494] AR0016: ARRTA [15:34:41.51].Put(view=0x09a2da74, field=1, size=6, verify=0, buffer='\32\4e\33\30\20\20' -> '2N30 ')
[1494] 0 <==[15:34:41.51;t=0;ovh=0] {}
[1494] AR0016: ARRTA [15:34:41.51].Read(view=0x09a2da74)
[f6c] --LINK-177: 15:34:41.51 GET ( handle=31, keyno=0 )
[f6c] --LINK-177: 15:34:41.54
[1494] 0 <==[15:34:41.54;t=30;ovh=0] {}
[1494] AR0016: ARRTA [15:34:41.54].Get(view=0x09a2da74, field=2, size=60)
[1494] 0 <==[15:34:41.54;t=0;ovh=0] {buffer='\32\25\20\2d\20\31\30\20\64\61\79\73\2c\20\4e\65\74\20\33\30\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20\20' -> '2% - 10 days, Net 30 '}
[1494] AR0016: ARRTA [15:34:41.54].Get(view=0x09a2da74, field=6, size=2)
[1494] 0 <==[15:34:41.54;t=0;ovh=0] {buffer='\00\00'}
[1494] 1 <==[15:34:41.54;t=3595;ovh=1804] {**ERROR**}
----------------

The same error occur with Put_Value, except i dont get the Unhandled exception in application : 0xC0000005: Access Violation

I'm not sure about my arrays, so please let me know if you have any comment or idea,

THANKS

Jo
 
Hi Jo,

The arrays look correct but I'm a Delphi programmer and not a C++ programmer.

Can you show me your code on how you are browsing or reading your first OE order?

You might also skip the step of creating the Fields objects and access the field object from the View object. e.g.:
Instead of: OEORD1headerFields->GetFieldByName("CUSTOMER")->PutWithoutVerification(vTemp);

Use:
OEORD1header->
Fields->
GetFieldByName("CUSTOMER")->
PutWithoutVerification(vTemp);

If you can try running RVSpy just for this one line and see what the view is receiving.

Regards,

Django
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top