Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Convert string to XML format

Former Member
0 Likes
604

Hi All,

My requirement is to download data to an excel sheet with specific formats like background color, font, size etc (can't use OLE or any function modules since I want to execute in background). I have chosen XSLT program to do this. following is my XSLT program

<asx:transform xmlns:asx="http://www.w3.org/1999/XSL/Transform"

xmlns:sap="http://www.sap.com/abapxml" version="1.0">

<asx:template match="/">

<asx:copy-of select="."/>

<html>

<body>

<table border="2">

<tr>

<th align="LEFT" colspan="7" rowspan="2">

<font face="Arial" size="2">New Bills</font>

</th>

</tr>

<table border="2">

<tr>

<b>

<font face="Arial" size="1">

<th colspan="2" rowspan="2">Payment Details</th>

<th colspan="3" rowspan="2">Total Charge Details</th>

<th colspan="2" rowspan="2"/>

</font>

</b>

</tr>

<table border="1">

<tr>

<b>

<font face="Arial" size="1">

<th>Payment reference</th>

<th bgcolor="#FFFF00">Payment approved (Yes/No)</th>

<th>Net charge</th>

<th>VAT</th>

<th>Total charge</th>

<th>Your Reference</th>

<th>Account Number</th>

</font>

</b>

</tr>

<asx:for-each select="catalog/cd">

<tr>

<td>

<asx:value-of select="payref"/>

</td>

<td>

<asx:value-of select="payapprov"/>

</td>

<td>

<asx:value-of select="netcharge"/>

</td>

<td>

<asx:value-of select="vat"/>

</td>

</tr>

</asx:for-each>

</table>

</table>

</table>

</body>

</html>

</asx:template>

</asx:transform>

I have written a piece of code in ABAP like this

wa_data-payref = '100000000013'.

wa_data-payapprov = 'N'.

wa_data-netcharge = '160.00'.

wa_data-vat = '20.00'.

APPEND wa_data TO it_data.

wa_final_data = '<catalog>'.

APPEND wa_final_data TO it_final_data.

LOOP AT it_data INTO wa_data.

CONCATENATE '<cd>' '<payref>' wa_data-payref '</payref>' INTO wa_final_data.

CONCATENATE wa_final_data '<payapprov>' wa_data-payapprov '</payapprov>' INTO wa_final_data.

APPEND wa_final_data TO it_final_data.

CONCATENATE '<netcharge>' wa_data-netcharge '</netcharge>' INTO wa_final_data.

CONCATENATE wa_final_data '<vat>' wa_data-vat '</vat></cd>' INTO wa_final_data.

APPEND wa_final_data TO it_final_data.

ENDLOOP.

CALL FUNCTION 'CONVERT_TABLE_TO_STRING'

EXPORTING

i_tabline_length = '255'

IMPORTING

e_string = ls_string

TABLES

it_table = it_final_data.

call transformation z_xml_xls_6

source tab = it_final_data[]

result xml lr_string.

I don't know whether my XSLT is wrong or my ABAP code, but when I see the result of LR_STRING in debug mode I am getting tag values as for example '&ltvat&gt' rather than <vat>.

Any help will be highly rewarded. I need this very urgently.

Thanks for your help.

Venkat

1 REPLY 1
Read only

brad_bohn
Active Contributor
0 Likes
411

Any help will be highly rewarded. I need this very urgently.

That is basically a 'kiss of death' in my book. I scanned down to see what your question was and didn't bother to look at your XSLT after that...