cancel
Showing results for 
Search instead for 
Did you mean: 

Browse Option in SAP

Former Member
0 Kudos

Hi Experts,

I want to Browse a txt file or xls file & fill a EditText with the File path..

Simply I want to attach a file in my own created Form in SAP..

How it can be done?

Thanks,

Nabanita Ghosh

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member209699
Contributor
0 Kudos

Hi,

This is in VB.Net

Call function as


Me.BrowseFileDialog(objForm)

-



  Sub ShowFolderBrowser()
        Dim MyTest As New OpenFileDialog
        Dim MyProcs() As Process
        MyProcs = Process.GetProcessesByName("SAP Business One")
        If MyProcs.Length <> 0 Then
            For i As Integer = 0 To MyProcs.Length - 1
                Dim MyWindow As New WindowWrapper(MyProcs(i).MainWindowHandle)
                MyTest.Filter = "Excel files (*.xls)|*.xls|Document files (*.doc)|*.doc"
                If MyTest.ShowDialog(MyWindow) = DialogResult.OK Then
                    If objForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE Or objForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE Then
                        objForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
                    End If
                    'MessageBox.Show(MyTest.FileName)
                    importpath = MyTest.FileName
                    If importpath <> Nothing Then
                        Try
                            Dim oDt As SAPbouiCOM.DataTable
                            oDt = Nothing
                            oDt = ReadXlDataFile(importpath)
                        Catch ex As Exception
                            MsgBox(ex.Message)
                            objForm.Freeze(False)
                        End Try
                    End If
                    System.Windows.Forms.Application.ExitThread()
                Else
                    System.Windows.Forms.Application.ExitThread()
                End If
            Next
        Else
            Console.WriteLine("No SBO instances found.")
        End If
    End Sub

-



    Sub BrowseFileDialog(ByVal objForm As SAPbouiCOM.Form)
        Try
            ShowFolderBrowserThread = New Threading.Thread(AddressOf ShowFolderBrowser)
            If ShowFolderBrowserThread.ThreadState = ThreadState.Unstarted Then
                ShowFolderBrowserThread.SetApartmentState(ApartmentState.STA)
                ShowFolderBrowserThread.Start()
                'ShowFolderBrowserThread.Join()
            ElseIf ShowFolderBrowserThread.ThreadState = ThreadState.Stopped Then
                ShowFolderBrowserThread.Start()
                ShowFolderBrowserThread.Join()
            End If
        Catch ex As Exception
            objMain.objApplication.StatusBar.SetText(ex.Message)
        End Try
    End Sub

End Class

Now if you want it in C#.. that you have to do yourself..

regards:

Sandy

Former Member
0 Kudos

hii,

thnx..I have used the given code.

Now I want to save the attachfile whose path is there in the EditText to a folder.

If I update the attach file path then the new file will be saved to the folder & old file will be deleted.

How it can be done?

Thanks,

Nabanita Ghosh.