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

Order entry 1

Status
Not open for further replies.

johnbritto

Programmer
Jun 17, 2003
7
US
I want to create a Order entry from VB using XAPI.

I recorded a macro, but I get some errors when I try to run that from VB.

Errors
1. View OE0520. View call failed
2. Internal error. Order payment schedule. Transaction not active (3).
3. View OE0520. View call failed.
 
A macro's code copied and pasted will usually not work 100% in VB. First off the Marco uses ACCPAC COMAPI and not the xAPI. The marco code is intended for use within ACCPAC and the xAPI from outside of ACCPAC. There is almost no difference in the syntax. But there seems to be a slight difference in the order of operations and how views are created and handled by the session object.

A Macro is a great place to start but will almost always require a bit of trial and error to get it right. I have found that the marco will repeat lines and contain lines that you don't need. As a result you basically need to simplify and clean up the macro code.

I have explained it further with an example in thread613-526541. Otherwise post the code that you have and we will take a look at it.

Thanks and Good Luck!

zemp
 
Thanks for ur reply,
It through an error at OEORD1header.Init.

----------------------------------------------


On Error GoTo ACCPACErrorHandler

Dim objsess As xapiSession
Set objsess = New xapiSession
Call objsess.Open("ADMIN", "ADMIN", "ADATTS", Date, 1)

Dim OEORD1header As ACCPACXAPILib.xapiView
Dim OEORD1headerFields As ACCPACXAPILib.xapiFields
Set OEORD1header = objsess.OpenView("OE0520", "OE")
Set OEORD1headerFields = OEORD1header.Fields

Dim OEORD1detail1 As ACCPACXAPILib.xapiView
Dim OEORD1detail1Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail1 = objsess.OpenView("OE0500", "OE")
Set OEORD1detail1Fields = OEORD1detail1.Fields

Dim OEORD1detail2 As ACCPACXAPILib.xapiView
Dim OEORD1detail2Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail2 = objsess.OpenView("OE0740", "OE")
Set OEORD1detail2Fields = OEORD1detail2.Fields

Dim OEORD1detail3 As ACCPACXAPILib.xapiView
Dim OEORD1detail3Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail3 = objsess.OpenView("OE0180", "OE")
Set OEORD1detail3Fields = OEORD1detail3.Fields

Dim OEORD1detail4 As ACCPACXAPILib.xapiView
Dim OEORD1detail4Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail4 = objsess.OpenView("OE0680", "OE")
Set OEORD1detail4Fields = OEORD1detail4.Fields

Dim OEORD1headerComps(8) As ACCPACXAPILib.xapiView
Set OEORD1headerComps(0) = OEORD1detail1
Set OEORD1headerComps(1) = OEORD1detail4
Set OEORD1headerComps(2) = OEORD1detail3
Set OEORD1headerComps(3) = OEORD1detail2
Set OEORD1headerComps(4) = Nothing
Set OEORD1headerComps(5) = Nothing
Set OEORD1headerComps(6) = Nothing
Set OEORD1headerComps(7) = Nothing
Set OEORD1headerComps(8) = Nothing
OEORD1header.Compose OEORD1headerComps

Dim OEORD1detail1Comps(1) As ACCPACXAPILib.xapiView
Set OEORD1detail1Comps(0) = OEORD1header
Set OEORD1detail1Comps(1) = Nothing
OEORD1detail1.Compose OEORD1detail1Comps

Dim OEORD1detail2Comps(1) As ACCPACXAPILib.xapiView
Set OEORD1detail2Comps(0) = OEORD1header
Set OEORD1detail2Comps(1) = Nothing
OEORD1detail2.Compose OEORD1detail2Comps

Dim OEORD1detail3Comps(2) As ACCPACXAPILib.xapiView
Set OEORD1detail3Comps(0) = OEORD1header
Set OEORD1detail3Comps(1) = Nothing
Set OEORD1detail3Comps(2) = OEORD1detail1
OEORD1detail3.Compose OEORD1detail3Comps

Dim OEORD1detail4Comps(2) As ACCPACXAPILib.xapiView
Set OEORD1detail4Comps(0) = OEORD1header
Set OEORD1detail4Comps(1) = Nothing
Set OEORD1detail4Comps(2) = OEORD1detail1
OEORD1detail4.Compose OEORD1detail4Comps


OEORD1header.Order = 0
OEORD1header.Cancel
OEORD1header.Init
OEORD1detail1.Order = 0
OEORD1headerFields("CUSTOMER").Value = "AL110-1" ' Customer Number

OEORD1headerFields("TEMPLATE").PutWithoutVerification ("") ' Template Code
OEORD1headerFields("TYPE").PutWithoutVerification ("1") ' Order Type
OEORD1headerFields("QTEXPDATE").PutWithoutVerification (Empty) ' Quote Expiration Date
OEORD1headerFields("ORDDATE").PutWithoutVerification (#6/17/2003#) ' Order Date
OEORD1headerFields("FOB").PutWithoutVerification ("") ' Free On Board Point
OEORD1headerFields("LOCATION").PutWithoutVerification ("") ' Default Location Code
OEORD1headerFields("LOCDESC").PutWithoutVerification ("") ' Location Code Desc.
OEORD1headerFields("ONHOLD").PutWithoutVerification ("0") ' On Hold Status
OEORD1headerFields("DESC").PutWithoutVerification ("") ' Order Description
OEORD1headerFields("COMMENT").PutWithoutVerification ("") ' Order Comment
OEORD1headerFields("REFERENCE").PutWithoutVerification ("") ' Order Reference
OEORD1headerFields("AUTOTAXCAL").PutWithoutVerification ("1") ' Auto-Tax Calculation Status
OEORD1headerFields("OPTIONAL2").Value = "ASE" ' Optional Field 2

OEORD1header.Insert

OEORD1headerFields("CUSTOMER").PutWithoutVerification ("AL110-1") ' Customer Number
OEORD1headerFields("OPTIONAL2").PutWithoutVerification ("ASE") ' Optional Field 2

Exit Sub

ACCPACErrorHandler:
Dim Errors, objError
Set Errors = objsess.Errors
'Dim Error As Variant

If Errors.Count = 0 Then
MsgBox Err.Description
Else
For i = 0 To Errors.Count - 1
Set objError = Errors.Item(i)
MsgBox objError.Description & " (" & objError.Priority & ")"
Next
'For Each Error In Errors
' MsgBox Error.Description
'Next
Errors.Clear
End If

Resume Next
 
Try Setting your Session flags to zero(0) instead of one.

objsess.Open "ADMIN", "ADMIN", "ADATTS", Date, 0

Also the two lines after your header .insert are not useful because there is no update afterwards. They can be removed.

I would also remove the reference to the detail1.Order line since the detail1 is not used anywhere else. I would also remove the header.order and header.cancel lines before the header.init.

Don't forget to properly dispose of the objects when you are done. After the header.insert place a header.cancel.


Thanks and Good Luck!

zemp
 
Thank u so much, I been fighting with this for more than a week.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top