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

Similar Messages

  • I would like to execute an existing BW report from Excel (using VBA).

    I would like to execute an existing BW report from Excel (using VBA) and download the results into Excel.  I understand that there is an Excel Add-In which (I believe) should allow me to do this.  I am an experienced user of Excel / VBA but I have virtually no experience with SAP.  If someone could point me to any source of information or specific instructions I would be extremely appreciative.  I've done multiple searches on the internet but everything I find seems to assume more knowledge of SAP and SAP acronyms than I possess. 

    Paul,
    If your company (or your client's company) has an SAP license (I assume this is the case, since there would be no other reason for you to want to access an SAP system using Excel), there is a person in your company who can request an ID for you.  It is called a SAP Service Marketplace userid, more commonly called an 'S' number.  This person in your company is usually a Basis Administrator.  Go to your SAP Basis team and ask them for access to Service Marketplace.
    The common solution for your Excel analysis problem is to install the Bex Analyzer on your PC.  You will need these same guys (Basis Team) to help you with getting the required SAP access, and to install the associated SAP software onto your PC.
    In the meantime, here is some bedtime reading for you.
    Analysis &amp;amp; Reporting: BEx Analyzer - Business Intelligence - SAP Library
    Best Regards,
    DB49

  • BAPI Access from Excel using VBA

    Im writing an excel macro (VBA) to call a bapi that populates a spreadsheet.
    The user will then do some manipulation of the data collected, and then it must be sent back to sap.
    The Bapi in question is BAPI_GET_USER_DETAIL
    *"  IMPORTING
    *"     VALUE(USERNAME) LIKE  BAPIBNAME-BAPIBNAME
    *"  EXPORTING
    *"     VALUE(LOGONDATA) LIKE  BAPILOGOND STRUCTURE  BAPILOGOND
    *"     VALUE(DEFAULTS) LIKE  BAPIDEFAUL STRUCTURE  BAPIDEFAUL
    *"     VALUE(ADDRESS) LIKE  BAPIADDR3 STRUCTURE  BAPIADDR3
    *"     VALUE(COMPANY) LIKE  BAPIUSCOMP STRUCTURE  BAPIUSCOMP
    *"     VALUE(SNC) LIKE  BAPISNCU STRUCTURE  BAPISNCU
    *"     VALUE(REF_USER) LIKE  BAPIREFUS STRUCTURE  BAPIREFUS
    *"     VALUE(ALIAS) LIKE  BAPIALIAS STRUCTURE  BAPIALIAS
    *"  TABLES
    *"      PARAMETER STRUCTURE  BAPIPARAM OPTIONAL
    *"      PROFILES STRUCTURE  BAPIPROF OPTIONAL
    *"      ACTIVITYGROUPS STRUCTURE  BAPIAGR OPTIONAL
    *"      RETURN STRUCTURE  BAPIRET2
    *"      ADDTEL STRUCTURE  BAPIADTEL OPTIONAL
    *"      ADDFAX STRUCTURE  BAPIADFAX OPTIONAL
    *"      ADDTTX STRUCTURE  BAPIADTTX OPTIONAL
    *"      ADDTLX STRUCTURE  BAPIADTLX OPTIONAL
    *"      ADDSMTP STRUCTURE  BAPIADSMTP OPTIONAL
    *"      ADDRML STRUCTURE  BAPIADRML OPTIONAL
    *"      ADDX400 STRUCTURE  BAPIADX400 OPTIONAL
    *"      ADDRFC STRUCTURE  BAPIADRFC OPTIONAL
    *"      ADDPRT STRUCTURE  BAPIADPRT OPTIONAL
    *"      ADDSSF STRUCTURE  BAPIADSSF OPTIONAL
    *"      ADDURI STRUCTURE  BAPIADURI OPTIONAL
    *"      ADDPAG STRUCTURE  BAPIADPAG OPTIONAL
    *"      ADDCOMREM STRUCTURE  BAPICOMREM OPTIONAL
    *"      GROUPS STRUCTURE  BAPIGROUPS OPTIONAL
    Ive Managed to glean from various sources on the internet, the various basics on doing a bapi call from VBA
    Here is what i have so far.
    Private Sub Fetch_User_details_Click()
    'Take username in cell 2,2 and check to see it it exists.
    'Display the First and Last name of the user
    'Get list of all roles and their expiry dates and populate list
    Dim R3, MyFunc, App As Object
    Dim SEL_TAB, NAMETAB, TABENTRY, ROW As Object
    Dim Result As Boolean
    Dim iRow, iColumn, iStart, iStartRow As Integer
    'RFC Paramaters
    Dim Pusername As Variant
    Dim Preturn As Variant
    Dim copyFromc As String
    'Clear Table Section of Spreadsheet
    Worksheets("Sheet1").Select
    For x = 9 To 200
      For y = 1 To 8
        Worksheets("Sheet1").Cells(x, y).ClearContents
        Next y
    Next x
    'Create Server object and Setup the connection
    Set R3 = CreateObject("SAP.Functions")
    R3.Connection.System = ""
    R3.Connection.client = ""
    R3.Connection.user = ""
    R3.Connection.Password = ""
    R3.Connection.Language = "EN"
    'Logon to SAP
    If R3.Connection.logon(0, False) <> True Then
       Exit Sub
    End If
    'R3.loglevel = 9
    'R3.logfilename = "c:guilog.txt"
    Set MyFunc = R3.Add("BAPI_USER_GET_DETAIL")
    copyFromc = Worksheets("Sheet1").Cells(3, 2).Text
    Set Pusername = MyFunc.exports("USERNAME")
    Pusername.Value = copyFromc
    'Call the BAPI
    If MyFunc.call Then
    '  ok now what ?
    ' Process the returned data into the spreadsheet
    Else
        MsgBox ("Call returned FALSE")
    End If
    'Close Connection to SAP
    R3.Connection.logoff
    End Sub
    To update the data ( User Role Assignements ) i will be using bapi BAPI_USER_ACTGROUPS_ASSIGN
    *"*"Lokale Schnittstelle:
    *"  IMPORTING
    *"     VALUE(USERNAME) LIKE  BAPIBNAME-BAPIBNAME
    *"  TABLES
    *"      ACTIVITYGROUPS STRUCTURE  BAPIAGR
    *"      RETURN STRUCTURE  BAPIRET2
    * Dieser Baustein ist gleichgestellt mit der Pflege eines Benutzers
    * über die Pflegetransaktion, gepflegt werden die Felder, für die die
    * Pflege erlaubt ist
    I need help deciphering the data received from the bapi and then repackaging it using VBA.
    I know writing this in ABAP would take less than 30 mins, but that is not an option for me.

    Ok, Ive made some headway
    I can now Read all the data i need from SAP
    Now comes the bit to write it back again.  Will Update when i have a solution
    Private Sub copydata_Click()
    Dim x1 As Integer, x2 As Integer
    'copy all data from "Copy From" to "Copy To"
    'first determine how many rows contain roles
    'before copying the roles, check that the destination user has no roles assigned
    If Cells(9, 6).Text <> "" Then
       MsgBox ("Error. Destination User already has Roles assigned.")
       Exit Sub
    End If
    For x1 = 0 To 1000
       If Cells(9 + x1, 1).Text = "" Then
         Exit For
       End If
    Next
    Worksheets("Sheet1").Range(Cells(9, 1), Cells(9 + x1 - 1, 4)).Copy _
       Destination:=Worksheets("Sheet1").Range(Cells(9, 6), Cells(9 + x1, 9))
    For x2 = 1 To x1
    Worksheets("Sheet1").Cells(9 + x2 - 1, 8).Value = Date
    Next
    End Sub
    Sub Mail_small_Text_Outlook()
    ' Is working in Office 2000-2007
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String
        Set OutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon
        Set OutMail = OutApp.CreateItem(0)
        strbody = "User " & Worksheets("Sheet1").Cells(3, 7).Text & _
                  " Has Been Moddelled off of User " & _
                    Worksheets("Sheet1").Cells(3, 2).Text & " in system " & _
                    Worksheets("Connection").Cells(1, 2).Text & vbNewLine & vbNewLine & _
                  "Please Adjust Mitigating Controls Accordingly"
        On Error Resume Next
        With OutMail
            .To = Worksheets("Connection").Cells(10, 2).Text
            .CC = ""
            .BCC = ""
            .Subject = "User Modelled"
            .Body = strbody
            .Send   'or use .Display
        End With
        On Error GoTo 0
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
    Private Sub Fetch_CopyTo_User_Click()
    'Take username in cell 3,7 and check to see it it exists.
    'Display the First and Last name of the user
    'Get list of all roles and their expiry dates and populate list
    Dim R3, MyFunc, App As Object
    Dim SEL_TAB, NAMETAB, TABENTRY, ROW As Object
    Dim Result As Boolean
    Dim iRow, iColumn, iStart, iStartRow As Integer
    'RFC Paramaters
    Dim Pusername As Object
    Dim PAddress As Object
    Dim PTable As Object
    Dim Preturn As Object
    Dim copyFromc As String
    'Clear Table Section of Spreadsheet
    Worksheets("Sheet1").Cells(5, 8).ClearContents
    Worksheets("Sheet1").Cells(6, 8).ClearContents
    'Create Server object and Setup the connection
    Set R3 = CreateObject("SAP.Functions")
    R3.Connection.System = Worksheets("Connection").Cells(1, 2).Text
    R3.Connection.SystemNumber = Worksheets("Connection").Cells(2, 2).Text
    R3.Connection.Destination = Worksheets("Connection").Cells(3, 2).Text
    R3.Connection.HostName = Worksheets("Connection").Cells(4, 2).Text
    R3.Connection.client = Worksheets("Connection").Cells(5, 2).Text
    R3.Connection.user = Worksheets("Connection").Cells(6, 2).Text
    R3.Connection.Password = Worksheets("Connection").Cells(7, 2).Text
    R3.Connection.Language = Worksheets("Connection").Cells(8, 2).Text
    'Logon to SAP
    If R3.Connection.Logon(0, -1) <> True Then
       MsgBox ("We Had a Logon Error")
       Exit Sub
    End If
    'R3.loglevel = 9
    'R3.logfilename = "c:\guilog.txt"
    Set MyFunc = R3.Add("BAPI_USER_GET_DETAIL")
    Set Pusername = MyFunc.exports("USERNAME")
    Set PAddress = MyFunc.imports("ADDRESS")
    Set Preturn = MyFunc.tables("RETURN")
    Set PTable = MyFunc.tables("ACTIVITYGROUPS")
    Pusername.Value = Worksheets("Sheet1").Cells(3, 7).Text
    'Call the BAPI
    If MyFunc.call Then
       Dim xxx As String
       Worksheets("Sheet1").Cells(5, 7).Value = PAddress.Value("FIRSTNAME")
       Worksheets("Sheet1").Cells(6, 7).Value = PAddress.Value("LASTNAME")
    'Get Assigned Roles
       Dim datarec As Object
       Dim datafld As Object
       x = 9
       For Each datarec In PTable.Rows
         Worksheets("Sheet1").Cells(x, 6).Value = datarec("AGR_NAME")
         Worksheets("Sheet1").Cells(x, 7).Value = datarec("AGR_TEXT")
         Worksheets("Sheet1").Cells(x, 8).Value = datarec("FROM_DAT")
         Worksheets("Sheet1").Cells(x, 9).Value = datarec("TO_DAT")
         x = x + 1
       Next
       copydata.Enabled = True
    Else
        MsgBox ("Error Calling Function - Probably Authorizations")
    End If
    'Close Connection to SAP
    R3.Connection.logoff
    End Sub
    Private Sub Fetch_User_details_Click()
    'Take username in cell 3,2 and check to see it it exists.
    'Display the First and Last name of the user
    'Get list of all roles and their expiry dates and populate list
    Dim R3, MyFunc, App As Object
    Dim SEL_TAB, NAMETAB, TABENTRY, ROW As Object
    Dim Result As Boolean
    Dim iRow, iColumn, iStart, iStartRow As Integer
    'RFC Paramaters
    Dim Pusername As Object
    Dim PAddress As Object
    Dim PTable As Object
    Dim Preturn As Object
    Dim copyFromc As String
    'Clear Table Section and other areas of Spreadsheet
    Worksheets("Sheet1").Select
    For x = 9 To 1000
      For y = 1 To 9
        Worksheets("Sheet1").Cells(x, y).ClearContents
        Next y
    Next x
    Worksheets("Sheet1").Cells(5, 2).ClearContents
    Worksheets("Sheet1").Cells(6, 2).ClearContents
    Worksheets("Sheet1").Cells(5, 7).ClearContents
    Worksheets("Sheet1").Cells(6, 7).ClearContents
    copydata.Enabled = False
    'Create Server object and Setup the connection
    Set R3 = CreateObject("SAP.Functions")
    R3.Connection.System = Worksheets("Connection").Cells(1, 2).Text
    R3.Connection.SystemNumber = Worksheets("Connection").Cells(2, 2).Text
    R3.Connection.Destination = Worksheets("Connection").Cells(3, 2).Text
    R3.Connection.HostName = Worksheets("Connection").Cells(4, 2).Text
    R3.Connection.client = Worksheets("Connection").Cells(5, 2).Text
    R3.Connection.user = Worksheets("Connection").Cells(6, 2).Text
    R3.Connection.Password = Worksheets("Connection").Cells(7, 2).Text
    R3.Connection.Language = Worksheets("Connection").Cells(8, 2).Text
    'Logon to SAP
    If R3.Connection.Logon(0, -1) <> True Then
       MsgBox ("We Had a Logon Error")
       Exit Sub
    End If
    'R3.loglevel = 9
    'R3.logfilename = "c:\guilog.txt"
    Set MyFunc = R3.Add("BAPI_USER_GET_DETAIL")
    Set Pusername = MyFunc.exports("USERNAME")
    Set PAddress = MyFunc.imports("ADDRESS")
    Set Preturn = MyFunc.tables("RETURN")
    Set PTable = MyFunc.tables("ACTIVITYGROUPS")
    Pusername.Value = Worksheets("Sheet1").Cells(3, 2).Text
    'Call the BAPI
    If MyFunc.call Then
       Dim xxx As String
       Worksheets("Sheet1").Cells(5, 2).Value = PAddress.Value("FIRSTNAME")
       Worksheets("Sheet1").Cells(6, 2).Value = PAddress.Value("LASTNAME")
    'Get Assigned Roles
       Dim datarec As Object
       Dim datafld As Object
       x = 9
       For Each datarec In PTable.Rows
         Worksheets("Sheet1").Cells(x, 1).Value = datarec("AGR_NAME")
         Worksheets("Sheet1").Cells(x, 2).Value = datarec("AGR_TEXT")
         Worksheets("Sheet1").Cells(x, 3).Value = datarec("FROM_DAT")
         Worksheets("Sheet1").Cells(x, 4).Value = datarec("TO_DAT")
         x = x + 1
       Next
    Else
        MsgBox ("Error Calling Function - Probably Authorizations")
    End If
    'Close Connection to SAP
    R3.Connection.logoff
    End Sub
    Private Sub UpdateSap_Click()
    End Sub

  • RFC call from MII using JCO

    Hi All,
    I am calling custom function module from MII using JCO and I am facing one problem. Problem is that if any new field is added in function module in ECC side that is not appearing in RFC structure until we restart the MII server. Can anybody provide any solution. I am using MII 12.1 SP5.
    Thanks in Advance
    Chandan

    I faced this same issue. Only one solution is to reset the JCo Proxy by running following URL in the same MII server
    http://<MII Server>/XMII/JCOProxy?mode=reset
    This will reset the JCo cache and the new added fields in RFC at SAP end will be reflected in the Request/Response xml structure of the RFC in BLS
    Regards
    Som

  • Duration of an Abap Function call from Java using Jco3

    Hi guys!
    I would like to use this discussion to get some refernces of the duration Timespan of an RFC call from Java to SAP. At the moment, i need at last about 200ms to call the Abap function. I'm just using one simple import and export parameter (so no deep structures). I think that the reason for my poor performance is, that the Java Tool and the SAP instance are not in the same network. So, i hope some of you have some data, how fast an RFC call from Java using Jco can be executed.
    greetings, Hannes

    Hi Hannes,
    I think you have already got the answer to your question - the network set-up you have is probably the bottleneck.  Whenever I've worked with Java <-> ABAP and they are in the same network, I've had no performance problems at all.
    Does your RFC contain any complex logic or business processes?  Are you able to try and call something that does nothing, say it just accepts an input string and returns it straight away as an export.  Do you have any scope for testing with your Java tool on the same network as the SAP system?
    Cheers,
    G.

  • Importing Structure field values in Excel using VBA and SAP RFC

    I am calling a RFC MEASUREM_DOCUM_RFC_SINGLE_001 from Excel VBA. The export parameters of the RFC has a parameter MEASUREMENT_DOCUMENT and structure COMPLETE_DOCUMENT. I am able to get back parameter value in excel from RFC using
    ActiveCell = Funct.imports("MEASUREMENT_DOCUMENT")
    Now I want to get the value of one of the fields say POINT of the structure COMPLETE_DOCUMENT in Excel. The following code doesnt work
    ActiveCell = Funct.imports("COMPLETE_DOCUMENT-POINT")
    It gives an error.
    Even I have tried to using code for tables
    dim tab as object
    set tab = funct.tabels("COMPLETE_DOCUMENT")
    but it did'nt work.
    Can any one help me how to access the field value of a structure?
    regards
    Ravindra

    I am calling a RFC MEASUREM_DOCUM_RFC_SINGLE_001 from Excel VBA. The export parameters of the RFC has a parameter MEASUREMENT_DOCUMENT and structure COMPLETE_DOCUMENT. I am able to get back parameter value in excel from RFC using
    ActiveCell = Funct.imports("MEASUREMENT_DOCUMENT")
    Now I want to get the value of one of the fields say POINT of the structure COMPLETE_DOCUMENT in Excel. The following code doesnt work
    ActiveCell = Funct.imports("COMPLETE_DOCUMENT-POINT")
    It gives an error.
    Even I have tried to using code for tables
    dim tab as object
    set tab = funct.tabels("COMPLETE_DOCUMENT")
    but it did'nt work.
    Can any one help me how to access the field value of a structure?
    regards
    Ravindra

  • Upload data from excel with vba by calling a function module

    Hello all,
    i have a problem with the function module "ALSM_EXCEL_TO_INTERNAL_TABLE". I will call this function module with vba to load data from excel to sap with a Buttonclick. I have copied this function module and set it remotable. But i can´t call it from excel.
    Can you give me some tips how can i
    upload data from excel with vba by click a button.
    The problem seems the function: call method cl_gui_frontend_services=>clipboard_import in the function module, because when i comment this function call the vba-call is true but no results. 
    How can I call the function module correct with vba?
    Thanks a lot for your tips!!!!
    Chris
    Message was edited by:
            Christoph Kirschner

    HI
    Uploading data directly from Excel file format
    * Upload data direct from excel.xls file to SAP
    REPORT ZEXCELUPLOAD.
    PARAMETERS: filename LIKE rlgrap-filename MEMORY ID M01,
                begcol TYPE i DEFAULT 1 NO-DISPLAY,
                begrow TYPE i DEFAULT 1 NO-DISPLAY,
                endcol TYPE i DEFAULT 100 NO-DISPLAY,
                endrow TYPE i DEFAULT 32000 NO-DISPLAY.
    * Tick don't append header
    PARAMETERS: kzheader AS CHECKBOX.
    DATA: BEGIN OF intern OCCURS 0.
            INCLUDE STRUCTURE  alsmex_tabline.
    DATA: END OF intern.
    DATA: BEGIN OF intern1 OCCURS 0.
            INCLUDE STRUCTURE  alsmex_tabline.
    DATA: END OF intern1.
    DATA: BEGIN OF t_col OCCURS 0,
           col LIKE alsmex_tabline-col,
           size TYPE i.
    DATA: END OF t_col.
    DATA: zwlen TYPE i,
          zwlines TYPE i.
    DATA: BEGIN OF fieldnames OCCURS 3,
            title(60),
            table(6),
            field(10),
            kz(1),
          END OF fieldnames.
    * No of columns
    DATA: BEGIN OF data_tab OCCURS 0,
           value_0001(50),
           value_0002(50),
           value_0003(50),
           value_0004(50),
           value_0005(50),
           value_0006(50),
           value_0007(50),
           value_0008(50),
           value_0009(50),
           value_0010(50),
           value_0011(50),
           value_0012(50),
           value_0013(50),
           value_0014(50),
           value_0015(50),
           value_0016(50),
           value_0017(50),
           value_0018(50),
           value_0019(50),
           value_0020(50),
           value_0021(50),
           value_0022(50),
           value_0023(50),
           value_0024(50),
           value_0025(50),
           value_0026(50),
           value_0027(50),
           value_0028(50),
           value_0029(50),
           value_0030(50),
           value_0031(50),
           value_0032(50),
           value_0033(50),
           value_0034(50),
           value_0035(50),
           value_0036(50),
           value_0037(50),
           value_0038(50),
           value_0039(50),
           value_0040(50),
           value_0041(50),
           value_0042(50),
           value_0043(50),
           value_0044(50),
           value_0045(50),
           value_0046(50),
           value_0047(50),
           value_0048(50),
           value_0049(50),
           value_0050(50),
           value_0051(50),
           value_0052(50),
           value_0053(50),
           value_0054(50),
           value_0055(50),
           value_0056(50),
           value_0057(50),
           value_0058(50),
           value_0059(50),
           value_0060(50),
           value_0061(50),
           value_0062(50),
           value_0063(50),
           value_0064(50),
           value_0065(50),
           value_0066(50),
           value_0067(50),
           value_0068(50),
           value_0069(50),
           value_0070(50),
           value_0071(50),
           value_0072(50),
           value_0073(50),
           value_0074(50),
           value_0075(50),
           value_0076(50),
           value_0077(50),
           value_0078(50),
           value_0079(50),
           value_0080(50),
           value_0081(50),
           value_0082(50),
           value_0083(50),
           value_0084(50),
           value_0085(50),
           value_0086(50),
           value_0087(50),
           value_0088(50),
           value_0089(50),
           value_0090(50),
           value_0091(50),
           value_0092(50),
           value_0093(50),
           value_0094(50),
           value_0095(50),
           value_0096(50),
           value_0097(50),
           value_0098(50),
           value_0099(50),
           value_0100(50).
    DATA: END OF data_tab.
    DATA: tind(4) TYPE n.
    DATA: zwfeld(19).
    FIELD-SYMBOLS: <fs1>.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                mask      = '*.xls'
                static    = 'X'
           CHANGING
                file_name = filename.
    START-OF-SELECTION.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = filename
                i_begin_col             = begcol
                i_begin_row             = begrow
                i_end_col               = endcol
                i_end_row               = endrow
           TABLES
                intern                  = intern
           EXCEPTIONS
                inconsistent_parameters = 1
                upload_ole              = 2
                OTHERS                  = 3.
      IF sy-subrc <> 0.
        WRITE:/ 'Upload Error ', SY-SUBRC.
      ENDIF.
    END-OF-SELECTION.
      LOOP AT intern.
        intern1 = intern.
        CLEAR intern1-row.
        APPEND intern1.
      ENDLOOP.
      SORT intern1 BY col.
      LOOP AT intern1.
        AT NEW col.
          t_col-col = intern1-col.
          APPEND t_col.
        ENDAT.
        zwlen = strlen( intern1-value ).
        READ TABLE t_col WITH KEY col = intern1-col.
        IF sy-subrc EQ 0.
          IF zwlen > t_col-size.
            t_col-size = zwlen.
    *                          Internal Table, Current Row Index
            MODIFY t_col INDEX sy-tabix.
          ENDIF.
        ENDIF.
      ENDLOOP.
      DESCRIBE TABLE t_col LINES zwlines.
      SORT intern BY row col.
      IF kzheader = 'X'.
        LOOP AT intern.
          fieldnames-title = intern-value.
          APPEND fieldnames.
          AT END OF row.
            EXIT.
          ENDAT.
        ENDLOOP.
      ELSE.
        DO zwlines TIMES.
          WRITE sy-index TO fieldnames-title.
          APPEND fieldnames.
        ENDDO.
      ENDIF.
      SORT intern BY row col.
      LOOP AT intern.
        IF kzheader = 'X'
        AND intern-row = 1.
          CONTINUE.
        ENDIF.
        tind = intern-col.
        CONCATENATE 'DATA_TAB-VALUE_' tind INTO zwfeld.
        ASSIGN (zwfeld) TO <fs1>.
        <fs1> = intern-value.
        AT END OF row.
          APPEND data_tab.
          CLEAR data_tab.
        ENDAT.
      ENDLOOP.
      CALL FUNCTION 'DISPLAY_BASIC_LIST'
           EXPORTING
                file_name     = filename
           TABLES
                data_tab      = data_tab
                fieldname_tab = fieldnames.
    *-- End of Program
    <b>Excel Upload Alternative - KCD_EXCEL_OLE_TO_INT_CONVERT</b>
    *Title : Excel Uploading
    TYPES:   BEGIN OF t_datatab,
             col1(25)  TYPE c,
             col2(30)  TYPE c,
             col3(30)  TYPE c,
             col4(30)  TYPE c,
             col5(30)  TYPE c,
             col6(30)  TYPE c,
             col7(30) TYPE c,
             col8(30)  TYPE c,
             col9(30)  TYPE c,
             col10(30)  TYPE c,
             col11(30)    TYPE c,
           END OF t_datatab.
    DATA: it_datatab TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0,
          wa_datatab TYPE t_datatab.
    Data : p_table type t_datatab occurs 0 with header line.
    DATA : gd_scol   TYPE i VALUE '1',
           gd_srow   TYPE i VALUE '1',
           gd_ecol   TYPE i VALUE '256',
           gd_erow   TYPE i VALUE '65536'.
    DATA: it_tab TYPE filetable,
          gd_subrc TYPE i.
    field-symbols : <fs>.
    *Selection screen definition
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:  p_file LIKE rlgrap-filename
                   DEFAULT 'c:test.xls' OBLIGATORY.   " File Name
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      REFRESH: it_tab.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title     = 'Select File'
          default_filename = '*.xls'
          multiselection   = ' '
        CHANGING
          file_table       = it_tab
          rc               = gd_subrc.
      LOOP AT it_tab INTO p_file.
    *    so_fpath-sign = 'I'.
    *    so_fpath-option = 'EQ'.
    *    append so_fpath.
      ENDLOOP.
    START-OF-SELECTION.
      PERFORM upload_excel_file TABLES   it_datatab
                                 USING   p_file
                                         gd_scol
                                         gd_srow
                                         gd_ecol
                                         gd_erow.
    * END-OF-SELECTION.
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3,
                wa_datatab-col4,
                wa_datatab-col5,
                wa_datatab-col6,
                wa_datatab-col7,
                wa_datatab-col8,
                wa_datatab-col9,
                wa_datatab-col10,
                wa_datatab-col11.
      ENDLOOP.
    *&      Form  UPLOAD_EXCEL_FILE
    *       upload excel spreadsheet into internal table
    *      -->P_TABLE    Table to return excel data into
    *      -->P_FILE     file name and path
    *      -->P_SCOL     start column
    *      -->P_SROW     start row
    *      -->P_ECOL     end column
    *      -->P_EROW     end row
    FORM upload_excel_file TABLES   p_table
                           USING    p_file
                                    p_scol
                                    p_srow
                                    p_ecol
                                    p_erow.
      DATA : lt_intern TYPE  kcde_cells OCCURS 0 WITH HEADER LINE.
    * Has the following format:
    *             Row number   | Colum Number   |   Value
    *      i.e.     1                 1             Name1
    *               2                 1             Joe
      DATA : ld_index TYPE i.
    * Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
        EXPORTING
          filename                = p_file
          i_begin_col             = p_scol
          i_begin_row             = p_srow
          i_end_col               = p_ecol
          i_end_row               = p_erow
        TABLES
          intern                  = LT_INTERN
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'Error Uploading file'.
        EXIT.
      ENDIF.
      IF lt_intern[] IS INITIAL.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'No Data Uploaded'.
        EXIT.
      ELSE.
        SORT lt_intern BY row col.
        LOOP AT lt_intern.
         MOVE lt_intern-col TO ld_index.
         assign component ld_index of structure
         p_table to <fs>.
    move : lt_intern-value to <fs>.
    *     MOVE lt_intern-value TO p_table.
          AT END OF row.
            APPEND p_table.
            CLEAR p_table.
          ENDAT.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "UPLOAD_EXCEL_FILE
    Regards
    Pavan

  • Excel sheet generation through RFC call from a BSP application

    Hi,
      I am calling a RFC FM ( in R3)  in Event handler 'OnInputProcessing' of a BSP application in a SRM server.
    That function submits a report program which geneates a excel sheet using download FM . Excel sheet is not getting generated.
    But when i am calling this RFC FM  (in R3) from a report program ( in srm server)
    this is generating an ecel sheet.
    I want to have call RFC from BSP application.
    I tried the way of submit a program ( which contains RFC call) from BSP application ,but it is also not generating excel sheet.
    My ultimate AIM is to generate excel sheet by trigerring CALL or submit from BSP
    application.
    can any one propose solution for it.
    Useful answers will be rewarded.

    Hi,
    Which FM is it. I guess that the download generated is a SAP gui oriented solution, which will never work in a web environment
    Eddy
    PS. Reward useful answers and earn points yourself

  • Export Project Tasks to Excel using VBA by Custom Field

    Question referring to the link:
    http://social.technet.microsoft.com/Forums/projectserver/en-US/9c46458c-893f-41ba-bd46-bdb59c533f4a/export-project-tasks-to-excel-using-vba-by-custom-field?forum=project2010custprog
    Help needed. I have inserted my question at this address for Andrew or anybody else to reply. Hope to hear from you.
    Regards,
    Chuck

    Thank you Andrew for getting back to me and I have found somewhere on the net the following macro that would do the job for the version 2007. Here is a copy for those that may need it.
    Option Explicit
    Sub CreateMenus()
    Dim cbrMain As CommandBar
    Dim ctlMain As CommandBarControl
    Dim ctlOLExport1 As CommandBarControl
    Dim ctlOLExport2 As CommandBarControl
    Dim ctlOLExport3 As CommandBarControl
    Set cbrMain = Application.CommandBars.ActiveMenuBar
    Set ctlMain = cbrMain.Controls.Add(Type:=msoControlPopup, Temporary:=True)
    ctlMain.Caption = "Export to Outlook"
    Set ctlOLExport1 = ctlMain.CommandBar.Controls.Add(Type:=msoControlButton)
    With ctlOLExport1
    .Caption = "Selection to Outlook tasks"
    .OnAction = "Macro """ & "Export_Selection_To_OL_Tasks"""
    End With
    Set ctlOLExport2 = ctlMain.CommandBar.Controls.Add(Type:=msoControlButton)
    With ctlOLExport2
    .Caption = "Selection to Outlook appointments"
    .OnAction = "Macro """ & "Export_Selection_To_OL_Appointments"""
    End With
    Set ctlOLExport3 = ctlMain.CommandBar.Controls.Add(Type:=msoControlButton)
    With ctlOLExport3
    .Caption = "Selection to Outlook notes"
    .OnAction = "Macro """ & "Export_Selection_To_OL_Notes"""
    End With
    End Sub
    Cheers!
    Chuck

  • RFC call from a Windows Service

    Hi All,
    I have created a simple windows service which is making an RFC call to R/3 system. This is not working. Whereas the same piece of code written in a windows application projects(exe) works properly. Does anyone had similer issues working with Windows services ? Is it a known issue of RFC calls from windows service ???
    Thanks & Regards
    Ganesh Datta

    Hi Juergen,
    After I put the debug statements I figured out that connection to R/3 system is unsuccessful.
    I am using the SAP .Net Connector 2.0. I wrote a windows service which is manually started. Withing my service I am using Single sign on to connect .This is what was causing the problem. If I disable Single sign on and supply userID and password then connection is successful and also subsequent RFC calls.
    I guess within windows service Single sign on does not work.
    Thanks for your reply
    Best Regards
    Ganesh Datta

  • Best approach for RFC call from Adapter module

    What is the best approach for making a RFC call from a <b>reciever</b> file adapter module?
    1. JCo
    2. Is it possible to make use of MappingLookupAPI classes to achieve this or those run in the mapping runtime environment only?
    3. Any other way?
    Has anybody ever tried this? Any pointers????
    Regards,
    Amol

    Hi ,
    The JCo lookup is internally the same as the Jco call. the only difference being you are not hardcoding the system related data in the code. So its easier to maintain during transportation.
    Also the JCO lookup code is more readable.
    Regards
    Vijaya

  • Invoke MII Transaction thru RFC Call from SAP

    Hi,
    We want to get the data from Oracle DB table thru MII (12.0.2).
    We need to use RFC call from SAP to MII.
    Is it possible to invoke the MII transaction thru RFC by setting in Message Listener?
    We have used iDoc messages but not tried with RFC.
    How to do that?
    Regards,
    Senthil

    I feel MII doesn't have anything equivalent to RFC in ECC. You may try web services in an ABAP program
    Hope the article below helps you
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/9f101377-0c01-0010-269f-c3ee905d583b&overridelayout=true
    Regards,
    Musarrat

  • Problem with uploading data from excel using BDC for tcode f-02

    Hi All,
    I am uploading data from excel using BDC for tcode f-02. The problem here is, while recording, the values of some fields are recording twice. I dont know why it's happening so. But if I run my abap program, I have to give those fields twice in my excel sheet. Otherwise data does not upload. But it is not the feasible way. We must give those fields once in excel. Please tell me, how I can solve the issue.
    With regards,
    Rosaline.

    Hi,
      in BDC each and every action is recording. If your press enter in same screen that also recorded once aging may be this is your case repeating field values will appear. we can solve the problem for repeat fields like below.
    suppose in your excel having repeated field X1 X2 X3 the X2 contains repeated field X3 means delete the X3 field.
    Now In your itab having X1 and X2 fields. While in the LOOP the ITAB pass the X2 field to repeated the fields.
    LOOP at ITAB to WA.
    CLEAR bdcdata_wa.
    bdcdata_wa-fnam = 'BDC_CURSOR'.
    bdcdata_wa-fval = 'RM08M-EBELN'.
    APPEND bdcdata_wa TO bdcdata_tab.
    CLEAR bdcdata_wa.
    bdcdata_wa-fnam = 'INVFO-BLDAT'.
    bdcdata_wa-fval = wa-X2." 1st time pass the X2 fields
    APPEND bdcdata_wa TO bdcdata_tab.
    CLEAR bdcdata_wa.
    bdcdata_wa-fnam = 'INVFO-BLDAT'.
    bdcdata_wa-fval = wa-X2." pass the same value to repeated field
    APPEND bdcdata_wa TO bdcdata_tab.
    Endloop.
    Hope you can understand.
    Regards,
    Dhina..

  • RFC Call from ABAP (R3) to Webdynpro EP

    Hi experts,
    I have a requirement to initiate a call from an ABAP program on R3 to a standard Portal (Webdynpro) API. Does anyone have any experience with this?
    I understand that normally Portal (Webdynpro) applications will make the RFC call to ABAP via the established JCO connection. However there's very limited literature elaborating how the call can be made in the other direction i.e. from ABAP R3 to Portal
    Anyone, please kindly advise how, if this can be done. Many thanks!
    Best regards,
    Lionel

    Hi,
    I'm trying to make a RFC call from the ABAP program to a built in Java method residing on EP. It is part of a suite of methods provided by the UME engine.
    Typically a call is made from a webdynpro program to a SAP ABAP function module. In this case, I'd like to make a call from the SAP ABAP report to the EP method.
    Best regards,
    Lionel

  • Making an RFC call from within the VM container

    Hi all,
    since a long time I am searching for information on how to implement an RFC call from within the VMC. The problem is that we have implemented several (p)functions in ABAP and we need to implement them in JAVA.
    Now I am searching for a way how to just call the already existing pfunctions???
    Is it possible to read CRM DB tables too?
    Thank you in advance
    Boris

    Hi Freeto,
    This may be due to the Network Failures.
    If you have triggered a job then because of the Network fluctuations the system may not respond properly and cannot execute the job.
    So, this is the cause for the failure.
    Hope you understood.
    With Regards,
    Ravi Kanth

Maybe you are looking for