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

Simple Transformation - Format Output

Former Member
0 Likes
2,321

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 NameTypeLenghtDecimals
CLIENTCHAR100
EMPRESCHAR140
INDCNPNUMC10
TICKETCHAR500
ACAOCHAR80
TAREFACHAR150
DATENVCHAR100
HORENVCHAR50
USUENVCHAR150
USUBPOCHAR300
REQMSGSTRING00
INDIDENUMC10
DATPROCHAR100
HORPROCHAR50
NREQIDNUMC150
NREQDPCHAR150
MESCOMNUMC20
ANOCOMNUMC40
CODFOLNUMC40
NROPFLCHAR60
IDEMPRCHAR150
VLANFLDEC112
NROHRADEC32

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>

<record>
<client>134566</client>

<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.

1 ACCEPTED SOLUTION
Read only

ttrapp
SAP Mentor
SAP Mentor
0 Likes
1,429

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

3 REPLIES 3
Read only

ttrapp
SAP Mentor
SAP Mentor
0 Likes
1,430

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

Read only

Former Member
0 Likes
1,429

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 .

Read only

0 Likes
1,429

This message was moderated.