‎2014 Feb 04 8:24 PM
Hello guys,
I have created a transformation and I'm facing a problem to format the output of numeric attributes.
My requirement is: the decimal separator needs to be comma (",") instead dot (".") and the XML output needs to be with 2 decimals places (as is in structure definition).
My dictionary structure:
| Field Name | Type | Lenght | Decimals |
| CLIENT | CHAR | 10 | 0 |
| EMPRES | CHAR | 14 | 0 |
| INDCNP | NUMC | 1 | 0 |
| TICKET | CHAR | 50 | 0 |
| ACAO | CHAR | 8 | 0 |
| TAREFA | CHAR | 15 | 0 |
| DATENV | CHAR | 10 | 0 |
| HORENV | CHAR | 5 | 0 |
| USUENV | CHAR | 15 | 0 |
| USUBPO | CHAR | 30 | 0 |
| REQMSG | STRING | 0 | 0 |
| INDIDE | NUMC | 1 | 0 |
| DATPRO | CHAR | 10 | 0 |
| HORPRO | CHAR | 5 | 0 |
| NREQID | NUMC | 15 | 0 |
| NREQDP | CHAR | 15 | 0 |
| MESCOM | NUMC | 2 | 0 |
| ANOCOM | NUMC | 4 | 0 |
| CODFOL | NUMC | 4 | 0 |
| NROPFL | CHAR | 6 | 0 |
| IDEMPR | CHAR | 15 | 0 |
| VLANFL | DEC | 11 | 2 |
| NROHRA | DEC | 3 | 2 |
My simple transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined">
<tt:root name="ROOT" type="?"/>
<tt:root name="RECORD" line-type="ddic:Z8H_ADP_TSK_LAUNCHES_DELETE"/>
<tt:template name="XALIAS0">
<root>
<tt:loop ref=".RECORD">
<record>
<client tt:value-ref="CLIENT"/>
<empres tt:value-ref="EMPRES"/>
<indcnp tt:value-ref="INDCNP"/>
<ticket tt:value-ref="TICKET"/>
<acao tt:value-ref="ACAO"/>
<tarefa tt:value-ref="TAREFA"/>
<datenv tt:value-ref="DATENV"/>
<horenv tt:value-ref="HORENV"/>
<usuenv tt:value-ref="USUENV"/>
<usubpo tt:value-ref="USUBPO"/>
<reqmsg tt:value-ref="REQMSG"/>
<indide tt:value-ref="INDIDE"/>
<datpro tt:value-ref="DATPRO"/>
<horpro tt:value-ref="HORPRO"/>
<nreqid tt:value-ref="NREQID"/>
<nreqdp tt:value-ref="NREQDP"/>
<mescom tt:value-ref="MESCOM"/>
<anocom tt:value-ref="ANOCOM"/>
<codfol tt:value-ref="CODFOL"/>
<nropfl tt:value-ref="NROPFL"/>
<idempr tt:value-ref="IDEMPR"/>
<vlanfl tt:value-ref="VLANFL"/>
<nrohra tt:value-ref="NROHRA"/>
</record>
</tt:loop>
</root>
</tt:template>
</tt:transform>
My output:
<root>
<empres>0000000</empres>
<indcnp>1</indcnp>
<acao>Gravar</acao>
<tarefa>EXCLUI_LAN</tarefa>
<datenv>03/02/2014</datenv>
<horenv>17:02</horenv>
<usuenv>RENAN</usuenv>
<usubpo>WEBSERVICE</usubpo>
<indide>2</indide>
<nreqid>000000000016591</nreqid>
<mescom>03</mescom>
<anocom>2013</anocom>
<codfol>0040</codfol>
<vlanfl>3635.0</vlanfl>
</record>
</root>
If anyone have suggestions, will be welcome.
Thanks in advance.
‎2014 Feb 04 9:04 PM
Hi Renan,
I'll have to think about it - at the moment I don't have much hope. The command tt:value has some parameters like length but I don't know any method for changing the decimal point: http://help.sap.com/saphelp_nw73ehp1/helpdata/en/4a/0ca25379291b43e10000000a42189c/content.htm?frame... and http://help.sap.com/saphelp_nw73ehp1/helpdata/en/4a/0c1a4279281b40e10000000a42189c/content.htm
The reason is that Simple Transformations are designed to map ABAP to XML Schema data types: http://help.sap.com/saphelp_nw73ehp1/helpdata/en/4a/168554581d1977e10000000a42189c/content.htm?frame...
In fact the SAP Library in NW 7.31 has a broken link but here you can find the parameter for tt:value and tt:write:
http://help.sap.com/saphelp_nw70ehp2/helpdata/de/4c/c75f3b156a2656e10000000a15822b/content.htm These are:
xsd:type
[xsd-maxInclusive="max"]
[xsd-maxExclusive ="max"]
[xsd-minInclusive="min"]
[xsd-minExclusive ="min"]
[xsd-totalDigits="dgts"]
[xsd-fractionDigits="dgts"]
So you can control some aspects of XML Schema facets like fraction digits. Mappings are useful for enumeration types and don't apply here.
Of course you use method calls to convert the values but maybe XSLT is much easier.
My advice is that you implement a proper XML data exchange using data types according to XML Schema. Every other solution is not conform to established standards and will be painful and lack of interoperability.
Best Regards,
Tobias
‎2014 Feb 04 9:04 PM
Hi Renan,
I'll have to think about it - at the moment I don't have much hope. The command tt:value has some parameters like length but I don't know any method for changing the decimal point: http://help.sap.com/saphelp_nw73ehp1/helpdata/en/4a/0ca25379291b43e10000000a42189c/content.htm?frame... and http://help.sap.com/saphelp_nw73ehp1/helpdata/en/4a/0c1a4279281b40e10000000a42189c/content.htm
The reason is that Simple Transformations are designed to map ABAP to XML Schema data types: http://help.sap.com/saphelp_nw73ehp1/helpdata/en/4a/168554581d1977e10000000a42189c/content.htm?frame...
In fact the SAP Library in NW 7.31 has a broken link but here you can find the parameter for tt:value and tt:write:
http://help.sap.com/saphelp_nw70ehp2/helpdata/de/4c/c75f3b156a2656e10000000a15822b/content.htm These are:
xsd:type
[xsd-maxInclusive="max"]
[xsd-maxExclusive ="max"]
[xsd-minInclusive="min"]
[xsd-minExclusive ="min"]
[xsd-totalDigits="dgts"]
[xsd-fractionDigits="dgts"]
So you can control some aspects of XML Schema facets like fraction digits. Mappings are useful for enumeration types and don't apply here.
Of course you use method calls to convert the values but maybe XSLT is much easier.
My advice is that you implement a proper XML data exchange using data types according to XML Schema. Every other solution is not conform to established standards and will be painful and lack of interoperability.
Best Regards,
Tobias
‎2014 Feb 04 9:38 PM
Hi Tobias,
The legacy system that I sending the information don't use the standards and are not flexible to update it. Based in your explanation about the proposal of ST, its really not make sense something like I'm searching.
I will do a workaround during XML file generation .
‎2014 Feb 06 2:59 PM