N
Naos
Guest
Re bonsoir tout le monde,
La, je m'adresse principalement à développeur SAP qui sont aussi dingues que moi avec le VBA...
J'ai une erreur dans le code VBA suivant :
Je n'arrive pas à la résoudre...
Une petite aide serait vraiment la bienvenue. voila le code en question....
en fait, c'est un truc tout con :
cela sert à lancer un programme dans SAP pour faire une reprise de données.
Public Sub add_bdcdata(BdcTable As Object, program As String, dynpro As String, dynbegin As String, fnam As String, fval As String)
Dim vField As Variant
Static j As Integer
j = j + 1
BdcTable.Rows.Add
BdcTable.Value(j, "PROGRAM") = program ' Program Name
BdcTable.Value(j, "DYNPRO") = dynpro ' Dynpro Number
BdcTable.Value(j, "DYNBEGIN") = dynbegin ' X if a screen
BdcTable.Value(j, "FNAM") = fnam ' Field Name
BdcTable.Value(j, "FVAL") = fval ' Field Value
End Sub
Public Sub rfc_call_transaction()
Dim Functions As Object
Dim RfcCallTransaction As Object
Dim Messages As Object
Dim BdcTable As Object
' Create the Function control (that is, the high-level Functions collection):
Set Functions = CreateObject("SAP.Functions")
sapConnection.SystemInformation
' Set the rest of Connection object values:
Functions.Connection.System = "client"
Functions.Connection.client = "110"
Functions.Connection.user = "ALGUE"
Functions.Connection.password = ""
Functions.Connection.Language = "FR"
If Functions.Connection.Logon(0, False) <> True Then
Exit Sub
End If
' Retrieve the Function object (the Connection object must be set up before Function objects can be created):
Set RfcCallTransaction = Functions.Add("RFC_CALL_TRANSACTION")
' Set the export parameters (here, get all customers whose names start with J):
RfcCallTransaction.exports("TRANCODE") = "ZJOD"
RfcCallTransaction.exports("UPDMODE") = "S"
Set BdcTable = RfcCallTransaction.Tables("BDCTABLE")
Sheets("Paramétrage").Select
Cells.Select
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("C6").Select
DATA = ActiveCell.FormulaR1C1
Range("C7").Select
MAP = ActiveCell.FormulaR1C1
Range("C8").Select
FICHIER = ActiveCell.FormulaR1C1
' Set the tables parameter and add the data for the call transaction
add_bdcdata BdcTable, "ZRITSJOD", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "P_BTCI"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/00"
add_bdcdata BdcTable, "", "", "", "P_BTCI", "C:\reprise\coucou.dat"
add_bdcdata BdcTable, "ZRITSJOD", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "P_TEST"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=ONLI"
add_bdcdata BdcTable, "", "", "", "P_SESS", "ALGUE"
add_bdcdata BdcTable, "", "", "", "P_TEST", ""
add_bdcdata BdcTable, "", "", "", "P_KEEP", "X"
add_bdcdata BdcTable, "SAPMSSY0", "0120", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=BACK"
add_bdcdata BdcTable, "ZRITSJOD", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/EBACK"
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "P_BTCI"
' Call the function (if the result is false, then display a message):
If RfcCallTransaction.Call = True Then
' Set Messages = RfcCallTransaction.imports("MESSG")
' MsgBox Messages.Value("MSGTX")
Else
' MsgBox " Call Failed! error: " + GetCustomers.Exception
End If
Functions.Connection.Logoff
Sheets("Lancement de macro").Select
Range("A1").Select
End Sub
Merci à tous ceux qui pourront m'aider
Naos
La, je m'adresse principalement à développeur SAP qui sont aussi dingues que moi avec le VBA...
J'ai une erreur dans le code VBA suivant :
Je n'arrive pas à la résoudre...
Une petite aide serait vraiment la bienvenue. voila le code en question....
en fait, c'est un truc tout con :
cela sert à lancer un programme dans SAP pour faire une reprise de données.
Public Sub add_bdcdata(BdcTable As Object, program As String, dynpro As String, dynbegin As String, fnam As String, fval As String)
Dim vField As Variant
Static j As Integer
j = j + 1
BdcTable.Rows.Add
BdcTable.Value(j, "PROGRAM") = program ' Program Name
BdcTable.Value(j, "DYNPRO") = dynpro ' Dynpro Number
BdcTable.Value(j, "DYNBEGIN") = dynbegin ' X if a screen
BdcTable.Value(j, "FNAM") = fnam ' Field Name
BdcTable.Value(j, "FVAL") = fval ' Field Value
End Sub
Public Sub rfc_call_transaction()
Dim Functions As Object
Dim RfcCallTransaction As Object
Dim Messages As Object
Dim BdcTable As Object
' Create the Function control (that is, the high-level Functions collection):
Set Functions = CreateObject("SAP.Functions")
sapConnection.SystemInformation
' Set the rest of Connection object values:
Functions.Connection.System = "client"
Functions.Connection.client = "110"
Functions.Connection.user = "ALGUE"
Functions.Connection.password = ""
Functions.Connection.Language = "FR"
If Functions.Connection.Logon(0, False) <> True Then
Exit Sub
End If
' Retrieve the Function object (the Connection object must be set up before Function objects can be created):
Set RfcCallTransaction = Functions.Add("RFC_CALL_TRANSACTION")
' Set the export parameters (here, get all customers whose names start with J):
RfcCallTransaction.exports("TRANCODE") = "ZJOD"
RfcCallTransaction.exports("UPDMODE") = "S"
Set BdcTable = RfcCallTransaction.Tables("BDCTABLE")
Sheets("Paramétrage").Select
Cells.Select
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("C6").Select
DATA = ActiveCell.FormulaR1C1
Range("C7").Select
MAP = ActiveCell.FormulaR1C1
Range("C8").Select
FICHIER = ActiveCell.FormulaR1C1
' Set the tables parameter and add the data for the call transaction
add_bdcdata BdcTable, "ZRITSJOD", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "P_BTCI"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/00"
add_bdcdata BdcTable, "", "", "", "P_BTCI", "C:\reprise\coucou.dat"
add_bdcdata BdcTable, "ZRITSJOD", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "P_TEST"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=ONLI"
add_bdcdata BdcTable, "", "", "", "P_SESS", "ALGUE"
add_bdcdata BdcTable, "", "", "", "P_TEST", ""
add_bdcdata BdcTable, "", "", "", "P_KEEP", "X"
add_bdcdata BdcTable, "SAPMSSY0", "0120", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=BACK"
add_bdcdata BdcTable, "ZRITSJOD", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/EBACK"
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "P_BTCI"
' Call the function (if the result is false, then display a message):
If RfcCallTransaction.Call = True Then
' Set Messages = RfcCallTransaction.imports("MESSG")
' MsgBox Messages.Value("MSGTX")
Else
' MsgBox " Call Failed! error: " + GetCustomers.Exception
End If
Functions.Connection.Logoff
Sheets("Lancement de macro").Select
Range("A1").Select
End Sub
Merci à tous ceux qui pourront m'aider
Naos