Welcome Notes

Welcome Viewers
Showing posts with label SAP B1 SDK. Show all posts
Showing posts with label SAP B1 SDK. Show all posts

29 February 2024

Distinguishing between `BoRecordset` and `BoRecordsetEx` within the SAP Business One SDK

 Distinguishing between `BoRecordset` and `BoRecordsetEx` within the SAP Business One SDK framework reveals key disparities in functionality and utility


1. BoRecordset:

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

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

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

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

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)