Run a Birt Report on click of a Button

Hi,

I was asked this question by one of the visitor on my blog.

How do I run and view a report using bean class?

So, here is the way to execute any report on button click in maximo.

Tis method will be in a bean class and the mxevent value of that button will be runassetreport.

The only part which I think I need to explain in this is:

 

this.app.put(“runtype”, “BIRT”);
this.app.put(“appname”, “ASSET”);
this.app.put(“reportname”, “asset_detail.rptdesign”);
String pageName = “reportd” + “1010”;

Because this solution talks about a BIRT Report the runtype is BIRT.

Appname is ASSET cause I am running azn asset detail report and this number 1010 is the reportnum from Report table.

As I was just doing a proof of concept I have hardcoded these values but ideally you will be using Report Mbo to get the relevant values.

 

    public int runassetreport() throws MXException, RemoteException, IOException, ServletException
      {

        try
        {
            
        ReportAdminServiceRemote reportAdminServiceRemote = (ReportAdminServiceRemote)getMXSession().lookup(“BIRTREPORT”);
        int engineState = reportAdminServiceRemote.getReportEngineState();
        if (engineState == 2)
        {
          this.clientSession.showMessageBox(this.clientSession.getCurrentEvent(), “Reports Overloaded”, getMessage(“reports”, “previewoverload”), 2);

          return 1;
        }
        if (engineState == 1)
        {
          this.clientSession.showMessageBox(this.clientSession.getCurrentEvent(), “Zero Concurrent Run”, this.clientSession.getMaxMessage(“reports”, “zeroConcurrentRun”).getMessage(), 2);

          return 1;
        }
         
          this.app.put(“runtype”, “BIRT”);
          this.app.put(“appname”, “ASSET”);
          this.app.put(“reportname”, “asset_detail.rptdesign”);
          String pageName = “reportd” + “1010”;
          
          ControlHandler lookup = RequestHandler.findDialog(this.sessionContext, pageName);
          
          if (lookup == null)
          {
            
            String[] params1 = { pageName };
            Utility.showMessageBox(this.sessionContext.getCurrentEvent(), “reports”, “repappnoxml”, params1);
            return 1;
          }
          
          RequestHandler.showDialog(this.sessionContext, pageName);
        }
        catch (MXException e)
        {
          e.printStackTrace();
        }
        return 1;
      }

 

A private util method to get the maxmessages used in the showMessageBox method:

private String getMessage(String msgGrp, String msgKey) throws RemoteException, MXException
      {
        return MXServer.getMXServer().getMaxMessageCache().getMessage(msgGrp, msgKey, this.sessionContext.getUserInfo()).getMessage();
      }

 

Enjoy….

 

-Aniruddh

//
//

Advertisements

14 thoughts on “Run a Birt Report on click of a Button

  1. mohamed maher

    first : when i click button request page appear .. i want report run directly

    second : how pass parameters to my report with reportParameterData ??,HOW??

    Thank You Advanced

    Reply
    1. admin Post author

      The request dialog calls the “requestreportrun” method in psdi.webclient.beans.report.ReportDialogBean, so have a read of that method and see if you can find a way to run it directly.

      And for whereclause use reportparameterdata object to pass it on.

      Reply
  2. mohamed maher

    thank u 4 help 🙂
    but i can’t assign ReportParameterData object to report so, report when run don’t take any parameters i pass.

    Reply
  3. Mary Skalicky

    I used this post to successfully print a BIRT report from JAVA when a certain error condition occurred. I did modify the code to to classes that are not deprecated. Specifically I use WebClientSession instead of Utility and RequestHandler and PageInstance instead of ControlHandler. Other than that it is working well for me. Thank you very much for taking the time to post this. I really needed it!

    Reply
    1. Rajiv

      Hi Mary,
      I have to achieve similar functionality, Really Appreciated if you share the java snippet here
      Thanks in Advance

      Reply
  4. mirws

    How can we open BIRT report and transfer report parameter with custom button without create any java class? maybe with automation script or just launch in context method just like when we use a toolbar action?

    Reply
  5. harry potter

    Just struggled with this. In Maximo 7.5 you can just add mxevent=RUNAREPORT and the reportnumber as the value. When hitting the button, the selected report starts.

    Reply
  6. Pingback: Java Customisation | surypollmaximo

  7. Arun Muniyappan

    Instead of running the report, i want to print a report- to send it to printer directly (like the direct print option) through workflow action. is there a solution for this? In my case the user prints the report every time they accept an assignment through workflow and they do not want to hit the direct print button, they want it to be printed automatically when the work order is assigned to them.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s