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

14 March 2018

Add Menu through SDK

Dear All,
   Today , We will see, How to Add Menu through SDK.



 Public Sub AddMenu(ByVal SBO_Application As SAPbouiCOM.Application, ByVal aFormUid As String, ByVal strUniqueID As String, ByVal Str As String)
        ''********************************************************************
        Dim oMenuItem As SAPbouiCOM.MenuItem = Nothing
        Dim oMenus As SAPbouiCOM.Menus = Nothing
        Dim oCreationPackage As SAPbouiCOM.MenuCreationParams = Nothing
        Dim aForm As SAPbouiCOM.Form = Nothing

        ''********************************************************************
        aForm = SBO_Application.Forms.Item(aFormUid)
        oCreationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)
        ''********************************************************************
        Try
            oCreationPackage.Checked = False
            oCreationPackage.Enabled = True
            oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING
            oCreationPackage.UniqueID = strUniqueID.Trim
            oCreationPackage.String = Str.Trim
            aForm.Menu.AddEx(oCreationPackage)
        Catch ex As Exception

        Finally
            If oMenuItem IsNot Nothing Then
                oMenuItem = Nothing
            End If
            If oMenus IsNot Nothing Then
                oMenus = Nothing
            End If
            If oCreationPackage IsNot Nothing Then
                oCreationPackage = Nothing
            End If
            If aForm IsNot Nothing Then
                aForm = Nothing
            End If
        End Try
     


    End Sub

13 March 2018

Add Linked Button through SAP Business One SDK- VB.NET

Add Linked Button through SAP Business One SDK- VB.NET

Introduction:

SAP Business One is a powerful enterprise resource planning (ERP) solution that allows businesses to streamline their operations. One of the key strengths of SAP Business One is its extensibility, which enables developers to enhance the user interface (UI) and functionality according to specific business needs.In this blog post, we will focus on a common customization - adding a linked button to a form using the SAP Business One SDK in VB.NET. Linked buttons are a convenient way to integrate custom functionality into the SAP Business One UI, providing users with quick access to specific actions.

Public Sub AddLinkedButton(ByVal objForm As SAPbouiCOM.Form, ByVal ItemUID As String, ByVal SourceID As String, ByVal iLeft As Integer, ByVal iWidth As Integer, ByVal iHeight As Integer, ByVal LinkTo As String, ByVal strLinkedObjectType As String, ByVal strLinkedObject As String)
        Dim oItem As SAPbouiCOM.Item = Nothing
        Try
            If objForm IsNot Nothing Then
                oItem = objForm.Items.Add(ItemUID, SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON)
                oItem.Top = objForm.Items.Item(SourceID).Top
                oItem.Left = iLeft + (objForm.Items.Item(SourceID).Left + objForm.Items.Item(SourceID).Width)
                oItem.Width = iWidth
                oItem.Height = iHeight
                oItem.LinkTo = LinkTo
                Dim btn As SAPbouiCOM.LinkedButton = objForm.Items.Item(ItemUID).Specific '' To Assign New Button
                btn.LinkedObjectType = strLinkedObjectType
                btn.LinkedObject = strLinkedObject
            End If
        Catch ex As Exception
        Finally
            If objForm IsNot Nothing Then
                objForm = Nothing
            End If
            If oItem IsNot Nothing Then
                oItem = Nothing
            End If
        End Try
    End Sub

To summarize, adding a linked button in SAP Business One SDK in VB.NET requires specific steps for successful implementation. This enhances functionality and customization in the platform.

UDF -- Setting Fields Screen SAP Business one

 This Screen uses for design for "Header level Table UDF". here You can create Category based on your needs and assign a Field order in the  "Order Column" on the Screen.
          We can also set Visible and active for that Field

Short Cut Key 
  Ctrl +Shift + B .

 Note :
    It does not work in UDO Screen and User Form.It's only work with System Form and need to open User Defined Field(s).