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

Macro Development - Fetch vs Read

Status
Not open for further replies.

kenaruj

Programmer
Jun 2, 2006
16
US
I had previously created a macro that loops through orders using .browse and .fetch (see code below). However, as more and more orders are put into the system (5000+), the macro takes longer and longer to run (now taking up to a minute to get to the first record). I have been trying to redo the macro, using .Read, but the only way I've been able to get .Read to work is if I put in ORDUNIQ - which the end user will not have access to (they only have ORDNUMBER). Using Read, the order appears to be accessed instantaneous.

So my question is, how can i use Read to loop through orders using ORDNUMBER and/or is there something I am doing wrong in the .browse/.fetch that's causing it to run so slow?

Code:
'--------------------------------------------------
'- Current Macro Code
'--------------------------------------------------
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)

Dim temp As Boolean
Dim orderHeader As AccpacCOMAPI.AccpacView
Dim orderHeaderFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0520", orderHeader
Set orderHeaderFields = orderHeader.Fields

Dim orderDetail As AccpacCOMAPI.AccpacView
Dim orderDetailFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0500", orderDetail
Set orderDetailFields = orderDetail.Fields

Dim orderDetailOptFlds As AccpacCOMAPI.AccpacView
Dim orderDetailOptFldsFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0501", orderDetailOptFlds
Set orderDetailOptFldsFields = orderDetailOptFlds.Fields

Dim orderDetailBOM As AccpacCOMAPI.AccpacView
Dim orderDetailBOMFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "OE0503", orderDetailBOM
Set orderDetailBOMFields = orderDetailBOM.Fields

orderHeader.Compose Array(orderDetail, Nothing, Nothing, Nothing, Nothing, Nothing)
orderDetail.Compose Array(orderHeader, orderDetailOptFlds, orderDetailBOM, Nothing)
orderDetailOptFlds.Compose Array(orderDetail)
orderDetailBOM.Compose Array(orderDetail)

Dim orderFilter As String

orderFilter = "(ORDNUMBER >= " + fromOrder + ")"

orderHeader.Browse orderFilter, 1

Do While orderHeader.Fetch
    
    If (orderNumber > toOrder) Then
        Exit Do
    End If

    'Processing code is here
Loop
The code below is what I would like to switch to.
Code:
'--------------------------------------------------
'- Macro code using read
'--------------------------------------------------

' Views are created the same as above

Dim Status As Boolean

orderHeaderFields("ORDUNIQ").PutWithoutVerification (145602) [b]'Works[/b]
[b]'OR[/b]
orderHeaderFields("ORDNUMBER").PutWithoutVerification ("ORD004500") [b]'Doesn't work[/b]

Status = orderHeader.Read
Do While Status = True
    'Processing code is here

    Status = orderHeader.Read
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top