×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Checking Active Fiscal Period While Posting Receipt Using Accpac/Sage Macro

Checking Active Fiscal Period While Posting Receipt Using Accpac/Sage Macro

Checking Active Fiscal Period While Posting Receipt Using Accpac/Sage Macro

(OP)
i want to know the status of my 3rd period in 2014 is locked or not

i had tried using code below

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 CSCALENDARHEADER As AccpacCOMAPI.AccpacView
'Dim CSCALENDARHEADERFields As AccpacCOMAPI.AccpacViewFields
'mDBLinkCmpRW.OpenView "CS2010", CSCALENDARHEADER
'Set CSCALENDARHEADERFields = CSCALENDARHEADER.Fields

Dim CSCALENDAR1 As AccpacCOMAPI.AccpacView
Dim CSCALENDAR1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "CS0002", CSCALENDAR1
Set CSCALENDAR1Fields = CSCALENDAR1.Fields

Dim CSCALENDAR2 As AccpacCOMAPI.AccpacView
Dim CSCALENDAR2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "CS0060", CSCALENDAR2
Set CSCALENDAR2Fields = CSCALENDAR2.Fields

Dim CSCALENDAR3 As AccpacCOMAPI.AccpacView
Dim CSCALENDAR3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "CS0120", CSCALENDAR3
Set CSCALENDAR3Fields = CSCALENDAR3.Fields

'CSCALENDARHEADER.Compose Array(CSCALENDAR1, CSCALENDAR2)
CSCALENDAR1.Compose Array(CSCALENDAR2)

CSCALENDAR1.Process
CSCALENDAR1.Process
CSCALENDAR1.Process
CSCALENDAR1.Process
CSCALENDAR1.Process
CSCALENDAR1.Process
CSCALENDAR1.Process
CSCALENDAR1.Process
CSCALENDAR1.Process
CSCALENDAR1.Browse "", 0
temp = CSCALENDAR1.Exists
temp = CSCALENDAR1.Exists
temp = CSCALENDAR1.Exists

CSCALENDAR1Fields("FSCYEAR").Value = "2014" ' Fiscal Year
CSCALENDAR1.Read
CSCALENDAR1.Process

CSCALENDAR2.Browse "", 0
CSCALENDAR2.Process
MsgBox (CSCALENDAR1Fields("FSCYEAR").Value)
MsgBox (CSCALENDAR2Fields("FSCYEAR").Value)
MsgBox (CSCALENDAR2Fields("STATUS3").Value)

CSCALENDAR1.Update



CSCALENDAR2Fields("STATUS3").Value the result was 1 that mean in open or unlocked, but in the accpac, the status was locked


and i tried to record error while posting Receipt. But the vba not showing hor to check the fiscal period

Sub MainSub()
'
' Sage 300 ERP Macro file: D:\ACCPAC62\ACCPAC\Macros\test2.AVB
' Recorded at: Fri Jun 22 08:19:10 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 PORCP1header As AccpacCOMAPI.AccpacView
Dim PORCP1headerFields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0700", PORCP1header
Set PORCP1headerFields = PORCP1header.Fields

Dim PORCP1detail1 As AccpacCOMAPI.AccpacView
Dim PORCP1detail1Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0710", PORCP1detail1
Set PORCP1detail1Fields = PORCP1detail1.Fields

Dim PORCP1detail2 As AccpacCOMAPI.AccpacView
Dim PORCP1detail2Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0695", PORCP1detail2
Set PORCP1detail2Fields = PORCP1detail2.Fields

Dim PORCP1detail3 As AccpacCOMAPI.AccpacView
Dim PORCP1detail3Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0718", PORCP1detail3
Set PORCP1detail3Fields = PORCP1detail3.Fields

Dim PORCP1detail4 As AccpacCOMAPI.AccpacView
Dim PORCP1detail4Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0714", PORCP1detail4
Set PORCP1detail4Fields = PORCP1detail4.Fields

Dim PORCP1detail5 As AccpacCOMAPI.AccpacView
Dim PORCP1detail5Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0699", PORCP1detail5
Set PORCP1detail5Fields = PORCP1detail5.Fields

Dim PORCP1detail6 As AccpacCOMAPI.AccpacView
Dim PORCP1detail6Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0705", PORCP1detail6
Set PORCP1detail6Fields = PORCP1detail6.Fields

Dim PORCP1detail7 As AccpacCOMAPI.AccpacView
Dim PORCP1detail7Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0703", PORCP1detail7
Set PORCP1detail7Fields = PORCP1detail7.Fields

Dim PORCP1detail8 As AccpacCOMAPI.AccpacView
Dim PORCP1detail8Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0696", PORCP1detail8
Set PORCP1detail8Fields = PORCP1detail8.Fields

Dim PORCP1detail9 As AccpacCOMAPI.AccpacView
Dim PORCP1detail9Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0717", PORCP1detail9
Set PORCP1detail9Fields = PORCP1detail9.Fields

Dim PORCP1detail10 As AccpacCOMAPI.AccpacView
Dim PORCP1detail10Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0721", PORCP1detail10
Set PORCP1detail10Fields = PORCP1detail10.Fields

Dim PORCP1detail11 As AccpacCOMAPI.AccpacView
Dim PORCP1detail11Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0719", PORCP1detail11
Set PORCP1detail11Fields = PORCP1detail11.Fields

Dim PORCP1detail12 As AccpacCOMAPI.AccpacView
Dim PORCP1detail12Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0697", PORCP1detail12
Set PORCP1detail12Fields = PORCP1detail12.Fields

Dim PORCP1detail13 As AccpacCOMAPI.AccpacView
Dim PORCP1detail13Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0704", PORCP1detail13
Set PORCP1detail13Fields = PORCP1detail13.Fields

Dim PORCP1detail14 As AccpacCOMAPI.AccpacView
Dim PORCP1detail14Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0789", PORCP1detail14
Set PORCP1detail14Fields = PORCP1detail14.Fields

Dim PORCP1detail15 As AccpacCOMAPI.AccpacView
Dim PORCP1detail15Fields As AccpacCOMAPI.AccpacViewFields
mDBLinkCmpRW.OpenView "PO0780", PORCP1detail15
Set PORCP1detail15Fields = PORCP1detail15.Fields

PORCP1header.Compose Array(PORCP1detail2, PORCP1detail1, PORCP1detail3, PORCP1detail4, PORCP1detail5, PORCP1detail6, PORCP1detail7, PORCP1detail8)

PORCP1detail1.Compose Array(PORCP1header, PORCP1detail2, PORCP1detail5, Nothing, Nothing, PORCP1detail9, PORCP1detail14, PORCP1detail15)

PORCP1detail2.Compose Array(PORCP1header, PORCP1detail1)

PORCP1detail3.Compose Array(PORCP1header, PORCP1detail4, PORCP1detail5, PORCP1detail10)

PORCP1detail4.Compose Array(PORCP1detail3, PORCP1detail5, PORCP1header, Nothing, Nothing, PORCP1detail11, PORCP1detail8)

PORCP1detail5.Compose Array(PORCP1header, PORCP1detail2, PORCP1detail1, PORCP1detail4, PORCP1detail3, PORCP1detail6, PORCP1detail8)

PORCP1detail6.Compose Array(PORCP1header, PORCP1detail5)

PORCP1detail7.Compose Array(PORCP1header)

PORCP1detail8.Compose Array(PORCP1detail4, PORCP1detail3, PORCP1header, PORCP1detail5, PORCP1detail12)

PORCP1detail9.Compose Array(PORCP1detail1)

PORCP1detail10.Compose Array(PORCP1detail3)

PORCP1detail11.Compose Array(PORCP1detail4)

PORCP1detail12.Compose Array(Nothing, PORCP1detail8, PORCP1detail4)

PORCP1detail13.Compose Array(PORCP1detail8, PORCP1detail1)

PORCP1detail14.Compose Array(PORCP1detail1, Nothing, Nothing)

PORCP1detail15.Compose Array(PORCP1detail1, Nothing, Nothing)


PORCP1header.Order = 1
PORCP1header.Order = 0

PORCP1headerFields("RCPHSEQ").PutWithoutVerification ("0") ' Receipt Sequence Key

PORCP1header.Init
PORCP1header.Order = 1
temp = PORCP1detail1.Exists
PORCP1detail1.RecordClear
PORCP1detail3.RecordClear
temp = PORCP1detail4.Exists
PORCP1detail4.RecordClear
PORCP1detail6.Init
PORCP1detail2.Init
PORCP1headerFields("RCPNUMBER").Value = "DUM18277002" ' Receipt Number
temp = PORCP1header.Exists
PORCP1header.Read
PORCP1detail6.Init

PORCP1detail6Fields("RCPRREV").PutWithoutVerification ("-999999999999999999") ' Line Number

PORCP1detail6.Browse "", 1
PORCP1detail6.Fetch
PORCP1detail2.Init

PORCP1detail2Fields("RCPCREV").PutWithoutVerification ("-999999999999999999") ' Comment Identifier

PORCP1detail2.Browse "", 1
PORCP1detail2.Fetch
PORCP1headerFields("DATE").Value = DateSerial(2018, 5, 1) ' Receipt Date
PORCP1detail5Fields("FUNCTION").Value = "61" ' Function
PORCP1detail5.Process
PORCP1headerFields("DATEBUS").Value = DateSerial(2018, 5, 31) ' Posting Date
PORCP1detail5Fields("FUNCTION").Value = "61" ' Function
PORCP1detail5.Process
PORCP1detail3.Browse "(RCPHSEQ = 14698680)", 1
PORCP1detail3.RecordClear
PORCP1detail5Fields("FUNCTION").PutWithoutVerification ("10") ' Function
PORCP1detail5.Process

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


can anyone help me what i missing in this code?

RE: Checking Active Fiscal Period While Posting Receipt Using Accpac/Sage Macro

Dim bGoodPeriod As Boolean
Dim bPeriodOpen As Boolean
bGoodPeriod = a4wLinkRead.GetFiscalCalendar.GetPeriod({mydatehere}, , , bPeriodOpen)
If Not bGoodPeriod Or Not bPeriodOpen Then
LogWrite "Error row " & iRow & ", posting date " & dDate & " is in a closed period"
bError = True
End If

Sage 300 Whisperer

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close