2
Name OSCO DUPONT D11 OSCO ApplicationServe r3-m04.mata.osco.de dbs4t r3-m04.mata.osco.de System M04 D11 M04 SystemNumber 01 00 01 Client 011 100 011 Language EN EN EN User aangeli angeli aangeli Password lagunas lagunas lagunas

Rfc Simple Test

Embed Size (px)

DESCRIPTION

Rfc Simple Test

Citation preview

LogonDataNameOSCODUPONT D11OSCOARBED DEVApplicationServerr3-m04.mata.osco.dedbs4tr3-m04.mata.osco.der3dev.profilarbed.luSystemM04D11M04DEVSystemNumber01000100Client011100011043LanguageENENENENUseraangeliangeliaangeliangeliaxPasswordlagunaslagunaslagunasocrival

Tabelle2

Tabelle3

Attribute VB_Name = "Tabelle1"Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = TrueAttribute VB_TemplateDerived = FalseAttribute VB_Customizable = True

Attribute VB_Name = "Tabelle2"Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = TrueAttribute VB_TemplateDerived = FalseAttribute VB_Customizable = True

Attribute VB_Name = "Tabelle3"Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = TrueAttribute VB_TemplateDerived = FalseAttribute VB_Customizable = True

Attribute VB_Name = "RFCtests"'************************************************************' (c) 2000, Axel Angeli' The R/3 Guide To ecommerce with mySAP.com, Visual Basic and WWW'------------------------------------------------------------' This is a little VB Script example that demonstrates in a very simple way' how you can call a RFC function module in R/3. The function used is' RFC_READ_TABLE which takes the name of a table as a parameter and' returns its contents. As on option you can pass a Tablefactory element' to contain a simple SQL WHERE-clause, which is added to the SQL statement issued by' RFC_READ_TABLE'------------------------------------------------------------' If you fully understood, how this example works, then you should' be able to write any program you want to connect to R/3'------------------------------------------------------------'************************************************************

'************************************************************' Declarations'************************************************************'------------------------------------------------------------Global App As New Excel.Application'------------------------------------------------------------Dim LogonControlDim connDim funcControl As New SAPFunctionsOCX.SAPFunctionsDim TableFactoryCtrlDim RFC_READ_TABLE

'------------------------------------------------------------' Pointers to function parameters'------------------------------------------------------------Dim eQUERY_TABDim TOPTIONSDim TDATA As SAPTableFactoryCtrl.TableDim TFIELDS

'************************************************************' Main Program'************************************************************'------------------------------------------------------------' Call Main'------------------------------------------------------------

'************************************************************' Subroutines'************************************************************Sub Main()'------------------------------------------------------------' Main is the principle Entry to the program pool'------------------------------------------------------------'** The following commented lines can be used from VB Script'** or if you do not want to use type library references Set LogonControl = CreateObject("SAP.LogonControl.1") Set funcControl = CreateObject("SAP.Functions") Set TableFactoryCtrl = CreateObject("SAP.TableFactory.1")'------------------------------------------------------------' Logon to your R/3 system'------------------------------------------------------------ Set conn = LogonControl.NewConnection'------------------------------------------------------------' ** Set here your system data. They are also found in the R/3 Logon Panel' Only the app server and the system number is mandatory. If the other params' are missing you will be prompted for'------------------------------------------------------------ conn.ApplicationServer = "192.68.2.22" ' IP of the R/3 application server conn.System = "MICKY" ' System ID of the instance, usually 00 conn.SystemNumber = "00" ' System (database) ID of the instance conn.Client = "100" ' opt. Client number to logon to conn.Language = "EN" ' opt. Your login language conn.User = "MICKYMOUSE" ' opt. Your user id conn.Password = "pazzwurd" ' opt. Your password

retcd = conn.Logon(0, False) '0=new instance; false=do not suppress dialog If retcd True Then MsgBox " Cannot log on! " MsgBox retcd' Stop Else' MsgBox " Logon OK." End If funcControl.Connection = conn Call R3RFC_READ_TABLE("T000") conn.Logoff MsgBox " Logged off from R/3! "End Sub' This is to test if you can read data from R/3 after you logged onSub R3RFC_READ_TABLE(pQueryTab)'------------------------------------------------------------' Call the R/3 RFC function RFC_READ_TABLE'------------------------------------------------------------ Set RFC_READ_TABLE = funcControl.Add("RFC_READ_TABLE")

'------------------------------------------------------------' If you get the error message "Collection Member Not Found"' then you have probable misspelled the parameter name' e.g. you wrote QUERY_TAB instead of QUERY_TABLE'------------------------------------------------------------ Set eQUERY_TAB = RFC_READ_TABLE.Exports("QUERY_TABLE") Set TOPTIONS = RFC_READ_TABLE.Tables("OPTIONS") ' Set TDATA = RFC_READ_TABLE.Tables("DATA") ' Set TFIELDS = RFC_READ_TABLE.Tables("FIELDS") '

eQUERY_TAB.Value = pQueryTab TOPTIONS.AppendRow ' new item line TOPTIONS(1, "TEXT") = "MANDT EQ '000'"

If RFC_READ_TABLE.Call = True Then If TDATA.RowCount > 0 Then MsgBox "Call to RFC_READ_TABLE successful! Data found" MsgBox TDATA(1, "WA") Else MsgBox "Call to RFC_READ_TABLE successful! No data found" End If Else MsgBox "Call to RFC_READ_TABLE failed!" End IfEnd Sub

Attribute VB_Name = "DieseArbeitsmappe"Attribute VB_Base = "0{00020819-0000-0000-C000-000000000046}"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = TrueAttribute VB_TemplateDerived = FalseAttribute VB_Customizable = True