当前位置:网站首页>VBA appelle SAP RFC pour réaliser la lecture et l'écriture des données
VBA appelle SAP RFC pour réaliser la lecture et l'écriture des données
2022-04-23 07:52:00 【Willie y】
1、RFCStructure
RFCConfiguration des propriétés:
RFCParamètres d'entrée:
ZSCE_MAT×Structure du tableau:
RFCParamètres de sortie:
2、VBACode
Public Const StartRow% = 2 ' Ligne de départ des données
Public Const EndRow% = 3 ' Ligne de fin de données
Public Const DataSheetName$ = "Data"
Public SAP As Object
'******************************************************************************
'* Function Desc:VBAAppelezSAP RFC
'* Author:
'* Param:
'* Returns:
'******************************************************************************
Sub InputData()
Dim WrtDataResult As String
Dim IMATNR$, ZYIELD$
If ContectSAP = False Then
MsgBox "ConnexionSAPÉchec"
Exit Sub
End If
If MsgBox("ConnexionSAPSuccès! Oui Non " & DataSheetName & "Importation de donnéesSAP?", vbYesNo, "Attention") = vbNo Then
Exit Sub
End If
Call OperationPrompts("Écrire des données àSAP,Attendez, s'il vous plaît.……")
Application.DisplayAlerts = False
Application.ScreenUpdating = False
With ThisWorkbook.Sheets(DataSheetName)
For i = StartRow To EndRow
IMATNR = .Cells(i, 1).Value
ZYIELD = .Cells(i, 2).Value
WrtDataResult = CallRFC(IMATNR, ZYIELD)
.Cells(i, 3).Value = WrtDataResult
Next i
'Déconnecter
SAP.Connection.LOGOFF
Call OperationPrompts("DéconnectéSAP……")
UF_Prompt.Label1.Caption = "【Programme terminé】"
ThisWorkbook.Save
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
AppelezRFCCode de base:
'******************************************************************************
'* Function Desc:VBAAppelezSAP RFC
'* Author:
'* Param:
'* MATNR_No:
'* ZYIELD_value:
'* Returns:
'******************************************************************************
Public Function CallRFC(MATNR_No$, ZYIELD_Value$) As String
Dim LogFlag As Boolean
Dim Result As String
Dim InputTable As Object
Dim Result1 As Object
Dim Result2 As Object
Set RFC = SAP.Add("RFC_Z_SCE_CHANGEMATERIAL")
Set InputTable = RFC.Tables("ZSCE_MAT_GDPW")
'rfc Assignation des tables de paramètres
With InputTable
.Rows.Add
.Value(.RowCount, "MATNR") = MATNR_No
'.Value(.ROWCOUNT, "VOLUM") = VOLUM_Value
.Value(.RowCount, "ZYIELD") = ZYIELD_Value
End With
'call RFC
LogFlag = RFC.Call
If LogFlag = True Then
' Définir les paramètres de retour
Set Result1 = RFC.Imports("ZMSGNO")
Set Result2 = RFC.Imports("ZMESSG")
CallRFC = MATNR_No & "," & Result1.Value & "," & Result2.Value
Else
CallRFC = "RFCL'appel a échoué!"
End If
InputTable.FreeTable
Set InputTable = Nothing
Set Result1 = Nothing
Set Result2 = Nothing
Set RFC = Nothing
End Function
Dans le CodeRFC L'assignation de la structure du tableau nécessite une assignation ligne par ligne .Exports Parameter Transfer participation ImportsParamètres similaires.
RFCDans l'appel de,ExportsIndique l'entréeRFCParamètres pour,ImportsReprésentationRFC Résultat de l'appel retourné .
Résumé:
Dans le travail quotidien,VBALireSAPTableau,Ou appelerRFCC'est plus pratique.,Pas besoin deSAPUtiliserABAP Développement et transmission de systèmes de production assortis , Fondamentalement, le code ci - dessus peut être modifié .
Pour de plus amples informations, veuillez consulter:ExcelVBAAvecSAPRFCInstance d'appel d'interface - Filet de douding
版权声明
本文为[Willie y]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230628041296.html
边栏推荐
猜你喜欢
Mongodb 启动警告信息处理
MySQL in window10 version does not work after setting remote access permission
Online Safe Trajectory Generation For Quadrotors Using Fast Marching Method and Bernstein Basis Poly
关于U盘数据提示RAW,需要格式化,数据恢复笔记
Mongodb starts warning information processing
基于NLP的软件安全研究(二)
Rethink | open the girl heart mode of station B and explore the design and implementation of APP skin changing mechanism
C# 多个矩形围成的多边形标注位置的问题
【Unity VFX】VFX特效入门笔记-火花制作
How does Apache Hudi accelerate traditional batch mode?
随机推荐
The problem of exporting excel form with wireframe and internal spacing of form by using web form
Understanding the role of individual units in a deep neural networks
将单行文字自动适应到目标矩形框内
SampleCameraFilter
SQL针对字符串型数字进行排序
基于NLP的软件安全研究(二)
Unity gets a resource that is referenced by those resources
自己封装unity的Debug函数
One of event management
IT高薪者所具备的人格魅力
Online Safe Trajectory Generation For Quadrotors Using Fast Marching Method and Bernstein Basis Poly
Encapsulate the debug function of unity
TimelineWindow
Teach-Repeat-Replan: A Complete and Robust System for Aggressive Flight in Complex Environments
使用flask时代码无报错自动结束,无法保持连接,访问不了url。
Weblux file upload and download
层次输出二叉树
Xamarin版的C# SVG路径解析器
Samplecamerafilter
关于U盘数据提示RAW,需要格式化,数据恢复笔记