269.6. IDoc のメッセージボディー
IDoc メッセージタイプ リンクのコピーリンクがクリップボードにコピーされました!
IDoc Camel SAP エンドポイントの 1 つを使用する場合、メッセージボディーのタイプは使用している特定のエンドポイントによって異なります。
sap-idoc-destination エンドポイントまたは sap-qidoc-destination エンドポイントの場合、メッセージのボディーは Document タイプになります。
org.fusesource.camel.component.sap.model.idoc.Document
sap-idoclist-destination エンドポイント、sap-qidoclist-destination エンドポイント、または sap-idoclist-server エンドポイントの場合、メッセージボディーは DocumentList タイプになります。
org.fusesource.camel.component.sap.model.idoc.DocumentList
IDoc ドキュメントモデル リンクのコピーリンクがクリップボードにコピーされました!
Camel SAP コンポーネントでは、IDoc のドキュメントは、基礎となる SAP IDoc API に関連したラッパー API を提供する Eclipse Modelling Framework(EMF)を使用してモデル化されます。このモデルで最も重要なタイプは、以下のとおりです。
org.fusesource.camel.component.sap.model.idoc.Document
org.fusesource.camel.component.sap.model.idoc.Segment
Document タイプは、IDoc ドキュメントインスタンスを表します。まとめると、Document インターフェースは以下のメソッドを公開します。
// Java
package org.fusesource.camel.component.sap.model.idoc;
...
public interface Document extends EObject {
// Access the field values from the IDoc control record
String getArchiveKey();
void setArchiveKey(String value);
String getClient();
void setClient(String value);
...
// Access the IDoc document contents
Segment getRootSegment();
}
Document インターフェースでは、以下のようなメソッドが公開されます。
- コントロールレコードにアクセスする方法
- ほとんどのメソッドは、IDoc コントロールレコードのフィールド値にアクセスまたは変更するためのものです。これらのメソッドは AttributeName, AttributeName の形式です。attributeName はフィールド値の名前です( 表269.2「IDoc ドキュメント属性」を参照してください)。
- ドキュメントコンテンツにアクセスする方法
getRootSegmentメソッドは、ドキュメントコンテンツ(IDoc データレコード)へのアクセスを提供し、そのコンテンツをSegmentオブジェクトとして返します。各セグメントには任意の数の子セグメントを含めることができ、セグメントは任意のレベルにネストできます。ただし、セグメント階層の正確なレイアウトは、ドキュメントの特定の IDoc タイプ で定義されている点に注意してください。したがって、セグメント階層を作成(または読み取り)する場合、IDoc タイプで定義される正確な構造に従う必要があります。
Segment タイプは、IDoc ドキュメントのデータレコードにアクセスするために使用されます。ここでは、セグメントはドキュメントの IDoc タイプで定義される構造に従ってレイアウトされます。要約すると、Segment インターフェースは以下のメソッドを公開します。
// Java
package org.fusesource.camel.component.sap.model.idoc;
...
public interface Segment extends EObject, java.util.Map<String, Object> {
// Returns the value of the '<em><b>Parent</b></em>' reference.
Segment getParent();
// Return a immutable list of all child segments
<S extends Segment> EList<S> getChildren();
// Returns a list of child segments of the specified segment type.
<S extends Segment> SegmentList<S> getChildren(String segmentType);
EList<String> getTypes();
Document getDocument();
String getDescription();
String getType();
String getDefinition();
int getHierarchyLevel();
String getIdocType();
String getIdocTypeExtension();
String getSystemRelease();
String getApplicationRelease();
int getNumFields();
long getMaxOccurrence();
long getMinOccurrence();
boolean isMandatory();
boolean isQualified();
int getRecordLength();
<T> T get(Object key, Class<T> type);
}
getChildren(String segmentType) メソッドは、特に新しい(入れ子)子をセグメントに追加する際に特に便利です。これは、以下のように定義される型 SegmentList のオブジェクトを返します。
// Java
package org.fusesource.camel.component.sap.model.idoc;
...
public interface SegmentList<S extends Segment> extends EObject, EList<S> {
S add();
S add(int index);
}
したがって、E1SCU_CRE タイプのデータレコードを作成するには、以下のような Java コードを使用できます。
Segment rootSegment = document.getRootSegment();
Segment E1SCU_CRE_Segment = rootSegment.getChildren("E1SCU_CRE").add();
ドキュメントインスタンスの作成例 リンクのコピーリンクがクリップボードにコピーされました!
たとえば、例269.1「Java での IDoc ドキュメントの作成」 は、Java で IDoc モデル API を使用して IDoc タイプ FLCUSTOMER_CREATEFROMDATA01 の IDoc ドキュメントを作成する方法を示しています。
例269.1 Java での IDoc ドキュメントの作成
// Java
import org.fusesource.camel.component.sap.model.idoc.Document;
import org.fusesource.camel.component.sap.model.idoc.Segment;
import org.fusesource.camel.component.sap.util.IDocUtil;
import org.fusesource.camel.component.sap.model.idoc.Document;
import org.fusesource.camel.component.sap.model.idoc.DocumentList;
import org.fusesource.camel.component.sap.model.idoc.IdocFactory;
import org.fusesource.camel.component.sap.model.idoc.IdocPackage;
import org.fusesource.camel.component.sap.model.idoc.Segment;
import org.fusesource.camel.component.sap.model.idoc.SegmentChildren;
...
//
// Create a new IDoc instance using the modelling classes
//
// Get the SAP Endpoint bean from the Camel context.
// In this example, it's a 'sap-idoc-destination' endpoint.
SapTransactionalIDocDestinationEndpoint endpoint =
exchange.getContext().getEndpoint(
"bean:SapEndpointBeanID",
SapTransactionalIDocDestinationEndpoint.class
);
// The endpoint automatically populates some required control record attributes
Document document = endpoint.createDocument()
// Initialize additional control record attributes
document.setMessageType("FLCUSTOMER_CREATEFROMDATA");
document.setRecipientPartnerNumber("QUICKCLNT");
document.setRecipientPartnerType("LS");
document.setSenderPartnerNumber("QUICKSTART");
document.setSenderPartnerType("LS");
Segment rootSegment = document.getRootSegment();
Segment E1SCU_CRE_Segment = rootSegment.getChildren("E1SCU_CRE").add();
Segment E1BPSCUNEW_Segment = E1SCU_CRE_Segment.getChildren("E1BPSCUNEW").add();
E1BPSCUNEW_Segment.put("CUSTNAME", "Fred Flintstone");
E1BPSCUNEW_Segment.put("FORM", "Mr.");
E1BPSCUNEW_Segment.put("STREET", "123 Rubble Lane");
E1BPSCUNEW_Segment.put("POSTCODE", "01234");
E1BPSCUNEW_Segment.put("CITY", "Bedrock");
E1BPSCUNEW_Segment.put("COUNTR", "US");
E1BPSCUNEW_Segment.put("PHONE", "800-555-1212");
E1BPSCUNEW_Segment.put("EMAIL", "fred@bedrock.com");
E1BPSCUNEW_Segment.put("CUSTTYPE", "P");
E1BPSCUNEW_Segment.put("DISCOUNT", "005");
E1BPSCUNEW_Segment.put("LANGU", "E");
文書化属性 リンクのコピーリンクがクリップボードにコピーされました!
表269.2「IDoc ドキュメント属性」 は、Document オブジェクトに設定できるコントロールレコード属性を示しています。
| 属性 | 長さ | SAP フィールド | 説明 |
|---|---|---|---|
|
| 70 |
| EDI アーカイブキー |
|
| 3 |
| クライアント |
|
| 8 |
| 日付 IDoc の作成 |
|
| 6 |
| 時間 IDoc の作成 |
|
| 1 |
| 方向 |
|
| 14 |
| メッセージへの参照 |
|
| 14 |
| メッセージグループへの参照 |
|
| 6 |
| EDI メッセージタイプ |
|
| 1 |
| EDI 標準 |
|
| 6 |
| EDI 標準のバージョン |
|
| 14 |
| 交換ファイルへの参照 |
|
| 8 |
| IDoc タイプ |
|
| 16 |
| IDoc 番号 |
|
| 4 |
| IDoc の SAP リリース |
|
| 30 |
| 基本的な IDoc タイプの名前 |
|
| 30 |
| エクステンションタイプの名前 |
|
| 3 |
| 論理メッセージコード |
|
| 3 |
| 論理メッセージ関数 |
|
| 30 |
| 論理メッセージタイプ |
|
| 1 |
| 出力モード |
|
| 10 |
| 受信者アドレス(SADR) |
|
| 70 |
| 受信側の論理アドレス |
|
| 2 |
| レシーバーのパートナー機能 |
|
| 10 |
| レシーバーのパートナー番号 |
|
| 2 |
| パートナータイプの受信側 |
|
| 10 |
| レシーバーポート(SAP System、EDI サブシステム) |
|
|
| 送信側アドレス(SADR) | |
|
| 70 |
| 送信者の論理アドレス |
|
| 2 |
| 送信者のパートナー機能 |
|
| 10 |
| パートナー向け送信者のパートナー数 |
|
| 2 |
| パートナーレベルの送信者 |
|
| 10 |
| 送信者ポート(SAP System、EDI サブシステム) |
|
| 20 |
| EDI/ALE: Serialization フィールド |
|
| 2 |
| IDoc のステータス |
|
| 1 |
| test フラグ |
Java でのドキュメント属性の設定 リンクのコピーリンクがクリップボードにコピーされました!
Java で制御レコード属性( 表269.2「IDoc ドキュメント属性」から)を設定する場合、Java Bean プロパティーの通常の規則に従います。つまり、属性値の取得および設定のために getName メソッドおよび setName メソッドを介して name 属性にアクセスできます。たとえば、iDocType 属性、 属性、および iDocType ExtensionmessageType 属性は、Document オブジェクトで以下のように設定できます。
// Java
document.setIDocType("FLCUSTOMER_CREATEFROMDATA01");
document.setIDocTypeExtension("");
document.setMessageType("FLCUSTOMER_CREATEFROMDATA");
XML でのドキュメント属性の設定 リンクのコピーリンクがクリップボードにコピーされました!
XML でコントロールレコード属性を設定する場合は、idoc:Document 要素に属性を設定する必要があります。たとえば、iDocType 属性、 属性、および iDocType ExtensionmessageType 属性は以下のように設定できます。
<?xml version="1.0" encoding="ASCII"?>
<idoc:Document ...
iDocType="FLCUSTOMER_CREATEFROMDATA01"
iDocTypeExtension=""
messageType="FLCUSTOMER_CREATEFROMDATA" ... >
...
</idoc:Document>