on 04-24-2008 5:14 PM
Hi All,
I am using XSLT mapping for file2file scenario(xml to flatfile).I have "Record ID" field in target side.I want to get the Record ID for each record as 1,2,3,.....There is no source field for "Record ID".
Please help me in this issue.
Hi,
maybe you can do the following...
GIVEN IS THIS XML-INPUT:
<X-ML_DATA xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<ROW>
<OPBEL>A00000001</OPBEL>
</ROW>
<ROW>
<OPBEL>B00000002</OPBEL>
</ROW>
<ROW>
<OPBEL>C00000003</OPBEL>
</ROW>
<ROW>
<OPBEL>D00000004</OPBEL>
</ROW>
<ROW>
<OPBEL>E00000005</OPBEL>
</ROW>
<ROW>
<OPBEL>F00000006</OPBEL>
</ROW>
</X-ML_DATA>
THIS IS THE MAPPING:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asx="http://www.sap.com/abapxml">
<xsl:template match="/">
<xsl:for-each select="X-ML_DATA/ROW">
<RecordSet>
<RECORD_ID>
<xsl:value-of select="position()"/>
</RECORD_ID>
<INVOICE_NUMBER>
<xsl:value-of select="OPBEL"/>
</INVOICE_NUMBER>
</RecordSet>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
THIS IS THE RESULT:
1A000000012B000000023C000000034D000000045E000000056F00000006
Value-of select="position()" brings you an ascending number in the new tag "RECORD_ID" of the target structure whenever the next "for-each select"-expression appears.
Regards,
Ralph
Edited by: Ralph Nitschke on Apr 28, 2008 12:06 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhuvan,
The solution proposed by Ralph is the best one.
As there is no straight forward function available in XSL to get the sequence number, it is better to follow that solution.
Let me explain you that login in words: You want a sequence of RecordIDs at receiver side, as how many records at sender side. For that, use the function "position" on the number of records at sender side and map it to RecordID at receiver side. This will result in RecordID: 1 for the first record, 2 for the second record, etc....
Regards
Bhanu Tiruveedula
Intelligroup.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.