Welcome Notes

Welcome Viewers

15 March 2018

Creating a Resource Master in SAP B1 via SDK

Dear Esteemed Readers,

Today, we embark on a journey through the intricate process of creating a Resource Master within SAP Business One using the Software Development Kit (SDK). Resource Masters form the backbone of efficient management within the SAP B1 ecosystem, enabling seamless tracking and utilization of vital organizational assets.



  Public Function AddResourceMaster(ByVal strVisCode As String, ByVal strResName As String, ByVal strResWarehouse As String) As Boolean
    Dim oCompanyService As SAPbobsCOM.CompanyService = Nothing
    Dim oResourceService As SAPbobsCOM.ResourcesService = Nothing
    Dim oResource As SAPbobsCOM.Resource = Nothing
    Dim oResWhs As SAPbobsCOM.ResourceWarehouse = Nothing
    Dim oResParamters As SAPbobsCOM.ResourceParams = Nothing

    Try
        oCompanyService = oApplication.SAPCompany.GetCompanyService
        oResourceService = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.ResourcesService)
        oResource = oCompanyService.GetDataInterface(SAPbobsCOM.ResourcesServiceDataInterfaces.rsdiResource)
        
        ' Assign values to Resource properties
        oResource.VisCode = strVisCode
        oResource.Name = strResName
        
        ' Add Resource Warehouse
        oResWhs = oResource.Warehouses.Add
        oResWhs.Warehouse = strResWarehouse
        
        ' Add Resource using Service
        oResParamters = oResourceService.Add(oResource)
        
        Return True
    Catch ex As Exception
        ' Log or handle the exception accordingly
        ' Logging or displaying error messages for debugging purposes
        Return False
    Finally
        ' Properly dispose of resources
        If oResParamters IsNot Nothing Then oResParamters = Nothing
        If oResWhs IsNot Nothing Then oResWhs = Nothing
        If oResource IsNot Nothing Then oResource = Nothing
        If oResourceService IsNot Nothing Then oResourceService = Nothing
        If oCompanyService IsNot Nothing Then oCompanyService = Nothing
    End Try
End Function

Add project through SDK

Dear All,
   Today , We will see, How to Add project through SDK.
Public Function AddProjectIntoSAP(ByVal strPrjCode As Object, ByVal strPrjName As Object, ByVal activeMode As SAPbobsCOM.BoYesNoEnum, ByVal dtVaidateFrom As Date, ByVal dtVaidateTo As Date) As Boolean
        Dim oCmpSrv As SAPbobsCOM.CompanyService = Nothing
        Dim projectService As SAPbobsCOM.IProjectsService = Nothing
        Dim project As SAPbobsCOM.IProject = Nothing
        Dim projectParams As SAPbobsCOM.IProjectParams = Nothing
        oCmpSrv = oApplication.SAPCompany.GetCompanyService
        projectService = oCmpSrv.GetBusinessService(SAPbobsCOM.ServiceTypes.ProjectsService)
        project = projectService.GetDataInterface(SAPbobsCOM.ProjectsServiceDataInterfaces.psProject)
        Try
            projectParams = projectService.GetProjectList()
            project.Code = strPrjCode
            project.Name = strPrjName
            project.Active = activeMode
            project.ValidFrom = dtVaidateFrom
            project.ValidTo = dtVaidateTo
            projectService.AddProject(project)
            Return True
        Catch ex As Exception
            Return False
        Finally
            If oCmpSrv IsNot Nothing Then
                oCmpSrv = Nothing
            End If
            If projectService IsNot Nothing Then
                projectService = Nothing
            End If
            If project IsNot Nothing Then
                project = Nothing
            End If
            If projectParams IsNot Nothing Then
                projectParams = Nothing
            End If
        End Try
    End Function