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.
Similar Messages
-
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 -
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
SteffenHi,
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. -
Convertion of XML node to string using Xquery transformation in OSB
How to convert XML node to string using a built in function using Xquery transformation in OSB? In BPEL we have the Xpath extension function ora:getContentAsString() to do the same.
fn:bea-serialize() function converts xml node to string. but it assigns namespace prefix in every xml node during the conversion. So is there any function to remove the namespace prefix from XML node using Xquery built in function?
-
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 -
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 -
Creating XML file Using Call Transformation
Hello Friends,
I have searched before posting thread, couldnt find anything.
I am creating an XML file using Call Transformation. My internal table has 3 date fields and some other fields. For some records I dont have values for the date fields. In that case my XML file is giving the date value as 0000-00-00 since I declared it as Date type. This value 0000-00-00 is not accepted by the middle ware as the valid date. I can not change it as String type as per the suggestion.
In that case I am advised to skip printing the date field tag if it doesnt have value.
Is there any way to skip the date field if it is empty. Any Suggestions please ?.
Thanks
Lakshmi.Hi,
I had exactly the same problem before. When you call a transformation there is an option called initial_components. According to SAP if you use initial_components = 'SUPRESS' the empty fields should not being generated on the XML.
Now, this didn't work for me and I have seen some people with the same problem. Here is how I solved this (maybe not the best way but it worked):
First: My fields are all CHAR in my table
Second: In the transformation, you can use conditional transformation to not display a tag if field is empty, here a piece of my transformation (I am using simple transformations):
<tt:root name="ROOT"/>
<tt:cond s-check="not-initial(ref('ROOT.L1_NM')) or not-initial(ref('ROOT.L2_NM'))">
<TRNMTR_NM>
<tt:cond s-check="not-initial(ref('ROOT.L1_NM'))">
<l1_nm>
<tt:value ref="ROOT.L1_NM"/>
</l1_nm>
</tt:cond>
<tt:cond s-check="not-initial(ref('ROOT.L2_NM'))">
<l2_nm>
<tt:value ref="ROOT.L2_NM"/>
</l2_nm>
</tt:cond>
</TRNMTR_NM>
</tt:cond>
As you can see, I first check if the fields have values.
Hope it helps
Edited by: carlosrv on Oct 4, 2011 8:22 PM -
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. -
Simple transformation XML to ABAP, runtime error: CX_ST_REF_ACCESS
Hi, all experts,
I got a runtime error CX_ST_REF_ACCESS, while I tried to use Simple Transformation to transfer XML-String to ABAP internal table.
Can anybody help me to fix the problem? Thanks very much. It's urgent.
The code of transformation like this:
<tt:root name="DATA"/>
<tt:template>
<node>
<tt:deserialize>
<tt:loop ref=".DATA" name="mdr_data">
<tt:attribute name="type">
<tt:value ref="$mdr_data.lf_type"/>
</tt:attribute>
<tt:attribute name="objid">
<tt:value ref="$mdr_data.lf_objid"/>
</tt:attribute>
<tt:attribute name="name" value-ref="$mdr_data.lf_name"/>
<tt:attribute name="short" value-ref="$mdr_data.lf_short"/>
</tt:loop>
</tt:deserialize>
</node>
</tt:template>
The Data-structure in my Report:
DATA: BEGIN OF ls_mdr_data,
lf_type TYPE /ehr/ct_dt_bo_type,
lf_objid TYPE realo,
lf_name TYPE stext,
lf_short TYPE short_d,
END OF ls_mdr_data,
lt_result_data like TABLE OF ls_mdr_data.
If I call the transformation use the XML-String like:
<node type="MDRFOLDER" objid="50016122" name="MDR Root Folder" short="MDR Root"/>
I got the error CX_ST_REF_ACCESS:
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not caught and
therefore caused a runtime error.
The reason for the exception is:
The goal was to access variable "LF_TYPE". However, this access was not
possible.Hi, all experts,
I got a runtime error CX_ST_REF_ACCESS, while I tried to use Simple Transformation to transfer XML-String to ABAP internal table.
Can anybody help me to fix the problem? Thanks very much. It's urgent.
The code of transformation like this:
<tt:root name="DATA"/>
<tt:template>
<node>
<tt:deserialize>
<tt:loop ref=".DATA" name="mdr_data">
<tt:attribute name="type">
<tt:value ref="$mdr_data.lf_type"/>
</tt:attribute>
<tt:attribute name="objid">
<tt:value ref="$mdr_data.lf_objid"/>
</tt:attribute>
<tt:attribute name="name" value-ref="$mdr_data.lf_name"/>
<tt:attribute name="short" value-ref="$mdr_data.lf_short"/>
</tt:loop>
</tt:deserialize>
</node>
</tt:template>
The Data-structure in my Report:
DATA: BEGIN OF ls_mdr_data,
lf_type TYPE /ehr/ct_dt_bo_type,
lf_objid TYPE realo,
lf_name TYPE stext,
lf_short TYPE short_d,
END OF ls_mdr_data,
lt_result_data like TABLE OF ls_mdr_data.
If I call the transformation use the XML-String like:
<node type="MDRFOLDER" objid="50016122" name="MDR Root Folder" short="MDR Root"/>
I got the error CX_ST_REF_ACCESS:
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not caught and
therefore caused a runtime error.
The reason for the exception is:
The goal was to access variable "LF_TYPE". However, this access was not
possible. -
How to skip XML tags in Simple transformation
Hi,
I am trying to convert an XML file to ABAP code using Simple Transformations.
I tired converting a small XML file to ABAP using it and it worked fine.
The problem is that the number of tags in the XML file I now want to parse is huge (over 200).
Is there any way that for the tag in XML corresponding tag is not created in ST? Is there any conditional tag to achieve this?
Also, is Simple Transformation a better way of parsing in such a scenario over XSLT and DOM parser?
Thanks and Regards,
Neha
Edited by: Neha Anand on Jun 2, 2008 1:19 PMHi Raja,
I have already looked through the code snippets and I am able to write a CALL TRANSFORMATION.
I want to find out if the number of tags is huge then if there is any way that some tags can be skipped for matching tags in XML which anyhow I dont need for manipulation.
Thanks and Regards,
Neha -
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 -
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 -
Free order of tags when deserialising XML-data using Simple Transformatiosn
Hi everybody,
I'm consuming a WebService and get something like this XML-data in the response:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getSalesResponse>
<getSalesReturn href="#id0"/>
</getSalesResponse>
<multiRef id="id0">
<customer href="#id1"/>
<salesOrg href="#id2"/>
<salesRecord soapenc:arrayType="SalesRecord[2]" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<salesRecord href="#id3"/>
<salesRecord href="#id4"/>
</salesRecord>
</multiRef>
<multiRef id="id1"><customer>124843</customer></multiRef>
<multiRef id="id2"><salesOrg>0001</salesOrg></multiRef>
<multiRef id="id3"><material>mat1</material></multiRef>
<multiRef id="id4"><material>mat2</material></multiRef>
</soapenv:Body>
</soapenv:Envelope>
</xml>
I've written a Simple Transformation: it fills my fields i_customer, i_salesorg, i_mat1 and i_mat2 from this XML-Data from the content of the <multiRef>-tags. But only if the order is exactly like this:
<multiRef><customer><tt:value ref="I_CUSTOMER"/>
</customer></multiRef>
<multiRef><salesOrg><tt:value ref="I_SALESORG"/>
</salesOrg></multiRef>
<multiRef><material><tt:value ref="I_MATERIAL1"/>
</material></multiRef>
<multiRef><material><tt:value ref="I_MATERIAL2"/>
</material></multiRef>
However the WebService doesn't guarantee a certain order for the <multiRef>-tags. That means the salesOrg could be contained ahead of the customer.
In a next step I've tried to use the command '<tt:group>' that allows free order of the first two elements:
<tt:group>
<tt:d-cond frq="1">
<multiRef><customer><tt:value ref="I_CUSTOMER"/>
</customer></multiRef>
</tt:d-cond>
<tt:d-cond frq="1">
<multiRef><salesOrg><tt:value ref="I_SALESORG"/>
</salesOrg></multiRef>
</tt:d-cond>
</tt:group>
<multiRef><material><tt:value ref="I_MATERIAL1"/>
</material></multiRef>
<multiRef><material><tt:value ref="I_MATERIAL2"/>
</material></multiRef>
However the WebService doesn't guarantee any order for the <multiRef>-tags. That means the first material could be contained ahead of the customer.
How can I insert the lines for my materials into to <tt:group>-command? Actually the WebService could deliever n materials, so I tried this (but that didn't work any more):
<tt:group>
<tt:d-cond frq="1">
<multiRef><customer><tt:value ref="I_CUSTOMER"/>
</customer></multiRef>
</tt:d-cond>
<tt:d-cond frq="1">
<multiRef><salesOrg><tt:value ref="I_SALESORG"/>
</salesOrg></multiRef>
</tt:d-cond>
<tt:d-cond frq="*">
<tt:loop name="tab" ref=".IT_MATERIALS">
<multiRef><material><tt:value ref="$tab.MATERIAL"/>
</material></multiRef>
</tt:loop>
</tt:d-cond>
Any help would be greatly appreciated. My colleagues have already begun to leave the office because I look more and more frustrated...
Greeting from Munich,
markus
Message was edited by: Markus Jarasch
Message was edited by: Markus JaraschI have some Interface Mapping questions I was hoping someone could help me with. As you know, my source is an XML File and my target is an OracleDB. I'll start with the "EFFECTIVEDATE" field which was automatically mapped when I added the Source and Target Datastores. As I previously mentioned, this caused an error "Target Column EFFECTIVEDATE: Data may be truncated: the target Column is smaller than the source Column". After looking further into it, would the problem be that the "EFFECTIVEDATE" datatype in the XML is "DATETIME" whereas the "EFFECTIVEDATE" datatype in the database is "TIMESTAMP"? If so, what would be the fix for this? Could I convert it in the Implemenation Mapping like so? -
CONVERT(MONEY.EFFECTIVEDATE,TIMESTAMP)
Would using that in the Implementation simply do the trick?
Anyway, moving onto some of the other TARGET fields...
-ACTIVITYGUID
This should be an automatically generated new GUID value. How could I implement this into the Implementation?
-TRANSACTIONGUID
I'll need to query some of the other tables in the database in order to get this value. Is this allowed in the Implemenation? Do I have to add said tables to the target somehow? Can I just query the other tables in the Implementation field using normal select statements, etc.? I'm a bit confused on how this would work...
-TYPECODE
This needs to be a fixed value of '01'. How do I simply do that in the Implementation?
The other fields will all be implemented similar to the above so those are the main questions I have for now. Any help would be appreciated.
Thanks again for your help. -
Optional XML fields in Simple transformations (ST)
Hi, I am using Simple Transformation (ST) to convert an XML file into ABAP data. In my XML file some XML tags are optional: sometimes they are available in the file, sometimes they are not. I can not find out how to define a ST for this.
Either the XML fields are in the ST definition and then these field should also be in the XML file or
the XML fields are not in the ST definition and then these fields are not allowed in the XML.
Regards jackHi Jack, please find some sample coding below that will solve your issue:
<tt:cond check="not-initial(ref('E1EDL20.INCO1'))">
<INCO1 tt:value-ref="E1EDL20.INCO1"/>
</tt:cond>
With the simple transformation tt cond statment you can make an XML tag optional. In below example during deserialisation xml tag <INCO1> will be skipped when not availabke in the xml and SAP data E1EDL20.INCO1 will not be filled by the transformation.
Regards. Please give points when usefull ! -
How to use a transformer xml to html
hi
I want to develop jsp pages based on xml data, so to construct components with xml data i must use a transformer converting xml to htm. so if there is a better or more generic solution of classes or examples that can help me , i tried to use cocoon but the problem was to use it within a jsp page.
please to mail me your suggestions or solutions .
thank youReview Xalan/Xerces from the Apache project.
http://xml.apache.org/xalan-j/index.html
http://xml.apache.org/xalan-j/usagepatterns.html#servlet
http://xml.apache.org/xalan-j/samples.html
Just one method...
Maybe you are looking for
-
I updated iTunes and now it doesn't open.
I updated iTunes a few days ago and now it doesn't open. It told me I needed to update quicktime and when I did that, quicktime didn't open either! So I reinstalled quicktime and it opened after a restart, not now. Does anyone know what's up with thi
-
Hotspot stop working with IOS 7
Hi, I used to have access to internet with my iPhone 4 hotspot, but since upgraded to IOS 7 it won't work anymore. I can not have access to iPhone either Bluetooth and Wi-Fi. I will need to do somthing to configure iPhone 4? Thank you in advance for
-
Best video camera to use with iMove '11 for iMac
I'm looking for the best video camera with no difficulties for iMovie. Just to be able to plug in the camera with out having to load additional software or any other difficulties. Or if any one else knows what type of file format is specifically need
-
Blackfin Performance Profiling
Hello, I'm acquiring 32 bits signals in which only 18 bits are used. As the acquisition rate is around 4.5 MHz and last a few seconds, I must compress my data. Therefore I wrote a simple VI that takes an array of 4 32 bits data (where only 4*18 bi
-
How to make a "save" function?
Hi everybody I am a novice and this is my first time to ask here I have seen a RPG flash game which have a "save" function although it is offline Could anyone tell me how can it do that please