104.7. IDoc のメッセージ本文
104.7.1. 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
104.7.2. IDoc 文書モデル リンクのコピーリンクがクリップボードにコピーされました!
Camel SAP コンポーネントの場合、IDoc ドキュメントは、基礎となる SAP IDoc API のラッパー API を提供する Eclipse Modeling 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 はフィールド値の名前です。
- ドキュメントコンテンツへのアクセス方法
getRootSegmentメソッドは、ドキュメントコンテンツ (IDoc データレコード) へのアクセスを提供し、コンテンツをSegmentオブジェクトとして返します。各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 an 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();