cancel
Showing results for 
Search instead for 
Did you mean: 

Handling Multi hierarchial Structure using XSLT or Java Mapping in XI

Former Member
0 Kudos

Hello Experts,

I have an requirement wherein i have sender as IDOC and File as Receiver.My target File structure is multi hierarchial with parent level and many child sub level node.

I tried to generate flat structure using graphical mapping by creating an intermediate structure and then mapping it to flat structure but that seems to be very complex for my scenario as there are many sub level at target structure..

Is there any simple way of handlng these????

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member463616
Contributor
0 Kudos

Hi,

By using XSLT mapping, you can achieve this.

Please see the below link.

[IdocToflatfile|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1819] [original link is broken] [original link is broken] [original link is broken];

Regards,

P.Rajesh

Former Member
0 Kudos

hi,

u can go for adapter module for the same. Chk this:

http://wiki.sdn.sap.com/wiki/display/Snippets/ConvertingXMLfileintoflatCSVfileusingCustomAdaptermoduleinPI7.1.

Thanks

Amit

former_member200962
Active Contributor
0 Kudos

The question that you have asked is very generic....if you provide details like how your source and target structure looks and what you ultimately need, then somebody from the forum will be able to help.

Regards,

Abhishek.

Former Member
0 Kudos

Hi ,

My idoc is an ORDERS idoc nd target field structure is somethng like this

-Header(Parent node) 0 unbounded

PO TYPE

PO Number

Delivery date

-Item(Child Node of Header) 0 unbounded

Item No

WW Item No

Site No

Quantity

- Delivery data(Child Node of Item) 0 unbounded

Fileld1

Field2

Field3

- Vendor data(Child Node of Delivery data) 0 unbounded

Filed4

Field5

Field6 and so on there are many child nodes..Now since receiver File adapter handles only 1 level data and not the nested level data,how to achieve these requirement..

My Output file should be somethng like these.

PO TYPE PO NUMBER Delivery date

ITEM NO WW ITEM NO SITE NO Quantity

Field1 Field2 Filed 3

Field 4 Filed5 Filed 6 and so on.

Former Member
0 Kudos

Hi ,

My idoc is an ORDERS idoc nd target field structure is somethng like this

-Header(Parent node) 0 unbounded

PO TYPE

PO Number

Delivery date

-Item(Child Node of Header) 0 unbounded

Item No

WW Item No

Site No

Quantity

- Delivery data(Child Node of Item) 0 unbounded

Fileld1

Field2

Field3

- Vendor data(Child Node of Delivery data) 0 unbounded

Filed4

Field5

Field6 and so on there are many child nodes..Now since receiver File adapter handles only 1 level data and not the nested level data,how to achieve these requirement..

My Output file should be somethng like these.

PO TYPE PO NUMBER Delivery date

ITEM NO WW ITEM NO SITE NO Quantity

Field1 Field2 Filed 3

Field 4 Filed5 Filed 6 and so on.

Former Member
0 Kudos

I think it should be possible with XSLT, very simple


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<Header>
			<Header1>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
			</Header1>
			<Header2>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
			</Header2>
			<Header3>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
			</Header3>
			<Header4>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
			</Header4>
			<Header5>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
			</Header5>
		</Header>
		<xsl:for-each select="/ORDERS/E1EDP05">
			<Item>
				<Item1>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
				</Item1>
				<Item2>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
				</Item2>
			</Item>
			<Delivery>
				<Delivery1>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
				</Delivery1>
				<Delivery2>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
				</Delivery2>
			</Delivery>
<Vendor>
				<Vendor1>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
				</Vendor1>
				<Vendor2>
				<xsl:copy-of select="/ORDERS/E1EDKA1/.."/>
				</Vendor2>
			</Vendor>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>

Former Member
0 Kudos

Hi,

My target structure s somethng like

Header is root node and inside it there are some fields.

then header has got Item has child Node and within Item there are some fields.

Within item there s an Delivery node and within it there are some fields and so on there are many childs..so

wat i want basically is using XSLT mapping can we generate an flat structure with only 1st level..so that receiver faile adapter can process it .

Because as we know receiver file adpter can only handle 1 level of data..It cannot convert an nested structure into an Text doc.

Thanks

Former Member
0 Kudos

hi vikas,

if you adapt the xpath expressions to your source structure, what you get is a xml file that can easily be converted to flat. what you will get is

header1 header2 .... headerN

item1 ...... .... .....

delivery1 ... ... ... ...

receive1 ... ... ...

item2 ......

.

.

.

etc

Former Member
0 Kudos

Hi,

I am trying to implement ur solution ..Thanks in advance for the solution.

Former Member
0 Kudos

Hi ,

I tried to implement your solution ..I am able to convert my idoc to XMLusing XLST but i have a question that how to convert that XMP to flat file as XI Receiver File adapter understand only 1st level of hierarchy..It doesnt understand nested level of hierarchy which is in my case...

Below is the xslt code which i have written:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<MT_SALES_PO_DATA_INBOUND>

<xsl:value-of select="WPUBON01/IDOC"/>

<xsl:for-each select="WPUBON01/IDOC/E1WPB01">

<E1WBBB01>

<Store_ID>A001</Store_ID>

<SYS_INVOICE_NO>

<xsl:value-of select="substring(BONNUMMER,'3','15')"/>

</SYS_INVOICE_NO>

<Cashier_ID>

<xsl:value-of select="KASSID"/>

</Cashier_ID>

</E1WBBB01>

</xsl:for-each>

<xsl:for-each select="WPUBON01/IDOC/E1WPB01/E1WPB02">

<E1WBB02>

<Transaction_Type>

<xsl:value-of select="VORGANGART"/>

</Transaction_Type>

<Article_Description>

<xsl:value-of select="QUALARTNR"/>

</Article_Description>

<ITEM_CODE>

<xsl:value-of select="ARTNR"/>

</ITEM_CODE>

<xsl:for-each select="WPUBON01/IDOC/E1WPB01/E1WPB02/E1WBB03">

<E1WBB03>

<Condition_Type>

<xsl:value-of select="KONDITION"/>

</Condition_Type>

<xsl:for-each select="">

<E1WBB04>

<TAX_Code>

<xsl:value-of select="MWSKZ"/>

</TAX_Code>

<TAX_Amount>

<xsl:value-of select="MWSBT"/>

</TAX_Amount>

</E1WBB04>

</xsl:for-each>

</E1WBB03>

</xsl:for-each>

</E1WBB02>

</xsl:for-each>

</MT_SALES_PO_DATA_INBOUND>

</xsl:template>

</xsl:stylesheet>

Any idea how do i convert these XML to falt file USing XSLT or File Receiver adapter in XI???

Thanks

Former Member
0 Kudos

Hi

Try this thing:

I removed E1WBB03 and created instead of it more E1WBB02, this way you have a root tag

MT_SALES_PO_DATA_INBOUND

- E1WBBB01 - header

- E1WBBB02 - repeating multiple times

This should be easily transformed with the converter from the File Comm Channel


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<MT_SALES_PO_DATA_INBOUND>
			<!--<xsl:value-of select="WPUBON01/IDOC"/>-->
			<xsl:for-each select="WPUBON01/IDOC/E1WPB01">
				<E1WBBB01>
					<Store_ID>A001</Store_ID>
					<SYS_INVOICE_NO>
						<xsl:value-of select="substring(BONNUMMER,'3','15')"/>
					</SYS_INVOICE_NO>
					<Cashier_ID>
						<xsl:value-of select="KASSID"/>
					</Cashier_ID>
				</E1WBBB01>
			</xsl:for-each>
			<xsl:for-each select="WPUBON01/IDOC/E1WPB01/E1WPB02">
				<E1WBB02>
					<Transaction_Type>
						<xsl:value-of select="VORGANGART"/>
					</Transaction_Type>
					<Article_Description>
						<xsl:value-of select="QUALARTNR"/>
					</Article_Description>
					<ITEM_CODE>
						<xsl:value-of select="ARTNR"/>
					</ITEM_CODE>
				</E1WBB02>
				<xsl:for-each select="WPUBON01/IDOC/E1WPB01/E1WPB02/E1WBB03">
					<E1WBB02>
						<Condition_Type>
							<xsl:value-of select="KONDITION"/>
						</Condition_Type>
						<xsl:for-each select="">
							<E1WBB04>
								<TAX_Code>
									<xsl:value-of select="MWSKZ"/>
								</TAX_Code>
								<TAX_Amount>
									<xsl:value-of select="MWSBT"/>
								</TAX_Amount>
							</E1WBB04>
						</xsl:for-each>
					</E1WBB02>
				</xsl:for-each>
			</xsl:for-each>
		</MT_SALES_PO_DATA_INBOUND>
	</xsl:template>
</xsl:stylesheet>

Former Member
0 Kudos

But i still doubt replacing EIWBB03 with E1WBB02 will work ...So wat i basically conclude from these s when ever u have deeply nested structure with more childs u should always replaced it with Parent node name ..Am i right??

Will try

Thankss

Former Member
0 Kudos

something like that,

basically you put everything under the same parent so as to flatten the structure