cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Business One - SDK landed costs example in C#

c_colacicco2
Explorer
0 Kudos

Hi,

I am looking for a working example of C# code that creates a new LandedCost object in SAP Business One. I will then be able to adapt this to my own needs.

Regards

Claudio

Accepted Solutions (0)

Answers (2)

Answers (2)

c_colacicco2
Explorer
0 Kudos

Hi Ankit,

Thanks for your answer. I am aware of the SDK documentation but need an example in C#, not VB. If you have anything that can help me with C# version then that would be greatly appreciated.

Best regards

Claudio

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi c.colacicco2,

Refer to the LandedCostsService object in SAP Business One SDK help file. Sample codes are provided there.

Private Sub test_Continue_LandedCost() 
 
'Continue System 
Dim svrLandedCost As SAPbobsCOM.LandedCostsService = oCompany.GetCompanyService().GetBusinessService(ServiceTypes.LandedCostsService) 
Dim oLandedCost As SAPbobsCOM.LandedCost = svrLandedCost.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) 
Dim oLandedCostParams As SAPbobsCOM.LandedCostParams = svrLandedCost.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCostParams) 
Dim oLandedCostsParams As SAPbobsCOM.LandedCostsParams = svrLandedCost.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCostsParams) 
 
 
Dim itemline As LandedCost_ItemLine = oLandedCost.LandedCost_ItemLines.Add() 
 
itemline.BaseDocumentType = LandedCostBaseDocumentTypeEnum.asGoodsReceiptPO 
itemline.BaseEntry = 2 
itemline.BaseLine = 0 
 
Dim itemline2 As LandedCost_ItemLine = oLandedCost.LandedCost_ItemLines.Add() 
 
itemline2.BaseDocumentType = LandedCostBaseDocumentTypeEnum.asGoodsReceiptPO 
itemline2.BaseEntry = 2 
itemline2.BaseLine = 1 
 
Try 
    svrLandedCost.AddLandedCost(oLandedCost) 
Catch ex As Exception 
    'exception process here 
End Try 
 
'Update  
oLandedCostParams.LandedCostNumber = 2 
oLandedCost = svrLandedCost.GetLandedCost(oLandedCostParams) 
oLandedCost.Remarks = "Update remark" 
 
Try 
    svrLandedCost.UpdateLandedCost(oLandedCost) 
Catch ex As Exception 
    'exception process here 
End Try 
 
Try 
    oLandedCostsParams = svrLandedCost.GetLandedCostList() 
Catch ex As Exception 
    'exception process here 
End Try 
 
'Cancel, Close not support in continue system 
 
    End Sub

Kind regards,

ANKIT CHAUHAN

SAP Business One Support