EDIFACT

 

Home ANSI X12 EDIFACT SAP IDOC Download XML Links

This page will use a actual EDIFACT formatted document to demostrate the XML document generation using a record template file and a equivlent XML template file

Input EDIFACT Document

UNB+UNOA:1+XXXXXSECURITY:XY+5013546005111:ZZ+971014:1544+600000641++ORDERS'
UNH+60000000000992+ORDERS:90:1:UN'
BGM+105:ORDERS+16849+971014:1544+00'
RFF+CT+16849REF'
NAD+BY+XXXXX SECURITY:92'
NAD+SE+0033454140:92'
NAD+BY+002440:92'CUX+GBP:IN'
UNS+D'
LIN+1++136-804-086:BP+CM316X7R474K16AT:MG+21:9000:PK+0.053:CT:1:PK'
PIA+4+AVX:MF'
SCC+1'
QTY+21:9000:PK'
DTM+002+971015'
SCC+1'QTY+21:2000:PK'
DTM+002+971016'
LIN+2++222-804-086:BP+GAM316X7R474K16AT:MG+21:9000:PK+0.053:CT:1:PK'
PIA+4+AVX:MF'
SCC+1'
QTY+21:7000:PK'
DTM+002+971017'
SCC+1'
QTY+21:8000:PK'
DTM+002+971018'
UNS+S'
UNT+25+60000000000992'
UNZ+1+600000641'    

(Note: This sample file has been edited by added a new line character (\n) after the segment terminator (' character).)

 

Record Format Template File

HDTXT=<?xml version="1.0"?><DOCUMENT>
TLTXT=</DOCUMENT>     
#
# for EDIFACT documents
#
header=UNB, Time=(4,1s), sep=KUNB+0, SUB=KUNOA+0, term=KUNH-0, Date=(4,0s), Version=(1,1s), Test=f11, ACK=f9 
RID=UNB, Sender=[Qualifier=(2,1s),SenderID=(2,0s)], Receiver=[Qualifier=(3,1s),ReceiverID=(3,0s)], IxCtlRef=f5, Pswd=f6, AppRef=f7
Trailer=UNZ
#
header=UNH, MsgRef=f1, MsgTyID=(2,0s), MsgTyVersion=(2,1s), MsgTyRel=(2,2s)
RID=UNH, MsgTyID=(2,0s)
RID=BGM, DocCode=(1,0s), DocTy=(1,1s), DocID=(2,0s)
RID=REF, RefQfr=(1,0s), RefNum=(1,1s)
RID=NAD, Qfr=(1,0s), ActNum=(2,0s), ActName=(2,1s), ActName(2,2s)
RID=CUX, CurQfr=(1,0s), CurCode=(1,1s), CurDtl=f2, CurRate=f3, CurExCode=f4
trailer=UNT
#
header=LIN
RID=LIN, LINSEG=[LinNum=f1, LIN02=f2, ItemNum=(3,0s), ItemTy=(3,1s), SLInd=(4,0s),LinItemNum=(4,1s), LIN05=f5, LIN06=f6]
RID=PIA, ProdID=f1, ItemNoID=(2,0s), ItemNoTy=(2,1s)
RID=QTY, QtyQfr=(1,0s), Qty=(1,1s), Unit=(1,2s)
RID=SCC, DlvCode=f1, DlvInst=f2
RID=DTM, DTQfr=(1,0s), DTPrd=(1,1s)

 

XML Format Template File

<?xml version="1.0"?>
<TEMPLATE>
<HDTXT>
<!--<?xml version="1.0"?>
 	<DOCUMENT>
-->

</HDTXT>
<TLTXT>
<!--</DOCUMENT>
-->
</TLTXT>

	#
   	# for EDIFACT documents
   	# 
-->
<HEADER match="UNB" TLR="UNZ" Time="(4,1s)" sep="KUNB+0" SUB="KUNOA+0" term="KUNH-0" Date="(4,0s)" Version="(1,1s)" Test="f11" ACK="f9"> 
	<RID match="UNB">
		<Sender group="1">
			<SQualifier>(2,1s)</SQualifier>
			<SenderID>(2,0s)</SenderID>
		</Sender>
		<Receiver group="1">
			<RQualifier>(3,1s)</RQualifier>
			<ReceiverID>(3,0s)</ReceiverID>
		</Receiver>
		<IxCtlRef>f5</IxCtlRef>
		<Pswd>f6</Pswd>
		<AppRef>f7</AppRef>
	</RID>
</HEADER>
<!--  #  -->
<HEADER match="UNH" TLR="UNT" MsgRef="f1" MsgTyVersion="(2,1s)" MsgTyRel="(2,2s)">
	<RID match="UNH">
		<MsgTyID>(2,0s)</MsgTyID>
	</RID>
	<RID match="BGM">
		<DocCode>(1,0s)</DocCode>
		<DocTy>(1,1s)</DocTy>
		<DocID>(2,0s)</DocID>
	</RID>
	<RID match="REF">
		<RefQfr>(1,0s)</RefQfr> 
		<RefNum>(1,1s)</RefNum>
	</RID>
	<RID match="NAD"> 
		<Qfr>(1,0s)</Qfr>
		<ActNum>(2,0s)</ActNum>
		<ActName>(2,1s)</ActName>
	</RID>
	<RID match="CUX">
		<CurQfr>(1,0s)</CurQfr>
		<CurCode>(1,1s)</CurCode>
		<CurDtl>f2</CurDtl>
		<CurRate>f3</CurRate>
		<CurExCode>f4</CurExCode>
	</RID>
</HEADER>
<!-- A new group for Line items -->
<HEADER match="LIN">
	<RID match="LIN">
		<LINSEG group="1">
		    <LinNum>f1</LinNum>
		    <LIN02>f2</LIN02>
		    <ItemNum>(3,0s)</ItemNum>
		    <ItemTy>(3,1s)</ItemTy>
		    <SLInd>(4,0s)</SLInd>
		    <LinItemNum>(4,1s)</LinItemNum>
		    <LIN05>f5</LIN05>
		    <LIN06>f6</LIN06>
		</LINSEG>
	</RID>
	<RID match="PIA">
		<ProdID>f1</ProdID>
		<ItemNoID>(2,0s)</ItemNoID>
		<ItemNoTy>(2,1s)</ItemNoTy>
	</RID>
	<RID match="QTY">
		<QtyQfr>(1,0s)</QtyQfr>
		<Qty>(1,1s)</Qty>
		<Unit>(1,2s)</Unit>
	</RID>
	<RID match="SCC">
		<DlvCode>f1</DlvCode>
		<DlvInst>f2</DlvInst>	
	</RID>
	<RID match="DTM">
		<DTQfr>(1,0s)</DTQfr>
		<DTPrd>(1,1s)</DTPrd>
	</RID>
</HEADER>

</TEMPLATE>

 

XML Output File Generated

<?xml version="1.0"?><DOCUMENT>

<UNB Time="1544" Date="971014" Version="1">
	<Sender>
		<Qualifier>XY</Qualifier>
		<SenderID>XXXXXSECURITY</SenderID>
	</Sender>
	<Receiver>
		<Qualifier>ZZ</Qualifier>
		<ReceiverID>5013546005111</ReceiverID>
	</Receiver>
	<IxCtlRef>600000641</IxCtlRef>
	<Pswd></Pswd>
	<AppRef>ORDERS</AppRef>
	<UNH MsgRef="60000000000992" MsgTyID="ORDERS" MsgTyVersion="90" MsgTyRel="1">
		<MsgTyID>ORDERS</MsgTyID>
		<BGM>
			<DocCode>105</DocCode>
			<DocTy>ORDERS</DocTy>
			<DocID>16849</DocID>
		</BGM>
		<NAD>
			<Qfr>BY</Qfr>
			<ActNum>XXXXX SECURITY</ActNum>
			<ActName>92</ActName>
		</NAD>
		<NAD>
			<Qfr>SE</Qfr>
			<ActNum>0033454140</ActNum>
			<ActName>92</ActName>
		</NAD>
		<NAD>
			<Qfr>BY</Qfr>
			<ActNum>002440</ActNum>
			<ActName>92</ActName>
		</NAD>
		<CUX>
			<CurQfr>GBP</CurQfr>
			<CurCode>IN</CurCode>
			<CurDtl></CurDtl>
			<CurRate></CurRate>
			<CurExCode></CurExCode>
		</CUX>
		<LIN>
			<LINSEG>
				<LinNum>1</LinNum>
				<LIN02></LIN02>
				<ItemNum>136-804-086</ItemNum>
				<ItemTy>BP</ItemTy>
				<SLInd>CM316X7R474K16AT</SLInd>
				<LinItemNum>MG</LinItemNum>
				<LIN05>21:9000:PK</LIN05>
				<LIN06>0.053:CT:1:PK</LIN06>
			</LINSEG>
			<PIA>
				<ProdID>4</ProdID>
				<ItemNoID>AVX</ItemNoID>
				<ItemNoTy>MF</ItemNoTy>
			</PIA>
			<SCC>
				<DlvCode>1</DlvCode>
				<DlvInst></DlvInst>
			</SCC>
			<QTY>
				<QtyQfr>21</QtyQfr>
				<Qty>9000</Qty>
				<Unit>PK</Unit>
			</QTY>
			<DTM>
				<DTQfr>002</DTQfr>
				<DTPrd></DTPrd>
			</DTM>
			<SCC>
				<DlvCode>1</DlvCode>
				<DlvInst></DlvInst>
			</SCC>
			<QTY>
				<QtyQfr>21</QtyQfr>
				<Qty>2000</Qty>
				<Unit>PK</Unit>
			</QTY>
			<DTM>
				<DTQfr>002</DTQfr>
				<DTPrd></DTPrd>
			</DTM>
		</LIN>
		<LIN>
			<LINSEG>
				<LinNum>2</LinNum>
				<LIN02></LIN02>
				<ItemNum>222-804-086</ItemNum>
				<ItemTy>BP</ItemTy>
				<SLInd>GAM316X7R474K16AT</SLInd>
				<LinItemNum>MG</LinItemNum>
				<LIN05>21:9000:PK</LIN05>
				<LIN06>0.053:CT:1:PK</LIN06>
			</LINSEG>
			<PIA>
				<ProdID>4</ProdID>
				<ItemNoID>AVX</ItemNoID>
				<ItemNoTy>MF</ItemNoTy>
			</PIA>
			<SCC>
				<DlvCode>1</DlvCode>
				<DlvInst></DlvInst>
			</SCC>
			<QTY>
				<QtyQfr>21</QtyQfr>
				<Qty>7000</Qty>
				<Unit>PK</Unit>
			</QTY>
			<DTM>
				<DTQfr>002</DTQfr>
				<DTPrd></DTPrd>
			</DTM>
			<SCC>
				<DlvCode>1</DlvCode>
				<DlvInst></DlvInst>
			</SCC>
			<DTM>
				<DTQfr>002</DTQfr>
				<DTPrd></DTPrd>
			</DTM>
		</LIN>
	</UNH>
</UNB>
</DOCUMENT>     

ANSI X12 EDIFACT SAP IDOC Download XML Links
1