Simple transformation dropping trailing zero.

Hi experts.
I am having a problem with my transformation file, and I was hoping someone could help me.
I have created a simple transformation file, with a variable using the type of "DMBTR" which Does have 2 decimal points.
IF I have data - the two decimal points print.
EG if the amount is 100.57..    I get the 100.57 to print which is what I need and expect.
BUT.
IF the amount is 100.50    I am getting 100.5    Is is dropping the final zero amount, and therefore is failing in the validation.
HOW can I FORCE the two decimal points to print?
I have even tried it where I declare it as a variable of type "I" with 2 decimal points, and it still does not work.
I can not figure out how to use the Number format   option with a Value-ref print line.
If someone could help me with that.. I could try that to see if it worked.
thank you.
eg: of the way the data is declared:
  <tt:type name="GRTOT14" type="I" length="13" decimals="2"/>
OR
  <tt:type name="GRTOT16" type="ddic:DMBTR"/>
  <tt:type name="GRTOT17" type="ddic:DMBTR"/>
eg: of the way I am using it where I am getting only one decimal place if the 2nd decimal place is ZERO
             <tot_grnt_sbsdy_amt tt:value-ref=".GRTOT14"/>
               <tot_insu_prcd_amt tt:value-ref=".GRTOT16"/>
              <tot_opay_rcap_amt tt:value-ref=".GRTOT17"/>
PLEASE HELP.
thank you.

From what I understand about XML (could be more), the canonical representation of decimal values does not allow a fixed number of decimal places.
SAP documentation:
http://help.sap.com/saphelp_nw04/helpdata/en/52/491a40251e2402e10000000a1550b0/frameset.htm
from there, this XML documentation is referenced:
http://www.w3.org/TR/xmlschema-2/#decimal
important bit:
Leading and trailing zeroes are prohibited subject to the following: there must be at least one digit to the right and to the left of the decimal point which may be a zero.
You already discarded my workaround: using a character or string type field and fill it to your liking prior to serialisation.
Thomas

Similar Messages

  • Simple Transformation to deserialize an XML file into ABAP data structures?

    I'm attempting to write my first simple transformation to deserialize
    an XML file into ABAP data structures and I have a few questions.
    My simple transformation contains code like the following
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
                  xmlns:pp="http://www.sap.com/abapxml/types/defined" >
    <tt:type name="REPORT" line-type="?">
      <tt:node name="COMPANY_ID" type="C" length="10" />
      <tt:node name="JOB_ID" type="C" length="20" />
      <tt:node name="TYPE_CSV" type="C" length="1" />
      <tt:node name="TYPE_XLS" type="C" length="1" />
      <tt:node name="TYPE_PDF" type="C" length="1" />
      <tt:node name="IS_NEW" type="C" length="1" />
    </tt:type>
    <tt:root name="ROOT2" type="pp:REPORT" />
        <QueryResponse>
        <tt:loop ref="ROOT2" name="line">
          <QueryResponseRow>
            <CompanyID>
              <tt:value ref="$line.COMPANY_ID" />
            </CompanyID>
            <JobID>
              <tt:value ref="$line.JOB_ID" />
            </JobID>
            <ExportTypes>
              <tt:loop>
                <ExportType>
                   I don't know what to do here (see item 3, below)
                </ExportType>
              </tt:loop>
            </ExportTypes>
            <IsNew>
              <tt:value ref="$line.IS_NEW"
              map="val(' ') = xml('false'), val('X') = xml('true')" />
            </IsNew>
          </QueryResponseRow>
          </tt:loop>
        </QueryResponse>
        </tt:loop>
    1. In a DTD, an element can be designated as occurring zero or one
    time, zero or more times, or one or more times. How do I write the
    simple transformation to accommodate these possibilities?
    2. In trying to accommodate the "zero or more times" case, I am trying
    to use the <tt:loop> instruction. It occurs several layers deep in the
    XML hierarchy, but at the top level of the ABAP table. The internal
    table has a structure defined in the ABAP program, not in the data
    dictionary. In the simple transformation, I used <tt:type> and
    <tt:node> to define the structure of the internal table and then
    tried to use <tt:loop ref="ROOT2" name="line"> around the subtree that
    can occur zero or more times. But every variation I try seems to get
    different errors. Can anyone supply a working example of this?
    3. Among the fields in the internal table, I've defined three
    one-character fields named TYPE_CSV, TYPE_XLS, and TYPE_PDF. In the
    XML file, I expect zero to three elements of the form
    <ExportType exporttype='csv' />
    <ExportType exporttype='xls' />
    <ExportType exporttype='pdf' />
    I want to set field TYPE_CSV = 'X' if I find an ExportType element
    with its exporttype attribute set to 'csv'. I want to set field
    TYPE_XLS = 'X' if I find an ExportType element with its exporttype
    attribute set to 'xls'. I want to set field TYPE_PDF = 'X' if I find
    an ExportType element with its exporttype attribute set to 'pdf'. How
    can I do that?
    4. For an element that has a value like
    <ErrorCode>123</ErrorCode>
    in the simple transformation, the sequence
    <ErrorCode>  <tt:value ref="ROOT1.CODE" />  </ErrorCode>
    seems to work just fine.
    I have other situations where the XML reads
    <IsNew value='true' />
    I wanted to write
    <IsNew>
            <tt:value ref="$line.IS_NEW"
            map="val(' ') = xml('false'), val('X') = xml('true')" />
           </IsNew>
    but I'm afraid that the <tt:value> fails to deal with the fact that in
    the XML file the value is being passed as the value of an attribute
    (named "value"), rather than the value of the element itself. How do
    you handle this?

    Try this code below:
    data  l_xml_table2  type table of xml_line with header line.
    W_filename - This is a Path.
      if w_filename(02) = '
        open dataset w_filename for output in binary mode.
        if sy-subrc = 0.
          l_xml_table2[] = l_xml_table[].
          loop at l_xml_table2.
            transfer l_xml_table2 to w_filename.
          endloop.
        endif.
        close dataset w_filename.
      else.
        call method cl_gui_frontend_services=>gui_download
          exporting
            bin_filesize = l_xml_size
            filename     = w_filename
            filetype     = 'BIN'
          changing
            data_tab     = l_xml_table
          exceptions
            others       = 24.
        if sy-subrc <> 0.
          message id sy-msgid type sy-msgty number sy-msgno
                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.

  • Simple transform not working as expected

    I'm new to Oracle Spatial, and I'm having some problems.
    I'm trying to do a simple transform of a rectangle from one srid to another, and I'm getting the craziest results. After playing around, I found that I get the same weird behavior when I transform from an srid to itself.
    This, for example, returns what I would expect it to:
    select
    -- SDO_CS.TRANSFORM (
    SDO_GEOMETRY ( 2003, 8307, null, sdo_elem_info_array ( 1, 1003, 3 ),
    SDO_ORDINATE_ARRAY ( -84.3416667, 41.2833333, -84.3250000, 41.2750000 )
    -- ) , 8307
    AS results FROM dual
    With the two lines commented out, this is a simple selection of a rectangular geometry, without any transformation. It returns the coordinates it was given, with the trailing '0's trimmed off:
    RESULTS(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 3), SDO_ORDINATE_ARRAY(
    -84.341667, 41.2833333, -84.325, 41.275))
    But if I uncomment the two lines, so that I' doing a transform of the rectangle from the WGS84 it was in into WGS 84, I get the weirdest results:
    select
    SDO_CS.TRANSFORM (
    SDO_GEOMETRY ( 2003, 8307, null, sdo_elem_info_array ( 1, 1003, 3 ),
    SDO_ORDINATE_ARRAY ( -84.3416667, 41.2833333, -84.3250000, 41.2750000 )
    ) , 8307
    AS results FROM dual
    RESULTS(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(
    -84.341667, 41.2833333, -84.340767, 41.2833333, -84.339868, 41.2833333, -84.338969, 41.2833333, -84.338069, 41.2833333, -84.33717, 41.2833333, -84.336271, 41.2833333, -84.335371, 41.2833333, -84.334472, 41.2833333, -84.333573, 41.2833333, -84.332673, 41.2833333, -84.331774, 41.2833333, -84.330875, 41.2833333, -84.329976, 41.2833333, -84.329076, 41.2833333, -84.328177, 41.2833333, -84.327278, 41.2833333, -84.326378, 41.2833333, -84.325479, 41.2833333, -84.325, 41.2833333, -84.325, 44.88325, -84.325, 48.4831666, -84.325, 52.0830833, -84.325, 55.683, -84.325, 59.2829166, -84.325, 62.8828333, -84.325, 66.48275, -84.325, 70.0826666, -84.325, 73.6825833, -84.325, 77.2825, -84.325, 80.8824166, -84.325, 84.4823333, -84.325, 88.08225, -84.325, 91.6821666, -84.325, 95.2820833, -84.325, 98.882, -84.325, 102.481917, -84.325, 106.081833, -84.325, 109.68175, -84.325, 113.281667, -84.325, 116.881583, -84.325, 120.4815, -84.325, 124.081417, -84.325, 127.681333, -84.325, 131.28125, -84.325, 134.881167, -84.325, 138.481083, -84.325, 142.081, -84.325, 145.680917, -84.325, 149.280833, -84.325, 152.88075, -84.325, 156.480667, -84.325, 160.080583, -84.325, 163.6805, -84.325, 167.280417, -84.325, 170.880333, -84.325, 174.48025, -84.325, 178.080167, -84.325, 181.680083, -84.325, 185.28, -84.325, 188.879917, -84.325, 192.479833, -84.325, 196.07975, -84.325, 199.679667, -84.325, 203.279583, -84.325, 206.8795, -84.325, 210.479417, -84.325, 214.079333, -84.325, 217.67925, -84.325, 221.279167, -84.325, 224.879083, -84.325, 228.479, -84.325, 232.078917, -84.325, 235.678833, -84.325, 239.27875, -84.325, 242.878667, -84.325, 246.478583, -84.325, 250.0785, -84.325, 253.678417, -84.325, 257.278333, -84.325, 260.87825, -84.325, 264.478167, -84.325, 268.078083, -84.325, 271.678, -84.325, 275.277917, -84.325, 278.877833, -84.325, 282.47775, -84.325, 286.077667, -84.325, 289.677583, -84.325, 293.2775, -84.325, 296.877417, -84.325, 300.477333, -84.325, 304.07725, -84.325, 307.677167, -84.325, 311.277083, -84.325, 314.877, -84.325, 318.476917, -84.325, 322.076833, -84.325, 325.67675, -84.325, 329.276667, -84.325, 332.876583, -84.325, 336.4765, -84.325, 340.076417, -84.325, 343.676333, -84.325, 347.27625, -84.325, 350.876167, -84.325, 354.476083, -84.325, 358.076, -84.325, 361.675917, -84.325, 365.275833, -84.325, 368.87575, -84.325, 372.475667, -84.325, 376.075583, -84.325, 379.6755, -84.325, 383.275417, -84.325, 386.875333, -84.325, 390.47525, -84.325, 394.075167, -84.325, 397.675083, -84.325, 41.275, -84.325899, 41.275, -84.326799, 41.275, -84.327698, 41.275, -84.328597, 41.275, -84.329497, 41.275, -84.330396, 41.275, -84.331295, 41.275, -84.332195, 41.275, -84.333094, 41.275, -84.333993, 41.275, -84.334893, 41.275, -84.335792, 41.275, -84.336691, 41.275, -84.337591, 41.275, -84.33849, 41.275, -84.339389, 41.275, -84.340288, 41.275, -84.341188, 41.275, -84.341667, 41.275, -84.341667, 37.6750833, -84.341667, 34.0751667, -84.341667, 30.47525, -84.341667, 26.8753333, -84.341667, 23.2754167, -84.341667, 19.6755, -84.341667, 16.0755833, -84.341667, 12.4756667, -84.341667, 8.87575, -84.341667, 5.27583333, -84.341667, 1.67591666, -84.341667, -1.924, -84.341667, -5.5239167, -84.341667, -9.1238333, -84.341667, -12.72375, -84.341667, -16.323667, -84.341667, -19.923583, -84.341667, -23.5235, -84.341667, -27.123417, -84.341667, -30.723333, -84.341667, -34.32325, -84.341667, -37.923167, -84.341667, -41.523083, -84.341667, -45.123, -84.341667, -48.722917, -84.341667, -52.322833, -84.341667, -55.92275, -84.341667, -59.522667, -84.341667, -63.122583, -84.341667, -66.7225, -84.341667, -70.322417, -84.341667, -73.922333, -84.341667, -77.52225, -84.341667, -81.122167, -84.341667, -84.722083, -84.341667, -88.322, -84.341667, -91.921917, -84.341667, -95.521833, -84.341667, -99.12175, -84.341667, -102.72167, -84.341667, -106.32158, -84.341667, -109.9215, -84.341667, -113.52142, -84.341667, -117.12133, -84.341667, -120.72125, -84.341667, -124.32117, -84.341667, -127.92108, -84.341667, -131.521, -84.341667, -135.12092, -84.341667, -138.72083, -84.341667, -142.32075, -84.341667, -145.92067, -84.341667, -149.52058, -84.341667, -153.1205, -84.341667, -156.72042, -84.341667, -160.32033, -84.341667, -163.92025, -84.341667, -167.52017, -84.341667, -171.12008, -84.341667, -174.72, -84.341667, -178.31992, -84.341667, -181.91983, -84.341667, -185.51975, -84.341667, -189.11967, -84.341667, -192.71958, -84.341667, -196.3195, -84.341667, -199.91942, -84.341667, -203.51933, -84.341667, -207.11925, -84.341667, -210.71917, -84.341667, -214.31908, -84.341667, -217.919, -84.341667, -221.51892, -84.341667, -225.11883, -84.341667, -228.71875, -84.341667, -232.31867, -84.341667, -235.91858, -84.341667, -239.5185, -84.341667, -243.11842, -84.341667, -246.71833, -84.341667, -250.31825, -84.341667, -253.91817, -84.341667, -257.51808, -84.341667, -261.118, -84.341667, -264.71792, -84.341667, -268.31783, -84.341667, -271.91775, -84.341667, -275.51767, -84.341667, -279.11758, -84.341667, -282.7175, -84.341667, -286.31742, -84.341667, -289.91733, -84.341667, -293.51725, -84.341667, -297.11717, -84.341667, -300.71708, -84.341667, -304.317, -84.341667, -307.91692, -84.341667, -311.51683, -84.341667, -315.11675, -84.341667, 41.2833333))
    Which makes no sense to me whatsoever. I mean, why so many points? And why such absurd points? Srid 8307 is "Longitude / Latitude (WGS 84)", it shouldn't be giving me X coordinates of -250, or Y coordinates of 196.
    Clearly I'm doing something fundamentally wrong, but I'm at a loss to see what.
    I'm hoping it's something obvious. Help would be appreciated.

    Hi
    For someone being new, I advice to start reading, and yes a lot of informartion to deal with in the beginning, is the very well written documentaion.
    In your case you should read carefully chapter 6
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_cs_concepts.htm#i891851
    with specific attention to 6.2 Geodetic Coordinate Support
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_cs_concepts.htm#i891851
    In there you will find a section 6.2.4 Geodetic MBRs
    which completely describes the reasons behind the behaviour you have noticed.
    most important:
    The following considerations apply to the use of geodetic MBRs:
    •Do not use a geodetic MBR with spatial objects stored in the database. Use it only to construct a query window.
    •The lower-left Y coordinate (minY) must be less than the upper-right Y coordinate (maxY). If the lower-left X coordinate (minX) is greater than the upper-right X coordinate (maxX), the window is assumed to cross the date line meridian (that is, the meridian "opposite" the prime meridian, or both 180 and -180 longitude). For example, an MBR of (-10,10, -100, 20) with longitude/latitude data goes three-fourths of the way around the Earth (crossing the date line meridian), and goes from latitude lines 10 to 20.
    •When Spatial constructs the MBR internally for the query, lines along latitude lines are densified by adding points at one-degree intervals. This might affect results for objects within a few meters of the edge of the MBR (especially objects in the middle latitudes in both hemispheres).
    •When an optimized rectangle spans more than 119 degrees in longitude, it is internally divided into three rectangles; and as a result, these three rectangles share an edge that is the common boundary between them. If you validate the geometry of such an optimized rectangle, error code 13351 is returned because the internal rectangles have a shared edge. You can use such an optimized rectangle for queries with only the following: SDO_ANYINTERACT operator, SDO_RELATE operator with the ANYINTERACT mask, or SDO_GEOM.RELATE function with the ANYINTERACT mask. (Any other queries on such an optimized rectangle may return incorrect results.)
    Good luck
    Luc

  • How to remove trailing zeros from a decimal (type) value?

    Hi Everyone,
    I would like to 'drop' some trailing zeros from a decimal value, e.g.: 50.000000, and I am wondering how to go about this?
    The value is definitely of decimal type, and in this instance I know that I want to eliminate exactly six (6) zeros.
    Any help here will be greatly appreciated.
    Kind Regards,
    David

    Try the below:
    This is sort of a display issue, you may do it at Application side, which would be efficient.
    Declare @s Decimal(10,6)='50.0000000'
    Select Cast(@s as decimal(10,0))

  • How to remove trailing zeros 20353675.0000000

    All numeric decimal columns all are showing trailing zeros, how to remove them while processing within the query transform.
    20353675.0000000
    Thanks a lot for the helpful info

    You can use the trunc function to remove the decimal places.
    Syntax: trunc( number, [ decimal_places ] )
              <number> is the number to truncate.
             <decimal_places> is the number of decimal places to truncate to. This value must be an integer. If this parameter is omitted, the trunc function will truncate the number to 0 decimal places.
    Eg:     trunc(125.815)  would return 125
              trunc(125.815,0)  would return 125
              trunc(125.815,1)  would return 125.8
             trunc(125.815,2)  would return 125.81
             trunc(125.815,-1)  would return 120

  • Trailing zero's

    Hello,
    I have a 15 digit code. It's of varchar data type. Now when i try to pull it into Obiee it's dropping off the trailing zero's. Is there a way to get them. I know we can get them in the report by using html tag. But i have this in the prompt. is there a way i can get the whole code without losing the zero's.
    thanks,
    deep

    Hi,
    can you try below on your column prompt --> edit formula --> try below
    cast(cast( Column as int) as char)
    alternative way
    column properties -> Data Format and select 'Override Default Data format' and treat number as 'Custom'.You can specify the format of that number as required set it.
    Thanks
    Deva

  • How to delete trailing zeros from a quantity field to display in ALV?

    Hi there,
    i am retrieving the field LGMNG from LIPS table, which is of type QUAN(13). All LGMNG values there are stored as
    1,000
    20,000
    50,000 etc.
    But i want my values to be displayed as
    1
    20
    50 etc.
    i have tried the " shift v_variable right deleting trailing '0'" but it does not work.
    also, if the value of LIPS_LGMNG =  0,000, i need those columns in ALV empty(that is no zeros or comma displayed)
    can anyone please help?
    Thanks a lot,
    Mee

    hi,
    use this it will solve your problem, just write down this on your Fieldcatalog.
       WA_FIELDCATALOG-FIELDNAME = 'VALUE7'.
       WA_FIELDCATALOG-SELTEXT_L = 'Contribution EE(due)'.
      WA_FIELDCATALOG-DATATYPE = 'INT2'.           " it will remove trailing zero
      WA_FIELDCATALOG-DECIMALS_OUT = 0.
       APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
       CLEAR WA_FIELDCATALOG.

  • Using Simple Transformations with Objects tt:copy .. results in Exception

    Question:
    How can I serialize an ABAP-Object-Instanz with my own simple transformation?
    In the sap-documentation I found the following solution for the serialisation of any data-objects.
    "z_steffens_simple_transf":
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="ROOT"/>
      <tt:template>
        <root>
          <tt:copy ref="ROOT"/>
        </root>
      </tt:template>
    </tt:transform>
    Following the example I wrote this report:
    report  zspahr_test_simple_transf.
    class serializable definition.
      public section.
        interfaces if_serializable_object.
        data attr type string value 'Attribute'.
    endclass.         
    method main_serializable.
        data: oref type ref to serializable,
              xmlstr type xstring.
        create object oref.
        call transformation id
          source root = oref
          result xml xmlstr.
        call function 'DISPLAY_XML_STRING'
          exporting
            xml_string = xmlstr.
        call transformation z_steffens_simple_object
          source root = oref
          result xml xmlstr.
        call function 'DISPLAY_XML_STRING'
          exporting
            xml_string = xmlstr.
      endmethod.                    "main_
    start-of-selection.
      demo=>main_serializable( ).
    Executing this report leads to an exception "CX_SY_REF_NOT_SUPPORTED".
    The "standard" transformation "ID" ist working an translates my object-instance into an asXML representation:
      <?xml version="1.0" encoding="utf-8" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
      <ROOT href="#o3" />
      </asx:values>
    - <asx:heap xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abap="http://www.sap.com/abapxml/types/built-in" xmlns:cls="http://www.sap.com/abapxml/classes/global" xmlns:dic="http://www.sap.com/abapxml/types/dictionary">
    - <prg:SERIALIZABLE xmlns:prg="http://www.sap.com/abapxml/classes/program/ZSPAHR_TEST_SIMPLE_TRANSF" id="o3">
    - <local.SERIALIZABLE>
      <ATTR>Attribute</ATTR>
      </local.SERIALIZABLE>
      </prg:SERIALIZABLE>
      </asx:heap>
      </asx:abap>
    How can I do this with my own Simple Transformation "ZSPAHR_TEST_SIMPLE_TRANSF" ?
    I want to serialize my object using my own xml-structure, not the asXML-structure !
    Regards
    Steffen

    Hi,
    try like this,i think it may help you.
    ABAP:
    CALL TRANSFORMATION ztrans_test
          SOURCE
               root = partab
         RESULT XML lv_xstring.
    Trnsformation:
    <tt:root name="ROOT" type="?"/>
    <tt:template>
    <VALUES>
    <VALUE_SOURCE>
            <tt:value ref=".ROOT"/>
    </VALUE_SOURCE>
    <VALUE_PARAM>
    <tt:value ref="NAME"/>
    <tt:value ref="VALUE"/>
    </VALUE_PARAM>
    </VALUES>
    Thanks,
    Rajesh.

  • How to escape special characters in Simple Transformation

    Hi Experts,
    I have got a problem to get a well formed xml document from the below simple transformation. The content of maktx contains
    special characters like & <, which are not allowed in a well formed XML-Document. But the result of the Simple Transformation
    contains this charcters even after the transformation as you can the in the result below. Has anyone a hint how to escape the
    characters included in the maktx.
    The transformation for maktx, should be something like
    Before: Material & < TEST
    After: Material &amp &lt TEST
    Report wihich calls the simple transformation
    types:
    BEGIN OF t_mat,
       matnr type matnr,
       maktx type maktx,
    end of t_mat.
    Data:
      mat type t_mat,
      xml_stream type xstring.
    START-OF-SELECTION.
    mat-matnr = '4711'.
    mat-maktx = 'Material & < Test'.
    CALL TRANSFORMATION ztest_st2
            SOURCE mat = mat
            RESULT XML xml_stream.
    CALL FUNCTION 'DISPLAY_XML_STRING'
      EXPORTING xml_string = xml_stream.
    Simple Transformation
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="MAT"/>
      <tt:template>
        <Leistungsschild>
            <CHARACT> MATNR </CHARACT>
            <CHARACT_DESCR> Materialnummer </CHARACT_DESCR>
            <VALUE tt:value-ref="MAT.MATNR"/>
            <CHARACT> MAKTX </CHARACT>
            <CHARACT_DESCR> Materialkurztext </CHARACT_DESCR>
            <VALUE tt:value-ref="MAT.MAKTX" />
        </Leistungsschild>
      </tt:template>
    </tt:transform>
    RESULT
    <?xml version="1.0" encoding="utf-8" ?>
    <Leistungsschild>
      <CHARACT>MATNR</CHARACT>
      <CHARACT_DESCR>Materialnummer</CHARACT_DESCR>
      <VALUE>4711</VALUE>
      <CHARACT>MAKTX</CHARACT>
      <CHARACT_DESCR>Materialkurztext</CHARACT_DESCR>
      <VALUE>Material & < Test</VALUE>   </Leistungsschild>

    Hi Sandra,
    First of all thaks for your quick answer to my problem.
    I see what you mean and get the same result, if I am using data-type string instead of xstring. But the recommendation in the XML-Books of SAP is to use XSTRING to save memory and circumflex problems between Codepages, when writing the XML-Stream to a filesystem.
    As you can see in the code abvoe I am using a SAP-FM to display the XML-Stream and this FM works only with XSTRING´s,
    that is one reason why I don´t understand that it displays it in the wrong way.
    Even the Debugger shows me for the XSTRING the wrong result. Does all that mean that the escaping will not be applyed if you are working with XSTING´s??

  • I want to remove Trailing zeros from a charecter value

    Hello ,
              i want to remove trailing zeros for a prticular value.Following is my code :
    DATA: V_FLOAT TYPE F VALUE '4.8240000000000000E+03',
               V_CHAR(25) ,
               P10_4(10) TYPE P DECIMALS 4.
    CALL FUNCTION 'CEVA_CONVERT_FLOAT_TO_CHAR'
    EXPORTING
    FLOAT_IMP = V_FLOAT
    FORMAT_IMP = P10_4
    ROUND_IMP = ' '
    IMPORTING
    CHAR_EXP = V_CHAR.
    SHIFT V_CHAR RIGHT DELETING TRAILING '0'.
    WRITE : V_CHAR ."NO-ZERO.
    <u><b>Output:</b></u>
    if we pass the value '1.3000000000000000E+01' it should be 13.0
    ex2: '1.3400000000000000E+01' it should be 13.4
    ex3:'4.8240000000000000E+03' it should be 4824
    is there any way to get the solution without functional module. If so Please tell me with code.

    hi
    u can do it in number of ways.
    Use TCODE SU3
    Select default tab and select radio button 123467.89 in decimal notation and save it.
    or u can try :
    if you want to do this through ABAP program.
    1. to delete trailing spaces.
    SHIFT <V_VARIABLE> RIGHT DELETING TRAILING '0'.
    to delete leading zeroes,
    SHIFT <VARIABLE_NAME> LEFT DELETING LEADING '0'.
    only for one abap program, u can use set country command
    for all programs :
    sap menu>system->go to user profil->own data>default --> and choose ur format.
    hope this helps u.
    Regards,
    Prasanth
    Reward all hepful replies

  • Simple transformation tt: utf-16 to utf-8 encoding

    Hi,
    (reposting here as no response in the ABAP General forum)
    I have a simple transformation the results of which are written to a file using open dataset. The XML in the file is appearing with encoding utf-16 but I need utf-8. I tried placing the following line in the transformation but it did not work:
    <xsl:output encoding="utf-8"/>
    The only way it works is if I use type xstring for the result of the transformation and not string. I then have to convert the xml from xstring to string before writing to the file. This works but I was wondering if there was an easier way to change the encoding of a simple transformation (tt:) ?????????
    Che

    Hi All,
    Reopening this old post, as I found that the same transformation and same program call results in an XML with utf-8 in a NW 7.30 system, while utf-16 in a NW 7.01 system!
    Any ideas why would it happen like this? And if there's anything that can be done to make sure the encoding remains same in both the systems?

  • Upload xml file to internal table only using simple transformation

    Hi Friends
    How to write transformation code for the following xml data.. Please let me know immedately if any one know..
    I have written as following but i encountered an eror staating -
    Iam facing the following error
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not caught in
    procedure "UPLOAD_XML" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    The goal was to access variable "ROOT1". However, this access was not
    possible.
    Go through my xml file , the code and code in simple transformation.. Please reply(transformation code) me as soon as possible
    - <Negara>
    - <item>
    - <COUNTRY>
    <MANDT>600</MANDT>
    <ZCODE>500</ZCODE>
    <ZDESC>Pening Lalat</ZDESC>
    <ZSAPCD>T1</ZSAPCD>
    </COUNTRY>
    </item>
    - <item>
    - <COUNTRY>
    <MANDT>600</MANDT>
    <ZCODE>600</ZCODE>
    <ZDESC>Pening Lalat2</ZDESC>
    <ZSAPCD>T2</ZSAPCD>
    </COUNTRY>
    </item>
    </Negara>
    DATA : BEGIN OF XDATA OCCURS 0,
    STR(255) TYPE C,
    END OF XDATA.
    DATA: XMLUPL TYPE string .
    DATA : BEGIN OF ITAB OCCURS 0,
    MANDT(3) TYPE C,
    ZCODE(3) TYPE C,
    ZDESC(15) TYPE C,
    ZSAPCD(2) TYPE C,
    END OF ITAB.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = 'C:\country.xml'
    FILETYPE = 'BIN'
    TABLES
    DATA_TAB = XDATA.
    LOOP AT XDATA.
    CONCATENATE XMLUPL XDATA-STR INTO XMLUPL.
    ENDLOOP.
    CALL TRANSFORMATION ('Y_XMLCTRY')
    SOURCE XML XMLUPL
    result xml = ITAB[].
    BREAK-POINT.
    <?sap.transform simple?>
    <tt:transform template="temp1"
    xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="ROOT1"/>
    <tt:root name="ROOT2"/>
    <tt:template name="temp1">
    <Negara>
    <tt:loop ref=".ROOT1" name="i">
    <item>
    <tt:loop ref=".ROOT2" name="c">
    <COUNTRY>
    <MANDT>
    <tt:value ref="$c.nummer" />
    </MANDT>
    <ZCODE>
    <tt:value ref="$c.nummer" />
    </ZCODE>
    <ZDESC>
    <tt:value ref="$c.name" />
    </ZDESC>
    <ZSAPCD>
    <tt:value ref="$c.name" />
    </ZSAPCD>
    </COUNTRY>
    </tt:loop>
    </item>
    </tt:loop>
    </Negara>
    </tt:template>
    </tt:transform>
    Thanking You
    Devi

    Hi Friends
    How to write transformation code for the following xml data.. Please let me know immedately if any one know..
    I have written as following but i encountered an eror staating -
    Iam facing the following error
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not caught in
    procedure "UPLOAD_XML" "(FORM)", nor was it propagated by a RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    The goal was to access variable "ROOT1". However, this access was not
    possible.
    Go through my xml file , the code and code in simple transformation.. Please reply(transformation code) me as soon as possible
    - <Negara>
    - <item>
    - <COUNTRY>
    <MANDT>600</MANDT>
    <ZCODE>500</ZCODE>
    <ZDESC>Pening Lalat</ZDESC>
    <ZSAPCD>T1</ZSAPCD>
    </COUNTRY>
    </item>
    - <item>
    - <COUNTRY>
    <MANDT>600</MANDT>
    <ZCODE>600</ZCODE>
    <ZDESC>Pening Lalat2</ZDESC>
    <ZSAPCD>T2</ZSAPCD>
    </COUNTRY>
    </item>
    </Negara>
    DATA : BEGIN OF XDATA OCCURS 0,
    STR(255) TYPE C,
    END OF XDATA.
    DATA: XMLUPL TYPE string .
    DATA : BEGIN OF ITAB OCCURS 0,
    MANDT(3) TYPE C,
    ZCODE(3) TYPE C,
    ZDESC(15) TYPE C,
    ZSAPCD(2) TYPE C,
    END OF ITAB.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = 'C:\country.xml'
    FILETYPE = 'BIN'
    TABLES
    DATA_TAB = XDATA.
    LOOP AT XDATA.
    CONCATENATE XMLUPL XDATA-STR INTO XMLUPL.
    ENDLOOP.
    CALL TRANSFORMATION ('Y_XMLCTRY')
    SOURCE XML XMLUPL
    result xml = ITAB[].
    BREAK-POINT.
    <?sap.transform simple?>
    <tt:transform template="temp1"
    xmlns:tt="http://www.sap.com/transformation-templates">
    <tt:root name="ROOT1"/>
    <tt:root name="ROOT2"/>
    <tt:template name="temp1">
    <Negara>
    <tt:loop ref=".ROOT1" name="i">
    <item>
    <tt:loop ref=".ROOT2" name="c">
    <COUNTRY>
    <MANDT>
    <tt:value ref="$c.nummer" />
    </MANDT>
    <ZCODE>
    <tt:value ref="$c.nummer" />
    </ZCODE>
    <ZDESC>
    <tt:value ref="$c.name" />
    </ZDESC>
    <ZSAPCD>
    <tt:value ref="$c.name" />
    </ZSAPCD>
    </COUNTRY>
    </tt:loop>
    </item>
    </tt:loop>
    </Negara>
    </tt:template>
    </tt:transform>
    Thanking You
    Devi

  • Simple transformation : deserialize

    Hi,
    I have a simple transformation that works if I serialize table data, but it doesn't work when I wan't to deserialize.
    Here is my ABAP program that calls the transformation:
    TYPES: BEGIN OF flight,
            f_id TYPE p LENGTH 5,
            data TYPE c LENGTH 40,
          END OF flight,
          tt_flight TYPE STANDARD TABLE OF flight
                          WITH DEFAULT KEY.
    DATA: data1 TYPE flight.
    DATA: data2 TYPE flight.
    DATA: xml_string TYPE string.
    DATA: tab_data TYPE tt_flight.
    data1-f_id = '00001'.
    data1-data = 'before'.
    APPEND data1 to tab_data.
    data2-f_id = '00002'.
    data2-data = 'before'.
    APPEND data2 to tab_data.
    concatenate '<?xml version="1.0" encoding="iso-8859-2"?><XY><flights>'
                                       '<flight><id>11111</id><data>data1</data></flight>'
                                       '<flight><id>22222</id><data>data2</data></flight>'
                                       '</flights></XY>'
                into xml_string.
    CALL TRANSFORMATION ...
      SOURCE XML xml_string
      RESULT root = tab_data.
    And the transformation:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp_main">
      <tt:root name="ROOT"/>
      <tt:template name="temp_main">
        <XY>
          <flights>
            <tt:loop name="line" ref="ROOT">
              <flight>
                <id>
                  <tt:value ref="f_id"/>
                </id>
                <data>
                  <tt:value ref="data">
                </data>
              </flight>
            </tt:loop>
          </flights>
        </XY>
      </tt:template>
    </tt:transform>
    It won't update or append the content of the xml to my table.
    I would like to read many "<flight><id>.....</id><data>......</data></flight>" lines and write them into the table "tab_data".
    Could somebody please help me?
    Thanks in advance,
    Greg

    Hi Greg,
    try to address the root node with a period. Instead of
    <tt:loop name="line" ref="ROOT">
    use
    <tt:loop name="line" ref=".ROOT">
    Regards
    Stephan

  • Simple transformation with reference to ddic structures

    Hi, experts,
    we decide to use xml as the format when exchanging massive data with other applications. and we want to use simple transformation because according to the document it's more fast.
    actually our file structure is determined by certain ddic structures, one xml file main contain several ddic structures , and they are all flat one, not deep structure.
    the xml file may look like this:
    <data>
    <ddic1>[components of ddic structure 1 ]</ddic1>
    <ddic2>[components of ddic structure 2 ]</ddic2>
    </data>
    i am new to ST,i am wondering that is it possible to make the ST more easy with the help of ddic structure? do i still need to declare the components one by one in the ST program?
    BR.
    jun

    It only runs ok with 2 internal tables because of the way you set up the XML string.  It will run ok with 3 internal tables too.  If you strip out the '<C>' nodes or move the '<C>' nodes around, you'll see what I mean (move the C nodes to the last B node).  Each time you start a loop in a simple transformation, the internal table is initialized.  So, you need to form your sample XML string differently, declare your internal tables differently (nested), or use XSLT for a little more power.

  • Simple Transformation - XML to Internal Table Error

    I have a webservice call that returns XML.  I need to transform a portion of the response to an internal table, but my simple transformation is not working with loop processing.  I have read through most posts regarding the topic but they're either too old or related to serialization.  There aren't any exceptions thrown, but I don't get any data in the internal table (PAPERWORK root).  Below are some code snippets.  Any ideas on the problem with the XSLT template?  Thanks.
    Sample XML:
    <?xml version="1.0" encoding="utf-8" ?>
    <PrintVersionDataSet>
    <Result>
    <ReturnCode>W</ReturnCode>
    <ReturnMessage>There are reports with later version(s)</ReturnMessage>
    </Result>
    <Paperwork>
    <ReportCode>CVR</ReportCode>
    <ReportName>Cover Sheet</ReportName>
    <Version>2</Version>
    <PrintedDateTime>2009-05-01T09:54:04.1-05:00</PrintedDateTime>
    </Paperwork>
    <Paperwork>
    <ReportCode>SPS</ReportCode>
    <ReportName>Sponsor Summary</ReportName>
    <Version>2</Version>
    <PrintedDateTime>2009-05-01T09:54:04.99-05:00</PrintedDateTime>
    </Paperwork>
    </PrintVersionDataSet>
    XSLT Code:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="RESULT"/>
      <tt:root name="PAPERWORK"/>
      <tt:template>
        <PrintVersionDataSet>
          <Result tt:ref="RESULT">
            <ReturnCode>
              <tt:value ref="RETURNCODE"/>
            </ReturnCode>
            <ReturnMessage>
              <tt:value ref="RETURNMESSAGE"/>
            </ReturnMessage>
          </Result>
          <tt:deserialize>
            <tt:loop ref=".PAPERWORK">
              <Paperwork>
                <ReportCode>
                  <tt:value ref="REPORTCODE"/>
                </ReportCode>
                <ReportName>
                  <tt:value ref="REPORTNAME"/>
                </ReportName>
                <Version>
                  <tt:value ref="VERSION"/>
                </Version>
                <PrintedDateTime>
                  <tt:value ref="PRINTEDDATETIME"/>
                </PrintedDateTime>
              </Paperwork>
            </tt:loop>
          </tt:deserialize>
        </PrintVersionDataSet>
      </tt:template>
    </tt:transform>
    ABAP Call to Transform Data:
    TRY.
    CALL TRANSFORMATION Z_GA_PAPERWORK_VERS_WEBSVC
          SOURCE XML LS_RESPONSE-VERIFY_PRINT_VERSION_RESULT
          RESULT RESULT     = LS_RESULT
                 PAPERWORK  = LT_PAPERWORK.
        CATCH CX_ROOT INTO ROOT_EXCEPTION.
          CALL METHOD ROOT_EXCEPTION->IF_MESSAGE~GET_TEXT
            RECEIVING
              RESULT = LV_MESSAGE.
      ENDTRY.

    Upon further inspection and testing with a simple file and program, I can see that the XML structure isn't quite correct for the loop process.  There needs to be a single <PAPERWORK> node, instead of one for each table line in the file.  This should allow the loop to execute properly after a slight adjustment to the XSLT template.

Maybe you are looking for