Skip to Content
author's profile photo Former Member
Former Member

Production Orders & Financial Periods

An Add-on that I am working on performs the following function

It provides a list of Released Production Orders that the user can select one or many from, and close in bulk (say at the end of a month).

An issue has been discovered in the following scenario over subsequent periods (for example, months):

- A PO is created in Period 1, no transactions occur.

- Period 1 is closed & locked by the User (eg. End of Month)

- In Period 2, the item is produced and completed (Goods Receipt from Production)

- When the PO is selected by the Add-on to be closed, an error is thrown "Period is locked for new data"

- HOWEVER, closing this PO through the Client (UI) is still possible, regardless of Period 1 being locked.

- If Period 1 is unlocked via the Client, the Add-on functions correctly

Is this a bug with the SDK?

A workaround we have brainstormed is unlocking the previous period by the SDK, closing the PO's then re-locking the period. Does this sound like a viable solution?

Any advice would be appreciated....

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2006 at 10:47 PM

    Any comments or help would be appreciated?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Anyone looking to manipulate Financial Periods, here is some sample code...

              ' If Period not found, or Period is already unlocked, return Nothing, else return locked Financial Period
              Private Function getFinancialPeriod(ByRef oCompServ As SAPbobsCOM.CompanyService, ByRef oProdOrder As SAPbobsCOM.ProductionOrders) As SAPbobsCOM.FinancePeriod
      
                  Dim lPeriod As Long = 0
      
                  Dim oPeriod As SAPbobsCOM.Recordset
                  oPeriod = B1Connections.diCompany.GetBusinessObject(BoObjectTypes.BoRecordset)
      
                  Dim strPeriodQry As String = "select AbsEntry from OFPR where Locked = 'Y' and " & _
                                                  "'" & oProdOrder.PostingDate.ToString("MM/dd/yyyy") & "' between F_RefDate and T_RefDate"
                  oPeriod.DoQuery(strPeriodQry)
      
                  If (oPeriod.RecordCount = 0) Then Return Nothing
      
                  oPeriod.MoveFirst()
                  lPeriod = CType(oPeriod.Fields.Item("AbsEntry").Value, Long)
      
                  Dim diPeriodParams As SAPbobsCOM.FinancePeriodParams = oCompServ.GetDataInterface(CompanyServiceDataInterfaces.csdiFinancePeriodParams)
                  diPeriodParams.AbsoluteEntry = lPeriod
      
                  Dim oFinPeriod As SAPbobsCOM.FinancePeriod
                  oFinPeriod = oCompServ.GetFinancePeriod(diPeriodParams)
      
                  Return oFinPeriod
      
              End Function
      
              Private Sub unlockPeriod(ByRef oCompServ As SAPbobsCOM.CompanyService, ByRef oFinPeriod As SAPbobsCOM.FinancePeriod)
      
                  If Not (oFinPeriod Is Nothing) Then
                      oFinPeriod.Locked = BoYesNoEnum.tNO
                      oCompServ.UpdateFinancePeriod(oFinPeriod)
                  End If
      
              End Sub
      
              Private Sub lockPeriod(ByRef oCompServ As SAPbobsCOM.CompanyService, ByRef oFinPeriod As SAPbobsCOM.FinancePeriod)
      
                  If Not (oFinPeriod Is Nothing) Then
                      oFinPeriod.Locked = BoYesNoEnum.tYES
                      oCompServ.UpdateFinancePeriod(oFinPeriod)
                  End If
      
              End Sub
      

      Hope this helps someone...

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.