Create Item Adjustment

Top  Previous  Next

[Visual Basic] The following example demonstrates how to create and save a new Item Adjustment document. (This example uses the ItemAdjustmentWebService.)

 

' ----------------------------------------

' Step 1: Create an instance of the web service.

' ----------------------------------------

Dim itemAdjustmentWs As New WebServices.ItemAdjustmentWebService("http://localhost/objacctwebservices/")

 

' ----------------------------------------

' Step 2: Set the LoginKey. (Use Login.GetLoginKey to

' login to a specific company and generate a LoginKey.)

' For this example, the LoginKey is being stored in a

' public variable called PublicLoginKey.

' ----------------------------------------

WebServices.SoapHeader.SetLoginKey(itemAdjustmentWs, PublicLoginKey)

 

' ----------------------------------------

' Step 3: Create and populate a DataSet with the new document.

' For this example, we're creating a new Item Adjustment document, so

' we will use the ObjAcct.WebServices.DataSets.ItemAdjustmentDataSet.

' ----------------------------------------

Dim itemAdjustmentDs As DataSet = New WebServices.DataSets.ItemAdjustmentDataSet()

 

' -------------------

' Document Header.

' -------------------

Dim headerDr As DataRow = itemAdjustmentDs.Tables("Header").NewRow

 

headerDr("RowID") = ""

headerDr("Description") = "Item Adjustment"

headerDr("DocDate") = Today.ToShortDateString

headerDr("DocID") = "IA5000"

headerDr("EnteredDate") = Today.ToShortDateString

headerDr("JobRowID") = "39.0"

 

' Add the row to the Header table.

itemAdjustmentDs.Tables("Header").Rows.Add(headerDr)

 

' -------------------

' Transaction.

' -------------------

Dim transDr As DataRow

 

transDr = itemAdjustmentDs.Tables("Transaction").NewRow

 

transDr("RowID") = ""

transDr("AccountRowID") = "11.0"

transDr("ClassRowID") = "20.0"

transDr("Description") = "Laserjet Printer Paper"

transDr("DisplayOrder") = 1

transDr("ItemRowID") = "52.0"

transDr("JobRowID") = "39.0"

transDr("Quantity") = 5

transDr("TransactionAmount") = 45.28

transDr("UnitRowID") = "5.0"

 

' Add the row to the Transaction table.

itemAdjustmentDs.Tables("Transaction").Rows.Add(transDr)

 

transDr = itemAdjustmentDs.Tables("Transaction").NewRow

 

transDr("RowID") = ""

transDr("AccountRowID") = "11.0"

transDr("ClassRowID") = "20.0"

transDr("Description") = "TextBooks"

transDr("DisplayOrder") = 2

transDr("ItemRowID") = "65.0"

transDr("JobRowID") = "39.0"

transDr("Quantity") = 500

transDr("TransactionAmount") = 5000

transDr("UnitRowID") = "2.0"

 

' Add the row to the Transaction table.

itemAdjustmentDs.Tables("Transaction").Rows.Add(transDr)

 

' ----------------------------------------

' Step 4: Save the document.

' ----------------------------------------

Dim returnDs As DataSet = itemAdjustmentWs.SaveDocument(itemAdjustmentDs, 1)

 

' Check for errors.

If StdLib.GetErrorNumber(returnDs) < 0 Then

       MsgBox(StdLib.GetErrorAsString(returnDs))

End If