BusinessObjects Board

What is this Macro Doing?

I have not worked with VB Macros and now need to estimate rewriting a report that contains one. I am more of a BA than a coder and would appreciate if someone can tell me what this macro is doing.

Thanks!

Sub ears_59()
   Dim doc As Document
   Dim inter As String
   Dim gu As Integer
 
   Dim j As Long
   Dim mydps As DataProviders
   Dim mydp As DataProvider
   Dim cols As Columns
   Dim col As Column
'   Dim rc As Long
   Dim rc As Integer

   Set doc = Application.ActiveDocument
      
   Set mydps = doc.DataProviders
   Set mydp = mydps.Item(1)
   Set cols = mydp.Columns
   rc = cols.Item(1).Count
       
'   Dim rpt As busobj.Report
   Set col = cols.Item(1)
   MsgBox (rc & " pages will be printed!")
   
   For j = 1 To rc
'relocated from above to be inside the loop, so I can ERASE it to not use up all the memory
   Dim rpt As busobj.Report
     
' commented out duplicating the report   Set rpt = ActiveDocument.Reports(1).Duplicate
   Set rpt = ActiveDocument.Reports(1)
   rpt.Name = col.Item(j)
   inter = col.Item(j)
   rpt.AddComplexFilter "EVENT_ID(SQL 1 with EARS FHSQL)", "=<EVENT_ID(SQL 1 with EARS FHSQL)>=" &amp; Chr(34) &amp; inter &amp; Chr(34)
   rpt.AddComplexFilter "EVENT_ID(SQL 4 with EARS FHSQL)", "=<EVENT_ID(SQL 4 with EARS FHSQL)>=" &amp; Chr(34) &amp; inter &amp; Chr(34)
   rpt.AddComplexFilter "EVENT_ID(SQL 5 with EARS FHSQL)", "=<EVENT_ID(SQL 5 with EARS FHSQL)>=" &amp; Chr(34) &amp; inter &amp; Chr(34)
   rpt.ForceCompute
   rpt.Activate
   ActiveReport.PrintOut

'new statement here
Set rpt = Nothing

  Next
End Sub

[Edited, when posting code samples please use the code option for formatting. It will preserve any indenting or formatting that you may have done. Thank you, Andreas.]


Contractor_D (BOB member since 2007-04-13)

What I think:

  1. looping through every value of the first column of the first dataprovider and then:
    a. every value from that column is used for three complex filters that are applied to the first report in the document
    b. the first report is printed

jbo :monaco: (BOB member since 2005-07-31)

It looks like a broken version of this code. I say “broken” because it doesn’t seem like it can possibly work, given the state of the code that you posted. Without duplicating the report the filters that are applied are likely to contradict or replace each other, resulting in an unexpected result.


Dave Rathbun :us: (BOB member since 2002-06-06)

Why should they contradict? The objects used for the three complex filters belong to different dataproviders that possibly are used all together in the same report??


jbo :monaco: (BOB member since 2005-07-31)

Thanks for the pointers. As I stated, I am just trying to estimate the conversion hours for this report into Webi. I know that the macro option is not available, so I needed a general understanding of it so that I could see if it could be done without a macro. I will need to think about that part.


Contractor_D (BOB member since 2007-04-13)

[Moderator Note: Moving from BusinessObjects Classic forum to SDK (VBA/ASP/JSP).]


Marek Chladny :slovakia: (BOB member since 2003-11-27)