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!

Extracting Item Information - Programming

Status
Not open for further replies.

rorye

Programmer
Mar 9, 2005
14
ZA
I have successfully extracted information out of the Item views (IC0310).

I am now trying to extract out of the IC0480 - Item pricing - as I need to extract the item prices for my external application. The problem I have, is that when I come to init the view, I get an error saying that "Session object is not loaded". If I had to take my code and change the view to say IC0310 - then the code works and initialises the view.

Is there something funny about extracting the prices for items out of ACCPAC? I know my code is ok since it works with the different view IC0310. What is going on with IC0480? Any sample code please for extracting the item list and the corresponding prices for these items?

Thanks in advance
R
 
What tools are you using? Which ACCPAC objects? Post the relevant code, maybe we can see something.

zemp
 
I have tried using COMAPI and XAPI. For the COM API, I use the following code:
=====================================================
Dim accSession As New AccpacCOMAPI.AccpacSession

accSession.Init "", "AS", "AS1000", "52A"
accSession.Open "ADMIN", "ADMIN", "RTCO", Date, 0, ""

Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim ICPRIC_T1header As AccpacCOMAPI.AccpacView
Dim ICPRIC_T1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "IC0480", ICPRIC_T1header
Set ICPRIC_T1headerFields = ICPRIC_T1header.Fields

Dim ICPRIC_T1detail As AccpacCOMAPI.AccpacView
Dim ICPRIC_T1detailFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "IC0490", ICPRIC_T1detail
Set ICPRIC_T1detailFields = ICPRIC_T1detail.Fields

ICPRIC_T1header.Compose Array(ICPRIC_T1detail, Nothing, Nothing, Nothing, Nothing, Nothing)

ICPRIC_T1detail.Compose Array(ICPRIC_T1header, Nothing, Nothing)


ICPRIC_T1header.Order = 2
=====================================================
But as soon as I hit the accSession.Open line above, I get error "-2147221230 Session could not be opened".

I have also tried the XAPI as in the code below:
++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dim Session As ACCPACXAPILib.xapiSession
Set Session = CreateObject("ACCPAC.xapisession")
Session.Open "ADMIN", "ADMIN", "RTCO", Date, 0 'UserName, Password, Database, Date, 0

Dim ICPRIC_T2header As ACCPACXAPILib.IxapiView
Dim ICPRIC_T2headerFields As ACCPACXAPILib.xapiFields
Set ICPRIC_T2header = Session.OpenView("IC0480", "IC")
Set ICPRIC_T2headerFields = ICPRIC_T2header.Fields

Dim ICPRIC_T2detail As ACCPACXAPILib.IxapiView
Dim ICPRIC_T2detailFields As ACCPACXAPILib.xapiFields
Set ICPRIC_T2detail = Session.OpenView("IC0490", "IC")
Set ICPRIC_T2detailFields = ICPRIC_T2detail.Fields

ICPRIC_T2header.Compose Array(ICPRIC_T2detail, Nothing, Nothing, Nothing, Nothing, Nothing)

ICPRIC_T2detail.Compose Array(ICPRIC_T2header, Nothing, Nothing)

With ICPRIC_T2header
.Init
.Order = 0
.Browse "SALEEND<=#2/28/2006# AND SALESTART>=#3/1/2005# AND ITEMNO = 'ITM1' AND CURRENCY = 'ZAR' ", True
End With
++++++++++++++++++++++++++++++++++++++++++++++++++++++
When I hit the line
" Set ICPRIC_T2headerFields = ICPRIC_T2header.Fields"

Then I get the error "-2147467259" The session object was not opened.

 
I think the problem with the xPAI might be that you are declaring your main view as
Code:
Dim ICPRIC_T2header As ACCPACXAPILib.[COLOR=red]I[/color]xapiView
instead of
Code:
Dim ICPRIC_T2header As ACCPACXAPILib.xapiView
This conflicts with the declaration of the fields view.

You can also drop the fields views. I just use the fields collection in the main views. Fewer objects to worry about.
Code:
Dim Session As ACCPACXAPILib.xapiSession
    Set Session = CreateObject("ACCPAC.xapisession")
    Session.Open "ADMIN", "ADMIN", "RTCO", Date, 0 'UserName, Password, Database, Date, 0

    Dim ICPRIC_T2header As ACCPACXAPILib.IxapiView
    Set ICPRIC_T2header = Session.OpenView("IC0480", "IC")
    
    Dim ICPRIC_T2detail As ACCPACXAPILib.IxapiView
    Set ICPRIC_T2detail = Session.OpenView("IC0490", "IC")
        
    ICPRIC_T2header.Compose Array(ICPRIC_T2detail, Nothing, Nothing, Nothing, Nothing, Nothing)

    ICPRIC_T2detail.Compose Array(ICPRIC_T2header, Nothing, Nothing)

   With ICPRIC_T2header
        .Init
        .Order = 0
        .Browse "SALEEND<=#2/28/2006# AND SALESTART>=#3/1/2005# AND ITEMNO = 'ITM1' AND CURRENCY = 'ZAR' ", True
        If .Fetch then
           debug.print .Fields("BASEPRICE").value
        End If
   End With

Also, your error message is very Generic, a problem with ACCPAC errors interpreted by VB. Ensure that you are using an ACCPAC error handler to loop through ACCPAC errors.

For the COMAPI I have sometimes inserted the following bolded line when opening a session. I would also declare and set the session variable separatly.
Code:
Dim accSession As AccpacCOMAPI.AccpacSession

Set accSession = New AccpacCOMAPI.AccpacSession

accSession.Init "", "AS", "AS1000", "52A"
[b]accSession.EnforceAppVersion = False[/b]
accSession.Open "ADMIN", "ADMIN", "RTCO", Date, 0, ""

Make sure that you are properly destroying your objects when you are finished with them. ACCPAC might still have a session open, even though your program doesn't, thus using an IAP licence that your next session object needs. Run out of IAP's and you can't open a session. Just Set the object to nothing.
Code:
Set accSession = Nothing

Some things that you can try. Hopefully one will work.


zemp
 
Thank you for your help.

Makes sense what you said.

I will try it and let know you.

R
 
Hello Zemp.

I did what you said, but it still bombs out when trying to open view IC480. Can this view be used?

What views do you use to extract item pricing?

If you read the item price using IC480 - what happens - does it work?

Rory
 
I use the that view without any problems. Here is an example of my xAPI code.
Code:
Public Function Return_BasePrice(pItem As String, pPriceList As String, pCurrency As String, pCustType As Integer) As Single
'// Returns the base price of the item.
   Dim ICPRIC As ACCPACXAPILib.xapiView
   
   On Error GoTo ERR_Handler
   
   If Trim$(pCurrency) = "" Then pCurrency = Session.Company.HomeCurrency
   Set ICPRIC = Session.OpenView("IC0480", "IC")
   With ICPRIC
      .Init
      .Order = 0
      .Browse "CURRENCY = " & pCurrency & " AND ITEMNO = " & pItem & " AND PRICELIST = " & pPriceList & "", True
      If .Fetch Then
         Select Case pCustType
            Case 0
               Return_BasePrice = .Fields("BASEPRICE").value
            Case 1
               Return_BasePrice = ((100 - .Fields("PRCNTLVL1").value) / 100) * .Fields("BASEPRICE").value
            Case 2
               Return_BasePrice = ((100 - .Fields("PRCNTLVL2").value) / 100) * .Fields("BASEPRICE").value
            Case 3
               Return_BasePrice = ((100 - .Fields("PRCNTLVL3").value) / 100) * .Fields("BASEPRICE").value
            Case 4
               Return_BasePrice = ((100 - .Fields("PRCNTLVL4").value) / 100) * .Fields("BASEPRICE").value
            Case 5
               Return_BasePrice = ((100 - .Fields("PRCNTLVL5").value) / 100) * .Fields("BASEPRICE").value
         End Select
      Else
         MsgBox "A default price, based on the Customer Price List" & vbCrLf & _
            "and Currency, could not be found." & vbCrLf & _
            "Please enter the price manually or configure" & vbCrLf & _
            "the Item pricing to include the correct currency" & vbCrLf & _
            "and Price List.", vbOKOnly + vbDefaultButton1 + vbExclamation + _
            vbApplicationModal, "Default Price Unavailable"
      End If
      .Close
   End With
   Set ICPRIC = Nothing
   Exit Function
   
ERR_Handler:
   ErrorACCPAC Err.Number, Err.Description, "modGeneral.Return_BasePrice"
End Function
Session is an open session object.
ErrorACCPAC is an ACCPAC error handling procedure.


zemp
 
Hello zemp, here is my code. When it runs, and the ARCUSTOMER view is initialised, then I get the error "View: AR0024. View call failed". Can you see anything?

-----------------------------------------------------------
Set Session = CreateObject("ACCPAC.xapisession")
Session.Open "ADMIN", "ADMIN", "RTCO", Date, 0 'UserName, Password, Database, Date, 0

'*******************************************************
'** Now get the Item information
'*******************************************************
Dim ARCUSTOMER As ACCPACXAPILib.IxapiView
Set ARCUSTOMER = Session.OpenView("AR0024", "AR")
With ARCUSTOMER
ARCUSTOMER.Init
.Order = 0
.Browse "IDCUST = " & Account & "", True
If Not .Fetch Then
MsgBox "Customer information could not be found.", vbOKOnly + vbExclamation, "Information Missing"
Else
PRICLIST = ARCUSTOMER.Fields("PRICLIST").Value
CODECURN = ARCUSTOMER.Fields("CODECURN").Value
CUSTTYPE = ARCUSTOMER.Fields("CUSTTYPE").Value
End If
End With
---------------------------------------------------------
Then when I try to run the get price list code I get the error "View: IC0480. View call failed". I tried using the code you sent me and this is the error I get. code is below:

----------------------------------------------------------
Set ICPRIC = Session.OpenView("IC0480", "IC")
With ICPRIC
.Init
.Order = 0
'.Browse "SALEEND<=#2/28/2006# AND SALESTART>=#3/1/2005# AND ITEMNO = 'ITM1' AND CURRENCY = 'ZAR' ", True
.Browse "CURRENCY = " & pCurrency & " AND ITEMNO = " & pItem & " AND PRICELIST = " & pPriceList & "", True
If .Fetch Then
----------------------------------------------------------
In both cases, I get an error at the init/browse statement.

However the following code below works fine?

-----------------------------------------------------------
Dim ICITEM_T1header As ACCPACXAPILib.IxapiView
Set ICITEM_T1header = Session.OpenView("IC0310", "IC")

Dim ICITEM_T12detail1 As ACCPACXAPILib.IxapiView
Set ICITEM_T12detail1 = Session.OpenView("IC0750", "IC")

Dim ICITEM_T12detail2 As ACCPACXAPILib.IxapiView
Set ICITEM_T12detail2 = Session.OpenView("IC0330", "IC")

x = 0
flag = 0
ReDim aPriceList(20000)

With ICITEM_T1header
.Init
.Order = 0
.Browse "", True
-----------------------------------------------------------

It just not make sense to me that when I comment out the customer parameters and the code to get the current price of the item, then it works fine and the item list is extracted? It is just the AR0024 and IC480 views that when I try to open them, that I get the errors as I have shown you above

Rory
 
I got the error checking working properly and it gives the error I gave you above, but it also gives this error

"System error. Call to cpGetCompanyInformation failed [FALSE]."

HELP please - at a dead end!!
 
You are declaring your views as type 'ACCPACXAPILib.IxapiView'. Try declaring them as type 'ACCPACXAPILib.xapiView'. The difference is only one (1) character(the 'I') but they are two different objects. Remember your session is declared as 'xapiSession' and not 'IxapiSession'. Your view and session need to be of the same type.

zemp
 
Thanks. I altered my statements like you said - no joy.

Any ideas why when I try to open the AR0024 view I get the error:

“ System error. Call to cpGetCompanyInformation failed [FALSE].”

I can open other views fine?

I have changed my code to this:

==========================================================
Private Function ARGetCustomer(Account As String)

On Error GoTo ARCUSTOMERHandler
Dim ARCUSTOMER As ACCPACXAPILib.xapiView
Set ARCUSTOMER = Session.OpenView("AR0024", "AR")
With ARCUSTOMER
ARCUSTOMER.Init
.Order = 0
.Browse "IDCUST = " & Account & "", True
If Not .Fetch Then
PRICLIST = ""
CODECURN = ""
CUSTTYPE = 0
Else
PRICLIST = ARCUSTOMER.Fields("PRICLIST").Value
CODECURN = ARCUSTOMER.Fields("CODECURN").Value
CUSTTYPE = ARCUSTOMER.Fields("CUSTTYPE").Value
End If
End With

ARCUSTOMERHandler:
'** If we cannot open the customer, then try ODBC **
Err.Clear
On Error GoTo arcusterr
Dim rsReadARCustomer As New ADODB.Recordset
Dim selectstr As String
selectstr = "Select DISTINCT PRICLIST, CODECURN, CUSTTYPE FROM ARCUS " + _
" WHERE IDCUST = '" & Account & "'"
rsReadARCustomer.Open selectstr, ConString, adOpenDynamic

Do While Not rsReadARCustomer.EOF
PRICLIST = rsReadARCustomer("PRICLIST").Value
CODECURN = rsReadARCustomer("CODECURN").Value
CUSTTYPE = rsReadARCustomer("CUSTTYPE").Value
rsReadARCustomer.MoveNext
Loop

Exit Function

arcusterr:
MsgBox Err.Description
End Function
==========================================================

As soon as it hits the ".init" line, it jumps to the error handler. I put in the test code to check if I could get the info out of the database (checking table integrity through another method) and it works fine - no problem.

I think the error is in that statement which says:

" System error. Call to cpGetCompanyInformation failed [FALSE]."

Any ideas why the cpGetCompanyInformation fails on this AR0024 view, but when I open other views (like IC0310) I do not get an error and I retrieve values fine?

Is there perhaps something wrong with my company setup? I did use a wizard from ACCPAC to create the accounts etc.

The calling code for the above is this
///////////////////////////////////////////////////////////
Call ARGetCustomer(Account)

'************************************************************************
'** Now get the item information
'************************************************************************
Dim ICITEM_T1header As ACCPACXAPILib.xapiView
Set ICITEM_T1header = Session.OpenView("IC0310", "IC")

Dim ICITEM_T12detail1 As ACCPACXAPILib.xapiView
Set ICITEM_T12detail1 = Session.OpenView("IC0750", "IC")

Dim ICITEM_T12detail2 As ACCPACXAPILib.xapiView
Set ICITEM_T12detail2 = Session.OpenView("IC0330", "IC")

x = 0
flag = 0
ReDim aPriceList(20000)

With ICITEM_T1header
.Init
.Order = 0
.Browse "", True '** this statement is used to limit the select statement

While .Fetch
flag = 1
fil.WriteLine (ICITEM_T1header.Fields("ITEMNO").Value)
fil.WriteLine (ICITEM_T1header.Fields("DESC").Value)
.....
///////////////////////////////////////////////////////////
So the ARGetCustomer function is called. As I said above, as soon as it gets to the .Init line in that function, I get the error. I put in the dummy code using ODBC as a test. Anyhow, then it executes the ODBC code and gets the information. After it returns to the calling function, it opens these views and processes data from them without any hassles. So I know my session object is fine and now the views are declared in the same way. Just do not understand that error I highlighted above????

(Session variable is a private scope for the module and therefore both functions use the same session object.}

Thanks in advance
Rory
 
Try replacing the .Init with this
Code:
.RecordClear
.RecordGenerate False
It does the same thing but sometimes works where init does not. Especially with 5.3.


zemp
 
Still an error. What I have noticed, is that you gave me the line of code
"Session.Company.HomeCurrency" is your code to extract price lists. When I try to execute this statement - it errors out. Also I the debugged the Sesion object and even though it was defined as xapisession, a lot of the variables under that where IXApi...

Under the company part of the session object, I saw there was an error. I also noticed that the session object was pointing to a database called RTCO2. I think this occured because I used a wizard to populate my database and my old company of RTCO was still valid and both companies pointed to the same database and had the same company name - since one was generated using "Database Setup" and he other using "Setup Wizard"

So I changed my session to point to the RTCO2 company and all of a sudden everything started working.

So that error I was getting relates to the session object being able to initialise and use certain views that do not require checking the company parameters of the session object. As soon as you use a view like AR0024 - it checks the company section of the session object and then bombs out with the error I gave above.

I truely thank you for your help Zemp - you are a good person.

Lastly - do you have an example of adding an order entry transaction? Please would help me a lot....

Thanks in advance

R
 
Glad to hear that you got things working.

The line
Code:
Session.Company.HomeCurrency
is used to determine the company's home currency from the xAPI session object. The xAPI session object allows you to retrieve company information while the COMAPI requires you to open a Company object.

Here is an example of a VB procedure for entering OE transactions from a UDT array.
Code:
Private Sub Export_Orders()
'// Export the Orders into Accpac order entry.
   Dim i As Integer, j As Integer
   Dim l_intLine As Integer, l_strID As String
   Dim l_strCustomer As String, l_strCategory As String
   Dim l_strPriceList As String, l_strLocation As String
   Dim OEORDheader As ACCPACXAPILib.xapiView
   Dim OEORDdetail1 As ACCPACXAPILib.xapiView
   Dim OEORDdetail2 As ACCPACXAPILib.xapiView
   Dim OEORDdetail3 As ACCPACXAPILib.xapiView
   Dim OEORDdetail4 As ACCPACXAPILib.xapiView
   Dim OEORDdetail5 As ACCPACXAPILib.xapiView
   Dim OEORDdetail6 As ACCPACXAPILib.xapiView
   Dim OEORDdetail7 As ACCPACXAPILib.xapiView
   Dim OEORDdetail8 As ACCPACXAPILib.xapiView
   Dim OEORDdetail9 As ACCPACXAPILib.xapiView
   Dim OEORDdetail10 As ACCPACXAPILib.xapiView
   
   On Error GoTo ERR_Handler

   '// Set the views.
   Set OEORDheader = ngjSess.OpenView("OE0520", "OE")
   Set OEORDdetail1 = ngjSess.OpenView("OE0500", "OE")
   Set OEORDdetail2 = ngjSess.OpenView("OE0740", "OE")
   Set OEORDdetail3 = ngjSess.OpenView("OE0180", "OE")
   Set OEORDdetail4 = ngjSess.OpenView("OE0680", "OE")
   If AP_ModuleVersion("OE") = "53A" Then
      Set OEORDdetail5 = ngjSess.OpenView("OE0526", "OE")
      Set OEORDdetail6 = ngjSess.OpenView("OE0522", "OE")
      Set OEORDdetail7 = ngjSess.OpenView("OE0501", "OE")
      Set OEORDdetail8 = ngjSess.OpenView("OE0502", "OE")
      Set OEORDdetail9 = ngjSess.OpenView("OE0504", "OE")
      Set OEORDdetail10 = ngjSess.OpenView("OE0503", "OE")
   End If
      
   '// Compose the views.
   If AP_ModuleVersion("OE") = "53A" Then
      OEORDheader.Compose Array(OEORDdetail1, OEORDdetail4, OEORDdetail3, OEORDdetail2, OEORDdetail5, OEORDdetail6)
      OEORDdetail1.Compose Array(OEORDheader, OEORDdetail7, OEORDdetail10, OEORDdetail8)
      OEORDdetail2.Compose Array(OEORDheader)
      OEORDdetail3.Compose Array(OEORDheader, OEORDdetail1)
      OEORDdetail4.Compose Array(OEORDheader, OEORDdetail1)
      OEORDdetail5.Compose Array(OEORDheader)
      OEORDdetail6.Compose Array(OEORDheader)
      OEORDdetail7.Compose Array(OEORDdetail1)
      OEORDdetail8.Compose Array(OEORDdetail1, OEORDdetail9)
      OEORDdetail9.Compose Array(OEORDdetail8)
      OEORDdetail10.Compose Array(OEORDdetail1)
   Else
      OEORDheader.Compose Array(OEORDdetail1, OEORDdetail4, OEORDdetail3, OEORDdetail2, Nothing, Nothing, Nothing, Nothing, Nothing)
      OEORDdetail1.Compose Array(OEORDheader, Nothing)
      OEORDdetail2.Compose Array(OEORDheader, Nothing)
      OEORDdetail3.Compose Array(OEORDheader, Nothing, OEORDdetail1)
      OEORDdetail4.Compose Array(OEORDheader, Nothing, OEORDdetail1)
   End If
   
   '// Send info to the user interface.
   Send_Message "Beginning Import of Orders to ACCPAC."
   LogEvent eLogStatus, "Beginning Import of Orders to ACCPAC."
   stbMain.Panels(1).Text = "Importing Orders..."
   Send_Progress 0, UBound(m_udtOrder) + 1
   DoEvents
   
   '// Get user defined default values
   l_strCustomer = Trim$(GetSetting("NGJ", "Export", "Customer", ""))
   l_strCategory = Trim$(GetSetting("NGJ", "Export", "Category", ""))
   l_strPriceList = Trim$(GetSetting("NGJ", "Export", "PriceList", ""))
   l_strLocation = Trim$(GetSetting("NGJ", "Export", "Location", ""))
   
   '// Start the looping of orders.
   For i = 0 To UBound(m_udtOrder)
      '// Set up the header information.
      stbMain.Panels(1).Text = "Exporting Orders... Order # " & m_udtOrder(i).OrderID
      With m_udtOrder(i)
         If AP_ModuleVersion("OE") = "53A" Then '// Sub to check module version.
            OEORDheader.RecordClear
            OEORDheader.RecordGenerate False
         Else
            OEORDheader.Init
         End If
         OEORDheader.Fields("CUSTOMER").value = l_strCustomer
         OEORDheader.Fields("BILNAME").value = Trim$(.bFirst & " " & .bLast)
         OEORDheader.Fields("BILADDR1").value = Trim$(.bAddr1)
         OEORDheader.Fields("BILADDR2").value = Trim$(.bAddr2)
         OEORDheader.Fields("BILCITY").value = Trim$(.bCity)
         OEORDheader.Fields("BILSTATE").value = Trim$(.bState)
         OEORDheader.Fields("BILZIP").value = Trim$(.bPostal)
         OEORDheader.Fields("BILCOUNTRY").value = Trim$(.bCountry)
         OEORDheader.Fields("BILPHONE").value = Trim$(.bPhone)
         OEORDheader.Fields("BILEMAIL").value = Trim$(.bEmail)
         OEORDheader.Fields("SHPNAME").value = Trim$(.sFirst & " " & .sLast)
         OEORDheader.Fields("SHPADDR1").value = Trim$(.sAddr1)
         OEORDheader.Fields("SHPADDR2").value = Trim$(.sAddr2)
         OEORDheader.Fields("SHPCITY").value = Trim$(.sCity)
         OEORDheader.Fields("SHPSTATE").value = Trim$(.sState)
         OEORDheader.Fields("SHPZIP").value = Trim$(.sPostal)
         OEORDheader.Fields("SHPCOUNTRY").value = Trim$(.sCountry)
         OEORDheader.Fields("TYPE").value = "1"
         OEORDheader.Fields("ORDDATE").value = .OrDate
         OEORDheader.Fields("LOCATION").value = l_strLocation
         OEORDheader.Fields("COMMENT").value = Trim$(.Notes)
         OEORDheader.Fields("RECALCTAX").value = "1"
         OEORDheader.Fields("GOCALCTAX").value = "1"
         OEORDheader.Fields("POSTINV").value = "0"
         OEORDheader.Update
         OEORDheader.Process
         OEORDheader.Read
         l_strID = OEORDheader.Fields("ORDUNIQ").value
      End With
      
      '// Detail Item information.
      If AP_ModuleVersion("OE") = "53A" Then
         l_intLine = -1    '// Set the first line number for 5.3.
      Else
         l_intLine = 0     '// All other versions.
      End If
      For j = 0 To UBound(m_udtDetail, 2)
         With m_udtDetail(i, j)
            If Trim$(.Name) <> "" Then
               If AP_ModuleVersion("OE") = "53A" Then
                  OEORDdetail1.RecordClear
                  OEORDdetail1.RecordGenerate False
               Else
                  OEORDdetail1.Init
               End If
               OEORDdetail1.Fields("ORDUNIQ").value = l_strID 
               OEORDdetail1.Fields("LINENUM").PutWithoutVerification (Str(l_intLine))
               OEORDdetail1.Fields("LINETYPE").value = 1 
               OEORDdetail1.Fields("ITEM").value = "A11000" '.Model
               OEORDdetail1.Fields("DESC").value = .Name 
               OEORDdetail1.Fields("PRICELIST").value = l_strPriceList 
               OEORDdetail1.Fields("CATEGORY").value = l_strCategory
               OEORDdetail1.Fields("LOCATION").value = l_strLocation
               OEORDdetail1.Fields("QTYORDERED").value = .Quantity
               OEORDdetail1.Fields("PRICEOVER").value = 1
               OEORDdetail1.Fields("UNITPRICE").value = .Price
               OEORDdetail1.Fields("PRIUNTPRC").value = .Price
               OEORDdetail1.Insert
               OEORDdetail1.Fields("DESC").value = .Name
               OEORDdetail1.Update
               l_intLine = l_intLine - 1
            End If
         End With
      Next j
      
      '// Insert the header.
      OEORDheader.Insert
      Send_Progress i + 1, UBound(m_udtOrder) + 1
      
NextOrder:
      '// Cancel the views.
      OEORDdetail1.Cancel
      OEORDheader.Cancel
   Next i   '// Number of Orders.
   
   '// Destroy the views.
   Set OEORDheader = Nothing
   Set OEORDdetail1 = Nothing
   Set OEORDdetail2 = Nothing
   Set OEORDdetail3 = Nothing
   Set OEORDdetail4 = Nothing
   Set OEORDdetail5 = Nothing
   Set OEORDdetail6 = Nothing
   Set OEORDdetail7 = Nothing
   Set OEORDdetail8 = Nothing
   Set OEORDdetail9 = Nothing
   Set OEORDdetail10 = Nothing
   
   If m_intFailure = 0 Then
      Send_Image False, 1
   Else
      Send_Image True, 1
   End If
   Exit Sub

ERR_Handler:
   Dim Errors As xapiErrors
   Dim Error As Variant
   
   Set Errors = ngjSess.Errors
   If Errors.count = 0 Then
      '// Errormessenger is an error handling sub.
      ErrorMessenger Err.Number, Err.Description, "frmMain.Export_Orders"
   Else
      For Each Error In Errors
         If Error.Priority = 1 Or Error.Priority = 2 Then
            Send_Message "Warning on Export Order # " & m_udtOrder(i).OrderID & "."
            LogEvent eLogStatus, "WARNING: On Export Order# " & m_udtOrder(i).OrderID & ". " & Error.Priority & ": " & Error.Description & "."
            Send_Warning
            Send_Progress i + 1, UBound(m_udtOrder) + 1
         Else
            Send_Message "Failure on Export Order # " & m_udtOrder(i).OrderID & "."
            LogEvent eLogStatus, "FAILURE: On Export Order # " & m_udtOrder(i).OrderID & ". " & Error.Priority & ": " & Error.Description & _
               ". Date: " & m_udtOrder(i).OrDate & " Customer: " & m_udtOrder(i).bFirst & " " & m_udtOrder(i).bLast & "."
            Send_Failure
            Send_Progress i + 1, UBound(m_udtOrder) + 1
         End If
         MsgBox Error.Priority & ": " & Error.Description   '// for testing only.
         Resume Next       '// for testing only.
      Next
      Errors.Clear
   End If
   Set Errors = Nothing
   Resume NextOrder
End Sub

Public Function AP_ModuleVersion(pMod As String) As String
'// Returns the version of ACCPAC module being used.
   Dim myApps As ACCPACXAPILib.xapiActiveApplications
   Dim oneApp As ACCPACXAPILib.xapiApplication
   
   On Error GoTo ERR_Handler
   
   Set myApps = ngjSess.ActiveApplications
   For Each oneApp In myApps
      If oneApp.PgmID = Trim$(pMod) Then
         AP_ModuleVersion = oneApp.PgmVer
         Exit For
      End If
   Next
   Set myApps = Nothing
   Set oneApp = Nothing
   Exit Function
   
ERR_Handler:
   '// ErrorACCPAC is an Accpac error handling sub.
   ErrorACCPAC Err.Number, Err.Description, "modGeneral.AP_ModuleVersion"
End Function

The Send_?? procedures are used to send information to the user interface. A progress bar for example.
The LogEvents are VB logging procedures that write to a text file.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top