I recorded a Marco for receiving material in Mysis purchasing module. When I tried to re-use this code to process receiving other material. It shows integrity issue where STOCK didn't get increased and ONORDER QTY didn't get decremented. The only changes I made to the recorded code are replacing Po number and line number with the one will be processed, and I also removed lines with “temp=bla bla” and view compose with blank parameter which caused code crash(why?). I don’t know if these changes are the problems and how to modify them correctly, or Macro recording itself missed the certain part of logic process. I monitored backend database and found two tables(MILOGH-MI0013 and MILOGD-MI0014) didn’t get new records inserted, but if I process receiving through accpac-mysis interface, two new records will be added into those two tables. My questions are
first, does macro record every thing happened while working through the accpac interface.
Second, if Marco recording do missed certain part of business logic, can it be manually amended by inserting two records into the tables directly.
System Info:
Accpac5.4
Mysis 5.4
Database: pervasive9.5
Recorded Code:
Sub MainSub()
On Error GoTo ACCPACErrorHandler
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 MIGLOB1 As AccpacCOMAPI.AccpacView
Dim MIGLOB1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0008", MIGLOB1
Set MIGLOB1Fields = MIGLOB1.Fields
MIGLOB1.Init
MIGLOB1.Browse "", 1
MIGLOB1.Fetch
Dim MIXPPO9header As AccpacCOMAPI.AccpacView
Dim MIXPPO9headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0110", MIXPPO9header
Set MIXPPO9headerFields = MIXPPO9header.Fields
Dim MIXPPO9detail As AccpacCOMAPI.AccpacView
Dim MIXPPO9detailFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0008", MIXPPO9detail
Set MIXPPO9detailFields = MIXPPO9detail.Fields
MIXPPO9header.Compose Array(MIXPPO9detail)
'MIXPPO9detail.Compose Array() 'if not remove this line, VBA Crashed
MIXPPO9header.Init
Dim MIPOH2header As AccpacCOMAPI.AccpacView
Dim MIPOH2headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0018", MIPOH2header
Set MIPOH2headerFields = MIPOH2header.Fields
Dim MIPOH2detail As AccpacCOMAPI.AccpacView
Dim MIPOH2detailFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0019", MIPOH2detail
Set MIPOH2detailFields = MIPOH2detail.Fields
MIPOH2header.Compose Array(MIPOH2detail, Nothing, Nothing, Nothing, Nothing)
MIPOH2detail.Compose Array(MIPOH2header, Nothing, Nothing)
Dim MIXTAX10header As AccpacCOMAPI.AccpacView
Dim MIXTAX10headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0118", MIXTAX10header
Set MIXTAX10headerFields = MIXTAX10header.Fields
Dim MIXTAX10detail1 As AccpacCOMAPI.AccpacView
Dim MIXTAX10detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0018", MIXTAX10detail1
Set MIXTAX10detail1Fields = MIXTAX10detail1.Fields
Dim MIXTAX10detail2 As AccpacCOMAPI.AccpacView
Dim MIXTAX10detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0019", MIXTAX10detail2
Set MIXTAX10detail2Fields = MIXTAX10detail2.Fields
MIXTAX10header.Compose Array(MIXTAX10detail1, MIXTAX10detail2)
MIXTAX10detail1.Compose Array(MIXTAX10detail2, Nothing, Nothing, Nothing, Nothing)
MIXTAX10detail2.Compose Array(MIXTAX10detail1, Nothing, Nothing)
Dim MIXCRU11header As AccpacCOMAPI.AccpacView
Dim MIXCRU11headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0100", MIXCRU11header
Set MIXCRU11headerFields = MIXCRU11header.Fields
Dim MIXCRU11detail1 As AccpacCOMAPI.AccpacView
Dim MIXCRU11detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0008", MIXCRU11detail1
Set MIXCRU11detail1Fields = MIXCRU11detail1.Fields
Dim MIXCRU11detail2 As AccpacCOMAPI.AccpacView
Dim MIXCRU11detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0029", MIXCRU11detail2
Set MIXCRU11detail2Fields = MIXCRU11detail2.Fields
Dim MIXCRU11detail3 As AccpacCOMAPI.AccpacView
Dim MIXCRU11detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0030", MIXCRU11detail3
Set MIXCRU11detail3Fields = MIXCRU11detail3.Fields
MIXCRU11header.Compose Array(MIXCRU11detail1, MIXCRU11detail2, MIXCRU11detail3)
'MIXCRU11detail1.Compose Array() 'if not remove this line, VBA Crashed
MIXCRU11detail2.Compose Array(MIXCRU11detail3)
MIXCRU11detail3.Compose Array(MIXCRU11detail2)
' from here, I am going to proccess PO "27410" and line "3000"
MIPOH2detail.Init
MIPOH2detail.Browse "", 1
MIPOH2detail.Fetch
MIXTAX10detail1Fields("ID").Value = "27410" ' PO No. replace with Po No. will be processed
MIPOH2headerFields("ID").Value = "27410" ' PO No. replace with Po No. will be processed
MIPOH2header.Read
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
temp = MIPOH2header.Exists
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detail.Read
MIPOH2header.Read
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detail.Read
MIXPPO9header.Init
MIXCRU11header.Init
MIXCRU11header.Process
MIPOH2header.Read
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No., Change to 3000 from previous value
MIPOH2detail.Read
MIXPPO9header.Init
MIXCRU11header.Process
MIXPPO9headerFields("REAL").PutWithoutVerification ("1") ' Real Flag
MIXPPO9headerFields("TYPE").PutWithoutVerification ("12") ' Transfer Type
MIPOH2detailFields("RECEIVED").Value = "2.000000" ' Received
MIPOH2detail.Update
MIPOH2header.Update
MIPOH2detail.Init
MIXPPO9header.Init
MIPOH2detail.Browse "", 1
MIPOH2detailFields("PODID").PutWithoutVerification ("-2147483647") ' Detail No.
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("1000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("2000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("4000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIXCRU11header.Init
MIXCRU11header.Process
MIPOH2header.Read
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detail.Read
MIXPPO9header.Init
MIPOH2detailFields("PODID").PutWithoutVerification ("1000") ' Detail No.
'*************************************************************************
'###########################################################################
MIPOH2detail.Read
MIPOH2header.Read
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
Exit Sub
ACCPACErrorHandler:
Dim lCount As Long
Dim lIndex As Long
If Errors Is Nothing Then
MsgBox Err.Description
Else
lCount = Errors.Count
If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Errors.Clear
End If
Resume Next
End If
End Sub
first, does macro record every thing happened while working through the accpac interface.
Second, if Marco recording do missed certain part of business logic, can it be manually amended by inserting two records into the tables directly.
System Info:
Accpac5.4
Mysis 5.4
Database: pervasive9.5
Recorded Code:
Sub MainSub()
On Error GoTo ACCPACErrorHandler
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 MIGLOB1 As AccpacCOMAPI.AccpacView
Dim MIGLOB1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0008", MIGLOB1
Set MIGLOB1Fields = MIGLOB1.Fields
MIGLOB1.Init
MIGLOB1.Browse "", 1
MIGLOB1.Fetch
Dim MIXPPO9header As AccpacCOMAPI.AccpacView
Dim MIXPPO9headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0110", MIXPPO9header
Set MIXPPO9headerFields = MIXPPO9header.Fields
Dim MIXPPO9detail As AccpacCOMAPI.AccpacView
Dim MIXPPO9detailFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0008", MIXPPO9detail
Set MIXPPO9detailFields = MIXPPO9detail.Fields
MIXPPO9header.Compose Array(MIXPPO9detail)
'MIXPPO9detail.Compose Array() 'if not remove this line, VBA Crashed
MIXPPO9header.Init
Dim MIPOH2header As AccpacCOMAPI.AccpacView
Dim MIPOH2headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0018", MIPOH2header
Set MIPOH2headerFields = MIPOH2header.Fields
Dim MIPOH2detail As AccpacCOMAPI.AccpacView
Dim MIPOH2detailFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0019", MIPOH2detail
Set MIPOH2detailFields = MIPOH2detail.Fields
MIPOH2header.Compose Array(MIPOH2detail, Nothing, Nothing, Nothing, Nothing)
MIPOH2detail.Compose Array(MIPOH2header, Nothing, Nothing)
Dim MIXTAX10header As AccpacCOMAPI.AccpacView
Dim MIXTAX10headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0118", MIXTAX10header
Set MIXTAX10headerFields = MIXTAX10header.Fields
Dim MIXTAX10detail1 As AccpacCOMAPI.AccpacView
Dim MIXTAX10detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0018", MIXTAX10detail1
Set MIXTAX10detail1Fields = MIXTAX10detail1.Fields
Dim MIXTAX10detail2 As AccpacCOMAPI.AccpacView
Dim MIXTAX10detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0019", MIXTAX10detail2
Set MIXTAX10detail2Fields = MIXTAX10detail2.Fields
MIXTAX10header.Compose Array(MIXTAX10detail1, MIXTAX10detail2)
MIXTAX10detail1.Compose Array(MIXTAX10detail2, Nothing, Nothing, Nothing, Nothing)
MIXTAX10detail2.Compose Array(MIXTAX10detail1, Nothing, Nothing)
Dim MIXCRU11header As AccpacCOMAPI.AccpacView
Dim MIXCRU11headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0100", MIXCRU11header
Set MIXCRU11headerFields = MIXCRU11header.Fields
Dim MIXCRU11detail1 As AccpacCOMAPI.AccpacView
Dim MIXCRU11detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0008", MIXCRU11detail1
Set MIXCRU11detail1Fields = MIXCRU11detail1.Fields
Dim MIXCRU11detail2 As AccpacCOMAPI.AccpacView
Dim MIXCRU11detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0029", MIXCRU11detail2
Set MIXCRU11detail2Fields = MIXCRU11detail2.Fields
Dim MIXCRU11detail3 As AccpacCOMAPI.AccpacView
Dim MIXCRU11detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "MI0030", MIXCRU11detail3
Set MIXCRU11detail3Fields = MIXCRU11detail3.Fields
MIXCRU11header.Compose Array(MIXCRU11detail1, MIXCRU11detail2, MIXCRU11detail3)
'MIXCRU11detail1.Compose Array() 'if not remove this line, VBA Crashed
MIXCRU11detail2.Compose Array(MIXCRU11detail3)
MIXCRU11detail3.Compose Array(MIXCRU11detail2)
' from here, I am going to proccess PO "27410" and line "3000"
MIPOH2detail.Init
MIPOH2detail.Browse "", 1
MIPOH2detail.Fetch
MIXTAX10detail1Fields("ID").Value = "27410" ' PO No. replace with Po No. will be processed
MIPOH2headerFields("ID").Value = "27410" ' PO No. replace with Po No. will be processed
MIPOH2header.Read
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
temp = MIPOH2header.Exists
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detail.Read
MIPOH2header.Read
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detail.Read
MIXPPO9header.Init
MIXCRU11header.Init
MIXCRU11header.Process
MIPOH2header.Read
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No., Change to 3000 from previous value
MIPOH2detail.Read
MIXPPO9header.Init
MIXCRU11header.Process
MIXPPO9headerFields("REAL").PutWithoutVerification ("1") ' Real Flag
MIXPPO9headerFields("TYPE").PutWithoutVerification ("12") ' Transfer Type
MIPOH2detailFields("RECEIVED").Value = "2.000000" ' Received
MIPOH2detail.Update
MIPOH2header.Update
MIPOH2detail.Init
MIXPPO9header.Init
MIPOH2detail.Browse "", 1
MIPOH2detailFields("PODID").PutWithoutVerification ("-2147483647") ' Detail No.
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("1000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("2000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("4000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIXPPO9header.Init
MIPOH2detail.Fetch
MIXCRU11header.Init
MIXCRU11header.Process
MIPOH2header.Read
MIPOH2detailFields("PODID").PutWithoutVerification ("3000") ' Detail No.
MIPOH2detail.Read
MIXPPO9header.Init
MIPOH2detailFields("PODID").PutWithoutVerification ("1000") ' Detail No.
'*************************************************************************
'###########################################################################
MIPOH2detail.Read
MIPOH2header.Read
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Init
MIPOH2detail.Browse "", -1
MIPOH2detailFields("PODID").PutWithoutVerification ("5000") ' Detail No.
MIPOH2detail.Read
MIPOH2detail.Browse "", -1
MIPOH2detail.Fetch
MIPOH2detail.Fetch
MIPOH2detail.Fetch
Exit Sub
ACCPACErrorHandler:
Dim lCount As Long
Dim lIndex As Long
If Errors Is Nothing Then
MsgBox Err.Description
Else
lCount = Errors.Count
If lCount = 0 Then
MsgBox Err.Description
Else
For lIndex = 0 To lCount - 1
MsgBox Errors.Item(lIndex)
Next
Errors.Clear
End If
Resume Next
End If
End Sub