Hi, I have the following Problem:
I want the upload some Files to SAP dms System.
First of all i implement the functionmodule "BAPI_DOCUMENT_CREATE2" in my .net Programm.
Then i tested tue Applikation... and the RFC call creates an correct document Info set in erp. I can have a look on it, with CV03N.
Now i wanted to implement the fileupload.
So i filled the Table DOCUMENTFILES ANd copied the sapftp.exe in my Program Exekution Directory.
If i now call my .net Program, it crashes with the exception "callback not supported".
What is my Problem?
I cant Figure it out.... Thanks for the help.
My Code:
Imports SAP.Middleware.Connector Imports System.IO Public Class frmMain Public Sub New() ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. RfcDestinationManager.RegisterDestinationConfiguration(New MyBackendConfig) End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'SAP TRANSACTIONS: 'CV01N - Create Document 'CV02N - Change Document 'CV04N - Find Document 'CV03N - Display document System.Windows.Forms.Cursor.Current = Cursors.WaitCursor #If DEBUG Then txtPfad.Text = "C:\Users\bkoch\Desktop\20141126153403.pdf" #End If ' Get a destination object from the destination manager Dim SapRfcDest As RfcDestination = RfcDestinationManager.GetDestination("DEV") Try ' Create connection to the RFC repository Dim SapRfcRepo As RfcRepository = SapRfcDest.Repository ' BAPI functionmodules Dim documentCreateBapi As IRfcFunction = SapRfcRepo.CreateFunction("BAPI_DOCUMENT_CREATE2") Dim bapiRollback As IRfcFunction = SapRfcRepo.CreateFunction("BAPI_TRANSACTION_ROLLBACK") Dim bapiCommit As IRfcFunction = SapRfcRepo.CreateFunction("BAPI_TRANSACTION_COMMIT") ' Structures Dim documentData As IRfcStructure = documentCreateBapi.GetStructure("DOCUMENTDATA") Dim bapireturn As IRfcStructure = documentCreateBapi.GetStructure("RETURN") Dim documentFiles As IRfcTable = documentCreateBapi.GetTable("DOCUMENTFILES") ' Fill fields documentCreateBapi.SetValue("HOSTNAME", My.Computer.Name) documentCreateBapi.SetValue("PF_FTP_DEST", "SAPFTP") ' Fill Fields for only one document documentData.SetValue("DOCUMENTTYPE", "ZOQ") documentData.SetValue("DOCUMENTNUMBER", "TEST DOCUMENT 01") documentData.SetValue("DOCUMENTVERSION", "00") documentData.SetValue("DOCUMENTPART", "000") documentData.SetValue("VALIDFROMDATE", System.DateTime.Now) documentData.SetValue("REVLEVEL", "00") documentData.SetValue("DESCRIPTION", "Test Document 01 Created via NCo3") documentData.SetValue("USERNAME", SapRfcDest.User.ToUpper) documentData.SetValue("AUTHORITYGROUP", "BVV") ' Fill documentFiles Table documentFiles.Append() documentFiles.SetValue("WSAPPLICATION", SetExtensionToSapExtension(Path.GetExtension(txtPfad.Text))) 'documentFiles.SetValue("DOCPATH", (Path.GetDirectoryName(txtPfad.Text) & "\").ToUpper) documentFiles.SetValue("DOCFILE", txtPfad.Text) '(Path.GetFileName(txtPfad.Text)).ToUpper) documentFiles.SetValue("LANGUAGE", "DE") documentFiles.SetValue("DESCRIPTION", "Test Document 01 Created via NCo3") documentFiles.SetValue("CHECKEDIN", "X") documentFiles.SetValue("STORAGECATEGORY", "ZBVV_LOGI") documentFiles.SetValue("CREATED_BY", SapRfcDest.User.ToUpper) RfcSessionManager.BeginContext(SapRfcDest) documentCreateBapi.Invoke(SapRfcDest) Dim DOCUMENTTYPE As String = documentCreateBapi.GetValue("DOCUMENTTYPE").ToString() Dim DOCUMENTNUMBER As String = documentCreateBapi.GetValue("DOCUMENTNUMBER").ToString() Dim DOCUMENTPART As String = documentCreateBapi.GetValue("DOCUMENTPART").ToString() Dim DOCUMENTVERSION As String = documentCreateBapi.GetValue("DOCUMENTVERSION").ToString() Select Case bapireturn.GetValue("TYPE").ToString Case "A" MessageBox.Show(bapireturn.GetValue("MESSAGE").ToString, bapireturn.GetValue("TYPE").ToString, MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1) bapiRollback.Invoke(SapRfcDest) Case "E" MessageBox.Show(bapireturn.GetValue("MESSAGE").ToString, bapireturn.GetValue("TYPE").ToString, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1) bapiRollback.Invoke(SapRfcDest) Case "W" If bapireturn.GetValue("MESSAGE").ToString <> String.Empty Then MessageBox.Show(bapireturn.GetValue("MESSAGE").ToString, bapireturn.GetValue("TYPE").ToString, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) MessageBox.Show(String.Format("Datei: '{0}', Type: '{1}', Part: '{2}', Version: '{3}' angelegt!", DOCUMENTNUMBER, DOCUMENTTYPE, DOCUMENTPART, DOCUMENTVERSION)) bapiCommit.Invoke(SapRfcDest) Case Else If bapireturn.GetValue("MESSAGE").ToString <> String.Empty Then MessageBox.Show(bapireturn.GetValue("MESSAGE").ToString, bapireturn.GetValue("TYPE").ToString, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) MessageBox.Show(String.Format("Datei: '{0}', Type: '{1}', Part: '{2}', Version: '{3}' angelegt!", DOCUMENTNUMBER, DOCUMENTTYPE, DOCUMENTPART, DOCUMENTVERSION)) bapiCommit.Invoke(SapRfcDest) End Select RfcSessionManager.EndContext(SapRfcDest) Catch ex As RfcCommunicationException MessageBox.Show(ex.Message, "RfcCommunicationException") Catch ex As RfcLogonException MessageBox.Show(ex.Message, "RfcLogonException") Catch ex As RfcAbapRuntimeException MessageBox.Show(ex.Message, "RfcAbapRuntimeException") Catch ex As RfcAbapBaseException MessageBox.Show(ex.Message, "RfcAbapBaseException") Catch ex As Exception MessageBox.Show(ex.Message, "Exception") Finally System.Windows.Forms.Cursor.Current = Cursors.Default End Try End Sub Private Sub btnPfad_Click(sender As Object, e As EventArgs) Handles btnPfad.Click Using _ofd As New OpenFileDialog _ofd.Multiselect = False If _ofd.ShowDialog <> Windows.Forms.DialogResult.Cancel Then txtPfad.Text = _ofd.FileName Else txtPfad.Text = String.Empty End If End Using End Sub Private Function SetExtensionToSapExtension(ByVal extension As String) As String If extension.Contains(".") Then Return extension.Substring(1, extension.Length - 1).ToUpper Else Return extension.ToUpper End If End Function End Class
Add a comment