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.3. IDoc가 Document 오브젝트와 관련된 방법
SAP 설명서에 따르면 IDoc 문서는 다음과 같은 주요 부분으로 구성됩니다.
- 제어 레코드
-
제어 레코드(IDoc 문서의 meta-data 포함)는
Document오브젝트의 속성으로 표시됩니다. 자세한 내용은 표 289.2. “IDoc 문서 속성” 을 참조하십시오. - 데이터 레코드
-
데이터 레코드는 세그먼트의 중첩 계층 구조로 생성되는
Segment개체로 표시됩니다.Document.getRootSegment메서드를 통해 루트 세그먼트에 액세스할 수 있습니다. - 상태 레코드
-
Camel SAP 구성 요소에서 상태 레코드는 문서 모델로 표시되지 않습니다. 그러나 제어 레코드의
status특성을 통해 최신 상태 값에 액세스할 수 있습니다.
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 필드 | 설명 |
|---|---|---|---|
|
| 70 |
| EDI 아카이브 키 |
|
| 3 |
| 클라이언트 |
|
| 8 |
| 날짜 IDoc 생성 |
|
| 6 |
| 시간 IDoc 생성 |
|
| 1 |
| 방향 |
|
| 14 |
| 메시지에 대한 참조 |
|
| 14 |
| 메시지 그룹에 대한 참조 |
|
| 6 |
| EDI 메시지 유형 |
|
| 1 |
| EDI 표준 |
|
| 6 |
| EDI 표준 버전 |
|
| 14 |
| exchange 파일에 대한 참조 |
|
| 8 |
| IDoc 유형 |
|
| 16 |
| IDoc 번호 |
|
| 4 |
| IDoc SAP 릴리스 |
|
| 30 |
| 기본 IDoc 유형의 이름 |
|
| 30 |
| 확장 유형 이름 |
|
| 3 |
| 논리 메시지 코드 |
|
| 3 |
| 논리 메시지 함수 |
|
| 30 |
| 논리 메시지 유형 |
|
| 1 |
| 출력 모드 |
|
| 10 |
| 수신자 주소(SADR) |
|
| 70 |
| 수신자의 논리 주소 |
|
| 2 |
| 수신자의 파트너 기능 |
|
| 10 |
| 수신자의 파트너 번호 |
|
| 2 |
| 수신자의 파트너 유형 |
|
| 10 |
| 수신자 포트(SAP 시스템, EDI 하위 시스템) |
|
|
| 보낸 사람 주소SADR) | |
|
| 70 |
| 보낸 사람의 논리 주소 |
|
| 2 |
| 보낸 사람의 파트너 기능 |
|
| 10 |
| 보낸 사람의 파트너 번호 |
|
| 2 |
| 보낸 사람의 파트너 유형 |
|
| 10 |
| 발신자 포트(SAP 시스템, EDI 하위 시스템) |
|
| 20 |
| EDI/ALE: 직렬화 필드 |
|
| 2 |
| IDoc 상태 |
|
| 1 |
| test 플래그 |
289.6.6. Java에서 문서 속성 설정
Java에서 컨트롤 레코드 속성을 설정할 때( 표 289.2. “IDoc 문서 속성”), Java 빈 속성에 대한 일반적인 규칙이 실행됩니다. 즉, 특성 값을 가져오고 설정하기 위해 getName 및 setName 메서드를 통해 name 속성에 액세스할 수 있습니다. 예를 들어 iDocType,iDocTypeExtension 및 messageType 특성은 Document 오브젝트에서 다음과 같이 설정할 수 있습니다.
// Java
document.setIDocType("FLCUSTOMER_CREATEFROMDATA01");
document.setIDocTypeExtension("");
document.setMessageType("FLCUSTOMER_CREATEFROMDATA");289.6.7. XML로 문서 속성 설정
XML에서 컨트롤 레코드 속성을 설정할 때 속성을 idoc:Document 요소에서 설정해야 합니다. 예를 들어 iDocType,iDocTypeExtension 및 messageType 특성은 다음과 같이 설정할 수 있습니다.
<?xml version="1.0" encoding="ASCII"?>
<idoc:Document ...
iDocType="FLCUSTOMER_CREATEFROMDATA01"
iDocTypeExtension=""
messageType="FLCUSTOMER_CREATEFROMDATA" ... >
...
</idoc:Document>