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.
Similar Messages
-
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.
junIt 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.
-
(261718088) Q: Can you use xm:multiple with Objects other than String?
Q: Can you use xm:multiple with Objects other than Strings?
<br>
A: You bet. Attached find a text file with some code from the example I showed
today, a version of the multipleSayHiTo() method that has a parameter of an Array
of Person objects rather than a parameter of an Array of Strings. The code within
the text file comes from the Greeting.jws file (the Greeting Web Service).
[multiple.txt]So you are saying that the recovery discs I made do include the copy of windows that was originally installed?
Absolutely! They will restore the hard disk to its original out-of-the-box contents. Follow the instructions in the section Restoring from recovery DVDs/media, which begins on p. 73 of the User's Guide.
Satellite A660 Series User’s Guide
maybe i can make a deal with wd to have them swap this drive out for the BEKT instead...
That would be a good idea in any case.
As I said, the 10-fc12-045d error would not be due to the drive's being AFT, but more likely the discs are not being read properly. New discs can be obtained from Toshiba. Scroll down to Get Recovery Media here
-Jerry -
XML to Nested Itab using Simple Transformation
Hi there is there any experts there who can show me an example of Transforming a XML to a Nested Internal Table using Simple Transformation?
I have tried this the program from the blog by
Tobias Trapp
<a href="/people/tobias.trapp/blog/2005/05/04/xml-processing-in-abap-part-1:///people/tobias.trapp/blog/2005/05/04/xml-processing-in-abap-part-1
but I have encountered this error
Runtime Errors ST_REF_ACCESS
Exception CX_ST_REF_ACCESS
1 <?sap.transform simple?>
2 <tt:transform template="temp1"
3 xmlns:tt="http://www.sap.com/transformation-templates">
4 <tt:root name="ROOT"/>
5 <tt:template name="temp1">
>>>> <tt:loop ref=".ROOT" name="a">
7 <A>
8 <name>
9 <tt:value ref="$a.name" />
10 </name>
11 <ZLS>
12 <tt:loop ref="$a.zls" name="z">
13 <Z>
14 <tt:value ref="$z.nummer" />
15 </Z>
16 </tt:loop>
17 </ZLS>
18 </A>
19 </tt:loop>
20 </tt:template>
21 </tt:transform>
Anyone knows whats wrong?I had to pass an XSLT program in the transformation statement.
-
Fieldcatalog to Excel using Simple transformation
Hi guys.
I have tried to sort out how to write own simple transormations but i've got problems along before i had expected.
The task is to make an XML file, that can be opened with Excel and it must contain row with column names of some dictionary table. The code is pretty simple:
REPORT ZJDTEST33.
parameters: p_tabnam type tabname matchcode object DD_DBTB,
p_file type string default 'C:\data\test.xls'.
data: gt_fcat type lvc_t_fcat,
gd_xml type string,
gt_xml type table of string.
start-of-selection.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = p_tabnam
CHANGING
ct_fieldcat = gt_fcat.
end-of-selection.
call transformation ztest_simple
SOURCE fieldcat = gt_fcat
RESULT XML gd_xml.
refresh gt_xml.
APPEND gd_xml TO gt_xml.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = p_file
filetype = 'ASC'
changing
data_tab = gt_xml.
This is transformation itself:
<?sap.transform simple?>
<?mso-application progid="Excel.Sheet"?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns:ddic="http://www.sap.com/abapxml/types/dictionary">
<tt:root name="fieldcat" line-type="ddic:LVC_S_FCAT"/>
<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">
<Worksheet ss:Name="Sheet1">
<Table>
<Row>
<tt:loop ref=".fieldcat">
<Cell>
<Data ss:Type="String">
<tt:value ref="SCRTEXT_M"/>
</Data>
</Cell>
</tt:loop>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
</tt:template>
</tt:transform>
Edited by: Petr.Plenkov on Nov 3, 2009 9:07 AMFinally, i've got the reason. If somebody has the same problem, just change the encoding manually into a string.
replace first occurrence of 'utf-16' in ld_xmlstr with 'windows-1251'.
Edited by: Petr.Plenkov on Nov 3, 2009 12:37 PM -
Simple query with like return wrong result
Hi,
I run simple query with like.
If I use parameter I get wrong results.
If I use query without parameter results are ok.
My script:
ALTER SESSION SET NLS_SORT=BINARY_CI;
ALTER SESSION SET NLS_COMP=LINGUISTIC;
-- drop table abcd;
create table abcd (col1 varchar2(10));
INSERT INTO ABCD VALUES ('122222');
insert into abcd values ('111222');
SELECT * FROM ABCD WHERE COL1 LIKE :1; -- wrong result with value 12%
COL1
122222
*111222*
select * from abcd where col1 like '12%'; -- result ok
COL1
122222
I use Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
and query run in Oracle SQL Developer 3.1.07.Hi,
welcome to the forum.
When you put some code please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
You should specify exactly how you run your code.
If I run this statement in SQL Plus:SQL> ALTER SESSION SET NLS_SORT=BINARY_CI;
Session altered.
SQL> ALTER SESSION SET NLS_COMP=LINGUISTIC;
Session altered.
SQL>
SQL> -- drop table abcd;
SQL> create table abcd (col1 varchar2(10));
Table created.
SQL>
SQL> INSERT INTO ABCD VALUES ('122222');
1 row created.
SQL> insert into abcd values ('111222');
1 row created.
SQL>
SQL> SELECT * FROM ABCD WHERE COL1 LIKE :1;
SP2-0552: Bind variable "1" not declared.
SQL>
I got this error. So I wonder how you set value 12%
Please specify exactly how you run your test as we cannot reproduce your problem.
Regards.
Al -
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
DeviHi 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 with very long XML element names
I am trying to write a program to deserialize XML documents using the Simple Transformation technique. There are many optional elements in the XML document, so I need to have conditional statements statements to avoid trying to process elements that are not in the document. The XML document, however, has several Element Names that are greater than 30 characters in length. The Simple Transformation technique seems to require ABAP data dictionary structures that mirror the schema of the XML document. But one cannot create structure component names that are greater than 30 characters in length. We don't have any control over the XML schema as the XML documents come from the US government. The ST fragment below shows the statement that I want to write, but since the ABAP Structure PlasticCardInformationGroup cannot have a component AuthorizationResponseInformation, the ST syntax checker yields an "Illegal Reference ADDITIONALPLASTICCARDINFORMATION" error message.
Does anyone know a way to avoid this error?
<tt:d-cond check="exist(TRS_TradingPartner_Agreement.TRS_FinancialTransaction.PlasticCardInformationGroup.AdditionalPlasticCardInformation)">
<ns2:AdditionalPlasticCardInformation>
<tt:attribute name="CardNetworkType" value-ref="TRS_TRADINGPARTNER_AGREEMENT.TRS_FINANCIALTRANSACTION.PLASTICCARDINFORMATIONGROUP.ADDITIONALPLASTICCARDINFORMATI.CARDNETWORKTYPE"/>
<tt:attribute name="DraftLocatorNumber" value-ref="TRS_TRADINGPARTNER_AGREEMENT.TRS_FINANCIALTRANSACTION.PLASTICCARDINFORMATIONGROUP.ADDITIONALPLASTICCARDINFORMATI.DRAFTLOCATORNUMBER"/>
</ns2:AdditionalPlasticCardInformation>could anyone help me?
-
Using Simple Transformation for content extraction
Hello,
Does someone know a solution for a simple and fast transformation to extract (text) content from an arbitary xml document. Only the text-values between two xml elements are needed to perform a search.
The corresponding behavior in XSL looks as follows (but lasts too long):
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
<xsl:text> </xsl:text><!-- just for separation -->
</xsl:template>
</xsl:transform>
The result could be a table with "strings" in each row or a concatenated string.
If someone can provide an ABAP regular expression (or a function module) fullfilling the same task I would be happy to.
Many thanks and regards
ChristianHi Keon,
Please find the below link
[Help|http://help.sap.com/abapdocu/en/ABAPCALL_TRANSFORMATION.htm]
[Help|http://help.sap.com/abapdocu/en/ABENABAP_ST.htm]
Please find the code below
[Code|https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/exportingdatatoExcel-XMLtotherescue]
Thanks
Kalyan -
I'm travelling to Santiago, Chile later this month. Do I need a transformer in order to charge my laptop, or will a converter suffice? Chile is on a 220V system (the US uses 120V outlets).
Thank you!!
MeganNo. The power adaptors auto-switch between 110 and 220 volt systems. You will probably need a wall outlet adaptor for the plug. You can find them in full-service travel agencies like AAA or local computer shops.
-
XML Simple Transformation with Name attribute
Current logic for reference:
ERS tag is presented in XML file as: <ERSFlag>X</ERSFlag>
Transformation logic to populate ERS flag value into PO_item structure is as:
<tt:cond><ERSFlag>
<tt:value ref="$po_item.ers_flag"/>
</ERSFlag></tt:cond>
New Changes:
XML template with New tag: TaxField1. New Tag included as:
- <TaxField1 name="GST" value="">
- <MultiCurrencyMoney>
<Transaction currency="CAD">400.0000000000000</Transaction>
<Base currency="USD">380.68</Base>
<Local currency="CAD">400.0000000000000</Local>
</MultiCurrencyMoney>
</TaxField1>
I have added new field Taxfield1 with Char1 in structure po_item. I would need to Populate 'Y' to new field Taxfield1 in po_item structure based on the above XML tag.
Could anyone please let me know the Tranformation code to populate 'Y' to new field Taxcode1 in po_item structure based on the above XML tag.
Thanks in advance.Share solution with us. Thank you!!!
-
Group columns in Excel using XSLT simple transformation
Hi All,
I have to group a few columns in the excel so that they can be expanded or collapsed. I am transforming an internal table into XML using Simple transformation. In this XSLT, I need to add the code to group the particular columns together in the final excel.
Can any one please help me in acheiving the columns grouped together.
Thanks and Regards,
Vishnu.
Edited by: Vishnu Kare on Mar 24, 2011 7:22 AMHi Vishnu, I am also using simple transformations (not XSLT) to create XML excel from SAP data. I always create a template excel workbook from excel by saving it as XML file. This XML can be pasted into the SAP transformation without completely understanding the Microsoft excel syntax. The dynamic SAP data then can be included to the XML in the transformation.
Regards Jack -
Simple Transformation XML to ABAP - error CX_ST_MATCH_ELEMENT
Hi all,
I have a problem with a transformation from xml to abap. My XML file (taken from a pdf file) is
<?xml version="1.0" encoding="iso-8859-1" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
- <asx:values>
<NETWORK>E60000000000</NETWORK>
<OPERAZIONE>0010</OPERAZIONE>
- <TABELLA>
- <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
<MANDT>300</MANDT>
<NETWORK>E60000000000</NETWORK>
<OPERAZIONE>0010</OPERAZIONE>
<ID_ACT>1</ID_ACT>
<DESC_ACT>ATTIVITÀ1</DESC_ACT>
<LONG_TXT></LONG_TXT>
<MAKE_BUY></MAKE_BUY>
<WP></WP>
<EVENTO_TECH></EVENTO_TECH>
<TIPO_LEGAME></TIPO_LEGAME>
<CONSEGNA></CONSEGNA>
</ROW>
- <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
<MANDT>300</MANDT>
<NETWORK>E60000000000</NETWORK>
<OPERAZIONE>0010</OPERAZIONE>
<ID_ACT>2</ID_ACT>
<DESC_ACT>ATTIVITÀ2</DESC_ACT>
<LONG_TXT>ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2</LONG_TXT>
<MAKE_BUY>M</MAKE_BUY>
<WP></WP>
<EVENTO_TECH></EVENTO_TECH>
<TIPO_LEGAME></TIPO_LEGAME>
<CONSEGNA></CONSEGNA>
</ROW>
</TABELLA>
</asx:values>
</asx:abap>
my transformation is
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"></tt:root>
<tt:root name="NETWORK"></tt:root>
<tt:root name="OPERAZIONE"></tt:root>
<tt:template>
<abap>
<values>
<network>
<tt:value ref="NETWORK"></tt:value>
</network>
<operazione>
<tt:value ref="OPERAZIONE"></tt:value>
</operazione>
<tabella>
<tt:loop ref=".ROOT" name="line">
<mandt>
<tt:value ref="$line.mandt"></tt:value>
</mandt>
<network>
<tt:value ref="$line.network"></tt:value>
</network>
<OPERAZIONE>
<tt:value ref="$line.OPERAZIONE"></tt:value>
</OPERAZIONE>
<ID_ACT>
<tt:value ref="$line.ID_ACT"></tt:value>
</ID_ACT>
<DESC_ACT>
<tt:value ref="$line.DESC_ACT"></tt:value>
</DESC_ACT>
<LONG_TXT>
<tt:value ref="$line.LONG_TXT"></tt:value>
</LONG_TXT>
<MAKE_BUY>
<tt:value ref="$line.MAKE_BUY"></tt:value>
</MAKE_BUY>
<WP>
<tt:value ref="$line.WP"></tt:value>
</WP>
<EVENTO_TECH>
<tt:value ref="$line.EVENTO_TECH"></tt:value>
</EVENTO_TECH>
<TIPO_LEGAME>
<tt:value ref="$line.TIPO_LEGAME"></tt:value>
</TIPO_LEGAME>
<CONSEGNA>
<tt:value ref="$line.CONSEGNA"></tt:value>
</CONSEGNA>
</tt:loop>
</tabella>
</values>
</abap>
</tt:template>
</tt:transform>
when I execute my code
the system dump with this error
ST_MATCH_FAIL
excep. CX_ST_MATCH_ELEMENT
TRY.
CALL TRANSFORMATION ('ZT_NETWORK')
SOURCE XML lv_xml_data_string
RESULT network = l_network
operazione = l_operazione
root = it_data_tmp.
CATCH cx_sy_conversion_data_loss .
CATCH cx_xslt_exception INTO xslt_error.
xslt_message = xslt_error->get_text( ).
WRITE:/ xslt_message .
ENDTRY.
Any help?
thanks
enzoEnzo Porcasi wrote:
> I have a problem with a transformation from xml to abap. My XML file (taken from a pdf file) is
>
<?xml version="1.0" encoding="iso-8859-1" ?>
> <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
> <asx:values>
Your XML is strange, it looks like a mix of pdf form content (xfa) and identity transformation (asx).
Could you explain more ?
Anyway, I tried to find out the errors (not only cx_st_match_element, that was just a catch missing), it works with the following program. Here are the main issues I have found :
- always catch exception class cx_st_error when you use simple transformations (it contains cx_st_match_element and all other simple transformation exceptions)
- xml "asx:abap" and "asx:values" in your input XML are useless, they are only used by identity transformation ("ID"); you may keep them if you want, but I advise you to see why they are in the xml !
- Use same case in your tags (if xml contains in the transformation so that it corresponds to the input XML
- I renamed all abap names with prefix ABAP_ so that to clearly differentiate xml tags and abap field names (so that it is more easy to understand, for every sdn reader; I hope it will help as I didn't find many threads in the forum).
Simple transformation :
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ABAP_NETWORK"></tt:root>
<tt:root name="ABAP_OPERAZIONE"></tt:root>
<tt:root name="ABAP_TABELLA"></tt:root>
<tt:template>
<ROOT>
<NETWORK>
<tt:value ref=".ABAP_NETWORK"></tt:value>
</NETWORK>
<OPERAZIONE>
<tt:value ref=".ABAP_OPERAZIONE"></tt:value>
</OPERAZIONE>
<TABELLA>
<tt:loop ref=".ABAP_TABELLA" name="line">
<ROW>
<MANDT>
<tt:value ref="$line.ABAP_MANDT"></tt:value>
</MANDT>
<NETWORK>
<tt:value ref="$line.ABAP_NETWORK"></tt:value>
</NETWORK>
<OPERAZIONE>
<tt:value ref="$line.ABAP_OPERAZIONE"></tt:value>
</OPERAZIONE>
<ID_ACT>
<tt:value ref="$line.ABAP_ID_ACT"></tt:value>
</ID_ACT>
<DESC_ACT>
<tt:value ref="$line.ABAP_DESC_ACT"></tt:value>
</DESC_ACT>
<LONG_TXT>
<tt:value ref="$line.ABAP_LONG_TXT"></tt:value>
</LONG_TXT>
<MAKE_BUY>
<tt:value ref="$line.ABAP_MAKE_BUY"></tt:value>
</MAKE_BUY>
<WP>
<tt:value ref="$line.ABAP_WP"></tt:value>
</WP>
<EVENTO_TECH>
<tt:value ref="$line.ABAP_EVENTO_TECH"></tt:value>
</EVENTO_TECH>
<TIPO_LEGAME>
<tt:value ref="$line.ABAP_TIPO_LEGAME"></tt:value>
</TIPO_LEGAME>
<CONSEGNA>
<tt:value ref="$line.ABAP_CONSEGNA"></tt:value>
</CONSEGNA>
</ROW>
</tt:loop>
</TABELLA>
</ROOT>
</tt:template>
</tt:transform>
Program and XML included :
REPORT zsro2.
DATA l_network TYPE string.
DATA l_operazione TYPE string.
DATA : BEGIN OF lt_data_tmp OCCURS 0,
abap_mandt TYPE string,
abap_network TYPE string,
abap_operazione TYPE string,
abap_id_act TYPE string,
abap_desc_act TYPE string,
abap_long_txt TYPE string,
abap_make_buy TYPE string,
abap_wp TYPE string,
abap_evento_tech TYPE string,
abap_tipo_legame TYPE string,
abap_consegna TYPE string,
END OF lt_data_tmp.
DATA xslt_error TYPE REF TO cx_xslt_exception.
DATA lo_st_error TYPE REF TO cx_st_error.
DATA lv_xml_data_string TYPE string.
DATA xslt_message TYPE string.
DEFINE conc.
concatenate lv_xml_data_string &1 into lv_xml_data_string.
END-OF-DEFINITION.
*conc '<?xml version="1.0" encoding="iso-8859-1" ?>'.
*conc '<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">'.
*conc ' <asx:values>'.
conc ' <ROOT>'.
conc ' <NETWORK>E60000000000</NETWORK> '.
conc ' <OPERAZIONE>0010</OPERAZIONE> '.
conc ' <TABELLA>'.
conc ' <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'.
conc ' <MANDT>300</MANDT> '.
conc ' <NETWORK>E60000000000</NETWORK> '.
conc ' <OPERAZIONE>0010</OPERAZIONE> '.
conc ' <ID_ACT>1</ID_ACT> '.
conc ' <DESC_ACT>ATTIVITÀ1</DESC_ACT> '.
conc ' <LONG_TXT></LONG_TXT> '.
conc ' <MAKE_BUY></MAKE_BUY> '.
conc ' <WP></WP> '.
conc ' <EVENTO_TECH></EVENTO_TECH> '.
conc ' <TIPO_LEGAME></TIPO_LEGAME> '.
conc ' <CONSEGNA></CONSEGNA> '.
conc ' </ROW>'.
conc ' <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'.
conc ' <MANDT>300</MANDT> '.
conc ' <NETWORK>E60000000000</NETWORK> '.
conc ' <OPERAZIONE>0010</OPERAZIONE> '.
conc ' <ID_ACT>2</ID_ACT> '.
conc ' <DESC_ACT>ATTIVITÀ2</DESC_ACT> '.
conc ' <LONG_TXT>ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2</LONG_TXT> '.
conc ' <MAKE_BUY>M</MAKE_BUY> '.
conc ' <WP></WP> '.
conc ' <EVENTO_TECH></EVENTO_TECH> '.
conc ' <TIPO_LEGAME></TIPO_LEGAME> '.
conc ' <CONSEGNA></CONSEGNA> '.
conc ' </ROW>'.
conc ' </TABELLA>'.
conc ' </ROOT>'.
*conc ' </asx:values>'.
*conc '</asx:abap>'.
DATA lv_xml_data_string_2 TYPE string.
TRY.
CALL TRANSFORMATION zsro
SOURCE
XML lv_xml_data_string
RESULT
abap_network = l_network
abap_operazione = l_operazione
abap_tabella = lt_data_tmp[].
CATCH cx_sy_conversion_data_loss .
CATCH cx_st_error INTO lo_st_error.
xslt_message = lo_st_error->get_text( ).
WRITE:/ xslt_message .
CATCH cx_xslt_exception INTO xslt_error.
xslt_message = xslt_error->get_text( ).
WRITE:/ xslt_message .
ENDTRY.
BREAK-POINT. -
Creating Simple transformation for an XML data having deep structure
Hi
I have the following XML structure..
<REQUESTS>
<REQUESTNAME>REQ123</REQUESTNAME>
<REQUESTID>1234</REQUESTID>
<CITY>NEWYORK</CITY>
<ZIPCODE>123456</ZIPCODE>
<COMPETENCIES>
<LANGUAGES>
<COMPETENCY>
<SKILL>SAP</SKILL>
<PROFICIENCY>TEST</PROFICIENCY>
<SKILL>JAVA</SKILL>
<PROFICIENCY>TEST123</PROFICIENCY>
(here we may have any number of records for SKILL&PROFICIENCY...)*
</COMPETENCIES>
</LANGUAGES>
</COMPETENCY>
</REQUESTS>
My requirement is to read the above data from an URL and push it into an internal table.
For this I'm trying to use Simple transformations but I'm facing difficulty in doing this.
Can you pl. guide me how to create the transformation and the corresponding code for this.
Best Regards
AnilHi
Here is the actual XML structure..
- <REQUEST>
<COUNTRY />
<ADDRESS />
<CITY />
<ASSIGNTYPE>IP</ASSIGNTYPE>
<CHARGETYPE>CH</CHARGETYPE>
<REMOTEALLOWED>Y</REMOTEALLOWED>
<SALESRATE>EUR</SALESRATE>
<SECURITY>NO</SECURITY>
<TRAVELEXP>Y</TRAVELEXP>
<MAXDAILYRATE />
<CREDENTIALS />
<EXPENDDATE />
<NEWENDDATE />
<NEWEXPENDDATE />
<REPLYBEFORE>2010-11-30</REPLYBEFORE>
<STARTDATE>2010-01-01</STARTDATE>
<ENDDATE>2010-12-31</ENDDATE>
<GCMTYPE>PM</GCMTYPE>
<GCMLEVELFROM>02</GCMLEVELFROM>
<GCMLEVELTO>08</GCMLEVELTO>
<LOCATION>FR43</LOCATION>
<MOBILITY>04</MOBILITY>
<ZIPCODE />
- <COMPETENCIES>
- <LANGUAGES>
- <COMPETENCY>
<SKILL>01106034</SKILL>
<PROFICIENCY>005103</PROFICIENCY>
</COMPETENCY>
</LANGUAGES>
- <ACTIVITIES>
- <COMPETENCY>
<SKILL>01105500</SKILL>
<PROFICIENCY>004507</PROFICIENCY>
</COMPETENCY>
</ACTIVITIES>
- <BUSINESS>
- <COMPETENCY>
<SKILL>01105729</SKILL>
<PROFICIENCY>004605</PROFICIENCY>
</COMPETENCY>
</BUSINESS>
- <INDUSTRIES>
- <COMPETENCY>
<SKILL>01105491</SKILL>
<PROFICIENCY>004901</PROFICIENCY>
</COMPETENCY>
</INDUSTRIES>
- <METHODS>
- <COMPETENCY>
<SKILL>01105591</SKILL>
<PROFICIENCY>004805</PROFICIENCY>
</COMPETENCY>
</METHODS>
- <OFFERINGS>
- <COMPETENCY>
<SKILL>01105840</SKILL>
<PROFICIENCY>005002</PROFICIENCY>
</COMPETENCY>
</OFFERINGS>
- <PRODUCTS>
- <COMPETENCY>
<SKILL>01107304</SKILL>
<PROFICIENCY>004703</PROFICIENCY>
</COMPETENCY>
</PRODUCTS>
</COMPETENCIES>
<CANDIDATES />
</REQUEST>
Here..... <SKILL></SKILL> <PROFICIENCY></PROFICIENCY> can be more than 1 entry...
For this I have created a simple transformation like below..
I have used the tcode 'XSLT_TOOL '..
In SE11 I have created a Table type 'ZCOMPETENCIES' which is having a line type 'ZLANGS'.
ZLANGS is a structure which has another structure called 'ZCOMPETENCY' and this 'ZCOMPETENCY' is having fields
SKILL & PROFICIENCY.
I have used the wizard button which u can find 'XSLT_TOOL '.. and provided the table type ZCOMPETENCIES' and it has automatically created the following 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="COMPETENCIES" type="ddic:ZCOMPETENCIES"/>
<tt:template>
<COMPETENCIES>
<tt:loop ref=".COMPETENCIES">
<ZLANGS>
<COMPETENCY>
<SKILL tt:value-ref="COMPETENCY.SKILL"/>
<PROF tt:value-ref="COMPETENCY.PROF"/>
</COMPETENCY>
</ZLANGS>
</tt:loop>
</COMPETENCIES>
</tt:template>
</tt:transform>
I have written following code to get the data
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
GET REFERENCE OF gt_person INTO gs_result_xml-value.
gs_result_xml-name = 'COMPETENCIES'.
APPEND gs_result_xml TO gt_result_xml.
TRY.
CALL TRANSFORMATION ZTEST_TRAN
SOURCE XML gt_itab
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
Please let me know if you need any further details..
Best Regards
Anil -
Simple transformation formatting
Dear Expert,
I would like to know how can I format my transformation result using simple transformation. I have an attribute that is supposed to display a date in the format YYYYMMDD. However, the default format is YYYY-MM-DD. How can I change this behavior in simple transformation? Thanks!
Regards,
AlexHey Alex,
do you have a solution already? I have the same problem, the format of the date in the XML-File is "20140101" and I can´t transform it with Simple Transformation to the ABAP Type DATS which waits for "2014-01-01" or "2014.01.01".
the Transformation looks like this in the moment:
<DATE tt:value-ref="DATE"/>
The ABAP type of the field DATE is DATS. And the XML looks at this part like this:
<DATE>20131201</DATE>
Regards,
Christoph
Maybe you are looking for
-
Capturing HD video directly into my computer using HDD Cam & FCE 3.5
I have a JVC Everio GZ-HD7. Unfortunately, I didn't realize how "crappy" these HDD cams can be, in time to be able to return it. It records in 4GB sections, which is bad for me because I record at a studio and I can't have songs being cut off all the
-
How to get previous 2 months from current date in a dropdown?
Hello Experts , In the application which I am developing, there is a requirement wherein , I want to Populate current month and previous two month in a drop down depending upon today's date. please help. Thanks & Regards, Pratb
-
Photos not showing in media view but are in catalogue
In Elements 12 not all photos are showing in the standard ALL MEDIA view, but it says they are in the catalogue if I trey to import a sample of the missing photos. Most of my albums are blank too. It was working fine yesterday but the problem has o
-
Access AppleTv through Macs Finder???
Hi There, Can I access the ATV through my iMac finder? I have a 160GB which I only use for 30%. I would like to dump some files (duplicates of Photo's, important files) as a backup on the ATV. But how to get in....? Roland
-
ADF Faces: When to expect production ready JSF components
I know this question has been asked many times, but there is no up to date information as to schedules. What are the time lines for releasing ADF faces components into production? Great things have been promised in demos at JavaOne and the like. In p