Hi,
I have to write a program in either VB6 or C# (preferably) to extract data for AP and AR Aging from ACCPAC 5.3.
The steps that I have taken are:
1) Run a macro in ACCPAC
2) Initialize a session using COMAPI
3) Open a View AP0043
4) Process (APAGING1.Process)
Essentially other than opening a session and stripping the code of all references to the code processing and writing to a Crystal report, all the steps are as they exist in the default macro.
My questions are:
1) Can I store the values returned by the DLL in a file (text file) or ARRAY or read it and store it in a database?As I do not wish to write it to a crystal report.
2) When I write APAGING1.Read or APAGING1.GoTop or any other recordset function it gives me an error?
3) Is this view that I am using AP0043 in any way different from the other views that ACCPAC has. I am an absolute newbie at this.
4) I used this code as a proof of concept in the code just to see if I am doing the necessary steps and this ran properly.
*****************************
Dim CSRATETYPS1 As AccpacCOMAPI.AccpacView
mDBLinkSysRW.OpenView "CS0004", CSRATETYPS1
CSRATETYPS1.Fields("RATETYPE").Value = "SP"
Dim Status As Boolean
Status = CSRATETYPS1.Read
If Status = False Then
MsgBox "The SP record does not exist."
Else
MsgBox "No Problems"
Exit Sub
End If
************************************
I have attached the code that I have written, any help will be highly appreciated.
Regards
'************************************************
Sub MainSub()
On Error GoTo ACCPACErrorHandler
Dim Session As AccpacCOMAPI.AccpacSession
Set Session = New AccpacCOMAPI.AccpacSession
Session.Init "", "AP", "AP0043", "53A"
Session.EnforceAppVersion = False
Session.Open "ADMIN", "ADMIN", "SAMINC", Date, 0, ""
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = Session.OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)
Dim APAGING1 As AccpacCOMAPI.AccpacView
Dim APAGING1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0043", APAGING1
Set APAGING1Fields = APAGING1.Fields
temp = APAGING1.Exists
APAGING1.Init
APAGING1Fields("CMNDCODE").PutWithoutVerification ("51") ' Command Code
APAGING1Fields("AGEINVDTSW").PutWithoutVerification ("0") ' Due Date / Invoice Date
APAGING1Fields("AGEPERIOD2").PutWithoutVerification ("30") ' First Period
APAGING1Fields("AGEPERIOD3").PutWithoutVerification ("60") ' Second Period
APAGING1Fields("AGEPERIOD4").PutWithoutVerification ("90") ' Third Period
APAGING1Fields("SWDETAIL").PutWithoutVerification ("2") ' Detail / Summary Report
APAGING1Fields("SWOPTMETER").PutWithoutVerification ("1") ' Display Meter
APAGING1.Process
'TRYING TO READ VALUE FROM THE FIELD - GIVES ME THE LAST RECORD OF IDVEND
' IF I TRY TO WRITE ANYTHING HERE APAGING1.GOTOP / PREVIOUS ETC. IT GIVES ME AN ERROR SESSION NOT INITIALIZED
MsgBox (APAGING1Fields.FieldByName("IDVEND").Value)
'THE CODE SNIPPET BELOW IS JUST A TEST AND HAS NOTHING TO DO WITH THE CODE ABOVE OR BELOW
'***********************************************************
Dim CSRATETYPS1 As AccpacCOMAPI.AccpacView
mDBLinkSysRW.OpenView "CS0004", CSRATETYPS1
CSRATETYPS1.Fields("RATETYPE").Value = "SP"
Dim Status As Boolean
Status = CSRATETYPS1.Read
If Status = False Then
MsgBox "The SP record does not exist."
Else
MsgBox "No Problems"
Exit Sub
End If
'***********************************
Set Session = Nothing
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
'****************************************************
I have to write a program in either VB6 or C# (preferably) to extract data for AP and AR Aging from ACCPAC 5.3.
The steps that I have taken are:
1) Run a macro in ACCPAC
2) Initialize a session using COMAPI
3) Open a View AP0043
4) Process (APAGING1.Process)
Essentially other than opening a session and stripping the code of all references to the code processing and writing to a Crystal report, all the steps are as they exist in the default macro.
My questions are:
1) Can I store the values returned by the DLL in a file (text file) or ARRAY or read it and store it in a database?As I do not wish to write it to a crystal report.
2) When I write APAGING1.Read or APAGING1.GoTop or any other recordset function it gives me an error?
3) Is this view that I am using AP0043 in any way different from the other views that ACCPAC has. I am an absolute newbie at this.
4) I used this code as a proof of concept in the code just to see if I am doing the necessary steps and this ran properly.
*****************************
Dim CSRATETYPS1 As AccpacCOMAPI.AccpacView
mDBLinkSysRW.OpenView "CS0004", CSRATETYPS1
CSRATETYPS1.Fields("RATETYPE").Value = "SP"
Dim Status As Boolean
Status = CSRATETYPS1.Read
If Status = False Then
MsgBox "The SP record does not exist."
Else
MsgBox "No Problems"
Exit Sub
End If
************************************
I have attached the code that I have written, any help will be highly appreciated.
Regards
'************************************************
Sub MainSub()
On Error GoTo ACCPACErrorHandler
Dim Session As AccpacCOMAPI.AccpacSession
Set Session = New AccpacCOMAPI.AccpacSession
Session.Init "", "AP", "AP0043", "53A"
Session.EnforceAppVersion = False
Session.Open "ADMIN", "ADMIN", "SAMINC", Date, 0, ""
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkCmpRW = Session.OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)
Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
Set mDBLinkSysRW = Session.OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)
Dim APAGING1 As AccpacCOMAPI.AccpacView
Dim APAGING1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0043", APAGING1
Set APAGING1Fields = APAGING1.Fields
temp = APAGING1.Exists
APAGING1.Init
APAGING1Fields("CMNDCODE").PutWithoutVerification ("51") ' Command Code
APAGING1Fields("AGEINVDTSW").PutWithoutVerification ("0") ' Due Date / Invoice Date
APAGING1Fields("AGEPERIOD2").PutWithoutVerification ("30") ' First Period
APAGING1Fields("AGEPERIOD3").PutWithoutVerification ("60") ' Second Period
APAGING1Fields("AGEPERIOD4").PutWithoutVerification ("90") ' Third Period
APAGING1Fields("SWDETAIL").PutWithoutVerification ("2") ' Detail / Summary Report
APAGING1Fields("SWOPTMETER").PutWithoutVerification ("1") ' Display Meter
APAGING1.Process
'TRYING TO READ VALUE FROM THE FIELD - GIVES ME THE LAST RECORD OF IDVEND
' IF I TRY TO WRITE ANYTHING HERE APAGING1.GOTOP / PREVIOUS ETC. IT GIVES ME AN ERROR SESSION NOT INITIALIZED
MsgBox (APAGING1Fields.FieldByName("IDVEND").Value)
'THE CODE SNIPPET BELOW IS JUST A TEST AND HAS NOTHING TO DO WITH THE CODE ABOVE OR BELOW
'***********************************************************
Dim CSRATETYPS1 As AccpacCOMAPI.AccpacView
mDBLinkSysRW.OpenView "CS0004", CSRATETYPS1
CSRATETYPS1.Fields("RATETYPE").Value = "SP"
Dim Status As Boolean
Status = CSRATETYPS1.Read
If Status = False Then
MsgBox "The SP record does not exist."
Else
MsgBox "No Problems"
Exit Sub
End If
'***********************************
Set Session = Nothing
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
'****************************************************