Welcome Notes

Welcome Viewers

13 April 2017

Bind Current Date SAP B1


Dear All,

   We will see to bind Current Date through DBDataSoruce Using SAP B1 SDK?


Friend 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, 1, String2date(Date.Now.ToString("dd-MM-yyyy", CultureInfo.CurrentCulture)))
                .SetValue(dbAlias, 0, DateTime.Today.ToString("yyyyMMdd"))
            End With
        Catch ex As Exception

        End Try

    End Sub

Display ButtonCombo caption SAP B1

Dear All,
   Today , we will see to Display Button Combo Caption through SAP SDK.


   Friend Sub DisplayComboBoxcaption(ByVal oForm As SAPbouiCOM.Form, ByVal butComboUid As String, ByVal butComCaption As String)
        Try

            Dim oComButton As SAPbouiCOM.ButtonCombo = Nothing
            oComButton = oForm.Items.Item(butComboUid).Specific
            If butComCaption = "CopyFrom" Then
                oComButton.Caption = "Copy From"
            ElseIf butComCaption = "CopyTo" Then
                oComButton.Caption = "Copy To"
            End If
        Catch ex As Exception

        End Try


    End Sub

Enable Matrix ArrowKeys SAP B1

Dear All,
   Today we will see to Enable Matrix ArrowKeys through SAP SDK


  Friend Sub EnableMatrixArrowKeys(ByVal oForm As SAPbouiCOM.Form, ByVal oMatrixUID As String)
        Try
            Dim oMatrix As SAPbouiCOM.Matrix = Nothing
            oMatrix = oForm.Items.Item(oMatrixUID).Specific
            Dim oMatrixcomSetting As SAPbouiCOM.CommonSetting = oMatrix.CommonSetting
            oMatrixcomSetting.EnableArrowKey = True


        Catch ex As Exception

        End Try
    End Sub

Set Current Date Matrix Row SAP B1

Dear All,
   Today we will see "How to set Current Date in Matrix Row " using SAP SDK


    ''' <summary>
    ''' To Set Current Date in Matrix Column 
    ''' </summary>
    ''' <param name="oForm">Pass Form Name</param>
    ''' <param name="strMatrixUID">Pass Matrix ID</param>
    ''' <param name="strColUID">Pass Column ID</param>
    ''' <param name="intRowNumber">Pass Row Number</param>
    ''' <remarks></remarks>
    Friend Sub SetCurrentDateInMatrix(ByVal oForm As SAPbouiCOM.Form, ByVal strMatrixUID As String, ByVal strColUID As String, ByVal intRowNumber As Integer)
        Try
            Dim oMatrix As SAPbouiCOM.Matrix = Nothing
            Dim oETDate As SAPbouiCOM.EditText = Nothing
            oMatrix = oForm.Items.Item(strMatrixUID).Specific
            oETDate = oMatrix.Columns.Item(strColUID).Cells.Item(intRowNumber).Specific
            ' oMatrix.Columns.Item(strColUID).Cells.Item(intRowNumber).Specific.Value = String2date(DateTime.Now.ToString("dd-MM-yyyy"))
            oETDate.String = DateTime.Now.ToString("dd-MM-yyyy", CultureInfo.CurrentCulture)


        Catch ex As Exception

        End Try
    End Sub

Bind Document Series SAP B1

Dear All,
   Today we will see "How to Bind Document Series" using SAP B1 SDK?


  Friend Sub BindDocSeries(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, "5")

            End With

        Catch ex As Exception



        End Try



    End Sub


Get DataSource Value SAP B1

Dear All,
   Today, we will see How to get DataSource Value in SAP Business One.
Code Here,


    Friend Function GetDataSourceValue(ByVal oForm As SAPbouiCOM.Form, ByVal odbSoruce As Object, ByVal odbAlias As Object) As String

        Dim oDBDataSource As SAPbouiCOM.DBDataSource = Nothing

        Dim strRetValue As String = String.Empty

        oDBDataSource = oForm.DataSources.DBDataSources.Item(odbSoruce)

        With oDBDataSource

            strRetValue = .GetValue(odbAlias, 0)

        End With



        Return strRetValue

    End Function

12 April 2017

Matrix CFL SAP B1


Dear All,
   Today ,we will see to set CFL in Matrix through SAP B1 SDK.

''' <summary>
    ''' Get CFL Data and Display Matrix  [Change Name MatrixDisplayCFL  To DisplayCFLToMatrix] On 06.01.2017

    ''' </summary>

    ''' <param name="oForm">Pass Form Name</param>

    ''' <param name="oMatrix">Pass Matrix</param>

    ''' <param name="itemUID">Pass Matrix Unique ID</param>

    ''' <param name="colName">Pass Column Name</param>

    ''' <param name="pVal">Refer Item Event</param>

    ''' <returns></returns>

    ''' <remarks></remarks>

    Friend Function DisplayCFLToMatrix(ByVal oForm As SAPbouiCOM.Form, ByVal oMatrix As SAPbouiCOM.Matrix, ByVal itemUID As String, ByVal colName As String, ByRef pVal As SAPbouiCOM.ItemEvent) As String

        Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent = Nothing

        Dim oCFL As SAPbouiCOM.ChooseFromList = Nothing

        Dim sCHFL_ID As String = String.Empty

        Dim val As String = String.Empty

        Dim oDataTable As SAPbouiCOM.DataTable = Nothing

        Try

            oCFLEvento = pVal

            sCHFL_ID = oCFLEvento.ChooseFromListUID

            oCFL = oForm.ChooseFromLists.Item(sCHFL_ID)

            If (oCFLEvento.BeforeAction = False) Then

                oDataTable = oCFLEvento.SelectedObjects

                Select Case pVal.ItemUID

                    Case itemUID

                        oMatrix = oForm.Items.Item(itemUID).Specific

                        val = oDataTable.GetValue(colName, 0)

                End Select

            End If

        Catch ex As Exception

        Finally

            oDataTable = Nothing

            oCFLEvento = Nothing

            oCFL = Nothing

        End Try

        Return val

    End Function

Set Document Series SAP B1

Dear All,
   We will see how to set Document Series in ComboBox using SAP Business one SDK.


   '***************************************************************

    '' Purpose : To Display Document Series in the Form

    '' Created Date : 24-11-2016; Author : LAKSHMI NARAYANAN.S

    '***************************************************************

    Friend Sub AddDocSeries(ByVal oForm As SAPbouiCOM.Form, ByVal oComboUID As Object)

        Try

            Dim oComboBox As SAPbouiCOM.ComboBox = Nothing

            oComboBox = oForm.Items.Item(oComboUID).Specific

            If oComboBox.ValidValues.Count > 0 Then

                While oComboBox.ValidValues.Count > 0

                    oComboBox.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index)

                End While

            End If

            oComboBox.ValidValues.Add("5", "Primary")

            oComboBox.ValidValues.Add("-1", "Manual")

            oComboBox.ValidValues.Add("", "")

            oComboBox.Item.DisplayDesc = True

            oComboBox.ExpandType = SAPbouiCOM.BoExpandType.et_DescriptionOnly



        Catch ex As Exception



        Finally



        End Try

    End Sub

Get Document Ownership Name SAP B1

   
Dear All,
   Today ,we will see how to Get Login User Name from SAP B1 throuh SDK


    ''' <summary>
    ''' Get Login Employee Name
    ''' </summary>
    ''' <param name="strLogin">Pass Login Name</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetOnwerDetails(ByVal strLogin As String) As String()
        Dim ORs As SAPbobsCOM.Recordset = Nothing
        Dim strSelQuery As String = String.Empty
        Dim strEmpName As String = String.Empty
        Dim strempID As String = String.Empty
        ORs = oApplication.SapCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
        Try
            If Not String.IsNullOrEmpty(strLogin) Then
                strSelQuery = "SELECT T2.[empID] , ISNULL(T2.[firstName],'') + ' ' + ISNULL(T2.[middleName],'') + ' '+  ISNULL(T2.[lastName],'') as 'EmpName' FROM [dbo].[OUSR]  T1 INNER JOIN OHEM T2 ON T1.[USERID] = T2.[userId] AND  T1.[USERID]='" & strLogin & "'"
                ORs.DoQuery(strSelQuery)
                If ORs.RecordCount > 0 Then
                    strempID = ORs.Fields.Item(0).Value
                    strEmpName = ORs.Fields.Item("EmpName").Value
                Else
                    strempID = String.Empty
                    strEmpName = String.Empty
                End If
            End If
        Catch ex As Exception
        Finally
            System.Runtime.InteropServices.Marshal.ReleaseComObject(ORs)
        End Try
        Return New String() {strempID, strEmpName}
    End Function

Display Project Details in CFL


Dear All,
   Today, we will discuss about below points
1) Display Active Project
2) Display Project based on Posting Date.

Code Here,


  '*************************************************************************************************************

    'Type               : Friend  Sub

    'Name               : CardDetailsCondition

    'Parameter          :

    'Return Value       :

    'Author             : Lakshmi Narayanan

    'Created Dt         : 26-11-2016

    'Last Modified By   :                       

    'Modified Dt        :

    'Purpose            : This Method is used for Project Details CFL Condition

    '*************************************************************************************************************

    Friend Sub ProjectDetailsCondition(ByVal SBO_Application As SAPbouiCOM.Application, ByVal oForm As SAPbouiCOM.Form, ByVal cflIndex As Object, ByVal strPostingDate As Object)

        Dim ocfl As SAPbouiCOM.ChooseFromList = Nothing

        'Dim oCFLcollection As SAPbouiCOM.ChooseFromListCollection

        Dim ocondition As SAPbouiCOM.Condition = Nothing

        Dim oconditions As SAPbouiCOM.Conditions = Nothing

        'oCFLcollection = oForm.ChooseFromLists

        ocfl = SBO_Application.Forms.ActiveForm.ChooseFromLists.Item(cflIndex)

        Try

            oconditions = ocfl.GetConditions

            If 0 = oconditions.Count Then

                ocondition = oconditions.Add

                ocondition.Alias = "Active"

                ocondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

                ocondition.CondVal = "Y"

                ocondition.Alias = "ValidTo"

                ocondition.Operation = SAPbouiCOM.BoConditionOperation.co_GRATER_THAN

                ocondition.CondVal = strPostingDate



                ocfl.SetConditions(oconditions)

            End If

        Catch ex As Exception



        Finally

            ocfl = Nothing

            ocondition = Nothing

            oconditions = Nothing



        End Try

       

    End Sub