Posted: Sun Nov 04, 2007 7:46 pm Post subject: VB codes (or VBA macro code) for access SAP, and run one RFC
I can give you some code, but not sure it will work for you. When you ( or the help desk ) installs the SAP GUI, you can also install the SAP RFC development kit, if you do this you will have in your c:\program files\SAP??? ( in my case C:\Program Files\SAP620 ) a folder with a .frm extension ( in my case "C:\Program Files\SAP620\SAPGUI\rfcsdk\ccsamp\RFCSamp.VB\RFCsamp.frm" )
From there you can start then, because you also need the vbp file and the vbw file in order to really make it work. If you just need the code, then here you go :
Code:
Option Explicit
Private Sub Command1_Click()
'Dim Foo As RFCSampObj ' Due to an acknowledged problem in MTS
Dim Foo As Object ' we Dim Foo as Object instead of as RFCSampObj
Dim searchterm As String
Dim custlist As Recordset
If Not Foo Is Nothing Then
searchterm = Text1.Text
'Unfortunately RFC_CUSTOMER_GET does not convert
' a SPACE selction into a * so we do it here....
If IsEmpty(searchterm) Then searchterm = "*"
On Error Resume Next
Call Foo.GetCustList(searchterm, "", custlist)
If Err.Number = 0 Then
If Not custlist Is Nothing Then
custlist.MoveFirst
While Not custlist.EOF
Debug.Print "------------------"
Debug.Print "custlist.Fields(name1) " &
custlist.Fields("NAME1")
Debug.Print "custlist.Fields(stras) " &
custlist.Fields("STRAS")
Debug.Print "custlist.Fields(ort01) " &
custlist.Fields("ORT01")
Debug.Print "custlist.Fields(pstlz) " &
custlist.Fields("PSTLZ")
Debug.Print "custlist.Fields(telf1) " &
custlist.Fields("TELF1")
Debug.Print "custlist.Fields(telfx) " &
custlist.Fields("TELFX")
custlist.MoveNext
Wend
Else
Debug.Print "ERROR: custlist is Nothing"
End If
Else
Debug.Print "ERROR" & Err.Description
MsgBox Err.Description, vbCritical, "Error:"
End If
Else
Debug.Print "Foo is nothing"
MsgBox "Foo is nothing"
End If
End Sub
Private Sub Command2_Click()
'Dim Foo As RFCSampObj ' Due to an acknowledged problem in MTS
Dim Foo As Object ' we Dim Foo as Object instead of as RFCSampObj
Dim rs As Recordset
Dim HeaderIn As Recordset
Dim ItemsIn As Recordset
Dim Partners As Recordset
Dim OrderNumber As String
Dim BapiReturn As Recordset
Dim SoldTo As Recordset
Dim ShipTo As Recordset
Dim Payer As Recordset
Dim ItemsOut As Recordset
'Input tables can be crafted in two different ways:
' - either using the DimAsXXXX method which returns a fully
' described but empty Recordset.
' - or using the AdvancedDataFactory to craft up a disconnected
' Recordset.
' An example of the later is shown with the Partners Table
' the remaining input tables are crafted with the dim as.
Dim adf As Object
' Describe the shape of a disconnected recordset
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.