2017 Dec 13 9:33 AM
Hi,
I'm using XSLT_TOOL to generate an excel file.
In this XSLT in make a loop an internal table. Depending on severals conditions I would like create a row with data.
It is possible to pass the index number of the row as variable.
instead of
<Row ss:Index="2"
I would like
<Row ss:Index=VARIABLE
Thanks in advance,
Joseph
2017 Dec 13 9:23 PM
So, you want to generate an Excel file in XMLSS format (AKA XML2003 for Excel). This format has been superseded by XLSX. Are you sure you can't use XLSX? (cf abap2xlsx project).
Now back to your question, note that it's an XSLT question, not an ABAP one. You may find assistance at any XSLT place in the web. Note that the input XML document corresponds to your variable in format ASXML (documented in the ABAP documentation), passed via CALL TRANSFORMATION SOURCE root = variable (automatically converted to ASXML), and you access to it via xpath expressions.
<Row>
<xsl:attribute name="ss:Index"><xsl:value-of select="xpath expression to your variable in ASXML format"/>
...
</Row>
Hi,
I'm using XSLT_TOOL to generate an excel file.
In this XSLT in make a loop an internal table. Depending on severals conditions I would like create a row with data.
It is possible to pass the index number of the row as variable.
instead of
<Row ss:Index="2"
I would like
<Row ss:Index=VARIABLE
Thanks in advance,
Joseph
2017 Dec 13 1:04 PM
Hey,
I'm not sure if I'm answering your question. What I understood you are asking is can you pass a variable to the transformation, in you case that variable would be used in <Row ss:Index=VARIABLE. If this is the question then the answer is yes.
Because there are many ways of handling a transformation and I am unclear on the whole process/flow of your need, I can advise you to read the documentation on the subject. In addition, check out all the DEMO programs that are offered by SAP in the documentation under Executable Examples (in the link I provided).
Just to clarify how vast the options are I suggest you take a look at HR_EXCEL_SHEET transformation and also check out the "where-used" of it to get a handle on the API for passing parameters (in this case it using a structure named param and it is passed via SOURCE).
2017 Dec 13 9:23 PM
So, you want to generate an Excel file in XMLSS format (AKA XML2003 for Excel). This format has been superseded by XLSX. Are you sure you can't use XLSX? (cf abap2xlsx project).
Now back to your question, note that it's an XSLT question, not an ABAP one. You may find assistance at any XSLT place in the web. Note that the input XML document corresponds to your variable in format ASXML (documented in the ABAP documentation), passed via CALL TRANSFORMATION SOURCE root = variable (automatically converted to ASXML), and you access to it via xpath expressions.
<Row>
<xsl:attribute name="ss:Index"><xsl:value-of select="xpath expression to your variable in ASXML format"/>
...
</Row>
2017 Dec 14 5:42 PM
Sandra,
thank you for you answer.
I really new at XSLT.
I create a variable name "myindex". I passed the value 7.
I want to pass this value to the cell's index.
I have this piece of code:
<tt:root name="myindex"/>
<tt:template>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html=
"http://www.w3.org/TR/REC-html40">
.....
<Row ss:AutoFitHeight="0" ss:Index="9">
<Cell ss:Index="$.myindex">
<Data ss:Type="String"><tt:copy ref="myindex"/></Data>
<NamedCell ss:Name="_FilterDatabase"/>
</Cell>
</Row>
....
My XML looks like this:
....
<Cell ss:Index="$.myvar">
<Data ss:Type="String">7</Data>
<NamedCell ss:Name="_FilterDatabase"/>
</Cell>
.....
Why the cell's index has value $.myvar" and not "7" ?
Thanks in advance,
Joseph
2017 Dec 14 5:44 PM
2017 Dec 14 6:10 PM
Oh, you made a big confusion 🙂 you are using Simple Transformation (ST), not XSLT. XSLT_TOOL is misleading, because you have the choice between ST and XSLT. I prefer using the transaction STRANS (an alias of XSLT_TOOL). I consider the "name" XSLT_TOOL deprecated because of the confusion. So, no XPATH anymore.
Second confusion : we are dealing with a variable in ABAP, it's converted into XML source when CALL TRANSFORMATION ... SOURCE myindex = variable_myindex is invoked (converted into ASXML format), but it's no more a variable in the XSLT, it's just the XML source. So you must not use the prefix $ which is reserved to XSLT variables only.
In ST, enter the attribute as follows (close to XSLT), and see how the "data node address" is to be entered instead of using XPATH (.MYINDEX, case insensitive):
<Cell>
<tt:attribute name="ss:Index" value-ref=".MYINDEX"/>
</Cell>
2017 Dec 14 6:53 PM
Sandra,
Thank you for your clarification about my misunderstanding of XSLT and ST.
It works fine! :)))
Joseph
2017 Dec 14 7:42 PM
By the way, ST is a SAP proprietary language (not XSLT), meaning that you can't get help about ST outside SAP, and "ABAP development" is the right place to post.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |