Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Update sales order method. web service

SBO version is 2005

Version PL5 of DIAPI

<WebMethod(EnableSession:=True, Description:="Test Function : Use this method to update Item Invoice. ")> _

Public Function ModifyItemOrder(ByVal OrderDataSet As DataSet) As String

Dim lngRetVal As Long

Dim strReturn As String = ""

Dim oDocument As SAPbobsCOM.Documents = Nothing

'Dim oUDF As SAPbobsCOM.UserFields

Dim dtOrdHeader As DataTable = Nothing

Dim dtOrdLines As DataTable = Nothing

Dim drOrdHeader As DataRow

Dim drOrdLines As DataRow

Dim oCompany As SAPbobsCOM.Company

Dim IngRow As Long = 0

Dim deleteLine As New Integer

Try

'Set Connection parametres- (System, DB Name, SBO id, SBO passowrd , DB ID, DB password)

SetConnectionParam("**")

'get data from web front.

dtOrdHeader = OrderDataSet.Tables("OrderHeader")

dtOrdLines = OrderDataSet.Tables("ItemLines")

If ConnectToDatabase() Then

oCompany = Session("g_CompanyConnection")

oDocument = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)

oDocument.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items

'main statement for update

If oDocument.GetByKey(OrderDataSet.Tables("OrderHeader").Rows(0).Item("DocNum")) Then

If dtOrdHeader.Rows.Count > 0 Then

drOrdHeader = dtOrdHeader.Rows(0)

'Set values to the fields

oDocument.DocDueDate = drOrdHeader("DocDueDate")

oDocument.Address2 = drOrdHeader("Address2")

oDocument.Comments = drOrdHeader("Comments").ToString()

oDocument.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO

End If

'count how many line in current line

deleteLine = oDocument.Lines.Count

If dtOrdLines.Rows.Count > 0 Then

Dim i As Integer

i = 0

'Add item into current document

While dtOrdLines.Rows.Count > i

oDocument.Lines.Add()

'strReturn = strReturn + "in while"

drOrdLines = dtOrdLines.Rows(i)

'item lines - set value to the first line

oDocument.Lines.ItemCode = drOrdLines("ItemCode").ToString()

oDocument.Lines.LineTotal = drOrdLines("LineTotal").ToString()

oDocument.Lines.ItemDescription = drOrdLines("Desc").ToString()

oDocument.Lines.Price = drOrdLines("Uprice").ToString()

oDocument.Lines.Quantity = drOrdLines("Quantity").ToString()

i = i + 1

'strReturn = strReturn + "loop" + i.ToString()

End While

'Delete previous item

i = 0

While deleteLine > i

'set first row

oDocument.Lines.SetCurrentLine(0)

'delete first row

oDocument.Lines.Delete()

i = i + 1

End While

lngRetVal = oDocument.Update

'Check the result

If lngRetVal = 0 Then

Session("g_LastErrorMsg") = " "

oCompany.GetNewObjectCode(strReturn) 'get last doc

Else

Session("g_LastErrorMsg") = oCompany.GetLastErrorDescription

End If

Else

Session("g_LastErrorMsg") = "No record found in data set"

End If

End If

End If

Catch ex As Exception

Session("g_LastErrorMsg") = ex.Message

strReturn = ex.Message.ToString()

Finally 'no matter above is success or failed must execute this portion

oDocument = Nothing 'release the resource/obj variable

End Try

Return strReturn

End Function

This is the method i have. After i have successfully update the sales order. SAP Business One 2005 display closed row for every product's row status i have in the sales order. Anybody know how to solve this? It should be Open row.

Regard,

Kean

Not what you were looking for? View more on this topic or Ask a question