289.6. IDoc에 대한 메시지 본문

289.6.1. IDoc 메시지 유형

IDoc Camel SAP 엔드포인트 중 하나를 사용하는 경우 메시지 본문 유형은 사용 중인 특정 엔드포인트에 따라 다릅니다.

sap-idoc-destination 끝점 또는 sap-qidoc-destination 끝점의 경우 메시지 본문은 문서 유형입니다.

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

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

문서 유형은 IDoc 문서 인스턴스를 나타냅니다. 개요에서 문서 인터페이스는 다음 방법을 노출합니다.

// 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 필드 값의 이름입니다( 표 289.2. “IDoc 문서 속성”참조).
문서 콘텐츠에 액세스하는 방법

getRootSegment 메서드는 문서 콘텐츠(IDoc 데이터 레코드)에 대한 액세스를 제공하고 콘텐츠를 Segment 오브젝트로 반환합니다. 각 세그먼트에는 임의 의 수의 자식 세그먼트가 포함될 수 있으며 세그먼트는 임의의 수준에 중첩될 수 있습니다.

그러나 세그먼트 계층 구조의 정확한 레이아웃은 문서의 특정 IDoc 유형으로 정의됩니다. 따라서 세그먼트 계층을 만들거나 읽을 때 IDoc 유형으로 정의된 정확한 구조를 따라야 합니다.

세그먼트 유형은 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);
}

get children(String segmentType) 메서드는 특히 새 자식 을 세그먼트에 추가하는 데 유용합니다. 다음과 같이 정의된 type인 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();

289.6.4. 문서 인스턴스 생성 예

예를 들어 예 289.1. “Java에서 IDoc 문서 생성” 은 Java에서 IDoc 유형인 FLCUSTOMER_CREATEFROMDATA01 을 사용하여 IDoc 문서를 생성하는 방법을 보여줍니다.

예 289.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");

289.6.5. 문서 속성

표 289.2. “IDoc 문서 속성” Document 개체에 설정할 수 있는 컨트롤 레코드 속성을 보여 줍니다.Shows the control record attributes that you can set on the Document object.

표 289.2. IDoc 문서 속성

속성길이SAP 필드설명

archiveKey

70

ARCKEY

EDI 아카이브 키

클라이언트

3

MANDT

클라이언트

creationDate

8

CREDAT

날짜 IDoc 생성

creationTime

6

CRETIM

시간 IDoc 생성

방향

1

DIRECT

방향

eDIMessage

14

REFMES

메시지에 대한 참조

eDIMessageGroup

14

REFGRP

메시지 그룹에 대한 참조

eDIMessageType

6

STDMES

EDI 메시지 유형

eDIStandardFlag

1

STD

EDI 표준

eDIStandardVersion

6

STDVRS

EDI 표준 버전

eDITransmissionFile

14

REFINT

exchange 파일에 대한 참조

iDocCompoundType

8

DOCTYP

IDoc 유형

iDocNumber

16

DOCNUM

IDoc 번호

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 시스템, EDI 하위 시스템)

senderAddress

 

SNDSAD

보낸 사람 주소SADR)

senderLogicalAddress

70

SNDLAD

보낸 사람의 논리 주소

senderPartnerFunction

2

SNDPFC

보낸 사람의 파트너 기능

senderPartnerNumber

10

SNDPRN

보낸 사람의 파트너 번호

senderPartnerType

2

SNDPRT

보낸 사람의 파트너 유형

senderPort

10

SNDPOR

발신자 포트(SAP 시스템, EDI 하위 시스템)

serialization

20

SERIAL

EDI/ALE: 직렬화 필드

status

2

STATUS

IDoc 상태

testFlag

1

TEST

test 플래그

289.6.6. Java에서 문서 속성 설정

Java에서 컨트롤 레코드 속성을 설정할 때( 표 289.2. “IDoc 문서 속성”), Java 빈 속성에 대한 일반적인 규칙이 실행됩니다. 즉, 특성 값을 가져오고 설정하기 위해 getNamesetName 메서드를 통해 name 속성에 액세스할 수 있습니다. 예를 들어 iDocType,iDocTypeExtensionmessageType 특성은 Document 오브젝트에서 다음과 같이 설정할 수 있습니다.

// Java
document.setIDocType("FLCUSTOMER_CREATEFROMDATA01");
document.setIDocTypeExtension("");
document.setMessageType("FLCUSTOMER_CREATEFROMDATA");

289.6.7. XML로 문서 속성 설정

XML에서 컨트롤 레코드 속성을 설정할 때 속성을 idoc:Document 요소에서 설정해야 합니다. 예를 들어 iDocType,iDocTypeExtensionmessageType 특성은 다음과 같이 설정할 수 있습니다.

<?xml version="1.0" encoding="ASCII"?>
<idoc:Document ...
               iDocType="FLCUSTOMER_CREATEFROMDATA01"
               iDocTypeExtension=""
               messageType="FLCUSTOMER_CREATEFROMDATA" ... >
    ...
</idoc:Document>