cancel
Showing results for 
Search instead for 
Did you mean: 

VBA SAPSetFilter AO Excel - Multiple Values via name range

flo-g
Explorer
0 Kudos

Dear all,


I would like to give a list of more than 20000 text values (document numbers) as filter for an BW Query in Analysis for Office. This I would like to do via a short VBA code to automate. The Filter value shall be based on a variable list length. I have defined a variable name range in Excel and tried to use this name range then as filter input via the Application.Run SAPSet filter function. For this I am joining my variable area together in one string with a ; seperator.


For a limited amount of documents this does work. But as soon as it comes to a bigger list, I do receive a runtime error 1004. I guess the SapSetFilter function has an input limit. Do you have an idea to solve it? Is there a possibility to use the "Paste from Clipboard" function via VBA to use a Range filter in AO?

Sub Test()

Dim lresult As String

Dim rng As Range
Dim i As String
Dim SourceRange As Range

Set SourceRange = Range("MyRangeTest")

For Each rng In SourceRange
i = i & rng & ";"
Next rng

lresult = Application.Run("SAPSetFilter", "DS_3", "0DOC_NUMBER", i, "INPUT_STRING")

End Sub

When it comes to a big amount of data in the String i, it comes to this Runtime Error for the lresult row:

Thank you.

quilton
Explorer
0 Kudos

Hello,

I do not have an answer to your question. And I have a question of my own.

Does it only work in BW queries? We have a CDS view report that we can access in Excel. When trying to call SAPSetFilter, in an Excel macro to set the filter for the report, I found that it did not work. Instead of 20000 values, we have only 3.

If it can work with CDS view reports, do we have to do anything else to make it work?

Thanks.

Accepted Solutions (0)

Answers (0)