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

Macro of AP Payment Detail cannot be recognized

Status
Not open for further replies.

aan09

Programmer
Mar 21, 2018
29
ID
Hi All,

I recorded an macro of Payment Entry in SAGE 300 2018, but there are no records of Payment detail in there.

this is the generated macro of Payment Entry.

Sub MainSub()
'
' Sage 300 Macro file: D:\Sage\Macro\Payment.AVB
' Recorded at: Mon Aug 13 10:10:27 2018
'

On Error GoTo ACCPACErrorHandler

' TODO: To increase efficiency, comment out any unused DB links.
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 APPAYMENT1batch As AccpacCOMAPI.AccpacView
Dim APPAYMENT1batchFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0030", APPAYMENT1batch
Set APPAYMENT1batchFields = APPAYMENT1batch.Fields

Dim APPAYMENT1header As AccpacCOMAPI.AccpacView
Dim APPAYMENT1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0031", APPAYMENT1header
Set APPAYMENT1headerFields = APPAYMENT1header.Fields

Dim APPAYMENT1detail1 As AccpacCOMAPI.AccpacView
Dim APPAYMENT1detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0033", APPAYMENT1detail1
Set APPAYMENT1detail1Fields = APPAYMENT1detail1.Fields

Dim APPAYMENT1detail2 As AccpacCOMAPI.AccpacView
Dim APPAYMENT1detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0034", APPAYMENT1detail2
Set APPAYMENT1detail2Fields = APPAYMENT1detail2.Fields

Dim APPAYMENT1detail3 As AccpacCOMAPI.AccpacView
Dim APPAYMENT1detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0032", APPAYMENT1detail3
Set APPAYMENT1detail3Fields = APPAYMENT1detail3.Fields

Dim APPAYMENT1detail4 As AccpacCOMAPI.AccpacView
Dim APPAYMENT1detail4Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0048", APPAYMENT1detail4
Set APPAYMENT1detail4Fields = APPAYMENT1detail4.Fields

Dim APPAYMENT1detail5 As AccpacCOMAPI.AccpacView
Dim APPAYMENT1detail5Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0170", APPAYMENT1detail5
Set APPAYMENT1detail5Fields = APPAYMENT1detail5.Fields

Dim APPAYMENT1detail6 As AccpacCOMAPI.AccpacView
Dim APPAYMENT1detail6Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0406", APPAYMENT1detail6
Set APPAYMENT1detail6Fields = APPAYMENT1detail6.Fields

APPAYMENT1batch.Compose Array(APPAYMENT1header)

APPAYMENT1header.Compose Array(APPAYMENT1batch, APPAYMENT1detail3, APPAYMENT1detail1, APPAYMENT1detail6, APPAYMENT1detail5)

APPAYMENT1detail1.Compose Array(APPAYMENT1header, APPAYMENT1detail2, APPAYMENT1detail4)

APPAYMENT1detail2.Compose Array(APPAYMENT1detail1)

APPAYMENT1detail3.Compose Array(APPAYMENT1header)

APPAYMENT1detail4.Compose Array(APPAYMENT1batch, APPAYMENT1header, APPAYMENT1detail3, APPAYMENT1detail1, APPAYMENT1detail2)

APPAYMENT1detail5.Compose Array(APPAYMENT1header)

APPAYMENT1detail6.Compose Array(APPAYMENT1header)


Dim APPAYMPOST2 As AccpacCOMAPI.AccpacView
Dim APPAYMPOST2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "AP0040", APPAYMPOST2
Set APPAYMPOST2Fields = APPAYMPOST2.Fields


APPAYMENT1batch.RecordClear

APPAYMENT1batchFields("PAYMTYPE").PutWithoutVerification ("PY") ' Batch Selector

APPAYMENT1headerFields("BTCHTYPE").PutWithoutVerification ("PY") ' Batch Type
APPAYMENT1detail3Fields("BATCHTYPE").PutWithoutVerification ("PY") ' Batch Type
APPAYMENT1detail1Fields("BATCHTYPE").PutWithoutVerification ("PY") ' Batch Type
APPAYMENT1detail2Fields("BATCHTYPE").PutWithoutVerification ("PY") ' Batch Type
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
APPAYMENT1batch.Browse "((PAYMTYPE = ""PY"") AND ((BATCHSTAT = 1) OR (BATCHSTAT = 7) OR (BATCHSTAT = 8)))", 1

APPAYMENT1batchFields("PAYMTYPE").PutWithoutVerification ("PY") ' Batch Selector
APPAYMENT1batchFields("CNTBTCH").PutWithoutVerification ("0") ' Batch Number

APPAYMENT1batch.RecordCreate 1

APPAYMENT1batchFields("PROCESSCMD").PutWithoutVerification ("1") ' Process Command Code

APPAYMENT1batch.Process
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
APPAYMENT1header.RecordCreate 2
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
APPAYMENT1batchFields("BATCHDESC").PutWithoutVerification ("Payment V0229") ' Description
APPAYMENT1batch.Update
APPAYMENT1headerFields("IDVEND").Value = "V0229" ' Vendor Number
APPAYMENT1detail1.Cancel
APPAYMENT1headerFields("PROCESSCMD").PutWithoutVerification ("0") ' Process Command Code
APPAYMENT1header.Process
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
APPAYMENT1header.Insert
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
APPAYMENT1batch.Read
APPAYMENT1headerFields("CNTENTR").PutWithoutVerification ("0") ' Entry Number
APPAYMENT1header.RecordCreate 2
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists
temp = APPAYMENT1header.Exists



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 already redorded it many times with only changes recorded or all recorded but the result was still same.
 
Then you'll have to add your own APPAYMENT1detail1.Insert. RVSPY will help.

Sage 300 Whisperer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top