cancel
Showing results for 
Search instead for 
Did you mean: 

INITIAL FILTER IN AFO VBA

0 Kudos

Hi Experts,

I would like to filter datasource before open workbook with VBA in AFO

Im trying yo filter a datasource with Workbook_SAP_Initialize()

CODE:

Public Sub Workbook_SAP_Initialize()

lresult = Application.Run("SAPSetFilter", "DS_1", "ACAUDIT", "CREP_TARJ", "INPUT_STRING")

End Sub


The same code execute with botton work but with the initialize of workbook not work.

Thank you all

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi!

In the code of VBA you have to refresh before the code of the filter:

Public Sub Workbook_SAP_Initialize()


Application.Run("SAPExecuteCommand", "Refresh.ActualSheet")

lresult = Application.Run("SAPSetFilter", "DS_1", "ACAUDIT", "CREP_TARJ", "INPUT_STRING")

End Sub

Thank you

Answers (3)

Answers (3)

0 Kudos

Hi Javier,

I don't understand why you want to do this filtering using VBA. Without code you can use BW variables, so the end user can set the restriction. The variable may be based on authorization. Variables have the advantage that you have one implementation that works for all workbooks and queries that contain the variables. VBA code has to be replicated in all relevant workbooks.

Regards,

Gregor

0 Kudos

YES, its defined in this section.

Thank you

former_member186338
Active Contributor
0 Kudos

Try to register callback AfterRedisplay and use SAPSetFilter here

former_member186338
Active Contributor
0 Kudos

Just from help:

"Callback 'Workbook_SAP_Initialize' has to be defined in the 'ThisWorkbook' section of the VBA editor."