140.4. IDoc のメッセージボディー


IDoc メッセージタイプ

IDoc Camel SAP エンドポイントのいずれかを使用する場合、メッセージボディーのタイプは、使用している特定のエンドポイントによって異なります。
sap-idoc-destination エンドポイントまたは sap-qidoc-destination エンドポイントの場合、メッセージボディーは Document タイプになります。
org.fusesource.camel.component.sap.model.idoc.Document
Copy to Clipboard Toggle word wrap
sap-idoclist-destination エンドポイント、sap-qidoclist-destination エンドポイント、または sap-idoclist-server エンドポイントの場合、メッセージボディーは DocumentList タイプになります。
org.fusesource.camel.component.sap.model.idoc.DocumentList
Copy to Clipboard Toggle word wrap

IDoc ドキュメントモデル

Camel SAP コンポーネントの場合、IDoc ドキュメントは Eclipse Modelling Framework (EMF)を使用してモデル化され、基礎となる SAP IDoc API に関するラッパー API を提供します。このモデルで最も重要なタイプは以下のとおりです。
org.fusesource.camel.component.sap.model.idoc.Document
org.fusesource.camel.component.sap.model.idoc.Segment
Copy to Clipboard Toggle word wrap
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();
}
Copy to Clipboard Toggle word wrap
以下の種類のメソッドは、Document インターフェイスによって公開されます。
コントロールレコードにアクセスする方法
メソッドのほとんどは、IDoc 制御レコードのフィールド値にアクセスまたは変更するためのものです。これらのメソッドは getAttributeNamesetAttributeName の形式を取ります。AttributeName はフィールド値の名前です( 表140.2「IDoc ドキュメントの属性」を参照)。
ドキュメントの内容にアクセスする方法
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 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);
}
Copy to Clipboard Toggle word wrap
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);
}
Copy to Clipboard Toggle word wrap
したがって、E1SCU_CRE タイプのデータレコードを作成するには、以下のような Java コードを使用します。
Segment rootSegment = document.getRootSegment();

Segment E1SCU_CRE_Segment = rootSegment.getChildren("E1SCU_CRE").add();
Copy to Clipboard Toggle word wrap

IDoc が Document オブジェクトにどのように関連しているか

SAP ドキュメントによると、IDoc ドキュメントは以下の主要部分で設定されています。
制御レコード
制御レコード(IDoc ドキュメントのメタデータを含む)は、Document オブジェクトの属性で表されます。詳細は、表140.2「IDoc ドキュメントの属性」 を参照してください。
データレコード
データレコードは、Segment オブジェクトによって表され、セグメントのネストされた階層として構築されます。Document.getRootSegment メソッドを使用してルートセグメントにアクセスできます。
ステータスレコード
Camel SAP コンポーネントでは、ステータスレコードはドキュメントモデルによって表され ません。ただし、コントロールレコードの status 属性を使用して、最新のステータス値にアクセスできます。

ドキュメントインスタンスの作成例

たとえば、例140.1「Java での IDoc ドキュメントの作成」 は、Java で IDoc モデル API を使用して、IDoc タイプ FLCUSTOMER_CREATEFROMDATA01 で IDoc ドキュメントを作成する方法を示しています。

例140.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");
Copy to Clipboard Toggle word wrap

ドキュメント属性

表140.2「IDoc ドキュメントの属性」 は、Document オブジェクトに設定できる制御レコード属性を示しています。
Expand
表140.2 IDoc ドキュメントの属性
属性 長さ SAP フィールド 説明
archiveKey 70 ARCKEY
EDI アーカイブキー
client 3 MANDT
クライアント
creationDate 8 CREDAT
日付 IDoc が作成されました
creationTime 6 CRETIM
時間 IDoc が作成されました
direction 1 DIRECT
方向
eDIMessage 14 REFMES
メッセージへの参照
eDIMessageGroup 14 REFGRP
メッセージグループへの参照
eDIMessageType 6 STDMES
EDI メッセージタイプ
eDIStandardFlag 1 STD
EDI 標準
eDIStandardVersion 6 STDVRS
EDI 標準のバージョン
eDITransmissionFile 14 REFINT
ファイル間の参照
iDocCompoundType 8 DOCTYP
IDoc タイプ
iDocNumber 16 DOCNUM
IDoc number
iDocSAPRelease 4 DOCREL
IDoc の SAP リリース
iDocType 30 IDOCTP
基本 IDoc タイプの名前
iDocTypeExtension 30 CIMTYP
エクステンションタイプの名前
messageCode 3 MESCOD
論理メッセージコード
messageFunction 3 MESFCT
論理メッセージ関数
messageType 30 MESTYP
論理メッセージタイプ
outputMode 1 OUTMOD
出力モード
recipientAddress 10 RCVSAD
受信者アドレス(SADR)
recipientLogicalAddress 70 RCVLAD
レシーバーの論理アドレス
recipientPartnerFunction 2 RCVPFC
レシーバーのパートナー機能
recipientPartnerNumber 10 RCVPRN
受信者のパートナー数
recipientPartnerType 2 RCVPRT
パートナータイプの受信者
recipientPort 10 RCVPOR
レシーバーポート(SAP System、EDI サブシステム)
senderAddress SNDSAD
送信者アドレス(SADR)
senderLogicalAddress 70 SNDLAD
送信者の論理アドレス
senderPartnerFunction 2 SNDPFC
送信者のパートナーの機能
senderPartnerNumber 10 SNDPRN
パートナーの送信者数
senderPartnerType 2 SNDPRT
パートナータイプの送信者
senderPort 10 SNDPOR
送信者ポート(SAP System、EDI サブシステム)
serialization 20 SERIAL
EDI/ALE: シリアル化フィールド
status 2 STATUS
IDoc のステータス
testFlag 1 TEST
test フラグ

Java でのドキュメント属性の設定

Java でコントロールレコード属性を設定する場合( 表140.2「IDoc ドキュメントの属性」から)、Java Bean プロパティーの通常の規則に従います。つまり、name 属性は、属性値を取得および設定するには、getName および setName メソッドを使用してアクセスできます。たとえば、iDocTypeiDocTypeExtension、および messageType 属性は、Document オブジェクトで以下のように設定できます。
// Java
document.setIDocType("FLCUSTOMER_CREATEFROMDATA01");
document.setIDocTypeExtension("");
document.setMessageType("FLCUSTOMER_CREATEFROMDATA");
Copy to Clipboard Toggle word wrap

XML でのドキュメント属性の設定

XML でコントロールレコード属性を設定する場合は、idoc:Document 要素に属性を設定する必要があります。たとえば、iDocTypeiDocTypeExtension、および messageType 属性は以下のように設定できます。
<?xml version="1.0" encoding="ASCII"?>
<idoc:Document ...
               iDocType="FLCUSTOMER_CREATEFROMDATA01"
               iDocTypeExtension=""
               messageType="FLCUSTOMER_CREATEFROMDATA" ... >
    ...
</idoc:Document>
Copy to Clipboard Toggle word wrap
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat