SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

call transformation



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
stanislav
Участник
Участник



Joined: 20 Feb 2008
Posts: 2

PostPosted: Tue Jun 10, 2008 7:11 am    Post subject: call transformation Reply with quote

Добрый день всем ! Вот такая проблема. Мне нужно с использованием шаблона xslt выгрузить данные из сапа. Программа состоит из двух частей : 1- ая выгрузка в xml файл - происходит без проблем. Код следующий.
.....
data:
lt_xml type string
rbkpfRes type table of ZKZ_FI_STS_FI_TAX_RR

......

CALL TRANSFORMATION id
SOURCE ROOT = rbkpfRes[]
RESULT XML lt_xml.

Я могу сохранить (для проверки) данный файл - и все ок.

А вот второй этап отрабатывает с ошибкой. На втором этапе я сначала создаю xslt шаблон (прикреплен ниже). Который если его отдельно тестирую - также хорошо отрабатывает ( там цепляю сформированный на предыдущем шаге xml ) - в результате получаю html файл.

Но вот когда я это делаю из программы путем

CALL TRANSFORMATION Z_STS_TRANS
SOURCE XML = lt_xml
RESULT XML restab.

То в результате получаю только шапку - данные из xml не цепляются.
Когда проходишь это дело дебаггером - то видно - что в загруженном xml открывающие и закрывающие скобы заменяются на &gt и &lt.

Може кто в курсе данной проблемы ?
Подскажите пожалуйста.



Code:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asx="http://www.sap.com/abapxml">



<xsl:output method="html" indent="no" encoding="windows-1251"
   omit-xml-declaration="yes" />
<xsl:template match="/">
<html>
  <head>
    <meta http-equiv="Content-Type"
    content="text/html; charset=utf-8" />
    <meta name="ProgId" content="Excel.Sheet" />
    <meta name="Generator" content="Microsoft Excel 11" />
    <link rel="File-List" href="Reestr1_files/filelist.xml" />
    <link rel="Edit-Time-Data" href="Reestr1_files/editdata.mso" />
    <link rel="OLE-Object-Data" href="Reestr1_files/oledata.mso" />
    <!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>MAN</o:Author>
  <o:LastAuthor>Stanislav.Zabudkin</o:LastAuthor>
  <o:LastPrinted>2005-01-20T05:04:01Z</o:LastPrinted>
  <o:Created>2001-08-07T10:12:53Z</o:Created>
  <o:LastSaved>2008-06-06T10:31:45Z</o:LastSaved>
  <o:Company>MAN Ltd.</o:Company>
  <o:Version>11.9999</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
    <style type="text/css">
&lt;!--table
        {mso-displayed-decimal-separator:&quot;\,&quot;;
        mso-displayed-thousand-separator:&quot; &quot;;}
@page
        {mso-header-data:&quot;&amp;RСтр\.  &amp;P&quot;;
        margin:.59in .43in .39in .79in;
        mso-header-margin:.39in;
        mso-footer-margin:.51in;
        mso-page-orientation:landscape;}
tr
        {mso-height-source:auto;}
col
        {mso-width-source:auto;}
br
        {mso-data-placement:same-cell;}
.style0
        {mso-number-format:General;
        text-align:general;
        vertical-align:bottom;
        white-space:nowrap;
        mso-rotate:0;
        mso-background-source:auto;
        mso-pattern:auto;
        color:windowtext;
        font-size:10.0pt;
        font-weight:400;
        font-style:normal;
        text-decoration:none;
        font-family:&quot;Arial Cyr&quot;;
        mso-generic-font-family:auto;
        mso-font-charset:204;
        border:none;
        mso-protection:locked visible;
        mso-style-name:Normal;
        mso-style-id:0;}
td
        {mso-style-parent:style0;
        padding-top:1px;
        padding-right:1px;
        padding-left:1px;
        mso-ignore:padding;
        color:windowtext;
        font-size:10.0pt;
        font-weight:400;
        font-style:normal;
        text-decoration:none;
        font-family:&quot;Arial Cyr&quot;;
        mso-generic-font-family:auto;
        mso-font-charset:204;
        mso-number-format:General;
        text-align:general;
        vertical-align:bottom;
        border:none;
        mso-background-source:auto;
        mso-pattern:auto;
        mso-protection:locked visible;
        white-space:nowrap;
        mso-rotate:0;}
.xl24
        {mso-style-parent:style0;
        font-family:&quot;Times New Roman&quot;, serif;
        mso-font-charset:0;}
.xl25
        {mso-style-parent:style0;
        font-size:9.0pt;
        font-family:Arial, sans-serif;
        mso-font-charset:0;}
.xl26
        {mso-style-parent:style0;
        font-size:9.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:center;}
.xl27
        {mso-style-parent:style0;
        font-size:7.0pt;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:left;}
.xl28
        {mso-style-parent:style0;
        font-size:7.0pt;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        mso-number-format:&quot;\@&quot;;
        text-align:center;}
.xl29
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-family:&quot;Arial Cyr&quot;, sans-serif;
        mso-font-charset:204;}
.xl30
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:center;
        border-top:2.0pt double windowtext;
        border-right:none;
        border-bottom:none;
        border-left:2.0pt double windowtext;}
.xl31
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:center;
        border-top:2.0pt double windowtext;
        border-right:none;
        border-bottom:none;
        border-left:none;}
.xl32
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:right;
        border-top:2.0pt double windowtext;
        border-right:none;
        border-bottom:none;
        border-left:none;}
.xl33
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:right;
        border-top:2.0pt double windowtext;
        border-right:2.0pt double windowtext;
        border-bottom:none;
        border-left:none;}
.xl34
        {mso-style-parent:style0;
        font-weight:700;
        text-align:center;
        border-top:none;
        border-right:none;
        border-bottom:2.0pt double windowtext;
        border-left:2.0pt double windowtext;}
.xl35
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:center;
        border-top:none;
        border-right:none;
        border-bottom:2.0pt double windowtext;
        border-left:none;}
.xl36
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:right;
        border-top:none;
        border-right:none;
        border-bottom:2.0pt double windowtext;
        border-left:none;}
.xl37
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:right;
        border-top:none;
        border-right:2.0pt double windowtext;
        border-bottom:2.0pt double windowtext;
        border-left:none;}
.xl38
        {mso-style-parent:style0;
        font-size:7.0pt;
        font-family:&quot;Arial CYR&quot;, sans-serif;
        mso-font-charset:204;
        mso-number-format:&quot;\@&quot;;
        text-align:center;}
.xl39
        {mso-style-parent:style0;
        font-size:7.0pt;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        mso-number-format:Standard;
        text-align:right;}
.xl40
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-weight:700;
        font-family:&quot;Arial Cyr&quot;, sans-serif;
        mso-font-charset:204;
        text-align:right;}
.xl41
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-family:&quot;Arial Cyr&quot;, sans-serif;
        mso-font-charset:204;
        text-align:left;}
.xl42
        {mso-style-parent:style0;
        font-size:9.0pt;
        font-weight:700;
        font-family:Arial, sans-serif;
        mso-font-charset:0;
        text-align:center;
        border-top:none;
        border-right:none;
        border-bottom:2.0pt double windowtext;
        border-left:none;}
.xl43
        {mso-style-parent:style0;
        font-size:8.0pt;
        font-family:&quot;Arial Cyr&quot;, sans-serif;
        mso-font-charset:204;
        mso-number-format:&quot;General Date&quot;;
        text-align:left;}
--&gt;
</style>
    <!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Лист1</x:Name>
    <x:WorksheetOptions>
     <x:Print>
      <x:ValidPrinterInfo/>
      <x:PaperSizeIndex>9</x:PaperSizeIndex>
      <x:HorizontalResolution>600</x:HorizontalResolution>
      <x:VerticalResolution>600</x:VerticalResolution>
     </x:Print>
     <x:CodeName>Лист1</x:CodeName>
     <x:Selected/>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
       <x:ActiveRow>11</x:ActiveRow>
       <x:ActiveCol>2</x:ActiveCol>
      </x:Pane>
     </x:Panes>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:WindowHeight>6675</x:WindowHeight>
  <x:WindowWidth>11325</x:WindowWidth>
  <x:WindowTopX>0</x:WindowTopX>
  <x:WindowTopY>90</x:WindowTopY>
  <x:AcceptLabelsInFormulas/>
  <x:ProtectStructure>False</x:ProtectStructure>
  <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
 <x:ExcelName>
  <x:Name>Print_Titles</x:Name>
  <x:SheetIndex>1</x:SheetIndex>
  <x:Formula>=Лист1!$5:$6</x:Formula>
 </x:ExcelName>
</xml><![endif]-->
    <title></title>
  </head>
  <body link="blue" vlink="purple">
    <table border="0" cellpadding="0" cellspacing="0"
    width="1131"
    style='border-collapse: collapse;table-layout:fixed;width:850pt'>

      <col width="100"
      style='mso-width-source:userset;mso-width-alt:3657;width:75pt' />
      <col width="86"
      style='mso-width-source:userset;mso-width-alt:3145;width:65pt' />
      <col width="113"
      style='mso-width-source:userset;mso-width-alt:4132;width:85pt' />
      <col width="111"
      style='mso-width-source:userset;mso-width-alt:4059;width:83pt' />
      <col width="70"
      style='mso-width-source:userset;mso-width-alt:2560;width:53pt' />
      <col width="99"
      style='mso-width-source:userset;mso-width-alt:3620;width:74pt' />
      <col width="98"
      style='mso-width-source:userset;mso-width-alt:3584;width:74pt' />
      <col width="95"
      style='mso-width-source:userset;mso-width-alt:3474;width:71pt' />
      <col width="60"
      style='mso-width-source:userset;mso-width-alt:2194;width:45pt' />
      <col width="39"
      style='mso-width-source:userset;mso-width-alt:1426;width:29pt' />
      <col width="78"
      style='mso-width-source:userset;mso-width-alt:2852;width:59pt' />
      <col width="60"
      style='mso-width-source:userset;mso-width-alt:2194;width:45pt' />
      <col width="38"
      style='mso-width-source:userset;mso-width-alt:1389;width:29pt' />
      <col class="xl24" width="84"
      style='mso-width-source:userset;mso-width-alt:3072; width:63pt' />
      <tr height="17" style='height:12.75pt'>
        <td height="17" class="xl29" width="100"
        style='height:12.75pt;width:75pt'>Дата ввода:</td>
        <td class="xl25" width="86" style='width:65pt'></td>
        <td class="xl25" width="113" style='width:85pt'></td>
        <td colspan="3" class="xl26" width="280"
        style='width:210pt'>РЕЕСТР
        <span style='mso-spacerun:yes'> </span>
        СЧЕТОВ-ФАКТУР</td>
        <td width="98" style='width:74pt'></td>
        <td class="xl40" width="95" style='width:71pt'>Форма
        307.00</td>
        <td width="60" style='width:45pt'></td>
        <td width="39" style='width:29pt'></td>
        <td width="78" style='width:59pt'></td>
        <td width="60" style='width:45pt'></td>
        <td width="38" style='width:29pt'></td>
        <td class="xl24" width="84" style='width:63pt'></td>
      </tr>
      <tr height="17" style='height:12.75pt'>
        <td height="17" colspan="2" class="xl26"
        style='height:12.75pt;mso-ignore:colspan'></td>
        <td colspan="5" class="xl26">ПО
        <span style='mso-spacerun:yes'> </span> ТОВАРАМ (
        РАБОТАМ,УСЛУГАМ ), ПРИОБРЕТЕННЫМ</td>
        <td colspan="6" style='mso-ignore:colspan'></td>
        <td class="xl24"></td>
      </tr>
      <tr height="17" style='height:12.75pt'>
        <td height="17" class="xl41" style='height:12.75pt'>c
        01.11.2007</td>
        <td colspan="7" class="xl26">В ТЕЧЕНИЕ
        <span style='mso-spacerun:yes'> </span> НАЛОГОВОГО
        <span style='mso-spacerun:yes'> </span> ПЕРИОДА
        <span style='mso-spacerun:yes'> </span> (ОТЧЕТНОГО
        КВАРТАЛА)</td>
        <td colspan="5" style='mso-ignore:colspan'></td>
        <td class="xl24"></td>
      </tr>
      <tr height="18" style='height:13.5pt'>
        <td height="18" class="xl29" style='height:13.5pt'>по
        07.11.2007</td>
        <td colspan="2" class="xl25" style='mso-ignore:colspan'>
        </td>
        <td colspan="3" class="xl42">ЗА НОЯБРЬ
        <span style='mso-spacerun:yes'> </span> 2007
        <span style='mso-spacerun:yes'> </span> Г.</td>
        <td class="xl25"></td>
        <td colspan="2" class="xl43">06.06.2008 11 : 02</td>
        <td colspan="4" style='mso-ignore:colspan'></td>
        <td class="xl24"></td>
      </tr>
      <tr height="18" style='height:13.5pt'>
        <td height="18" class="xl30" style='height:13.5pt'
        >№
        <span style='mso-spacerun:yes'> </span></td>
        <td class="xl31">РНН</td>
        <td class="xl31">Серия и №</td>
        <td class="xl31" style='border-top:none'>№</td>
        <td class="xl31" style='border-top:none'>Дата</td>
        <td class="xl32" style='border-top:none' >
        Стоимость
        <span style='mso-spacerun:yes'> </span></td>
        <td class="xl32">Облагаемый</td>
        <td class="xl33">Сумма НДС</td>
        <td colspan="5" style='mso-ignore:colspan'></td>
        <td class="xl24"></td>
      </tr>
      <tr height="18" style='height:13.5pt'>
        <td height="18" class="xl34" style='height:13.5pt'>
        докум.</td>
        <td class="xl35">поставщика</td>
        <td class="xl35">свид-ва НДС</td>
        <td class="xl35">сч-фактуры</td>
        <td class="xl35">сч-фактуры</td>
        <td class="xl36">без НДС</td>
        <td class="xl36">оборот</td>
        <td class="xl37"> </td>
        <td colspan="5" style='mso-ignore:colspan'></td>
        <td class="xl24"></td>
      </tr>
    </table>
  </body>
</html>


   <xsl:for-each select="asx:abap/asx:values/DATA_NODE/ZKZ_FI_STS_FI_TAX_RR">
      <xsl:value-of select="BELNR"/>
      <xsl:value-of select="LIFNR"/>
      <xsl:value-of select="PRIZK"/>
      <xsl:value-of select="GJAHR"/>
      <xsl:value-of select="BLDAT"/>
      <xsl:value-of select="XBLNR"/>
      <xsl:value-of select="STBLG"/>
      <xsl:value-of select="WAERS"/>
      <xsl:value-of select="DMBTR"/>
      <xsl:value-of select="CPUDT"/>
      <xsl:value-of select="SHKZG"/>
      <xsl:value-of select="NDS"/>
      <xsl:value-of select="STCD1"/>
      <xsl:value-of select="STCEG"/>
      </xsl:for-each>
</xsl:template>

</xsl:stylesheet>
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 200
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Wed Jun 11, 2008 11:49 am    Post subject: Reply with quote

К сожалению система старая, лично не проверить.
На sdn.sap.com John Doe приводил пример, может Вам попробовать проверить его работоспособность, и если работает - разбираться со структурой XSLT файла.

Form SAP Help:
Quote:
Simple Transformations
Simple Transformations (ST) is an SAP programming language for describing transformations between ABAP data and XML formats. ST is restricted to the two modes of serialization (ABAP to XML) and deserialization (XML to ABAP) of ABAP data, which are most important for data integration. Transformations from ABAP to ABAP and XML to XML, like in the more general XSLT are not possible in ST.

In comparison with XSLT, the main advantages of ST programs are as follows:

ST programs are declarative and thus easier to read
ST programs only have serial access to the XML data and are therefore very efficient even with large data volumes
ST programs describe serialization and deserialization simultaneously - that is, ABAP data serialized in XML with ST can also be deserialized with the same ST program.
Simple transformations that can be called using CALL TRANSFORMATION must be in the repository. ST programs can be edited using the Transformation Editor. This is called up either with transaction STRANS or by choosing Edit Object → More → Transformation followed by Simple Transformation in the ABAP Workbench object navigator

More information on Simple Transformations is available in the Knowledge Warehouse.


Example (from help also Smile )
Quote:
Simple Transformation Example
Serialization of a nested structure. In the following ABAP program section, a nested structure struc1 is serialized to xml_string with the Simple Transformation st_trafo and deserialized with the same transformation.

DATA: BEGIN OF struc1,
col1 TYPE c LENGTH 10 VALUE 'ABCDEFGHIJ',
col2 TYPE i VALUE 111,
BEGIN OF struc2,
col1 TYPE d VALUE '20040126',
col2 TYPE t VALUE '084000',
END OF struc2,
END OF struc1.

DATA: xml_string TYPE string,
result LIKE struc1.

TRY.

CALL TRANSFORMATION st_trafo
SOURCE para = struc1
RESULT XML xml_string.

...

CALL TRANSFORMATION st_trafo
SOURCE XML xml_string
RESULT para = result.

CATCH cx_st_error.

...

ENDTRY.

The Simple Transformation st_trafo has the following form:


<tt:transform template="temp"
xmlns:tt="http://www.sap.com/transformation-templates"
version="0.1">

<tt:root name="PARA"/>

<tt:template name="temp">
<X>
<X1>
<tt:value ref="PARA.COL1" />

<X2>
<tt:value ref="PARA.COL2" />

<X3>
<X1>
<tt:value ref="PARA.STRUC2.COL1" />

<X2>
<tt:value ref="PARA.STRUC2.COL2" />


</X>




The transformation consists of a Template temp that defines the structure of the XML document and establishes relationships between value nodes and components of the structure. The result of the transformation is as follows (line breaks and indentations were inserted for clarification purposes):

<X>
<X1>ABCDEFGHIJ
<X2>111
<X3>
<X1>2004-01-26
<X2>08:40:00

</X>

The conversion of elementary data types is the same as for asXML. The reverse transformation generates the same content in the structure result as in struc1.


Good luck.

PS: John Doe - прости, ссылку на твой пост на sdn не сохранил, только текст.
Back to top
View user's profile Send private message Blog Visit poster's website
kig
Участник
Участник



Joined: 17 Jul 2008
Posts: 1

PostPosted: Fri Jul 18, 2008 2:13 pm    Post subject: Re: call transformation Reply with quote

Но вот когда я это делаю из программы путем

CALL TRANSFORMATION Z_STS_TRANS
SOURCE XML = lt_xml
RESULT XML restab.


Уберите знак "=" между xml и lt_xml
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.