callfromexcel
3990 단어 Excel
Dim R3, App As Object
Dim Customers, Customer As Object
Dim Result As Boolean
'**********************************************
'Create Server object and Setup the connection
'**********************************************
Sub SAP_Logon()
Set R3 = CreateObject("RFC.ServerObject")
Set App = R3.Application
R3.connection.client = "010"
'R3.connection.user = "SAP*"
'R3.connection.password = "19920706"
R3.connection.user = "CPICUSER"
R3.connection.password = "19920706"
R3.connection.language = "E"
R3.connection.Gatewayhost = ""
R3.connection.Gatewayservice = ""
R3.connection.hostname = "SAPENT"
R3.connection.destination = "E40"
R3.connection.system = "00"
If R3.connection.logon <> True Then
App.Quit
Exit Sub
End If
End Sub
Sub Command1_Click()
SAP_Logon
Get_Mara
SAP_LOGOFF
End Sub
Sub SAP_LOGOFF()
R3.Close False 'do not save the server object
App.Quit
End Sub
Sub Get_cust()
Result = R3.RFC_CUSTOMER_GET(Exception, KUNNR:="*", CUSTOMER_T:=Customers)
If Result <> True Then
MsgBox (Exception)
App.Quit
Exit Sub
End If
'**************************************
'Display table header
'**************************************
Cells(3, 1) = "Customer ID"
Cells(3, 2) = "Customer Name"
Cells(3, 3) = "Zip Code"
Range(Cells(3, 1), Cells(3, 3)).Font.Bold = True
'**************************************
'Display Contents of the customer table
'
'If many customers are expected, use
'the second alternative
'**************************************
bManyCustomers = False
If (bManyCustomers = False) Then
i = 4
For Each Customer In Customers.Rows
Cells(i, 1) = Customer("KUNNR")
Cells(i, 2) = Customer("NAME1")
Cells(i, 3) = Customer("PSTLZ")
i = i + 1
Next
Else
For i = 1 To Customers.RowCount
Cells(i, 1) = Customers(i, "KUNNR")
Cells(i, 2) = Customers(i, "NAME1")
Cells(i, 3) = Customers(i, "PSTLZ")
Next
End If
End Sub
Sub Get_Mara()
Dim Materials, Material As Object
Result = R3.Y_RFC_MARA_GET(Exception, MATNR:="S0039*", BWKEY:="1331", BWART:="", T_MARA:=Materials)
If Result <> True Then
MsgBox (Exception)
App.Quit
Exit Sub
End If
'**************************************
'Display table header
'**************************************
Cells(3, 1) = "Material No"
Cells(3, 2) = "Material Name"
Cells(3, 3) = "Zip Code"
Range(Cells(3, 1), Cells(3, 3)).Font.Bold = True
'**************************************
'Display Contents of the customer table
'
'If many customers are expected, use
'the second alternative
'**************************************
bManyCustomers = False
If (bManyCustomers = False) Then
i = 4
For Each Material In Materials.Rows
Cells(i, 1) = Material("MATNR")
Cells(i, 2) = Material("MAKTX")
Cells(i, 3) = Material("VERPR")
i = i + 1
Next
Else
For i = 1 To Materials.RowCount
Cells(i, 1) = Materials(i, "MATNR")
Cells(i, 2) = Materials(i, "MAKTX")
Cells(i, 3) = Materials(i, "VERPR")
Next
End If
End Sub
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Excel Grep toolExcel Grep tool ■히나가타 ■ 시트 구성 ExcelGrep.cls...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.