Welcome Notes

Welcome Viewers

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