Welcome Notes

Welcome Viewers

12 April 2017

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