cancel
Showing results for 
Search instead for 
Did you mean: 

SAP B1 Cancel Asset Capitalization through DI-API

ibrey
Explorer
0 Kudos

Hello,

 

I am trying to cancel Asset Capitalization document through DI-API (VB.net)

Below are my code.

Dim oActivity As SAPbobsCOM.AssetDocumentService
oActivity = oCompany.GetBusinessObject(SAPbobsCOM.ServiceTypes.AssetCapitalizationService)
'Dim oParam As SAPbobsCOM.AssetDocumentParams
Dim oParam = oActivity.GetDataInterface(SAPbobsCOM.AssetDocumentServiceDataInterfaces.adsAssetDocumentParams)
oParam.Code = docno
oParam.CancellationOption = SAPbobsCOM.ClosingOptionEnum.coByOriginalDocumentDat
oActivity.Cancel(oParam)

 

I get the error at line Dim oParam = oActivity.GetDataInterface(SAPbobsCOM.AssetDocumentServiceDataInterfaces.adsAssetDocumentParams)

 

Error saying Object reference not set to an instance of an object.

I think i am not calling the function correctly.

Please help me identify the issue.

 

Thanks in Advance.

Ibrahim

Accepted Solutions (0)

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ibrey,

Try something as below:

 

 

Dim oService As SAPbobsCOM.CompanyService = oCompany.GetCompanyService()
Dim AssetService As SAPbobsCOM.AssetDocumentService = oService.GetBusinessService(SAPbobsCOM.ServiceTypes.AssetCapitalizationService)
Dim AssetDocument As SAPbobsCOM.AssetDocument = AssetService.GetDataInterface(SAPbobsCOM.AssetDocumentServiceDataInterfaces.adsAssetDocument)
Dim AssetDocumentParams As SAPbobsCOM.AssetDocumentParams = AssetService.GetDataInterface(SAPbobsCOM.AssetDocumentServiceDataInterfaces.adsAssetDocumentParams)
AssetDocumentParams.Code = 25
AssetDocumentParams.CancellationOption = SAPbobsCOM.ClosingOptionEnum.coBySpecifiedDate
AssetDocumentParams.CancellationDate = "2024-03-01"
AssetService.Cancel(AssetDocumentParams)

 

 

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

ibrey
Explorer
0 Kudos

Below line doesnt work

 

Dim AssetService As SAPbobsCOM.AssetDocumentService = oService.GetBusinessService(SAPbobsCOM.ServiceTypes.AssetCapitalizationService)

oService is not recongnized.

 

Regards,

Ibrahim

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ibrey,

The code has been updated. Kindly check it.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support