Welcome Notes

Welcome Viewers

21 March 2018

Change Receiver System Integration Framework SAP

Dear All 
   Today  , we will see Change "Receiver System" though  Integration Framework SAP.

    Go To Integration Framework Scanario Package OverView Screen
                  Scenarios >> Control

   UnCheck Package Scenario
   Go To Setup Scenario
                  Scenarios >> Setup
                  Click "Receiver" button
                  Change "Receiver System"

19 March 2018

Transfer Sale order Record to flat file using Integration Framework

Dear All,
    Today ,we will discuss how to Transfer Sale order Record to flat file using Integration Framework.


Scenario : Transfer Sale order Record to flat file
The following record fetched from Sale Order

1)Card Code 2) Card Name 3) Doc Total 4) Doc Currency 5) DocDate 6) DocNum

Step by Step Procedure to Transfer record from SAP Business One to File Format

1) Create Scenario Package
2) Create Scenario Steps
              2.1   Inbound
              2.2   Outbound
              2.3   Processing
3) Create System
4) Test


1) Create Scenrio Package
    Go To Scenario Tab
    Click "Package Design"
    Click  "+" button for Create Scenario Package.
    Enter  Package Name on Scenario package Idetifier.
    Select "No Authentication" Authentication Browse Button.
    Click "Save"icon.
2) Create Scenario Steps
   Go To Scenario Tab
   Click "Scenario Package Design"
    Click  "+" button for Create Scenario Steps.
    Enter  Steps Name on Scenario steps Idetifier.
    Assign Scenario Package in Scenario Package Identifier.
    Click "Save"icon.

 2.1 Create Inbound
    Click "Inbound" Button.
      2.1.1) Create Channel
    Click "Channel" Button.
        Select Inbound Type "SAP Business One"
        Select Process Mode "Asynchronous"
        Select Process Trigger "B1Event"
        Select Identification Method "B1Event"
        Enter Identification Paramter :n.a
        Select Identifier  (In Our case  Select "17")
        Click "Save"icon.
        Click "Close" button.
      2.1.2) Create Retrieval
                  Click "Retrieval" Button.
                        Select "DI API" in Retrieval Adapter.
                        Select "Object" in Retrieval Type.
                        Click "Save"icon.
                Click "Close" button.

  2.2) Outbound
             Click "Outbound" Button.
             Select  "FlatFile" in Outbound Channel.
             Select "file" in Outbound Format.
             Click "Details" button
                  Select Scenario Step identifier
                  Select "dsv" Output Format.
                  Select "Write" in Mode.
                  Select "ISO-8859-1" in Character Encoding (if you want you can change it based on your requirement)
                   Click "Save"icon.
           Click "Close" button.
             Click "Save"icon.
         Click "Close" button. 
  2.3) Processing
             If you have any issue when you press "Processing" button,You can follow below step(s).
                Click "Control" on the Scenarios Page.
                Find your "Package Name"
                Click "Overview" Button.
                you see Integration Framework - Scanrio Overview Screen.
                Click/Double Click "Final Processing step"
                 you see the BixFlow Screen.
                 Click "Final" icon
                 you see "Integration Framework - XML Editor"
                 Paste below XSLT Code under transform tag
                          <Fileout type="file">
<row>
<col>
<xsl:value-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;S&apos;]/BOM/BO/Documents/row/CardCode"></xsl:value-of>
</col>
<col>
<xsl:value-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;S&apos;]/BOM/BO/Documents/row/CardName"></xsl:value-of>
</col>
<col>
<xsl:value-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;S&apos;]/BOM/BO/Documents/row/DocTotal"></xsl:value-of>
</col>
<col>
<xsl:value-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;S&apos;]/BOM/BO/Documents/row/DocDueDate"></xsl:value-of>
</col>
<col>
<xsl:value-of select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role=&apos;S&apos;]/BOM/BO/Documents/row/DocNum"></xsl:value-of>
</col>

</row>
</Fileout>
                 Click "Save"icon.

3) Create System
      Go To SLD Tab
      Click "Create System"
      Select "F:AnySystem" on the Type
      Enter Name of the System.
      Select "Id" on the ID .
      Enter "output Path" in filePattern FILO
       Eg: D:\SAPB1if\data????.xml
                Do not remove this "\data????.xml" content on the Input Box.
       Click "Test Connection" button.
       Connect to <Name>(FILO) successfully.
       
         Click "Save"icon.       


4) Test
    Open SAP Business One
    Add Sale Order Document
    Go and Check Output Path Folder.
    XML File will created.like this (data0000 and so on)....

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).   

12 March 2018

Fill Record into Grid through SDK

Dear All,
   Today , We will see, How to Fill Record into Grid through SDK.



 Public Sub FillRecordIntoGrid(ByVal aform As SAPbouiCOM.Form, ByVal oGridUid As Object, ByVal strQuery As String)
        Dim dtTemp As SAPbouiCOM.DataTable = Nothing
        Dim oGrid As SAPbouiCOM.Grid = Nothing
        Try
            aform.Freeze(True)
            oGrid = aform.Items.Item(oGridUid).Specific
            dtTemp = oGrid.DataTable
            dtTemp.ExecuteQuery(strQuery)
            oGrid.DataTable = dtTemp
        Catch ex As Exception
        Finally
            If dtTemp IsNot Nothing Then
                dtTemp = Nothing
            End If
            aform.Freeze(False)
        End Try
    End Sub

Add user Permission to Form through SDK

Dear All,
   Today , We will see, How to Add user Permission to Form through SDK


 Public Function AddUserPermissionTree(ByVal strPermissionId As String, ByVal strName As String, ByVal strMode As SAPbobsCOM.BoUPTOptions, ByVal intLevel As Integer, ByVal strFatherId As String) As Boolean
        '**********************************************
        '' DECLARE LOCAL VARIABLE(S)
        '**********************************************
        Dim li_RetVal As Integer = 0
        Dim pUserPer As SAPbobsCOM.UserPermissionTree = Nothing
        Dim blnReturn As Boolean = False
        '**********************************************
        oApp = New ClsSAPConn
        pUserPer = oApp.SAPCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserPermissionTree)
        '**********************************************
        Try
            If pUserPer.GetByKey(strPermissionId) = False Then
                pUserPer.PermissionID = strPermissionId
                pUserPer.Name = strName

                pUserPer.Options = strMode
                li_RetVal = pUserPer.Add()
                If li_RetVal <> 0 Then
                    blnReturn = False
                Else
                    blnReturn = True
                End If
            Else
                pUserPer.Name = strName
                pUserPer.Options = strMode
                li_RetVal = pUserPer.Update()
                If li_RetVal <> 0 Then
                    blnReturn = False
                Else
                    blnReturn = True
                End If
            End If
        Catch ex As Exception
            blnReturn = False
        Finally
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pUserPer)
            If oApp IsNot Nothing Then
                oApp = Nothing
            End If
        End Try
        Return blnReturn
    End Function

Add UDO to Add On Menu

   Dear All,
     
           Today, we will discuss to add User Defined Object to Add On menu .

            SAP does not support  , we  create User Defined Object through SAP or SDK ,you need to map with only SAP Menu Id not Add On menu .
          If you are trying to through SDK ,you got error ,see blow error

           Invalid parent menu ID; specify an existing SAP Business One menu as the parent menu
     

                   
      

11 March 2018

Add UserDataSource To Form through SDK

Dear All,
   Today , We will see, How to Add UserDataSource To Form through SDK.


 Public Sub AddUserDataSourceToForm(ByVal aForm As SAPbouiCOM.Form, ByVal oUserDataSorce As String, ByVal strDateType As SAPbouiCOM.BoDataType, ByVal length As Integer)

        Try
            aForm.DataSources.UserDataSources.Add(oUserDataSorce, strDateType, length)
        Catch ex As Exception
        Finally
            If aForm IsNot Nothing Then
                aForm = Nothing
            End If
        End Try


    End Sub

A Step-by-Step Tutorial on Getting Item Alias Names through SDK

            To retrieve an Item Alias Name using the SAP Business One SDK in VB.NET, you can use the following code snippet



 Public Function GetItemAliasName(ByVal SBO_Application As SAPbouiCOM.Application, ByVal oFormType As String, ByVal strItemUid As String, Optional ByVal strColUid As String = "") As String
        Dim resource As SAPbouiCOM.ResourceData = Nothing
        Dim oFormInfo As SAPbouiCOM.FormInfo = Nothing
        Dim oItemInfo As SAPbouiCOM.ItemInfo = Nothing
        Dim strFormType As String = String.Empty
        resource = SBO_Application.ResourceData
        oFormInfo = resource.GetFormInfo(oFormType)
        Try
            oItemInfo = oFormInfo.GetItemInfo(strItemUid, strColUid)
            strFormType = oItemInfo.Alias.Trim
        Catch ex As Exception
            strFormType = String.Empty
        Finally
            If resource IsNot Nothing Then
                resource = Nothing
            End If
            If oFormInfo IsNot Nothing Then
                oFormInfo = Nothing
            End If
            If oItemInfo IsNot Nothing Then
                oItemInfo = Nothing
            End If
        End Try
        Return strFormType.Trim

    End Function

How to Get Form Info through the SAP B1 SDK

Dear All,
   Today , We will see, How to Get Form Info through SDK



    Public Function GetFormType(ByVal SBO_Application As SAPbouiCOM.Application, ByVal oFormType As String) As String
        Dim resource As SAPbouiCOM.ResourceData = Nothing
        Dim oFormInfo As SAPbouiCOM.FormInfo = Nothing
        Dim strFormType As String = String.Empty
        resource = SBO_Application.ResourceData
        oFormInfo = resource.GetFormInfo(oFormType)
        Try
            strFormType = oFormInfo.Type
        Catch ex As Exception
            strFormType = String.Empty
        Finally
            If resource IsNot Nothing Then
                resource = Nothing
            End If
            If oFormInfo IsNot Nothing Then
                oFormInfo = Nothing
            End If
        End Try
        Return strFormType.Trim

    End Function

10 March 2018

Add Form through SDK

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



  Public Sub AddForm(ByVal SBO_Application As SAPbouiCOM.Application, ByVal aForm As String, ByVal strUniqueID As String, ByVal strFormType As String, ByVal FormXml As String)
        Dim oForm As SAPbouiCOM.Form = Nothing
        Dim creationPackage As SAPbouiCOM.FormCreationParams = Nothing
        Try
            creationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
            creationPackage.UniqueID = strUniqueID
            creationPackage.FormType = strFormType
            creationPackage.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed
            creationPackage.XmlData = FormXml
            oForm = SBO_Application.Forms.AddEx(creationPackage)

        Catch ex As Exception
        Finally
            If oForm IsNot Nothing Then
                oForm = Nothing
            End If
            If creationPackage IsNot Nothing Then
                creationPackage = Nothing
            End If

        End Try
        
    End Sub

Check Item Exists on Form through SDK

Dear All,
   Today , We will see, How to Check Item Exists on Form through SDK


Public Function IsCheckItemExists(ByVal aForm As SAPbouiCOM.Form, ByVal aItemUId As String) As Boolean
        Dim oItem As SAPbouiCOM.Item = Nothing
        Dim blnResult As Boolean = False
        Try
            oItem = aForm.Items.Item(aItemUId)
            blnResult = True

        Catch ex As Exception
            blnResult = False
        Finally
            If oItem IsNot Nothing Then
                oItem = Nothing
            End If
        End Try

        Return blnResult
    End Function

Check Form Exists through SDK

Dear All,
   Today , We will see, How to Check Form Exists through SDK



   Public Function IsCheckFormExists(ByVal SBO_App As SAPbouiCOM.Application, ByVal aForm As String) As Boolean
        Dim oForm As SAPbouiCOM.Form = Nothing
        Dim blnResult As Boolean = False
        Try
            oForm = SBO_App.Forms.Item(aForm)

            blnResult = True

        Catch ex As Exception
            blnResult = False
        Finally
            If oForm IsNot Nothing Then
                oForm = Nothing
            End If
        End Try

        Return blnResult
    End Function

Get Default Doc Series Number through SDK

Dear All,
   Today , We will see, How to Get Default Doc Series Number through SDK



    Public Enum SeriesNumber
        DefaultSeriesNumber
        FirstSeriesNumber
        NextSeriesNumber

    End Enum


   Public Function GetDefaultSeriesNum(ByVal strObjType As String, ByVal strMode As SeriesNumber) As Integer
        '**********************************************
        '' Declare Local Variable(s)
        '**********************************************
        Dim oCompanyService As SAPbobsCOM.CompanyService = Nothing
        Dim oSeriesService As SAPbobsCOM.SeriesService = Nothing
        Dim oSeries As Series = Nothing
        Dim oSeriesParams As SeriesParams = Nothing
        Dim oDocumentTypeParams As DocumentTypeParams = Nothing
        Dim intReturn As Integer = 0
        '**********************************************
         oCompanyService = oApplication.SAPCompany.GetCompanyService
        oSeriesService = oCompanyService.GetBusinessService(ServiceTypes.SeriesService)
        oSeries = oSeriesService.GetDataInterface(SeriesServiceDataInterfaces.ssdiSeries)
        oDocumentTypeParams = oSeriesService.GetDataInterface(SeriesServiceDataInterfaces.ssdiDocumentTypeParams)

        '**********************************************
        Try
            oDocumentTypeParams.Document = strObjType
            oSeries = oSeriesService.GetDefaultSeries(oDocumentTypeParams)
            Select Case strMode
                Case SeriesNumber.DefaultSeriesNumber
                    intReturn = oSeries.Name
                Case SeriesNumber.FirstSeriesNumber
                    intReturn = oSeries.InitialNumber
                Case SeriesNumber.NextSeriesNumber
                    intReturn = oSeries.NextNumber
            End Select

            Return True
        Catch ex As Exception
            Return False
        Finally
            If oCompanyService IsNot Nothing Then
                oCompanyService = Nothing
            End If
            If oSeriesService IsNot Nothing Then
                oSeriesService = Nothing
            End If
            If oSeries IsNot Nothing Then
                oSeries = Nothing
            End If
            If oSeriesParams IsNot Nothing Then
                oSeriesParams = Nothing
            End If
            If oDocumentTypeParams IsNot Nothing Then
                oDocumentTypeParams = Nothing
            End If
        End Try
    End Function

09 March 2018

Update Path Admin through SDK

Dear All,
   Today , We will see, How to Update Path Admin through SDK



Public Function UpdatePathAdmin(ByVal WordTemplateFolderPath As String, ByVal PicturesFolderPath As String, ByVal AttachmentsFolderPath As String, ByVal ExtensionsFolderPath As String) As Boolean
        Dim oCompanyService As SAPbobsCOM.CompanyService = Nothing
        Dim oPathAdmin As SAPbobsCOM.PathAdmin = Nothing
        oCompanyService = oApp.SAPCompany.GetCompanyService

        Try
            If Not String.IsNullOrEmpty(WordTemplateFolderPath) Then
                oPathAdmin.WordTemplateFolderPath = WordTemplateFolderPath
            Else
                oPathAdmin.WordTemplateFolderPath = oPathAdmin.WordTemplateFolderPath
            End If
            If Not String.IsNullOrEmpty(PicturesFolderPath) Then
                oPathAdmin.PicturesFolderPath = PicturesFolderPath
            Else
                oPathAdmin.PicturesFolderPath = oPathAdmin.PicturesFolderPath
            End If
            If Not String.IsNullOrEmpty(AttachmentsFolderPath) Then
                oPathAdmin.AttachmentsFolderPath = AttachmentsFolderPath
            Else
                oPathAdmin.AttachmentsFolderPath = oPathAdmin.AttachmentsFolderPath
            End If
            If Not String.IsNullOrEmpty(ExtensionsFolderPath) Then
                oPathAdmin.ExtensionsFolderPath = ExtensionsFolderPath
            Else
                oPathAdmin.ExtensionsFolderPath = oPathAdmin.ExtensionsFolderPath
            End If
            oCompanyService.UpdatePathAdmin(oPathAdmin)
            Return True
        Catch ex As Exception
            Return False
        Finally
            If oCompanyService IsNot Nothing Then
                oCompanyService = Nothing
            End If
        End Try
    End Function

Get System Currency through SAP Business one SDK

Dear All,
   Today , We will see, How to Get System Currency through SDK


  Public Function GetSysCurrency() As String
        Dim vObj As SAPbobsCOM.SBObob = Nothing
        oApp = New ClsSAPConn
        Dim oRS As SAPbobsCOM.Recordset
        Dim strSysCurrency As String = String.Empty
        vObj = oApp.SAPCompany.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)
        oRS = oApp.SAPCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
        Try
            oRS = vObj.GetSystemCurrency()
            strSysCurrency = oRS.Fields.Item(0).Value
        Catch ex As Exception
            strSysCurrency = String.Empty
        Finally
            If vObj IsNot Nothing Then
                vObj = Nothing
            End If
            System.Runtime.InteropServices.Marshal.ReleaseComObject(oRS)
            If oApp IsNot Nothing Then
                oApp = Nothing
            End If
        End Try
        Return strSysCurrency
    End Function

08 March 2018

Get Exchange Rate through SDK

Dear All,
   Today , We will see, How to Get Exchange Rate through SDK


  Public Sub SetExchangeRate(ByVal strSourceCurr As String, ByVal oDate As Date, ByVal dblValue As Double)
        Dim vObj As SAPbobsCOM.SBObob
        oApp = New ClsSAPConn
        vObj = oApp.SAPCompany.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)
        Try
            vObj.SetCurrencyRate(strSourceCurr, oDate, dblValue, True)
        Catch ex As Exception

        Finally
            If vObj IsNot Nothing Then
                vObj = Nothing
            End If
        End Try

    End Sub

Split String Price in Matrix SAP B1

Dear All,
   Today , We will see, How to Split string Price in Matrix SAP B1



    Public Function SAPPriceSpliter(ByVal aForm As SAPbouiCOM.Form, ByVal aMatrixUid As Object, ByVal oColId As Object, ByVal oRowId As Object) As Double
        '**********************************************
        ' Declare Local Variable
        '**********************************************
        Dim oMatrix As SAPbouiCOM.Matrix = Nothing
        Dim dblPurPrice As Double = 0
        '**********************************************
        oMatrix = aForm.Items.Item(aMatrixUid).Specific
        Try
            Dim result As String = Regex.Replace(oMatrix.Columns.Item(oColId).Cells.Item(oRowId).Specific.Value, "[a-zA-Z\s]+", String.Empty)
            dblPurPrice = Convert.ToDouble(result)
        Catch ex As Exception
            dblPurPrice = 0
        Finally
            If oMatrix IsNot Nothing Then
                oMatrix = Nothing
            End If
        End Try
        Return dblPurPrice

    End Function

Split String with Separator

Dear All,
   Today , We will see, How to Split String with Separator


 Public Function SplitString(ByVal str As String, ByVal strSeparator As String) As String()
        Dim strRight As String = String.Empty
        Dim strEmpty As String = strSeparator.Trim
        Dim strSplit() As String = Convert.ToString(str).Split(strEmpty)
        Return strSplit
    End Function

Convert String To Double

Dear All,
   Today , We will see, How to Convert String To Double.



 Public Function ConvertStringToDouble(ByVal str As String) As Double()
        Dim strRight As String = String.Empty
        Dim strSplit() As String = Convert.ToString(str).Split(":")
        Dim strLeft As String = strSplit(0)
        If strSplit.Length = 1 Then
            strRight = "00"
        Else
            strRight = strSplit(1)
        End If
        Dim result(1) As Double
        result(0) = strLeft
        If strRight.Length = 2 Then
            If Not strRight.Contains("00") Then
                result(1) = "." & strRight
            End If
        Else
            result(1) = strRight.Remove(3, 2)
        End If
        Return result
    End Function

Convert Date String To Date through SDK

Dear All,
   Today , We will see, How to Convert Date String To Date through SDK



Public Function ConvertDateStringToDate(ByVal strDateValue As String) As DateTime
        Dim vObj As SAPbobsCOM.SBObob = Nothing
        Dim retDate As DateTime
   
        vObj = oApplication.SAPCompany.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge)
        Try
            retDate = Convert.ToDateTime(vObj.Format_StringToDate(strDateValue).Fields.Item(0).Value)
        Catch ex As Exception
            retDate = Nothing
        Finally
           If vObj IsNot Nothing Then
                vObj = Nothing
            End If
        End Try
        Return retDate
    End Function

07 March 2018

Convert Time To StringFormat through SQL

Dear All,
   Today , We will see, How to Convert Time To StringFormat through SQL


strQuery = "SELECT CAST((" & noofHours & " / 60) as VARHAR(2)) + '" & & "' + CAST((" &  & "  % 60) as VARCHAR(2))"

SAP B1: How to Populate Combo Box Values Using SDK

Introduction:
In SAP Business One, combo boxes offer a convenient way to select predefined values within the user interface. Today, we'll delve into the SAP Business One Software Development Kit (SDK) to understand how to populate and fill a combo box dynamically.

Requirements:
SAP Business One SDK installed and configured.
Familiarity with C# or VB.NET programming languages.
Step-by-Step Guide:
1. Connect to SAP B1 Company Database
Ensure that your SDK environment is set up and correctly connected to the SAP B1 company database.

2. Access the Combo Box Object
Retrieve the combo box object you want to populate with values. Identify the specific combo box control by its unique ID or name.

3. Define Values to Populate
Prepare the values you wish to fill into the combo box. These can be retrieved from a database, predefined list, or generated dynamically.

4. Populate Combo Box with Values


 Public Sub FillComboBoxValue(ByVal oApp As Object, ByVal aForm As SAPbouiCOM.Form, ByVal aComUId As Object, ByVal strQuery As String, ByVal blnDefNew As Boolean)
        '********************************************
        '' DECLARE LOCAL VARIABLES'
        '********************************************
        Dim aCombo As SAPbouiCOM.ComboBox = Nothing
        Dim oRS As SAPbobsCOM.Recordset = Nothing
        '********************************************
        oApp = New ClsSAPConn
        '********************************************
        oRS = oApp.SAPCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
        aCombo = aForm.Items.Item(aComUId).Specific
        '******************************************
        Try

            oRS.DoQuery(strQuery)
            '' To Avoid Valid Value Issue
            If aCombo.ValidValues.Count > 0 Then
                For i As Integer = 1 To aCombo.ValidValues.Count
                    aCombo.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index)
                Next
            End If
            If oRS.RecordCount > 0 Then
                While Not oRS.EoF
                    aCombo.ValidValues.Add(oRS.Fields.Item(0).Value, oRS.Fields.Item(1).Value)
                    oRS.MoveNext()
                End While
            End If
            Select Case blnDefNew
                Case True
                    aCombo.ValidValues.Add("-9", "DEFINE NEW")
                Case False
                    aCombo.ValidValues.Add("", "")
            End Select
            aCombo.Item.DisplayDesc = True


        Catch ex As Exception
        Finally
            If aCombo IsNot Nothing Then
                aCombo = Nothing
            End If
            If oApp IsNot Nothing Then
                oApp = Nothing
            End If
        End Try
    End Sub

Set Current Date Edit Text through SDK

Dear All,
   Today , We will see, How to Set Current Date Edit Text through SDK


    Public Sub SetCurrentDate(ByVal aForm As SAPbouiCOM.Form, ByVal strEditText As String)
        Dim oEditText As SAPbouiCOM.EditText = Nothing
        oEditText = aForm.Items.Item(strEditText).Specific
        Try
            oEditText.Value = DateTime.Now.ToString("yyyyMMdd")
        Catch ex As Exception

        Finally
            If oEditText IsNot Nothing Then
                oEditText = Nothing
            End If
        End Try
    End Sub

Get Combo Box Selected Value SAP SDK

Dear All,
   Today , We will see, How to set Get Combo Box Selected Value through SDK.


Public Function GetComboBoxSelectedValue(ByVal oForm As SAPbouiCOM.Form, ByVal oComUID As String) As Object
        '*****************************************
        'DECLARE LOCAL VARIABLE(S)
        '*****************************************
        Dim oComboBox As SAPbouiCOM.ComboBox = Nothing
        '*****************************************
        oComboBox = oForm.Items.Item(oComUID).Specific
        Try
            Return oComboBox.Value.Trim()
        Catch ex As Exception
            Return Nothing
        Finally
          
        End Try
    End Function

Display Auto Select Value in ComboBox through SDK

Dear All,
   Today , We will see, How to Display Auto Select Value in ComboBox through SDK.


    Public Sub DisplayAutoSelValue(ByVal oApp As Object, ByVal aForm As SAPbouiCOM.Form, ByVal aComUId As Object, ByVal intIndex As Integer)

        '********************************************
        '' DECLARE LOCAL VARIABLES'
        '********************************************
        Dim aCombo As SAPbouiCOM.ComboBox = Nothing
        Dim oRS As SAPbobsCOM.Recordset = Nothing
        '********************************************
        oApp = New ClsSAPConn
        '********************************************
        oRS = oApp.SAPCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
        aCombo = aForm.Items.Item(aComUId).Specific
        '********************************************
        Try
            aCombo.Select(intIndex, SAPbouiCOM.BoSearchKey.psk_Index)
        Catch ex As Exception
        Finally
            If aCombo IsNot Nothing Then
                aCombo = Nothing
            End If
            If oApp IsNot Nothing Then
                oApp = Nothing
            End If
        End Try
    End Sub

06 March 2018

Add button through SDK

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



Friend Sub AddButton(ByVal objForm As SAPbouiCOM.Form, ByVal SourceID As String, ByVal ItemUID As String, ByVal iLeft As Integer, ByVal iWidth As Integer, ByVal LinkTo As String, ByVal Caption As String, ByVal iHeight As Integer)
        Try
            Dim oItem As SAPbouiCOM.Item
            If objForm IsNot Nothing Then
                oItem = objForm.Items.Add(ItemUID, SAPbouiCOM.BoFormItemTypes.it_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.Button = objForm.Items.Item(ItemUID).Specific '' To Assign New Button
                btn.Caption = Caption
            End If
        Catch ex As Exception

        Finally
          
        End Try
    End Sub

Cursor focus on Grid Row

Dear All,
   Today , We will see, How to set Cursor focus on Grid Row through SDK.



C#.Net
_Grid.Columns.Item("Colunique").Click(0, false, 0);

VB.net
_Grid.Columns.Item("Colunique").Click(0, false, 0)

Get Matrix Combo Box Selected Value through SDK

Dear All,
   Today , We will see, How to Get Matrix Combo Box Selected Value through SDK.


Public Function GetComboBoxSelectedValue(ByVal oMatrix As SAPbouiCOM.Matrix, ByVal intRowIndex As Integer, ByVal intColIndex As Integer) As Integer
        Dim oComBo As SAPbouiCOM.ComboBox = oMatrix.Columns.Item(intColIndex).Cells.Item(intRowIndex).Specific
        Return oComBo.Value.Trim()
    End Function

05 March 2018

Get Date Separator SAP B1

Dear All,
   Today , We will see, Get Date Separator SAP B1 through SDK.



  Friend Function GetDateSep() As String
        Dim oCompanyService As SAPbobsCOM.CompanyService = Nothing
        Dim oCompanyAdminInfo As AdminInfo = Nothing
        Dim strReturn As String = String.Empty
        'get company service
        oCompanyService = oApp.SAPCompany.GetCompanyService
        'get admin info
        oCompanyAdminInfo = oCompanyService.GetAdminInfo
        Try
            strReturn = oCompanyAdminInfo.DateSeparator
        Catch ex As Exception
            strReturn = String.Empty
        Finally
            If oCompanyService IsNot Nothing Then
                oCompanyService = Nothing
            End If
            If oCompanyAdminInfo IsNot Nothing Then
                oCompanyAdminInfo = Nothing
            End If
        End Try


        Return strReturn
    End Function

Display Define New and Display last value from UDT in SAP B1

Dear All,
   Today , We will see, How to Display Define New and Display last value from UDT through SDK.


Private Sub ComboBox0_ComboSelectAfter(ByVal sboObject As Object, ByVal pVal As SAPbouiCOM.SBOItemEventArg) Handles ComboBox0.ComboSelectAfter
            Try
                If Me.ComboBox0.Selected.Value = "-9" Then
                    SBO_Application.ActivateMenuItem("51202")
                Else
                    Me.ComboBox0.ExpandType = SAPbouiCOM.BoExpandType.et_ValueDescription
                End If
            Catch ex As Exception

            End Try
        End Sub
 Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

            If pVal.FormTypeEx = "SetColorComboBox.Form1" Then
                Select Case pVal.EventType
                    Case SAPbouiCOM.BoEventTypes.et_FORM_ACTIVATE
                        If pVal.ActionSuccess And pVal.BeforeAction = False Then
                            objForm = SBO_Application.Forms.Item(pVal.FormUID)
                            If objForm IsNot Nothing Then
                                blnForm = False
                                If blnForm = False Then
                                    ComboBoxLoadValues(Me.ComboBox0, "SELECT Code,Name FROM ""@TESTDEFINENEW""  Order by Code")
                                    Me.ComboBox0.Item.DisplayDesc = True
                                End If
                            End If

                        End If
                End Select
            End If
        End Sub

        Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
            If pVal.BeforeAction And pVal.MenuUID = "51202" Then
                ComboBox0.ValidValues.Remove(ComboBox0.ValidValues.Count - 1, SAPbouiCOM.BoSearchKey.psk_Index)
                ComboBox0.Item.Description = String.Empty
                blnForm = True
            End If

        End Sub




Get UDT Menu Id from SAP B1

Dear All,
   Today , We will see, How to Get UDT Menu Id from SAP B1 through SDK.


'' It is Only No Object Table Type
SELECT convert(nvarchar(6), row_number() over (order by t0.tablename) + 51201),T0.TableName, T0.Descr, T0.TblNum+ 51201 as [Menu ID] FROM OUTB T0 WHERE T0.ObjectType = 0 order by t0.tablename

Get UDO Menu ID SAP B1 SDK

Dear All,
   Today , We will see, How to Get UDO Menu ID SAP B1 SDK.


select 51119 + row_number() over (order by tableid), tableid
from
(
select distinct 
tableID from cufd
where tableid like N'@%'
and tableid not in
(
select '@' + tablename from oudo
)
and tableid not in
(
select '@' + tablename from udo1
)
) t
order by tableID

04 March 2018

AutoSum of Matrix Column

Dear All,
   Today , We will see, AutoSum of Matrix Column through SDK.


SAPbouiCOM.Column oColumn;
oColumn = (SAPbouiCOM.Column)oMatrixItem.Columns.Item("COLUID");           
oColumn.ColumnSetting.SumType = BoColumnSumType.bst_Auto;

Delete Grid Selected Row

Dear All,
   Today , We will see,Delete Grid Selected Row.


Grid0.DataTable.Rows.Remove(Grid0.GetDataTableRowIndex(Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_SelectionOrder)));

03 March 2018

Add Invoice for Service Item through DI API

Dear All,
   Today , We will see, Add Invoice for Service Item through DI API


serviceInvoice.DocType = BoDocumentTypes.dDocument_Service

Set value into matrix cell without change focus

Dear All,
   Today , We will see, Set value into matrix cell without change focus.
Write into Beforeaction=true and et_validate event.

form.Freeze(true);

var cell = matrix.GetCellFocus();

matrix.SetCellValue(columnId, row, value);

matrix.SetCellFocus(cell);

form.Freeze(false)

02 March 2018

Open Form through Menu ID SAP B1 SDK

Dear All,
   Today , We will see, How to Open Form through Menu ID SAP B1 SDK.


 Public Sub OpenFormThroughMenuId(ByVal SBO_Application As SAPbouiCOM.Application, ByVal oActMenu As String)
        SBO_Application.ActivateMenuItem(oActMenu)
    End Sub

Bind Current Date through SDK

Dear All,
   Today , We will see, How to Bind Current Date in Edit Text through SDK



Public Sub BindDate(ByVal oForm As SAPbouiCOM.Form, ByVal oDsName As Object, ByVal dbAlias As Object)

        Dim oDBDataSource As SAPbouiCOM.DBDataSource = Nothing
        oDBDataSource = oForm.DataSources.DBDataSources.Item(oDsName)
        Try
            With oDBDataSource
                .SetValue(dbAlias, 0, DateTime.Today.ToString("yyyyMMdd"))
            End With
        Catch ex As Exception
        End Try
    End Sub

Assign CFL To EditText through SDK

Dear All,
   Today , We will see, How to Assign CFL To EditText through SDK



 Public Sub AssignCFLToEditText(ByVal aForm As SAPbouiCOM.Form, ByVal strEditUid As String, ByVal strCFLId As String, ByVal strCFLAliase As String)
        Dim oItem As SAPbouiCOM.Item = Nothing
        Dim oEdit As SAPbouiCOM.EditText = Nothing
        Try
            oItem = aForm.Items.Item(strEditUid)
            oEdit = oItem.Specific
            oEdit.ChooseFromListUID = strCFLId
            oEdit.ChooseFromListAlias = strCFLAliase
        Catch ex As Exception

        Finally
            If oItem IsNot Nothing Then
                oItem = Nothing
            End If
            If oEdit IsNot Nothing Then
                oEdit = Nothing
            End If
        End Try


    End Sub

Get Current User Signature through SDK

Dear All,
   Today , We will see, How to Get Current User Signature through SDK



oApplication.SAPCompany.UserSignature

Get Current User Name through SDK

Dear All,
   Today , We will see, How to Get Current User Name through SDK



oApplication.SAPCompany.UserName.Trim

Set Cell BackColor and ForeColor through SAP B1 SDK

Dear All,
   Today , We will see, How to set CellB Back Color and ForeColor through SDK.



Imports System.Drawings

oGrid.Column.Item("ColName").Backcolor = ColorTranslator.ToOle(Color.White)