104.7. IDoc 的消息正文


104.7.1. 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

104.7.2. IDoc 文档模型

对于 Camel SAP 组件,IDoc 文档使用 Eclipse Modeling 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

文档 类型代表 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 控制记录的字段值。这些方法是 AttributeName 的形式,其中 AttributeName 是字段值的名称。
访问文档内容的方法

getRootSegment 方法提供对文档内容(IDoc 数据记录)的访问,将内容返回为 Segment 对象。每个分段对象可以包含任意数量的子片段,片段可以嵌套到任意程度。

但请注意,片段层次结构的精确布局由文档的特定 IDoc 类型定义。在创建(或读取)片段层次结构时,您必须确保遵循 IDoc 类型定义的确切结构。

分段类型用于访问 IDoc 文档的数据记录,其中片段根据文档的 IDoc 类型定义的结构而定。简而言之,分段 接口会公开以下方法:

// 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);
}
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
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat