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

unable to create invoice that contain only miscellaneous information

Status
Not open for further replies.

sara403

Technical User
Jun 10, 2008
58
IN
Hi,

The sample macro is given below, which is very long. Still i am having a problem when i insert an order detail. it is generating an error, Internal errror "Order detail". "Operation is not allowed" i also use session.errors for traping the error. But i am unable to fix the bug. Please can any one find the mistake what i did.

oSession.Open user, password, database, Date, 0 'Open a session with current date

Dim temp As Boolean

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

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

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


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

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


Dim OEORD1detail5 As ACCPACXAPILib.xapiView
Dim OEORD1detail5Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail5 = oSession.OpenView("OE0526", "OE")
Set OEORD1detail5Fields = OEORD1detail5.Fields

Dim OEORD1detail6 As ACCPACXAPILib.xapiView
Dim OEORD1detail6Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail6 = oSession.OpenView("OE0522", "OE")
Set OEORD1detail6Fields = OEORD1detail6.Fields

Dim OEORD1detail7 As ACCPACXAPILib.xapiView
Dim OEORD1detail7Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail7 = oSession.OpenView("OE0501", "OE")
Set OEORD1detail7Fields = OEORD1detail7.Fields

Dim OEORD1detail8 As ACCPACXAPILib.xapiView
Dim OEORD1detail8Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail8 = oSession.OpenView("OE0502", "OE")
Set OEORD1detail8Fields = OEORD1detail8.Fields

Dim OEORD1detail9 As ACCPACXAPILib.xapiView
Dim OEORD1detail9Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail9 = oSession.OpenView("OE0504", "OE")
Set OEORD1detail9Fields = OEORD1detail9.Fields

Dim OEORD1detail10 As ACCPACXAPILib.xapiView
Dim OEORD1detail10Fields As ACCPACXAPILib.xapiFields
Set OEORD1detail10 = oSession.OpenView("OE0503", "OE")
Set OEORD1detail10Fields = OEORD1detail10.Fields

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)


OEORD1headerFields("DRIVENBYUI").Value = "1" ' Driven by UI

OEORD1detail1Fields("DRIVENBYUI").Value = "1" ' Driven by UI?
OEORD1header.Cancel
OEORD1header.Cancel
temp = OEORD1header.Exists
OEORD1header.Init
OEORD1detail2.Browse "", 1

OEORD1detail2Fields("PAYMENT").PutWithoutVerification ("-32767") ' Payment Number

OEORD1detail2.Browse "", -1
OEORD1detail2.Fetch
OEORD1headerFields("CUSTOMER").Value = "1200" ' Customer Number
OEORD1detail2.Browse "", 1

OEORD1detail2Fields("PAYMENT").PutWithoutVerification ("-32767") ' Payment Number



OEORD1detail2.Browse "", -1
OEORD1detail2.Fetch
temp = OEORD1detail1.Exists
OEORD1detail1.RecordClear
temp = OEORD1detail1.Exists
OEORD1detail1.Init
temp = OEORD1detail1.Exists
OEORD1detail1.RecordClear
temp = OEORD1detail1.Exists
OEORD1detail1.RecordClear
temp = OEORD1detail1.Exists

OEORD1detail1.Init

OEORD1detail1Fields("LINETYPE").Value = "2" ' Line Type

OEORD1detail1Fields("MISCCHARGE").Value = "HC" ' Miscellaneous Charges Code
OEORD1detail1Fields("EXTINVMISC").Value = "10.000" ' Extended Amount


OEORD1detail1.Insert

OEORD1detail1Fields("LINENUM").PutWithoutVerification ("-2") ' Line Number

OEORD1detail1.Read
temp = OEORD1detail1.Exists
OEORD1detail1.Init

OEORD1detail1Fields("LINETYPE").Value = "2" ' Line Type

OEORD1detail1Fields("MISCCHARGE").Value = "PACK" ' Miscellaneous Charges Code
OEORD1detail1Fields("EXTINVMISC").Value = "25.000" ' Extended Amount

OEORD1detail1.Insert

OEORD1detail1Fields("LINENUM").PutWithoutVerification ("-3") ' Line Number

OEORD1detail1.Read
temp = OEORD1detail1.Exists
OEORD1detail1.Init

OEORD1detail1Fields("LINENUM").PutWithoutVerification ("-3") ' Line Number

OEORD1detail1.Read
OEORD1headerFields("INVPRODUCE").Value = "1" ' Invoice Will Be Produced

OEORD1headerFields("OECOMMAND").Value = "4" ' Process O/E Command

OEORD1header.Process
OEORD1header.Insert
OEORD1header.Order = 1
OEORD1header.Read
OEORD1header.Order = 0
OEORD1detail1Fields("LINENUM").PutWithoutVerification ("-32767") ' Line Number
OEORD1detail1.Browse "", 1
OEORD1detail1.Fetch
OEORD1detail8Fields("PRNCOMPNUM").PutWithoutVerification ("-2147483647") ' Parent Component Number

OEORD1detail8Fields("COMPNUM").PutWithoutVerification ("-2147483647") ' Component Number

OEORD1detail8.Browse "", 1
OEORD1detail8.Fetch
OEORD1detail4Fields("UNIQUIFIER").PutWithoutVerification ("-32767") ' Uniquifier
OEORD1detail4.Browse "", 1
OEORD1detail4.Fetch
OEORD1detail3Fields("UNIQUIFIER").PutWithoutVerification ("-32767") ' Uniquifier
OEORD1detail3.Browse "", 1
OEORD1detail3.Fetch
OEORD1detail2Fields("PAYMENT").PutWithoutVerification ("-32767") ' Payment Number
OEORD1detail2.Browse "", -1
OEORD1detail2.Fetch

OEORD1detail2Fields("PAYMENT").PutWithoutVerification ("-2") ' Payment Number
OEORD1detail2.Browse "", 1

OEORD1detail2Fields("PAYMENT").PutWithoutVerification ("-32767") ' Payment Number


Thanks

Saravana Bavan.T
 
Hi

Version accpac 5.4A

Thanks

saravanan.T
 
Change to the COMAPI, then do this:

OEORD1header.RecordClear
OEORD1header.RecordCreate 0
OEORD1header.Fields("CUSTOMER").Value = "1200" ' Customer Number
OEORD1header.Fields("PROCESSCMD").PutWithoutVerification ("1") ' Process OIP Command
OEORD1header.Process
OEORD1detail1.RecordClear
OEORD1detail1.RecordCreate 0
OEORD1detail1.Fields("LINETYPE").Value = "2" ' Line Type
OEORD1detail1.Fields("MISCCHARGE").Value = "HC" ' Miscellaneous Charges Code
OEORD1detail1.Fields("EXTINVMISC").Value = "10.000" ' Extended Amount
OEORD1detail1.Fields("PROCESSCMD").PutWithoutVerification ("1") ' Process Command
OEORD1detail1.Process
OEORD1detail1.Insert
OEORD1header.Fields("INVPRODUCE").Value = "1" ' Invoice Will Be Produced
OEORD1header.Fields("OECOMMAND").Value = "4" ' Process O/E Command
OEORD1header.Process
OEORD1header.Insert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top