Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

RFC from Excel

Former Member
0 Kudos
1,161

Hi,

i want to update a SAP table with the info from excel.Request you to provide inputs on how to make RFC call from the Excel Macro.

Regards,

Kalyan Chakravarthi.M

2 REPLIES 2
Read only

Former Member
0 Kudos
555

SAP upload: if you have hundreds of records to create or modify, the solutions available are:

Build a program in ABAP. Use FM "ALSM_EXCEL_TO_INTERNAL_TABLE" to upload excel to internal table

Use one SAP tool called LSMW (Legacy Systems Migration Workbench).

Use one internal test tool called CATT (Computer Aided Test Tool).

Use some easy to use third party tools (see list in #Commercial Tools section below).

For some business objects, use the SAP mass maintenance transactions such as MASS or MM17:

Regards

Neha

Read only

Former Member
0 Kudos
555

Here is some sample code I had written to fetch data from SAP. It uses a RFC enabled FM - RFC_READ_TABLE for reading a DB table. You will have to find a RFC enabled FM that lets you update the DB table you want to update. ( I dont think there is any generic RFC enabled FM for doing that, off course you are free to create a custom one ).

Here is the sample code for using the FM from SAP EXcel macros.. I had developed it using a sub routine in a class module for using across Excel sheets..

Sub Get_Report_List()
Dim SAPFunCtl As New SAPFunctions
Dim RFCFunc As New SAPFunctionsOCX.Function

Dim I_QUERY_TABLE
Dim T_OPTIONS
Dim T_FIELDS
Dim T_DATA

Dim Row As Integer

'Pop up for Automatic Logon.
 SAPFunCtl.AutoLogon = True
 
'Set the Function Module to be called
 Set RFCFunc = SAPFunCtl.Add("RFC_READ_TABLE")
 
'Set the Import, Export & Table Parameters
 Set I_QUERY_TABLE = RFCFunc.Exports("QUERY_TABLE")
 Set T_OPTIONS = RFCFunc.Tables("OPTIONS")
 Set T_FIELDS = RFCFunc.Tables("FIELDS")
 Set T_DATA = RFCFunc.Tables("DATA")
 
'Query Table TRDIR
 I_QUERY_TABLE.Value = "TRDIR"
 T_OPTIONS.AppendRow
 T_OPTIONS(1, "TEXT") = "NAME LIKE 'Z%'"
 
 T_FIELDS.AppendRow
 T_FIELDS(1, "FIELDNAME") = "NAME"
 T_FIELDS.AppendRow
 T_FIELDS(2, "FIELDNAME") = "SUBC"
 
  If RFCFunc.Call = True Then
    If T_DATA.RowCount > 0 Then
    'Clear Sheet3 - Data
        Sheet3.Cells.Clear
        For Row = 1 To T_DATA.RowCount
        Sheet3.Cells(Row, 1) = T_DATA(Row, "WA")
        Next Row
        Sheet3.Activate
    End If
 Else
    MsgBox "Connection failure."
 End If


End Sub

Hope it helps.