cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_REPMANCONF1_CREATE_MTS problem

Former Member
0 Kudos

Hi all you experts,

I'm having the following problem. I'm developing a database with MS Access 2003 and want to use the RFC BAPI_REPMANCONF1_CREATE_MTS to execute a backflushing to stock. I've written the following code to achieve this. The problem is, when I execute the code there are no error and everything seems to run fine. Except I don't see the transaction in SAP. Who can help me? What I'm doing wrong? Thank you for your help.

This is de code I use.

Public Function MFBF()

'*********************************************
'Connection Log-IN

Dim oBAPICtrl As Object

Set oBAPICtrl = CreateObject("SAP.Functions")

oBAPICtrl.Connection.ApplicationServer = "xxx.xxx.xxx.xxx"
oBAPICtrl.Connection.SystemNumber = "02"
oBAPICtrl.Connection.SystemID = "C34"
oBAPICtrl.Connection.Client = "200"
oBAPICtrl.Connection.User = "**********"
oBAPICtrl.Connection.Language = "EN"
oBAPICtrl.Connection.Password = "**********"
oBAPICtrl.Connection.Logon 1, True

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

If oBAPICtrl.Connection.Logon = True Then

    If oBAPICtrl.Connection.ConnectionHandle = 0 Then
        MsgBox "Could not connect on SAP"
        Exit Function
    End If

    Set MyFunc = oBAPICtrl.Add("BAPI_REPMANCONF1_CREATE_MTS")

    If MyFunc Is Nothing Then
        MsgBox "Unknown function"
        Exit Function
    End If

    Set oBflushFlags = MyFunc.Exports("BFLUSHFLAGS")
    Set oBflushDataGen = MyFunc.Exports("BFLUSHDATAGEN")
    Set oBflushDataMTS = MyFunc.Exports("BFLUSHDATAMTS")
    oBflushFlags.Value("BCKFLTYPE") = "1"
    oBflushDataGen.Value("PRODPLANT") = "2724"
    oBflushDataGen.Value("STORAGELOC") = "EPSS"
    oBflushDataGen.Value("BATCH") = ""
    oBflushDataGen.Value("PRODVERSION") = "1"
    oBflushDataGen.Value("POSTDATE") = "20101216"
    oBflushDataGen.Value("DOCDATE") = "20101216"
    oBflushDataGen.Value("BACKFLQUANT") = "10"
    oBflushDataGen.Value("MATERIALNR") = "2516801"
    bResult = MyFunc.Call
    
    If bResult <> True Then
        Set oReturn = MyFunc.Imports("RETURN")
        If oReturn.Value("TYPE") = "A" Or oReturn.Value("TYPE") = "E" Then
            MsgBox "Create Structure Error (" + oReturn.Value("TYPE") + ") " + oReturn.Value("MESSAGE")
            MsgBox oReturn.Name
            oBAPICtrl.Connection.Logoff
            bResult = ""
            Set oBAPICtrl = Nothing
        End If
        Exit Function
    End If
    
    Set oReturn = MyFunc.Imports("CONFIRMATION")
    MsgBox oReturn.Value

    Set MyFunc = oBAPICtrl.Add("BAPI_TRANSACTION_COMMIT")
    bResult = MyFunc.Call
    
    If bResult <> True Then
        Set oReturn = MyFunc.Imports("CONFIRMATION")
        If oReturn.Value("TYPE") = "A" Or oReturn.Value("TYPE") = "E" Then
            MsgBox "Commit Error " + oReturn.Value("TYPE") + " " + oReturn.Value("MESSAGE")
            MsgBox oReturn.Name
            oBAPICtrl.Connection.Logoff
            bResult = ""
            Set oBAPICtrl = Nothing
        End If
        Exit Function
    End If
    BAPI_REPMANCONF1_CREATE_MTSV2 = True
Else
    Set oReturn = MyFunc.Imports("RETURN")
    MsgBox ("Connection not Made To Sap Exiting The function")
    MsgBox "Connection Error " + oReturn.Value("TYPE") + " " + oReturn.Value("MESSAGE")
    oBAPICtrl.Connection.Logoff
    MsgBox oReturn.Name
    SAP_CONNECTED = 0
    Set oBAPICtrl = Nothing
    bResult = ""
    Exit Function
End If

End Function

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi,

I didn't get what you meant by "didn't see the transaction in SAP".

However, please add the following lines:

Set oBAPICtrl = CreateObject("SAP.Functions")

oBAPICtrl.LogFileName="C:\FunctionLog.log"

oBAPICtrl.LogLevel=10

This will generate the trace file. Verify whether there is any exception or error gets recorded in the trace file.

Regards,

Dinesh