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

Closing a draft

I am trying to close an exisitng draft via DI API - SAP B1 2005 A SP 00 PL 11.

I don't receive an error but the draft is open too.

Why?

'----


Private Function ChiusuraBozza(ByVal lDocEntry As Long) As Boolean

Try

Dim oDraft As SAPbobsCOM.Documents

oDraft = m_oCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts)

'Check errors

Dim bRetVal As Boolean

bRetVal = oDraft.GetByKey(lDocEntry)

Dim lErrCode As Long

Dim sErrMsg As String

If (Not bRetVal) = True Then

m_oCmp.GetLastError(lErrCode, sErrMsg)

If lErrCode <> 0 Then Throw New Exception(sErrMsg)

End If

If oDraft.DocNum = 0 Then

sErrMsg = "Bozza n." & lDocEntry

Throw New Exception(sErrMsg & " non trovata con il GetByKey")

End If

If oDraft.DocumentStatus = SAPbobsCOM.BoStatus.bost_Open Then

'Chiusura bozza

bRetVal = oDraft.Close

If (Not bRetVal) = True Then

m_oCmp.GetLastError(lErrCode, sErrMsg)

If lErrCode <> 0 Then

Throw New Exception("Bozza n." & oDraft.DocNum & " aperta: " & sErrMsg)

End If

End If

If Not SBOLog Is Nothing Then SBOLog.WriteLog(Me.ToString(), "ChiusuraBozza()", "Bozza n." & oDraft.DocNum & " chiusa correttamente", C_Log.TIME_MEDIUM, C_Log.Levels.LEVEL_GOOD)

End If

oDraft = Nothing

ChiusuraBozza = True

Catch ex As Exception

If Not SBOLog Is Nothing Then SBOLog.WriteLog(Me.ToString(), "ChiusuraBozza()", ex.Message, C_Log.TIME_MEDIUM, C_Log.Levels.LEVEL_ERROR)

ChiusuraBozza = False

End Try

System.GC.Collect() 'Release the handle to the table

End Function

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Oct 19, 2006 at 07:34 AM

    Hi Andrea,

    Just a stupid question from me: Are you using the correct doc number? Remember the docentry is not always the same as the doc number. Ensure you are looking at the correct document by checking the numbering in the DB.

    Add a comment
    10|10000 characters needed characters exceeded

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.