Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing a cursor to a SAP Function ????
Message
De
04/04/2006 06:52:45
Albert Beermann
Piepenbrock Service Gmbh & Cokg
Osnabrück, Allemagne
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Passing a cursor to a SAP Function ????
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MySQL
Divers
Thread ID:
01110208
Message ID:
01110208
Vues:
128
Hello Everybody !

I want to make a connection to an SAP-System and pass a existing cursor (array) to a bapi function.
    functionCtrl = CreateObject("SAP.Functions")
    sapConnection = functionCtrl.Connection
    sapConnection.Client = "900"
    sapConnection.User = "RFC"
    sapConnection.Language = "DE"
    sapConnection.System = "PU1"
    sapConnection.ApplicationServer = "128.1.1.5"
    sapConnection.Password = "xyz"

    If sapConnection.Logon(0, .T.) <> .T.
        WAIT clear
        MESSAGEBOX("No Connection to R/3!",0.p_messagetitel)
        return                                           
    EndIf
* calling the sapfunction
    theFunc = functionCtrl.Add("Z_COFU_INNENAUF_RFC")
Up to here everything works !!!!

Now sap needs a table "I_Auf" and i want to pass my cursor "myauf" (which i have created and manipulated in Foxpro befor) to the sap function.

I have no idea how to code this in foxpro ??????

With visual basic we did it this way:
Sub Auftraege()
    Dim iRow As Integer
    
    Dim functionCtrl As Object             'Function Control (Sammelobjekt)
    Dim sapConnection As Object            'Verbindungsobjekt
    Dim theFunc As Object                  'Function Objekt
    Dim returnFunc As Boolean            ' Rückgabewert des FB
    Dim meldungen As Object
    Dim i_auf As Object
    
    
    Dim aufdat
    Dim Filename As String
    Dim StrLineText As String
    Dim aufArray() As Variant
    Dim aufFelder
    Dim i As Integer
    
    Set functionCtrl = CreateObject("SAP.Functions")
    Set sapConnection = functionCtrl.Connection
    
    sapConnection.Client = "900"
    sapConnection.User = "RFC"
    sapConnection.Language = "DE"
   
   
    sapConnection.System = "PU1"
    sapConnection.ApplicationServer = "128.1.1.5"
    sapConnection.Password = "xyz"
    
    If sapConnection.Logon(0, True) <> True Then
        MsgBox "no connection to R/3!"
        Exit Sub                                          
    End If
    
    Set theFunc = functionCtrl.Add("Z_COFU_INNENAUF_RFC")
    Set i_auf = theFunc.tables.Item("I_AUF")
    
   
    ' reading a text file with data
    ' this is the data i have in my foxprocursor mentioned above
    ' we create it with copy to type csv	

    Filename = "u:\aufsapc.txt"
    aufdat = FreeFile()
    Open Filename For Input As #aufdat
    While Not EOF(aufdat)
      Line Input #aufdat, StrLineText
      ReDim Preserve aufArray(12, i)
      aufArray(0, i) = Mid(StrLineText, 1, 12)
      aufArray(1, i) = Mid(StrLineText, 13, 4)
      aufArray(2, i) = Mid(StrLineText, 17, 40)
      aufArray(3, i) = Mid(StrLineText, 57, 4)
      aufArray(4, i) = Mid(StrLineText, 61, 4)
      aufArray(5, i) = Mid(StrLineText, 65, 10)
      aufArray(6, i) = Mid(StrLineText, 75, 10)
      aufArray(7, i) = Mid(StrLineText, 85, 8)
      aufArray(8, i) = Mid(StrLineText, 93, 8)
      aufArray(9, i) = Mid(StrLineText, 101, 6)
      aufArray(10, i) = Mid(StrLineText, 107, 6)
      aufArray(11, i) = Mid(StrLineText, 113, 2)
      aufArray(12, i) = Mid(StrLineText, 115, 10)
      
       Set auftrag = i_auf.appendrow
       'For Each auftrag In i_auf.Rows
        auftrag("AUFNR") = aufArray(0, i)
        auftrag("AUART") = aufArray(1, i)
        auftrag("KTEXT") = aufArray(2, i)
        auftrag("BUKRS") = aufArray(3, i)
        auftrag("GSBER") = aufArray(4, i)
        auftrag("PRCTR") = aufArray(5, i)
        auftrag("KOSTV") = aufArray(6, i)
        auftrag("USER7") = aufArray(7, i)
        auftrag("USER8") = aufArray(8, i)
        auftrag("KALSM") = aufArray(9, i)
        auftrag("PROGP") = aufArray(10, i)
        auftrag("AENKZ") = aufArray(11, i)
        auftrag("BRCHE") = aufArray(12, i)
       'Next
      i = i + 1
    Wend
    
    theFunc.Exports("L_AUF") = StrLineText
      
   '   theFunc.tables("I_AUF").Rows = aufArray()
           
      returnFunc = theFunc.Call
      exeptnFunc = theFunc.Exception
      If returnFunc = True Then
        Set ok = theFunc.imports("OK")
        If ok = "" Then
            Set meldungen = theFunc.imports("L_MSG")
        End If
    
        Set i_msg = theFunc.tables("I_MSG")
        Set i_mtab = theFunc.tables("I_MTAB")
      Else
        MsgBox theFunc.Exception
      End If
   
   
    functionCtrl.Connection.Logoff
    
    Set sapConnection = Nothing
    Set functionCtrl = Nothing
    
    MsgBox "Finished!", vbInformation, "End"
    
End Sub
Any help welcomed

Best regards

Albert
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform