RFC from Excel

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

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.

Similar Messages

  • Call RFC from Excel

    I have created rfc function, and it works fine in SAP, but when I try to call this function from Excel I get '0.00000', data type is correct.
    VBA code:
        Set F2 = functionCtrl.Add("ZFUNC")
        F2.exports("PARAM1") = "123"
        F2.exports("PARAM2") = "321"
        F2.Call
        MsgBox F2.Imports("EXP1").Value
    Any suggestions?

    it's is ok now

  • How to call RFC from Excel

    Hi all,
    Can any one give me sample VBA code to connect to SAP and call an RFC.
    I have found some code fragments in this forum, I would be grateful if someone can send me code for end-to-end processing.
    Regards,
    Hanif
    Message was edited by: Muhammad Hanif

    check out this,
    http://www.vbforums.com/showthread.php?t=337408
    Regards
    Raja

  • RFC call from Excel using VBA

    I am trying to do an RFC call from Excel to SAP using VBA. RFC is working fine for most the RFC enabled Function Modules except DDIF_FIELDINFO_GET and DDIF_FIELDLABEL_GET.
    What can be the reason for this?
    Can someonme please help me with a macro code where these FMs are working.
    Also can someone please help me with some tutorial on SAP connection with Excel.
    <REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>
    Edited by: Alvaro Tejada Galindo on Nov 12, 2008 9:14 AM

    Hello Jon.
    DDIF_FIELDINFO_GET is not working for me either. But I have used another FM (/ZOPTION/LIVE_DDIF_FIELDINFO):
    Public Sub RFC_FIELDINFO()
    Dim Func As Object
    Dim sapConn As Object
    Dim tblFIELDTAB
    Dim tblFIXED_VALUES
    Dim intRow%
    Dim intCol%
    '* Sub     : Call FM /ZOPTION/LIVE_DDIF_FIELDINFO                         *
    '* Author  : Holger Köhn                                                  *
    '* Created : 23.08.2014                                                   *
    '* Changed :                                                              *
    ThisWorkbook.Sheets("TEST").Activate
    Cells.Select
    Selection.ClearContents
    ThisWorkbook.Sheets("TEST").Range("A1").Select
    '* create RFC-Connection                                                  *
    Set sapConn = CreateObject("SAP.Functions")
    sapConn.Connection.RfcWithDialog = True
    If sapConn.Connection.LogOn(1, False) <> True Then
        MsgBox "Cannot Logon to SAP"
        Exit Sub
    End If
    DoEvents
    '* run FM /ZOPTION/LIVE_DDIF_FIELDINFO                                    *
    Set Func = sapConn.Add("/ZOPTION/LIVE_DDIF_FIELDINFO")
    Func.Exports("TABNAME") = "AUFK"
    Set tblFIELDTAB = Func.Tables("FIELDTAB")
    If Func.Call = False Then
         MsgBox Func.Exception
         Exit Sub
    Else
        Application.ScreenUpdating = False
            For intCol = 1 To tblFIELDTAB.ColumnCount
                ThisWorkbook.Sheets("TEST").Cells(1, intCol).Value = tblFIELDTAB.ColumnName(intCol)
            Next
            If tblFIELDTAB.RowCount > 0 Then
                For intRow = 1 To tblFIELDTAB.RowCount
                    For intCol = 1 To tblFIELDTAB.ColumnCount
                        ThisWorkbook.Sheets("TEST").Cells((intRow + 1), intCol).Value = tblFIELDTAB(intRow, intCol)
                    Next
                Next
                ThisWorkbook.Sheets("TEST").Activate
            End If
            Columns.AutoFit
        Application.ScreenUpdating = True
    End If
    '* clear tblFIELDTAB                                                      *
    Do Until tblFIELDTAB.RowCount = 0
         Call tblFIELDTAB.Rows.Remove(1)
    Loop
    Set sapConn = Nothing
    Set Func = Nothing
    Set tblFIELDTAB = Nothing
    End Sub

  • Download Data From Excel - VBA Code to SAP Using BDC

    Hi ,
    I am Sudhir Dure, working with Satyam Computers.
    I need help on the below query:
    I have an excel file which download data from Excel to SAP using RFC function & with the help of VBA interface.
    In this VBA code I have used BDC recording of SAP Transaction KE21N to post data into SAP.
    Now I am facing problem to find sub screen (tab page screen ) in SAP from VBA code .
    How to pass BDC Subscreen details from VBA code to SAP using below code?
    BDCTABLE.Rows.Add
    BDCTABLE.Cell(J, "PROGRAM") = PROGRAMNAME
    BDCTABLE.Cell(J, "DYNPRO") = "0200"
    BDCTABLE.Cell(J, "DYNBEGIN") = "X"
    BDCTABLE.Cell(J, "FNAM") = "BDC_OKCODE"
    BDCTABLE.Cell(J, "FVAL") = "=NEXT"
    Thanks,
    Sudhir Dure
    9972097464

    can anyone tell me how to get the PurchaseOrder number and item quantity from the Salesorder...? what are the fields here as given below..??
    For Each oItem In oSalesOrder.items
    wsTemplate.Range(cols(3) & Indexv).Value = oItem.material.material
    'wsTemplate.Range(cols(4) & Indexv).Value = ' I need item quantity here ????
    wsTemplate.Range(cols(1) & Indexv).Value = sapSoNumber
    wsTemplate.Range(cols(2) & Indexv).Value = ' I need purchase order number here>???
    Indexv = (Indexv + 1)
    Next
    reply fast. please .. thanks

  • Calling RFC from VB

    Hi,
    I'm trying to call an RFC enabled function module from excel.  My code in VB is:
        Set theFunc = sapConn.Add("ZGETREVENUE")
        theFunc.Exports("VBELN") = strSalesOrder
        ResultsOk = theFunc.imports("OK_CODE")
        Set objSalesOrder = theFunc.Tables("TBL_RETURN")
    The table TBL_RETURN is coming back fine but the return code OK_CODE is always 0.  Can someone point out what I'm doing wrong?
    Thanks,
    Gill

    Sorry Gill, Dinesh is right.
    The call method returns a true/false condition (true indicates a correct execution)
    The code should look something like
    Set theFunc = sapConn.Add("ZGETREVENUE")
    theFunc.Exports("VBELN") = strSalesOrder
    If theFunc.Call Then
       ResultsOk = theFunc.imports("OK_CODE")
       Set objSalesOrder = theFunc.Tables("TBL_RETURN")
    else
       msgbox "Call error"
    end if
    Cheers,
    Michael

  • Upload data from Excel to BI

    Hi 2 all,
    Can anyone please send me the complete steps for uploading of data from excel to BI??
    Also tell me that when we use DSO or when we use infocube? and if we design query in query designer then we use info cube fields or DSO fields??
    Please respond.
    Regards,
    Aisha Ishrat
    ICI Pakistan Ltd.

    Hi,
    there is no separate Tcode for 3.5 environment... but in RSA1 itself they give 3.X functionality also.. So, if you want to follow the 3.5 procedure you can go thru that... in the Infosource tab--> select your info area -->and right clcik it.. ->in that create INFOSOURCE 3.X.. for that just right clcik ur CUBE or DSO and --> Additional functions --> Update Rules.. and like that you can follow the same procedure which you done in 3.5..
    and for data loading in BI 7.0 from fla file means
    fisrt create one Cube or DSO with the same structure which you have in flatfile..
    and activate it..
    ->now comes to Datasource tab> create one Datasource here you need to select type of data for example.. select Transactional data --> and menntion your flatfile name in extraction tab- and file type and eneter your info object names in FIELDS tab --> and load preview data Activate it..
    now select your datasource and create info package and schedule it.. now your data will loded in to PSA level...
    > and now comes to info provider select your cube.. and right clcik it.. and create transformations.,. and activate it..
    > and create DTP -- Activate it.. and Execute it..
    1)Create datasource. Here u can set/check the Soucre System fields.
    2)Create Transformation for that datasource. (no more update rules/transfer rules)
    2.1) While creating transformation for DS it will ask you for data target name, so just assign where u want to update ur data.
    DataSource -> Transformation -> (DTP)-->Data Target
    Now if you want to load data into data target from Source System Datasource:
    1) Create infopackage for that data source. If you are creating infopackage for new datasources, it will only allow you update upto PSA, all other options u can see as disabled.
    2)Now Create DTP (Data Transfer Process) for that data source.
    3) NOw schdule the Infopackage, once the data is loaded to PSA, you can execute your DTP which will load data to data target.
    Data Transfer Process (DTP) is now used to load data using the dataflow created by the Transformation. Here's how the DTP data load works:
    1) Load InfoPackage
    2) Data gets loaded into PSA (hence why PSA only is selected)
    3) DTP gets "executed"
    4) Data gets loaded from PSA into the data target once the DTP has executed
    1) Create a data source
    RSA1->Source Systems->FILE(File)->PC_FILE(Filesourcesystem)->Create Application Component(optional)-Create Data source
    2) Create the data provider
    3) Create Transformation
    Right click on the data provider, choose 'create transformation' and choose your data source (give relevant data source and its type)
    Just connect the relavant fields between your data source and data provider.
    4) Create DTP
    Then Double click on the DTP node created under yous transformations. choose the extraction mode
    5) Load the data: there are 2 ways:
    you can run the infopackage and DTP separately or create a process chain consisting of these infopackage and DTP and run.
    Also check /people/sankar.kumar/blog/2006/10/11/loading-text-filestxt-into-bw-with-hex-option for hex option
    Thanks,
    Sankar M

  • I am having trouble printing to an Epson XP600.  It is a new printer and it has been replaced because we thought it was the printer.  Basically, when I print from Excel, only color will print.

    I am having trouble printing to an Epson XP600.  We have replaced the printer and we are still having the same problem.  When I try to print from Excel, only the color prints.  Any suggestions?

    Has anyone else had issues not being able to print black (such as a document)?  My photos print great, but when I try to print a simple black-ink document, it won't work. Any suggestions?

  • Send email from excel

    Can anyone help please.
    I would like to send a range from excel 2011 by email using VBA code. I can do this with Outlook but It fails because of using the Mac Mail Client.
    Is there any code out there that will send via the mac mail client
    Regards
    Gary

    Have you tried zipping Outlook application, and quitting Excel and reopening it?   Perhaps if there is no Outlook, it will go to the default e-mail client.

  • Reading records from excel

    hi all,
    i am using Forms [32 Bit] Version 6.0.8.24.1 (Production).
    i am uploading data from excel to form(record wise)and saving.
    now i am reading the data from 2nd row by assuming that 1st row followed with columns titles.But, my question is we cannot predict the excel that the record always starts from 2nd row. how check for the starting for the actual data
    is its something like if column1 is null and col2 is null and col3 is null
    then increment the row and repeat the process.. but, upto which record i should continue this process..
    anybody is having better solution than this..
    Thanks..

    Hi,
    The nice option would be keep the upload (start from and end) manually, What i mean is in the uploading screen put two more fields like Start Row and End Row and let the user fill these fields before starting the upload process. So, if any error will happen during upload then let the user handle.
    -Ammad

  • HP ePrint from excel add-in: Error while getting driver name for printer

    Trying to use add-in for ePrint from excel/word I get, "error while getting driver name for printer \\...HP DesignJet 800PS 42 by HP," with an option to select "OK" and that same message repeats with each printer in our network, and then it doesn't allow me to print using the add-in. However, I can print normally to HP Go Web, open up Print and Share,  then print it from there. This happens with excel and word. I have Office Suite 2007.

    Hello modameister,
    Sorry you are having issues with this printer and the ePrint add-on.  There are a couple of questions I would like you to answer please.
    1.  What operating system are you using? (XP,VISTA,7,MAC OS X)
    2.  What and how much data are you trying to print?
    3.  Have you tried to copy and paste the data into a different application or tried using the snip it tool?
    4.  Are you receiving any .dll errors (mscms.dll)
    Thanks
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • Upload data from Excel to Itab

    Dear All,
    Suppose I have data in the form of a matrix and I need to upload the data into the database after validation. The excel sheet is of the format:
    Emp Empdept E1     E2     E3     E4     E5     E6     E7     E8     E9     
    E1     MEC     0     2     3     4     5     6     6     5     7
    E2     ELE     4     0     5     5     6     2     2     1     3
    E3     ELE     4     4     0     6     1     4     7     8     9
    E4     ECE     2     2     4     0     6     7     5     9     4
    E5     CHE     7     8     9     5     0     5     6     1     3
    E6     ELE     8     9     10     12     11     0     5     6     4     
    E7     MEC     4     5     4     6     7     6     0     5     7
    E8     MEC     9     4     7     5     2     2     8     0     1
    E9      ELE     1     5     2     4     2     6     4     6     0
    The first column is the employee number
    The second column is the employee department and
    The matrix indicates the time taken by emplyee1 to be trained to handle position of employee E2 is 2 months (map using row of E1 and column of E2).
    Similarly E9 to E8 is 6 months.
    I have to get the above data into an internal table of the format
    Emp_from     Emp_to     Duration
    E1          E1          0     
    E1          E2          2
    E1          E3          3     
    E1          E4          4          
    E1          E5          5     
    E1          E6          6
    E1          E7          6
    E1          E8          5     
    E1          E9          7
    E2             E1          4
    E2          E2          0     
    E2          E3          5
    Points wil be rewarded.
    Regards,
    Shiva.

    declare an internal table it_excel with field
    EMPno
    EMPOdept
    E1
    E2
    E3
    E4
    E5
    E6
    E7
    E6
    upload the data from excel to this internal table.
    loop it_excel into wa_excel.
    wa_output-emp_from = wa_excel-empno.
      wa_output-emp_to = 'E1'.
      wa_output-Duration = wa_excel-E1.
    append wa_output to it_output.
    wa_output-emp_from = wa_excel-empno.
      wa_output-emp_to = 'E2'.
      wa_output-Duration = wa_excel-E2.
    append wa_output to it_output.
    wa_output-emp_from = wa_excel-empno.
      wa_output-emp_to = 'E3'.
      wa_output-Duration = wa_excel-E3.
    append wa_output to it_output.
    so on
    endloop.
    try something like this

  • Upload data from excel to snp livecach

    Dear All.
    I need to up load data from excel to snp. is their any bapi or function module.

    Hello,
    If you are using SCM 5.0 or above version you can load the data from Excel to SNP in two steps.
    1. Load the data from excel to infocube with normal process.
    2. Load the data from infocube to SNP by transaction /SAPAPO/REL_TO_SNP
    Hope this helps.
    Regards,
    Prafulla

  • Upload data from Excel to Internal table in ECC

    Hello SDN,
    Here I am facing a problem for uploading the data from excel sheet to internal table in ECC6.0
    Main problem is we don't have any FM ALSM_EXCEL_TO_INTERNAL_TABLE.
    Please provide me the solution how to upload the data from excel to internal table through class. If possible please provide me the sample code so that it will be very helpful for me.
    Waitingfor your valuable response.
    Thanks & Regards,
    Kumar.

    Hi,
    you can use OLE to acces (not only) excel, but this will only work in dialog processing.
    regards,
    Hans

  • Upload data from Excel to the Planning Book

    We are on APO 5.1. We have APO DP at the moment. I wanted to test upload of data from Excel to the planning book. I have tried several times. I have been unable to see any changed data in the planning. I do not get ANY errors during the upload. But I cannot see any changes that I made in the excel in the planning book. Please let me know what I am doing wrong. These are the step that I follow.
    1. Go to planning book.
    2. Short list only one key figure e.g Customer Forecast.
    3. Go into Details All mode.
    4. Download the file using the "Prepare File for Upload" option.
    5. Open the saved Excel.
    6. Change the values in the excel , save and close.
    7. Upload the excel into the planning book using the upload file option.
    I do not get any errors during all these steps. However, when I check to see if the values have been updated, the changes made in the excel are not updated in the planning book.

    Hello,
    Instead of selecting one key figure in data view, please select all key figures of the planning book and then try all the steps which you have carried out.
    please revert after you carry out this.
    Regards,
    Prafulla

Maybe you are looking for