let say we have s insurance xml data as a response of a web service and we want to expose this data as a complex structure data type to deal with it in SAP (the same like DOM parser in other programming languages)
the xml data as below
<?xml version="1.0" encoding="utf-8"?>
<RequestResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Response>
<TreatmentBasis>1</TreatmentBasis>
<TreatmentClassification>1</TreatmentClassification>
<MemberDetails>
<Tag>
<ID>1</ID>
<Label>DOB</Label>
<Value>05-Jun-2011</Value>
<Type>Date</Type>
</Tag>
<Tag>
<ID>2</ID>
<Label>Gender</Label>
<Value>Female</Value>
<Type>Text</Type>
</Tag>
</MemberDetails>
<CoverageNotes>
<Tag>
<ID>1</ID>
<Label>NetworkTypeName</Label>
<Value>General Network</Value>
<Type>Text</Type>
</Tag>
</CoverageNotes>
<ApprovalRequirements>
<Tag>
<ID>5</ID>
<Label>Approval required for:</Label>
<Value>All in-patient services</Value>
<Type>Text</Type>
</Tag>
</ApprovalRequirements>
<Attachments>
<File>
<ID>1</ID>
<Filename>IP Approvals - Elective.pdf</Filename>
<DisplayedName>Applicable procedure</DisplayedName>
<FileContent />
</File>
<File>
<ID>2</ID>
<Filename>IP Approvals - Emergency.pdf</Filename>
<DisplayedName>Emergency Applicable procedure</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>3</ID>
<Filename>Exclusions - VIP 5.pdf</Filename>
<DisplayedName>Exclusions</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>4</ID>
<Filename>Capital Markets Authority - 2016 (1 month ext.)_118223.xls</Filename>
<DisplayedName>Table of Benefits</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>11</ID>
<Filename>ConsultationForm.pdf</Filename>
<DisplayedName>Consultation / Claim Form</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>12</ID>
<Filename>PrescriptionForm.pdf</Filename>
<DisplayedName>Prescription Form</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>12</ID>
<Filename>2817951.png</Filename>
<DisplayedName>Member Card</DisplayedName>
<FileContent>ICAgICAgIA==</FileContent>
</File>
</Attachments>
<Messages>
<Message>
<Category>Room Type</Category>
<Text>Private (One Bed)</Text>
<Severity>2</Severity>
</Message>
</Messages>
<Sender>1070</Sender>
<Receiver>11</Receiver>
<ReferenceID>23423434234</ReferenceID>
<RequestReferenceID>342342343</RequestReferenceID>
<Result>1</Result>
<Reason />
<MemberName>dfgdfgdfgdf</MemberName>
<CardNumber>fgdfgdfgfg</CardNumber>
<PayerName>Tazur Takaful Insurance Co. (K.S.C.C.)</PayerName>
<CoverStartDate>12-Jun-2017</CoverStartDate>
<CoverEndDate>11-Jul-2017</CoverEndDate>
<MemberPhoto>string based 64</MemberPhoto>
<IsVIP>VIP</IsVIP>
<IsTHIQA>Non THIQA</IsTHIQA>
<ValidityDate>02-Jul-2018</ValidityDate>
</Response>
</RequestResponse>
the structure as below
TYPES:
BEGIN OF tag,
ID TYPE I,
Label TYPE string,
Value TYPE string,
Type TYPE string,
END OF tag,
BEGIN OF file,
ID TYPE i,
Filename TYPE STRING,
DisplayedName TYPE STRING,
FileContent TYPE STRING,
END OF file,
BEGIN OF Message,
Category TYPE STRING,
Text TYPE STRING,
Severity TYPE I,
END OF Message,
BEGIN OF Messages,
Message TYPE Message,
END OF Messages.
TYPES: MemberDetails TYPE TABLE OF tag WITH NON-UNIQUE DEFAULT KEY,
CoverageNotes TYPE TABLE OF tag WITH NON-UNIQUE DEFAULT KEY,
ApprovalRequirements TYPE TABLE OF tag WITH NON-UNIQUE DEFAULT KEY,
Attachments TYPE TABLE OF file WITH NON-UNIQUE DEFAULT KEY.
TYPES: BEGIN OF RESPONSE,
TreatmentBasis TYPE i,
TreatmentClassification TYPE i,
MemberDetails TYPE MemberDetails,
CoverageNotes TYPE CoverageNotes,
ApprovalRequirements TYPE ApprovalRequirements,
Attachments TYPE Attachments,
Messages TYPE Messages,
Sender TYPE i,
Receiver TYPE i,
ReferenceID TYPE string,
RequestReferenceID TYPE STRING,
Result TYPE STRING,
Reason TYPE STRING,
MemberName TYPE STRING,
CardNumber TYPE STRING,
PayerName TYPE STRING,
CoverStartDate TYPE STRING,
CoverEndDate TYPE STRING,
MemberPhoto TYPE STRING,
IsVIP TYPE STRING,
IsTHIQA TYPE STRING,
ValidityDate TYPE STRING,
END OF RESPONSE.
the transformer template will be as below
<?sap.transform simple?>
<!-- tt:transform xmlns:tt="http://www.sap.com/transformation-templates" -->
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns:ddic="http://www.sap.com/abapxml/types/dictionary"
xmlns:def="http://www.sap.com/abapxml/types/defined">
<tt:root name="ROOT"/>
<tt:template>
<RequestResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tt:loop name="res" ref=".ROOT">
<Response>
<TreatmentBasis tt:value-ref = "TreatmentBasis" />
<TreatmentClassification tt:value-ref = "TreatmentClassification"/>
<MemberDetails>
<tt:loop name="md" ref="MemberDetails">
<Tag>
<ID tt:value-ref="$md.ID"/>
<Label tt:value-ref="$md.Label"/>
<Value tt:value-ref="$md.Value"/>
<Type tt:value-ref="$md.Type"/>
</Tag>
</tt:loop>
</MemberDetails>
<CoverageNotes>
<tt:loop name="cn" ref="CoverageNotes">
<Tag>
<ID tt:value-ref="$cn.ID"/>
<Label tt:value-ref="$cn.Label"/>
<Value tt:value-ref="$cn.Value"/>
<Type tt:value-ref="$cn.Type"/>
</Tag>
</tt:loop>
</CoverageNotes>
<ApprovalRequirements>
<tt:loop name="ar" ref="ApprovalRequirements">
<Tag>
<ID tt:value-ref="$ar.ID"/>
<Label tt:value-ref="$ar.Label"/>
<Value tt:value-ref="$ar.Value"/>
<Type tt:value-ref="$ar.Type"/>
</Tag>
</tt:loop>
</ApprovalRequirements>
<Attachments>
<tt:loop ref="Attachments" name="atts">
<File>
<ID tt:value-ref="$atts.ID"/>
<Filename tt:value-ref="$atts.Filename"/>
<DisplayedName tt:value-ref="$atts.DisplayedName"/>
<FileContent tt:value-ref="$atts.FileContent"/>
</File>
</tt:loop>
</Attachments>
<Messages>
<tt:loop name="msg" ref="Messages">
<Message>
<Category tt:value-ref="$msg.Category"/>
<Text tt:value-ref="$msg.Text"/>
<Severity tt:value-ref="$msg.Severity"/>
</Message>
</tt:loop>
</Messages>
<Sender tt:value-ref="Sender" />
<Receiver tt:value-ref="Receiver" />
<ReferenceID tt:value-ref="ReferenceID" />
<RequestReferenceID tt:value-ref="RequestReferenceID" />
<Result tt:value-ref="Result" />
<Reason tt:value-ref="Reason" />
<MemberName tt:value-ref="MemberName" />
<CardNumber tt:value-ref="CardNumber" />
<PayerName tt:value-ref="PayerName" />
<CoverStartDate tt:value-ref="CoverStartDate" />
<CoverEndDate tt:value-ref="CoverEndDate" />
<MemberPhoto tt:value-ref="MemberPhoto" />
<IsVIP tt:value-ref="IsVIP" />
<IsTHIQA tt:value-ref="IsTHIQA" />
<ValidityDate tt:value-ref="ValidityDate" />
</Response>
</tt:loop>
</RequestResponse>
</tt:template>
</tt:transform>
the xml data as below
<?xml version="1.0" encoding="utf-8"?>
<RequestResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Response>
<TreatmentBasis>1</TreatmentBasis>
<TreatmentClassification>1</TreatmentClassification>
<MemberDetails>
<Tag>
<ID>1</ID>
<Label>DOB</Label>
<Value>05-Jun-2011</Value>
<Type>Date</Type>
</Tag>
<Tag>
<ID>2</ID>
<Label>Gender</Label>
<Value>Female</Value>
<Type>Text</Type>
</Tag>
</MemberDetails>
<CoverageNotes>
<Tag>
<ID>1</ID>
<Label>NetworkTypeName</Label>
<Value>General Network</Value>
<Type>Text</Type>
</Tag>
</CoverageNotes>
<ApprovalRequirements>
<Tag>
<ID>5</ID>
<Label>Approval required for:</Label>
<Value>All in-patient services</Value>
<Type>Text</Type>
</Tag>
</ApprovalRequirements>
<Attachments>
<File>
<ID>1</ID>
<Filename>IP Approvals - Elective.pdf</Filename>
<DisplayedName>Applicable procedure</DisplayedName>
<FileContent />
</File>
<File>
<ID>2</ID>
<Filename>IP Approvals - Emergency.pdf</Filename>
<DisplayedName>Emergency Applicable procedure</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>3</ID>
<Filename>Exclusions - VIP 5.pdf</Filename>
<DisplayedName>Exclusions</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>4</ID>
<Filename>Capital Markets Authority - 2016 (1 month ext.)_118223.xls</Filename>
<DisplayedName>Table of Benefits</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>11</ID>
<Filename>ConsultationForm.pdf</Filename>
<DisplayedName>Consultation / Claim Form</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>12</ID>
<Filename>PrescriptionForm.pdf</Filename>
<DisplayedName>Prescription Form</DisplayedName>
<FileContent>string based 64</FileContent>
</File>
<File>
<ID>12</ID>
<Filename>2817951.png</Filename>
<DisplayedName>Member Card</DisplayedName>
<FileContent>ICAgICAgIA==</FileContent>
</File>
</Attachments>
<Messages>
<Message>
<Category>Room Type</Category>
<Text>Private (One Bed)</Text>
<Severity>2</Severity>
</Message>
</Messages>
<Sender>1070</Sender>
<Receiver>11</Receiver>
<ReferenceID>23423434234</ReferenceID>
<RequestReferenceID>342342343</RequestReferenceID>
<Result>1</Result>
<Reason />
<MemberName>dfgdfgdfgdf</MemberName>
<CardNumber>fgdfgdfgfg</CardNumber>
<PayerName>Tazur Takaful Insurance Co. (K.S.C.C.)</PayerName>
<CoverStartDate>12-Jun-2017</CoverStartDate>
<CoverEndDate>11-Jul-2017</CoverEndDate>
<MemberPhoto>string based 64</MemberPhoto>
<IsVIP>VIP</IsVIP>
<IsTHIQA>Non THIQA</IsTHIQA>
<ValidityDate>02-Jul-2018</ValidityDate>
</Response>
</RequestResponse>
the structure as below
TYPES:
BEGIN OF tag,
ID TYPE I,
Label TYPE string,
Value TYPE string,
Type TYPE string,
END OF tag,
BEGIN OF file,
ID TYPE i,
Filename TYPE STRING,
DisplayedName TYPE STRING,
FileContent TYPE STRING,
END OF file,
BEGIN OF Message,
Category TYPE STRING,
Text TYPE STRING,
Severity TYPE I,
END OF Message,
BEGIN OF Messages,
Message TYPE Message,
END OF Messages.
TYPES: MemberDetails TYPE TABLE OF tag WITH NON-UNIQUE DEFAULT KEY,
CoverageNotes TYPE TABLE OF tag WITH NON-UNIQUE DEFAULT KEY,
ApprovalRequirements TYPE TABLE OF tag WITH NON-UNIQUE DEFAULT KEY,
Attachments TYPE TABLE OF file WITH NON-UNIQUE DEFAULT KEY.
TYPES: BEGIN OF RESPONSE,
TreatmentBasis TYPE i,
TreatmentClassification TYPE i,
MemberDetails TYPE MemberDetails,
CoverageNotes TYPE CoverageNotes,
ApprovalRequirements TYPE ApprovalRequirements,
Attachments TYPE Attachments,
Messages TYPE Messages,
Sender TYPE i,
Receiver TYPE i,
ReferenceID TYPE string,
RequestReferenceID TYPE STRING,
Result TYPE STRING,
Reason TYPE STRING,
MemberName TYPE STRING,
CardNumber TYPE STRING,
PayerName TYPE STRING,
CoverStartDate TYPE STRING,
CoverEndDate TYPE STRING,
MemberPhoto TYPE STRING,
IsVIP TYPE STRING,
IsTHIQA TYPE STRING,
ValidityDate TYPE STRING,
END OF RESPONSE.
the transformer template will be as below
<?sap.transform simple?>
<!-- tt:transform xmlns:tt="http://www.sap.com/transformation-templates" -->
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns:ddic="http://www.sap.com/abapxml/types/dictionary"
xmlns:def="http://www.sap.com/abapxml/types/defined">
<tt:root name="ROOT"/>
<tt:template>
<RequestResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tt:loop name="res" ref=".ROOT">
<Response>
<TreatmentBasis tt:value-ref = "TreatmentBasis" />
<TreatmentClassification tt:value-ref = "TreatmentClassification"/>
<MemberDetails>
<tt:loop name="md" ref="MemberDetails">
<Tag>
<ID tt:value-ref="$md.ID"/>
<Label tt:value-ref="$md.Label"/>
<Value tt:value-ref="$md.Value"/>
<Type tt:value-ref="$md.Type"/>
</Tag>
</tt:loop>
</MemberDetails>
<CoverageNotes>
<tt:loop name="cn" ref="CoverageNotes">
<Tag>
<ID tt:value-ref="$cn.ID"/>
<Label tt:value-ref="$cn.Label"/>
<Value tt:value-ref="$cn.Value"/>
<Type tt:value-ref="$cn.Type"/>
</Tag>
</tt:loop>
</CoverageNotes>
<ApprovalRequirements>
<tt:loop name="ar" ref="ApprovalRequirements">
<Tag>
<ID tt:value-ref="$ar.ID"/>
<Label tt:value-ref="$ar.Label"/>
<Value tt:value-ref="$ar.Value"/>
<Type tt:value-ref="$ar.Type"/>
</Tag>
</tt:loop>
</ApprovalRequirements>
<Attachments>
<tt:loop ref="Attachments" name="atts">
<File>
<ID tt:value-ref="$atts.ID"/>
<Filename tt:value-ref="$atts.Filename"/>
<DisplayedName tt:value-ref="$atts.DisplayedName"/>
<FileContent tt:value-ref="$atts.FileContent"/>
</File>
</tt:loop>
</Attachments>
<Messages>
<tt:loop name="msg" ref="Messages">
<Message>
<Category tt:value-ref="$msg.Category"/>
<Text tt:value-ref="$msg.Text"/>
<Severity tt:value-ref="$msg.Severity"/>
</Message>
</tt:loop>
</Messages>
<Sender tt:value-ref="Sender" />
<Receiver tt:value-ref="Receiver" />
<ReferenceID tt:value-ref="ReferenceID" />
<RequestReferenceID tt:value-ref="RequestReferenceID" />
<Result tt:value-ref="Result" />
<Reason tt:value-ref="Reason" />
<MemberName tt:value-ref="MemberName" />
<CardNumber tt:value-ref="CardNumber" />
<PayerName tt:value-ref="PayerName" />
<CoverStartDate tt:value-ref="CoverStartDate" />
<CoverEndDate tt:value-ref="CoverEndDate" />
<MemberPhoto tt:value-ref="MemberPhoto" />
<IsVIP tt:value-ref="IsVIP" />
<IsTHIQA tt:value-ref="IsTHIQA" />
<ValidityDate tt:value-ref="ValidityDate" />
</Response>
</tt:loop>
</RequestResponse>
</tt:template>
</tt:transform>
Comments
Post a Comment