Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9564

Re: RFC call from Excel using VBA

$
0
0

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

Viewing all articles
Browse latest Browse all 9564

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>