EGL レポート・ハンドラーの手操作による作成

「新規 EGL レポート・ハンドラー (New EGL Report Handler)」ウィザードを使用してレポート・ハンドラーを作成したくない場合は、 手操作でレポート・ハンドラーを作成できます。

レポート・ハンドラーを手操作で作成する手順は、次のとおりです。
  1. 新規 EGL ソース・ファイルを作成する。
  2. 次のどちらかを実行する。
    • 手操作でハンドラー・コードを入力する。
    • 次のように、レポート・ハンドラー・テンプレートを使用してハンドラーを挿入する。
      1. レポート・ハンドラー・テンプレートにナビゲートし、使用したいテンプレートを選択する。
      2. 編集」をクリックする。
      3. handler を入力した後、Ctrl+space を押す。
      4. 必要に応じてテンプレート・コードを変更する。
このトピックのこれ以降の部分では、次のものを示すコード例を記載しています。

このコードをコピーし、ご使用のアプリケーションに合わせて変更することができます。

手操作でレポート・ハンドラーを作成するための構文を示すサンプル・コード

次のコードは、手操作で EGL レポート・ハンドラーを作成するための一般的な構文を示しています。
handler handlerName type jasperReport
	
	 // Use Declarations (optional)
	 use usePartReference;
	
  	// Constant Declarations (optional)
	 const constantName constantType = literal;
	
	 // Data Declarations (optional)
	 identifierName declarationType;
	
	 // Pre-defined Jasper callback functions (optional)
	 function beforeReportInit()
		...
	 end	
	 function afterReportInit()
...
  end
	
	 function beforePageInit()
		...
	 end	
	 function afterPageInit()
		...
	 end	
	 function beforeColumnInit()
		...
	 end	
	 function afterColumnInit()
		...
	 end	
	 function beforeGroupInit(stringVariable string)
		...
	 end	
	 function afterGroupInit(stringVariable string)
		...
	 end	
	 function beforeDetailEval()
		...
	 end	
	 function afterDetailEval()
		...
	 end	
	 // User-defined functions (optional)
	 function myFirstFunction()
		...
	 end	
	 function mySecondFunction()
		...
	 endend

レポート・パラメーターの取得方法を示す例

次のコードの断片は、レポート・ハンドラーでレポート・パラメーターを取得する方法を示しています。
handler myReportHandler type jasperReport
	
	// Data Declarations
	 report_title	String;

	 // Jasper callback function
	 function beforeReportInit()
...

 		  report_title = getReportTitle();

...
  end

	...
	
	 // User-defined function
	 function getReportTitle() Returns (String)
    	return (getReportParameter("ReportTitle"));
  	end
	
end

レポート変数を設定し、取得する方法を示す例

下に示すコードの断片は、レポート・ハンドラーでレポート変数を設定し、取得する方法を示しています。
handler myReportHandler type jasperReport
	
  	// Data Declarations
	 employee_serial_number	int;

	 // Jasper callback function
	 function afterPageInit()
		...
		  employee_serial_number = getSerialNumberVar();
		...
	 end	
	...
	
	 // User-defined function
	 function getSerialNumberVar() Returns (int)
    	employeeName String;
   	 employeeName = "Ficus, Joe";
   	 setReportVariableValue("employeeNameVar", employeeName);
   	 return (getReportVariableValue("employeeSerialNumVar"));
  	end
end

レポート・ハンドラー内のレポート・フィールド値の取得方法を示す例

下に示すコードの断片は、レポート・ハンドラーでレポート・フィールド値を取得する方法を示しています。
handler myReportHandler type jasperReport
	
	// Data Declarations
	 employee_first_name	String;

	 // Jasper callback function
	 function beforeColumnInit()
		  ...
		  employee_first_name = getFirstNameField();
		  ...
	 end	
  	...
	
	 // User-defined function
	 function getFirstNameField() Returns (String)
    	fldName String;
    	fldName = "fname";
    	return (getFieldValue(fldName));
  	end
	
end

レポート・ハンドラーでレポート・データ・フレキシブル・レコードを追加する方法を示す例

下に示すコード例は、レポート・ハンドラーでレポート・データ・フレキシブル・レコードを追加する方法を示しています。
handler myReportHandler type jasperReport
	
	// Data Declarations
	customer_array 	customerRecordType[];
	c 			customerRecordType;

	// Jasper callback function
	 function beforeReportInit()
		  customer ReportData;
		  datasetName String;
		
   		//create the ReportData object for the Customer subreport
		  c.customer_num  = getFieldValue("c_customer_num");
    c.fname         = getFieldValue("c_fname");
    c.lname         = getFieldValue("c_lname");
    c.company       = getFieldValue("c_company");
    c.address1      = getFieldValue("c_address1");
    c.address2      = getFieldValue("c_address2");
    c.city          = getFieldValue("c_city");
    c.state         = getFieldValue("c_state");
    c.zipcode       = getFieldValue("c_zipcode");
    c.phone         = getFieldValue("c_phone");	
    customer_array.appendElement(c);
		  customer.data = customer_array;	
    	datasetName = "customer";
    	addReportData(customer, datasetName);
  		    end	
end

XML 設計文書がレポート・ハンドラーからレポート・データ・レコードを取得する方法を示す例

下に示すコードの断片は、XML 設計文書がレポート・ハンドラーからレポート・データ・フレキシブル・レコードを取得する方法を示しています。
<jasperReport name="MasterReport" 
   scriptletClass="subreports.SubReportHandler">
...

<subreport>
	 <dataSourceExpression>
    <![CDATA[(JRDataSource)(((subreports.SubReportHandler) 
    $P{REPORT_SCRIPTLET}).getReportData( 
       new String("customer")))]]&gt;
  </dataSourceExpression>
	 <subreportExpression class="java.lang.String">
    <![CDATA["C:/RAD/workspaces/Customer.jasper"]]&gt;
  </subreportExpression>
</subreport>

...
</jasperReport>

関連する概念
EGL レポートの概要
EGL レポート作成プロセスの概要

関連するタスク
EGL ソース・ファイルの作成
EGL レポート・ハンドラーの作成
レポート・テンプレートの使用

関連する参照項目
EGL レポート・ライブラリー
EGL レポート・ハンドラー
事前定義されたレポート・ハンドラー関数
追加の EGL レポート・ハンドラー関数

ご利用条件 | フィードバック
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.
(C) Copyright IBM Japan 2005.