Skip to Content
0
Jul 24, 2019 at 02:53 PM

CALL FM RSAQ_REMOTE_QUERY_CALL in VBA

736 Views Last edit Jul 24, 2019 at 02:53 PM 2 rev

Hello,

I Have a mission to create a VBA macro that can extract a report directly from sq01 to an excel sheet, i was using RFC_READ_TABLE but this FM work just with one table at a time, so i found this FM RSAQ_REMOTE_QUERY_CALL which can query a report but i have this exception error "NO_SELECTION"

This is my code :

Sub z_Read_RFC_TAB_Function(R3 As Object)

Set func = R3.Add("RSAQ_REMOTE_QUERY_CALL")

func.Exports("WORKSPACE") = " "

func.Exports("QUERY") = "CLASSIF"

func.Exports("USERGROUP") = "CQ"

func.Exports("VARIANT") = " "

func.Exports("DBACC") = "0"

func.Exports("SKIP_SELSCREEN") = "X"

func.Exports("DATA_TO_MEMORY") = " "

func.Exports("EXTERNAL_PRESENTATION") = " "

Dim objLDataTable As Object

Set objLDataTable = func.Tables("LDATA")

Dim objLDescTable As Object

Set objLDescTable = func.Tables("LISTDESC")

objLDescTable.Rows.Add

objLDescTable(objLDescTable.RowCount, "FDESC") = "OBJEK"

If func.Call = False Then

MsgBox func.Exception

Exit Sub

Else

Sheets("SHEET1").Select

Dim objLDataRecord As Object

Dim objLDescRecord As Object

For Each objLDataRecord In objLDataTable.Rows

For Each objLDescRecord In objLDescTable.Rows

a = objLDataRecord("LINE")

Cells(objLDataRecord.Index + 1, objLDescRecord.Index) = objLDataRecord("LINE") 'Cells(objDatRec.Index + 1, objFldRec.Index) = Mid(objDatRec("WA"), objFldRec("OFFSET") + 1, objFldRec("LENGTH"))

Next

Next

End If

End Sub

**Thank you