Skip to Content
0

INITIAL FILTER IN AFO VBA

May 16, 2017 at 09:10 AM

89

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
avatar image
Former Member May 18, 2017 at 08:24 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Vadim Kalinin May 16, 2017 at 09:24 AM
0

Just from help:

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member May 16, 2017 at 09:25 AM
0

YES, its defined in this section.

Thank you

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Try to register callback AfterRedisplay and use SAPSetFilter here

0
Gregor Dieckmann
May 18, 2017 at 03:47 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded