// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the ReportService.
ReportServiceInterface reportService = user.getService(DfpService.V201208.REPORT_SERVICE);
Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");
// Create statement to filter for an order.
Statement filterStatement =
new StatementBuilder("WHERE ORDER_ID = :id").putValue("id", orderId).toStatement();
// Create report job.
ReportJob reportJob = new ReportJob();
// Create report query.
ReportQuery reportQuery = new ReportQuery();
reportQuery.setDateRangeType(DateRangeType.LAST_MONTH);
reportQuery.setDimensions(new Dimension[] {Dimension.ORDER});
reportQuery.setDimensionAttributes(new DimensionAttribute[] {
DimensionAttribute.ORDER_TRAFFICKER, DimensionAttribute.ORDER_START_DATE_TIME,
DimensionAttribute.ORDER_END_DATE_TIME});
reportQuery.setStatement(filterStatement);
reportQuery.setColumns(new Column[] {Column.AD_SERVER_IMPRESSIONS,
Column.AD_SERVER_CLICKS, Column.AD_SERVER_CTR,
Column.AD_SERVER_CPM_AND_CPC_REVENUE, Column.AD_SERVER_AVERAGE_ECPM});
reportJob.setReportQuery(reportQuery);
// Run report job.
reportJob = reportService.runReportJob(reportJob);
do {
System.out.println("Report with ID '" + reportJob.getId() + "' is still running.");
Thread.sleep(30000);
// Get report job.
reportJob = reportService.getReportJob(reportJob.getId());
} while (reportJob.getReportJobStatus() == ReportJobStatus.IN_PROGRESS);
if (reportJob.getReportJobStatus() == ReportJobStatus.FAILED) {
System.out.println("Report job with ID '" + reportJob.getId()
+ "' failed to finish successfully.");