Posting Files into Report Manager using PostReport Class

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)


Have 2000 report files that need to be available in Report Manager. Reports need to be distributed to a custom role and to specific users that can be controlled by a specific user, in charge of the process. Users should also be able to receive an email with those reports attached.


Create a simple page to allow add users that need to receive reports. In this case all of the users have a profile updated with current email address. So we just needed to create a page and allow adding users from PSOPRDEFN table:

Add Report Users Page

Add Report Users Page

So how do we get the reports into report manager? One of the answers is – using app engine and PostReport Class in peoplecode. I chose this particular approach because of the dynamic nature of how the reports needed to be distributed to the users.

Let’s not  go through all the details of the app engine, as they may not be relevant, instead let’s review the how PostReport Class is used to post reports.

  1. Note the code check for directory existence – PeopleCode does not have  good filesystem functions for this purpose, so Java Object is used instead
  2. PostReport object allows to specify multitude of options – distribution ids (user ids), Role, Reporting Folder, Process and Process Name

Local PostReport &RPTINFO;
Local number &RPTINSTANCE;
Local SQL &userDistSQL;
Local string &distID;
Local number &ExitCode;
Local JavaObject &javaFile;

&filepath = “/psoft/psreports/GUARD/DTAR/dept” | ZZ_DTAR_RPT_AET.DEPTID_FROM | “/”;

/* Check if directory exists */
&javaFile = CreateJavaObject(“”, &filepath);
&checkFirectory = &javaFile.exists();
If &checkFirectory = True Then

&RPTINFO = SetPostReport();

&RPTINFO.ProcessType = “SQR Report”;
&RPTINFO.ReportFolder = “DTAR”;
&RPTINFO.SourceReportPath = “/psoft/psreports/GUARD/DTAR/dept” | ZZ_DTAR_RPT_AET.DEPTID_FROM | “/”;
&RPTINFO.ExpirationDate = AddToDate(%Date, 1, 0, 0);
&RPTINFO.ReportDescr = “Department Activity Report ” | ZZ_DTAR_RPT_AET.DEPTID_FROM | ” – ” | ZZ_DTAR_RPT_AET.THRU_DATE;
&RPTINFO.ServerName = “PSUNX2”;

/* Loop through DTAR Configuration user distribution table and add to distribution*/
While &userDistSQL.Fetch(&distID)
&RPTINFO.AddDistributionOption(“USER”, &distID);

&RPTINFO.AddDistributionOption(“ROLE”, “GLIC_DTAR_ALL”);


If (&RPTINSTANCE > 0) Then
MessageBox(0, “”, 63, 119, “Successfully processed request with Rpt. ID %1 for Process %2 to post from directory %3”, &RPTINSTANCE, &RPTINFO.ProcessName, &RPTINFO.SourceReportPath);
MessageBox(0, “”, 63, 122, “Not successful for process request for Process %1 to post from directory %2”, &RPTINFO.ProcessName, &RPTINFO.SourceReportPath);
MessageBox(0, “”, 0, 0, “Directory %1 does not exist”, &filepath);
Once the app engine runs and uses PostReport to post the files, they are available for viewing using Report Manager:

Report Manager View

Report Manager View

Those same reports can also be available for viewing in delivered My Reports Pagelet:

My Reports Pagelet View

My Reports Pagelet

I hope you enjoyed reading, and in the next post I will discuss how can we make the presentation of the above My Reports Pagelet better.

I really want to know what you think