cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting of item record by fields

former_member581827
Participant
0 Kudos

Hi All,

I am having one scenario where source is IDOC and Target is file.The file will contain one header record and several Items.I want the file to be like one header and Items to be sorted depending on 2 feilds.Can any one come across this type of scenario where Item records are sorted depending on more than one field.

Thanks in Advance,

Chandra.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi chandra,

there are two solutions to your problem,

1)use java mapping/XSLT mapping.

2)if you have used graphical mapping for IDOC to file scenario,then do not change it,go to the receiver communication channel,in the parameter tab fill in the usual file adapter details;go to module tab;in the processing sequence area uwill find a default module name localejbs/CallSapAdapter;add one row and copy that first row details to the second row;in the first row do the following

==>in the modulename text box type: localejbs/AF_Modules/MessageTransformBean

==>in the type combo box choose "Local Enterprise Bean"

==>If you are using paches < SP15 then type some key name;

(in SP15 you will not find that so dont worry)

==>go to the Module Configuration area after selecting the first row in the processing sequence area (this is important since module configuration corresponds to individual rows of parameter sequence)

==>in the module configuration area

==>in the first row

in parameter name text box type :Transform.Class

in parameter value text box type : com.sap.aii.messaging.adapter.XSLTConversion

==> in the second row

in parameter name text box type : XSLTConversion.XSLTFileName

in parameter value text box type : the location of the XSL file name for example
system1\dir1\sort.xsl;

write this XSL as others said;yo can write this XSL to fabricate your XML in any format ex:you can sort;for writing xsl refer W3schools.

now save the receiver communication channel;

if you run the scenario you can see the output in the format you have specified in the XSl;

cheers,

Sundar.

former_member581827
Participant
0 Kudos

Hi Sundar,

Thanks for your reply.

We are still facing problem thru graphical mapping.

Can you please let me know how can we do XSL mapping and how it can be imported and how can we include in interface mapping.

An example is very much appreciated.

Regards,

Chandra.

Former Member
0 Kudos

Hi Chandra,

dont try to sort in graphical mapping.....just do normal mapping in graphical mapping....i.e assigning correct values to the target.....oce its done.....u know the o/p xml structure...write an XSL to sort the XML file..(go to w3schools and see how to use sort)....once its done...kindly refer my previous post in the thread how to import that xsl...and activate the scenario......if ur still not clear kindly mention which part u r not clear so that i may say it in a way u could understand.....

cheers,

Sundar.

Answers (2)

Answers (2)

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Chandra sekhar,

This is possible using iether JAVA or XSLT mapping. I dont think this can be done using your normal Graphical Mapping.

For info on java mapping, I would suggest that your go through this link,

http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm

For XSLT,

http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm

http://www.w3.org/TR/xslt20/

Regards,

Bhavesh

udo_martens
Active Contributor
0 Kudos

Hi Chandra,

this is possible with several mapping languages, very easy with xsl:sort or message mapping function "sort".

Regards,

Udo

former_member581827
Participant
0 Kudos

Hi Udo,

Thanks for your quick response.

Can you tell me how to do with XSL:Sort or would appreciate if you send any sample code.

Regards,

Chandra.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Chandra,

This link deals with the XSL SORT element along with an example code.

http://www.w3.org/TR/xslt20/#sorting

Hope this helps,

Regards,

Bhavesh

PS DO award points for useful answers

udo_martens
Active Contributor
0 Kudos

Hi Chandra,

a simple source xml:

<?xml version="1.0" encoding="UTF-8"?>
<root>
	<field value1="A" value2="2">first</field>
	<field value1="B" value2="1">second</field>
	<field value1="A" value2="1">third</field>
</root>

A style, what is sorting the output on attributes first value1, second value2:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:template match="/">
		<outputdata>
			<xsl:for-each select="root/*">
				<xsl:sort select="./@value1" order="ascending" />
				<xsl:sort select="./@value2" order="ascending" />
				<output>
					<xsl:value-of select="."/>
				</output>
			</xsl:for-each>
		</outputdata>
	</xsl:template>
</xsl:stylesheet>

Regards,

Udo