XML to ABAP Conversion
Hi Experts,
I am using SFP transaction.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_file_table
rc = lv_rc
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
READ TABLE lt_file_table
INTO lv_filename
INDEX 1.
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = lv_filename
filetype = 'BIN' "Binary
IMPORTING
filelength = lv_filelength
CHANGING
data_tab = lt_rawtab
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 ).
Get FP reference
DATA: lo_fp TYPE REF TO if_fp VALUE IS INITIAL.
lo_fp = cl_fp=>get_reference( ).
For handling exceptions
DATA: lo_fpex TYPE REF TO cx_fp_runtime VALUE IS INITIAL.
TRY.
Create PDF Object using destination 'ADS' (<-- this is how it is
defined in SM59)
DATA: lo_pdfobj TYPE REF TO if_fp_pdf_object VALUE IS INITIAL.
lo_pdfobj = lo_fp->create_pdf_object( connection = 'ADS' ).
FIELD-SYMBOLS: <ls_rawtab> LIKE LINE OF lt_rawtab.
Move to XSTRING
LOOP AT lt_rawtab ASSIGNING <ls_rawtab>.
CONCATENATE pdf_data <ls_rawtab>-data INTO pdf_data IN BYTE MODE.
ENDLOOP.
Set document
lo_pdfobj->set_document(
EXPORTING
pdfdata = PDF_DATA).
CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
EXPORTING
IM_XSTRING = XML_DATA
IMPORTING
EX_STRING = LV_XML_DATA_STRING.
Remove NEW-LINE character from XML data in STRING format
CLASS cl_abap_char_utilities DEFINITION LOAD.
REPLACE ALL OCCURrENCES OF cl_abap_char_utilities=>newline IN
lv_xml_data_string WITH ''.
Make the XML envelope compliant with identity transform
REPLACE '<?xml version="1.0" encoding="UTF-8"?><data>'
IN lv_xml_data_string
WITH '<?xml version="1.0" encoding="iso-8859-1"?><asx:abap xmlns :asx="http://www.sap.com/abapxml" version="1.0"><asx:values>'.
REPLACE '</data>' IN lv_xml_data_string WITH '</asx:values></asx:abap>'.
Apply the identity transform and convert XML into ABAP in one step
CALL TRANSFORMATION ('ID')
SOURCE XML lv_xml_data_string
RESULT out = out.
But getting error
Short text
XSLT: No valid XML source
Runtime Errors XSLT_BAD_SOURCE_CONTEXT
Except. CX_XSLT_RUNTIME_ERROR
How i call -->call transforamtion...Can any one please tell me how to convert XML to abap internal table?...
Thanks
Hi,
I just catch the exception.
Regards,
Mathi
Similar Messages
-
XML to ABAP Conversion Error - CX_SY_CONVERSION_DATA_LOSS
REPORT y_rpt_test .
TYPE-POOLS sscr.
DATA: restrict TYPE sscr_restrict,
opt_list TYPE sscr_opt_list,
*** TYPE sscr_***.
DATA: options TYPE STANDARD TABLE OF rfc_db_opt ,
fields TYPE STANDARD TABLE OF rfc_db_fld ,
meta TYPE STANDARD TABLE OF ywas_metadata ,
xml_out TYPE string .
data: xml_out_x type xstring.
DATA: wa_options LIKE LINE OF options,
wa_fields LIKE LINE OF fields ,
wa_meta LIKE LINE OF meta .
FIELD-SYMBOLS: <outtab> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
DATA: xslt_error TYPE REF TO cx_xslt_exception ,
xslt_message TYPE string .
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
TYPES: BEGIN OF s_text,
partnum(18) TYPE c,
LONG_DESC(3000) TYPE c,
END OF s_text.
data: lt_outtab type standard table of s_text,
is_outtab type s_text.
data: it_temp_text(1000) TYPE c OCCURS 0 with header line.
data : l_file TYPE string value 'C:xmlload.xml'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file
FILETYPE = 'ASC'
tables
data_tab = it_temp_text.
loop at it_temp_text.
concatenate xml_out it_temp_text into xml_out.
endloop.
IF NOT xml_out IS INITIAL .
TRY .
CALL TRANSFORMATION (`ZTEST1`)
SOURCE XML xml_out
RESULT outtab = lt_outtab.
CATCH cx_xslt_exception INTO xslt_error.
xslt_message = xslt_error->get_text( ).
WRITE:/ xslt_message .
ENDTRY.
ENDIF .
break-point.
write : / 'test'.
==========================================================
I am using above code to convert input XML file into internal table I am getting conversion error. My input XML file looks is as follows. It is throwing this error in call transformation. Appreciate your help in Advance.
<MODIFIED BY MODERATOR - RESPECT THE 2,500 CHAR LIMIT>
Code Formatted by: Alvaro Tejada Galindo on Jan 4, 2010 3:31 PMThanks for quick response.
I think the problem is with special characters in the input XML file. If I don't have special characters in XML file then it works fine.
Anyway here is the XSLT code. This is a generic XSLT code which I used from one of the examples
posted on this site.
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xa="urn:schemas-microsoft-com:xml-analysis:mddataset" xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<xsl:output method="xml" />
<xsl:variable name="fieldNames" select="//asx:abap/asx:values/FIELDCAT" />
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<!--FIELDCAT>
<xsl:apply-templates select="//YWAS_METADATA" />
</FIELDCAT-->
<OUTTAB>
<xsl:apply-templates select="//item" />
</OUTTAB>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="//YWAS_METADATA">
<item>
<xsl:for-each select="*">
<!--column ><xsl:apply-templates/></column-->
<xsl:copy>
<xsl:apply-templates select="@*|*|text()"/>
</xsl:copy>
</xsl:for-each>
</item>
</xsl:template>
<xsl:template match="//item">
<item>
<xsl:for-each select="*">
<!--column ><xsl:apply-templates/></column-->
<xsl:copy>
<xsl:apply-templates select="@*|*|text()"/>
</xsl:copy>
</xsl:for-each>
</item>
</xsl:template>
</xsl:stylesheet> -
Hi Experts ,
i have a scenario proxy to soap where i am getting error while getting the response .
we are sending the request successfully and getting response .some times we are getting in proxy level error below
PARSE_APPLICATION_DATA Error during XML => ABAP conversion: Response Message; CX_ST_DESERIALIZATION_ERROR in /1SAI/SAS0446CC11CC6EC1AD4789 Line 24 An error occurred when deserializing in the simple transformation program /1SAI/SAS0446CC11CC6EC1AD4789 (Cha
Please help us to fix this bug in proxy response.
Regards
RaviHello Ravinder,
Can you please post the complete stack trace, it seems to be some fields are getting truncated i,e data sent from the program to the proxy object might be violating some length restrictions.
Please check your message interface field lengths and what is being passed to the proxy.
Regards,
Ravi. -
Hello,
From a provider we get the following XSD from a response message:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://xxx" targetNamespace="http://yyy">
<xsd:element name="loginResponse" type="loginResponse" />
<xsd:complexType name="loginResponse">
<xsd:sequence>
<xsd:element name="result" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
His actual response looks like this:
<SOAP-ENV:loginResponse
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:SOAPENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-Instance'>
<Result xsi:type='xsd:string'>artv8uv38gvqu05gjohv26g8l5</Result>
</SOAP-ENV:loginResponse>
PI accepts this well, but during the conversion from XML to ABAP we get the following error:
PARSE_APPLICATION_DATA Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT; (/1SAI/TXS3656E9BD8
Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT; (/1SAI/TXS3656E9BD8A34AE8B7F16 XML Bytepos
Element 'loginResponse' verwacht
I have the impression that there is a problem with the namespace and wonder how I can solve this. I do not know enough about XML to judge if the returned XML is valid according to the definition. Maybe the problem lies there.
Thanks for any help.
KrisYou are right. The error is the root node:
SOAP-ENV:loginResponse
This prefix is not allowed.
It should be something like this:
<loginResponse xmlns="http://xxx"
Edited by: Stefan Grube on Aug 23, 2010 4:35 PM -
Error during XML = ABAP conversion
Hi
We have a synchronous call from a SRM application through a proxy framework to a vendor http server through XI. The response from the vendor's http server is returned through a custom structure -and is returned through XI back to the calling SRM application.
After receiving the response, the calling SRM application checks for a particular field value of the custom return structure for a error code and sends out an email - accordingly.
Now, the response message comes back from the vendor's server - but the lines of code beyond the synchronous call in the SRM calling application does not get executed ( mail generation part ) I get the following error on the SRM front end - <b>Error in Exchange Infrastructure: Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT; (/1SAI/TXS00000000000000000001 XML Bytepos.: 39 XML Path: Error Text: System e</b>
Now, this error when occured in our dev environment, I set the extended xml attribute property to 'X' for the synchronous payload in calling SRM application code. The problem is, this error is occuring now in our QA environment inspite of this property being set.
Any ideas/suggestions as to why this message occurs in a standard proxy framework setup ?Hi,
Please check this link <a href="http://help.sap.com/saphelp_nw04/helpdata/en/0c/402040abf2c442e10000000a1550b0/content.htm"></a>
This talks about having the first element of the xml fragment as X0.
Hope this helps.
Regards,
Smitha. -
Error during XML = ABAP conversion, empty tag
Hi.
Im sending data from a Data Base to a proxy using BI.
But when I get an empty response from the data base wich gives me an empty XML tag the proxy shows me an error:
-PARSE_APPLICATION_DATA Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT;
-Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT;
-System expected the end of the element 'STMT_DC_response'
This is the message that originates the fail:
<?xml version="1.0" encoding="utf-8" ?>
<ns0:MT_PRV23_BS_desg_response xmlns:ns0="urn:tompla-com:xi:ventas_SD">
<STMT_response>
<row>
<TIPO>P</TIPO>
<NUM_OT>55062330</NUM_OT>
<NUM_DESGLOSE>1</NUM_DESG>
<CANT_DESG>1724000</CANT_DESG>
</row>
</STMT_response>
<STMT_DC_response />
</ns0:MT_PRV23_BD_desg_response>
In case that the tag is filled runs ok
<?xml version="1.0" encoding="utf-8" ?>
<ns0:MT_PRV23_BD_desg_response xmlns:ns0="urn:tompla-com:xi:ventas_SD">
<STMT_response>
<row>
<TIPO>P</TIPO>
<NUM_OT>55062330</NUMERO_OT>
<NUM_DESG>1</NUM_DESG>
<CANT_DESG>1724000</CANT_DESG>
</row>
</STMT_response>
<STMT_DC_response>
<row>
<TIPO>P</TIPO>
<NUMERO_OT>55062330</NUMERO_OT>
<NUMERO_DESGLOSE />
<COD_CAR_ADICIONA>8</COD_CAR_ADICIONA>
<PORC_CAR_ADICION>1</PORC_CAR_ADICION>
</row>
</STMT_DC_response>
</ns0:MT_PRV23_BD_desg_response>
The definition for the data is:
STMT_DC_response 0..1
row 0..n
tipo 0..1
Thanks for the help you can give me about my problem with empty tags.I moved this question to other forum
Expert Forums » SAP NetWeaver » Exchange Infrastructure -
XML - ABAP conversion, empty tag
Hi.
Im sending data from a DB to a proxy using XI.
But when I get an empty response from the DB, wich gives me an empty XML tag the proxy shows me an error:
-PARSE_APPLICATION_DATA Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT;
-Error during XML => ABAP conversion (Response Message; error ID: CX_ST_MATCH_ELEMENT;
-System expected the end of the element 'STMT_DC_response'
This is the message that originates the fail:
<ns0:MT_xxx_response xmlns:ns0="urn:s-com:xi:SD">
<STMT_response>
<row>
<c11>P</c11>
<c12>55062330</c12>
<c13>1</c13>
</row>
</STMT_response>
<STMT_DC_response />
</ns0:MT_xxx_response>
In case that the tag is filled runs ok
<ns0:MT_xxx_response xmlns:ns0="urn:s.com:xi:SD">
<STMT_response>
<row>
<c11>P</c11>
<c12>55062330</c12>
<c13>1</c13>
</row>
</STMT_response>
<STMT_DC_response>
<row>
<c21>P</c21>
<c22>55062330</c22>
<c23 />
</row>
</STMT_DC_response>
</ns0:MT_xxx_response>
The definition for the data is:
STMT_DC_response 0..1
row 0..n
tipo 0..1
Thanks for the help you can give me about my problem with empty tags.thanks for your help!
yes, The definition for the data is:
STMT_DC_response 0..1
to be sure I disabled that node, so I wont get it from the DB, and It was ok
this is ok:
<ns0:MT_xxx_response xmlns:ns0="urn:s-com:xi:SD">
<STMT_response>
<row>
<c11>P</c11>
<c12>55062330</c12>
<c13>1</c13>
</row>
</STMT_response>
</ns0:MT_xxx_response>
but this is not
<ns0:MT_xxx_response xmlns:ns0="urn:s-com:xi:SD">
<STMT_response>
<row>
<c11>P</c11>
<c12>55062330</c12>
<c13>1</c13>
</row>
</STMT_response>
<STMT_DC_response />
</ns0:MT_xxx_response> -
XML = ABAP conversion error (CX_ST_GROUP_MISSING_CASE)
Hi ,
we are using wsdl connection
We are not able to display data in SAP
its showing error :
Error during <b>XML => ABAP conversion</b> (Response Message; error ID: CX_ST_GROUP_MISSING_CASE; (/1SAI/TXS00000000000000000010 XML Bytepos.: 205 XML Path: root(1)ns0:requestEventResponse(1) Error Text: Element 'TESTRESPONSE' missing))Are you by any chance using a message interface with multiple namespaces as source for your ABAP proxy? I am currently facing the very same problem and my best guess so far is that the ABAP proxy cannot handle multiple namespaces in one message.
Did you get open a ticket on SapOSS? Any hints are very welcome!
Stefan -
Xml to abap internal table by using a dynamic internal table at runtime
Hi ,
I have a requirement to convert xml to abap internal table . But the requirement is that i need to create internal table according to the XML .
Ex : If my XML is :
<?xml version="1.0" ?>
- <flights>
- <airline code="AA" name="American Airlines">
- <flight number="0017">
<from airport="JFK">NEW YORK,US</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>110000</departure>
<arrival>140100</arrival>
<type>Scheduled</type>
</flight>
- <flight number="0064">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="JFK">NEW YORK,US</to>
<departure>090000</departure>
<arrival>172100</arrival>
<type>Scheduled</type>
</flight>
</airline>
So after conversion my abap internal table shoul have fields as :
airline_code Name flight_number from_airport to_airport departure arrival type
and the field values should be corresponding field values .
Thanks in advance .
Regards .Hi Ujjwal,
use
CALL TRANSFORMATION
Study the online documentation and if required do some search for CALL TRANSFORMATION and/or XML PARSER
And, when coming back here with next question, tell us what searches you did with what results - please always follow the 'search before post' rule, thank you.
Regards,
Clemens -
To convert XML to ABAP internal table can we do it with DOM or we need XSLT
I have a requirement where I need to collect the data from XML file into an internal table.
I need to collect this data into an internal table as I should make use of this data and do Goods Receipt in SAP.
My XML file is very very complex and the child nodes in my XML file may occur ones or 10 times and change dynamically.
I want to know if XML to ABAP internal table is possible with DOM or does it need XSLT too.
I used the blog of Robert which uses DOM, but it I am unable to collect the data in internal table. The blog explains only how to wtite the out put to screen as element and value.
I want to know if XML to ABAP internal table is possible with DOM or do I need XSLT too? I am confused please help.
Any help will be highly appreciated.
Regards,
Jessica SamHello Jessica
Why not using the DOM itself for processing?
Below you see the post-processing coding which I use to add the interchange control number (ICN) into an EDI message (which at this stage is still an XML-EDI stream). This is done on SAP-XI yet on the ABAP stack so you could use this approach on your R/3 system as well.
method POSTPROCESSING.
* Post-Processing of outbound EDI invoices & dispatch advices
me->map_icn( ).
endmethod.
method MAP_ICN.
* define local data
DATA: lo_node TYPE REF TO if_ixml_node,
ld_name TYPE string,
ld_value TYPE string,
ld_error_code type MPG_ERRCODE,
** ld_control_number TYPE char13,
ld_rc TYPE i,
ld_msg TYPE string. " bapi_msg.
DATA: ld_interface TYPE string.
DATA: incode TYPE REF TO if_ixml_node_collection.
LOG-POINT ID zedi
SUBKEY mc_subkey_method_trace.
ld_error_code = md_clsname.
* Get next interchange control number (ICN)
me->md_next_number = me->get_next_number(
id_nrobj = me->md_nrobj " Object (SNRO)
id_nrnr = me->md_nrnr ). " Number Range
CALL METHOD zcl_edi_uk_counter=>calculate_modulo_n09
EXPORTING
id_input = me->md_next_number
receiving
rd_output = me->md_next_number.
* Build ICN according to naming conventions agreed with EDI customer
me->md_icn = me->generate_icn( me->md_next_number ).
ld_value = me->md_icn. " type conversion to string
CLEAR: incode,
lo_node.
incode = me->mo_document->get_elements_by_tag_name( mc_d_0020 ).
lo_node = incode->get_item( index = 0 ).
CALL METHOD lo_node->set_value
EXPORTING
value = ld_value
RECEIVING
rval = ld_rc.
IF ( ld_rc NE 0 ).
CONCATENATE 'Error [' mc_d_0020
']: Method SET_VALUE (IF_IXML_NODE)'
INTO ld_msg.
CONDENSE ld_msg.
me->mif_trace->trace2( message = ld_msg ).
RAISE EXCEPTION TYPE cx_mapping_fault
EXPORTING
* textid =
* previous =
error_code = ld_error_code
error_text = ld_msg.
** MESSAGE ld_msg TYPE 'A'.
ENDIF.
CLEAR: incode,
lo_node.
incode = me->mo_document->get_elements_by_tag_name( mc_d_0020_2 ). " element for ICN
lo_node = incode->get_item( index = 0 ).
CALL METHOD lo_node->set_value
EXPORTING
value = ld_value
RECEIVING
rval = ld_rc.
IF ( ld_rc NE 0 ).
CONCATENATE 'Error [' mc_d_0020_2
']: Method SET_VALUE (IF_IXML_NODE)'
INTO ld_msg.
CONDENSE ld_msg.
me->mif_trace->trace2( message = ld_msg ).
RAISE EXCEPTION TYPE cx_mapping_fault
EXPORTING
* textid =
* previous =
error_code = ld_error_code
error_text = ld_msg.
** MESSAGE ld_msg TYPE 'A'.
ENDIF.
* define local data
DATA: ls_record TYPE mpp_dynamic.
CLEAR: ls_record.
ls_record-namespace = mc_dynamic_namespace.
ls_record-name = mc_icn.
ls_record-value = ld_value.
mif_dynamic->add_record( ls_record ).
endmethod.
In your case you would need to do a DO...ENDDO loop until you parsed all required nodes.
NOTE: ME->MO_DOCUMENT is of TYPE REF TO IF_IXML_DOCUMENT.
Regards
Uwe -
How to convert xml to ABAP data?
Hi Expert,
I need to write a transformation and convert an XML file into ABAP data.
The XML looks like following:
<?xml version="1.0" ?>
- <ServiceProtocol version="2.1">
- <CmdTest CheckId="123456789">
- <ExceptionMessage>
<id>003</id>
<text>Test</text>
- <arguments>
<argument>2.2</argument>
<argument>2.1</argument>
</arguments>
<creator>Hello</creator>
</ExceptionMessage>
</CmdTest>
</ServiceProtocol>
I have no knowledge in transformation. Can some one help me on this or provide deatail guideline on the conversion of XML to ABAP data.
Thanks in advance,
Best Regards, Johnney.Hi Johnney,
It's actually not that difficult. For that little XML of yours, I would suggest a Simple Transformation, because it's ... simple. And fast.
You should do some reading in the online documentation, and then it's trial-and-error. To accelerate your trialling, I've prepared a little example for you. Which you can use as follows.
Call SE80, and go Workbench > Edit object... , and create a "Transformation" (you give it a suitable name, and click on the "Create" button; in the pop-up, you specify Transformation type = "Simple transformation").
In the source code, you replace everything between "<tt:transform>" and "</tt:transform>" with the following bit of code:
<tt:root name="PROTOCOL_VERSION"/>
<tt:root name="CHECK_ID"/>
<tt:root name="MESSAGE_ID"/>
<tt:root name="MESSAGE_TEXT"/>
<tt:root name="CREATOR"/>
<tt:root name="T_ARGUMENTS"/>
<tt:template>
<ServiceProtocol>
<tt:attribute name="version" value-ref="PROTOCOL_VERSION"/>
<CmdTest>
<tt:attribute name="CheckId" value-ref="CHECK_ID"/>
<ExceptionMessage>
<id>
<tt:value ref="MESSAGE_ID"/>
</id>
<text>
<tt:value ref="MESSAGE_TEXT"/>
</text>
<arguments>
<tt:loop name="Arguments" ref="T_ARGUMENTS">
<argument>
<tt:value ref="$Arguments.ARGUMENT"/>
</argument>
</tt:loop>
</arguments>
<creator>
<tt:value ref="CREATOR"/>
</creator>
</ExceptionMessage>
</CmdTest>
</ServiceProtocol>
</tt:template>
Your simple transformation is ready; all you have to do is call it from a little program, more or less as follows:
DATA:
l_prot_version TYPE string,
l_check_id TYPE string,
l_msg_id TYPE string,
l_msg_text TYPE string,
l_creator TYPE string,
BEGIN OF ls_arguments,
argument TYPE string,
END OF ls_arguments,
lt_arguments LIKE STANDARD TABLE OF ls_arguments.
TRY.
CALL TRANSFORMATION your_transformation_name
SOURCE XML l_xml_string
RESULT protocol_version = l_prot_version
check_id = l_check_id
message_id = l_msg_id
message_text = l_msg_text
t_arguments = lt_arguments
creator = l_creator.
CATCH cx_st_error.
* Your error handling comes here...
ENDTRY.
The variables starting with "l_" should be character fields of appropriate length, or character strings, while "lt_arguments" should be a standard table with a single field called "ARGUMENT" (otherwise you'd have to change the name in the transformation, in the line that says "<tt:value ref="$Arguments.ARGUMENT"/>").
There's more pitfalls for you, like the encoding of the XML string, but you'll find examples of how to handle that if you look for class CL_ABAP_CONV_IN_CE, either here in the forum or in your system (or in the online help, of course).
Oh, and you should definitely catch and handle CX_ST_ERROR - transformations dump easily if something is wrong with the data.
Hope this helps - sure took longer than planned...
Rainer -
J2SE adapter PI 7.1 issue with XML to flat conversion and namespace length
Dear reader,
We are facing an issue with J2SE Adapter PI7.1 for a number of flows.
The flow requirements:
[1] Namespace length for interfaces is up to 100 characters
[2] The XML message must be converted to Flat on the adapter channel
Our PI system is at patch level 7 and we implement J2SE adapter on patch level 7 as well.
We found that the J2SE adapter on patch level 7 does not support long namespaces [1] (as it should since this is an PI 7.1 j2SE adapter) but no issues where found with the XML to flat conversion [2].
Experimenting with J2SE adapter on patch level 6 we found the long namespaces [1] are supported however an issue is found with the XML to flat conversion [2] as stated in SAP note 1335527.
An SAP Customer Message is raised on this issue however your input is highly appricated!
With Kind Regards,
Harald Kastelijn
Edited by: Harald Kastelijn on Mar 6, 2010 9:17 AM
Edited by: Harald Kastelijn on Mar 6, 2010 9:19 AMWe found that the J2SE adapter on patch level 7 does not support long namespaces [1] (as it should since this is an PI 7.1
j2SE adapter) but no issues where found with the XML to flat conversion [2]
I think the restriction of namespace length still remains in design time (IR).....the same however has been extended in configuration and runtime...this SAP note has some information: https://service.sap.com/sap/support/notes/870809 -
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. -
Hello friends,
I am trying a ABAP program (posted on SDN) to convert XML into ABAP (internal table) and not having any luck. Either it is my table/structure declaration or XSLT. Could any of you experts give me a hand with it please?
Thanks in advance..but points on help!
Here is my XML:
And my ABAP program:
REPORT ZTESTXMLREAD.
TYPE-POOLS: abap, ixml.
class cl_ixml definition load.
TYPES: BEGIN OF t_dc40,
docnum(17) TYPE C,
status(2) TYPE C,
END OF t_dc40.
TYPES: BEGIN OF t_emkt,
spras(2) TYPE C,
maktx(35) TYPE C,
END OF t_emkt.
TYPES: BEGIN OF t_emrm,
matnr(12) TYPE C,
ersda(8) TYPE C,
ernam(25) TYPE C,
emktx TYPE t_emkt,
END OF t_emrm.
TYPES: BEGIN OF t_mm,
dc40 TYPE t_dc40,
emrm TYPE t_emrm,
END OF t_mm.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_istream TYPE REF TO if_ixml_istream.
DATA: l_filename TYPE string.
DATA: it_airplus TYPE STANDARD TABLE OF t_mm,
wa_airplus TYPE t_mm.
*Errorvariables
DATA: xslt_err TYPE REF TO cx_xslt_exception,
err_string TYPE string.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'c:Test.XML'.
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
Creating input stream
l_istream = l_streamfactory->create_istream_uri( 'file://c:Test.xml' ).
here we use the CALL TRANSFORMATION method which calls
TRY.
CALL TRANSFORMATION ZTestXSLT
SOURCE xml l_istream
RESULT xml_output = it_airplus
catch any error, very helpful if the XSLT isn't correct
CATCH cx_xslt_exception INTO xslt_err.
err_string = xslt_err->get_text( ).
WRITE: / 'Transformation error: ', err_string.
EXIT.
ENDTRY.
setting a breakpoint to watch the workarea
by the internal table "it_airplus"
break-point.
LOOP AT it_airplus INTO wa_airplus.
ENDLOOP.Thank you Durairaj, as a matter of fact my program is based on your post (one that you pointed me to). For whatever reason I'm not having luck figuring it out (may be just a bit of work pressure) could you please hlep me a bit more by pointing me to where in my program code/xslt I'm going wrong? I somehow feel that it could be my table structure or xslt.
I would really appreciate it!
Thanks again,
erfan. -
How to use STRANS to translate XML to ABAP with deep structure
every experts, I want to use Tcode: STRANS to translate XML to ABAP, But it does not work well,
here is XML code,I want to translate this XML into an an Inter table gt_orders with deep structure of oeb, and colum oeb is also and intertable,how can I do this.
<?xml version="1.0" encoding="gb2312" ?><axmt410><ObjectID>setSalesOrder</ObjectID><azp01>000000</azp01><oea00>1</oea00><ta_oeaecn>SO-140227-3041</ta_oeaecn><oea03>25325017</oea03><oea02>2014-02-27 17:44:44.0</oea02><ta_oea002>2763.0</ta_oea002><ta_oea001>0.0</ta_oea001><oea14></oea14><oea15>25325017</oea15><oea23>RMB</oea23><oeaconf>S3</oeaconf><oea10></oea10><oeaud01>null</oeaud01><ta_oea007></ta_oea007><oea25>101</oea25><ta_oea008>0</ta_oea008><ta_oea009>null</ta_oea009><oeauser>Hanjingya</oeauser><ta_oeanday>2014-02-27 17:44:44.991</ta_oeanday><ta_oeamday>2014-02-28 08:30:14.866</ta_oeamday><ta_oeacday>2014-02-28 08:30:14.866</ta_oeacday><oeaud02>0</oeaud02><ta_oea030>null</ta_oea030><oeb><oeb03>1</oeb03><oeb04>7400208249</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address1</ta_oeb003><ta_oeb004>zhangdagui、zhanglan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb><oeb><oeb03>2</oeb03><oeb04>7400208250</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address2</ta_oeb003><ta_oeb004>zhangdagui、chenlan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb></axmt410>
I write these codes in SAP XSLT editor
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ORDERS>
<xsl:apply-templates select="//axmt410"/>
</ORDERS>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="axmt410">
<OBJECTID>
<xsl:value-of select="ObjectID"/>
</OBJECTID>
<AZP01>
<xsl:value-of select="azp01"/>
</AZP01>
<OEA00>
<xsl:value-of select="oea00"/>
</OEA00>
<TA_OEAECN>
<xsl:value-of select="ta_oeaecn"/>
</TA_OEAECN>
<OEA03>
<xsl:value-of select="oea03"/>
</OEA03>
<OEA05>
<xsl:value-of select="oea05"/>
</OEA05>
<OEA02>
<xsl:value-of select="oea02"/>
</OEA02>
<TA_OEA002>
<xsl:value-of select="ta_oea002"/>
</TA_OEA002>
<TA_OEA001>
<xsl:value-of select="ta_oea001"/>
</TA_OEA001>
<OEA14>
<xsl:value-of select="ora14"/>
</OEA14>
<OEA15>
<xsl:value-of select="ora15"/>
</OEA15>
<OEA23>
<xsl:value-of select="ora23"/>
</OEA23>
<OEACONF>
<xsl:value-of select="oeaconf"/>
</OEACONF>
<OEA10>
<xsl:value-of select="ora10"/>
</OEA10>
<OEAUD01>
<xsl:value-of select="oeaud01"/>
</OEAUD01>
<TA_OEA007>
<xsl:value-of select="ta_oea007"/>
</TA_OEA007>
<OEA25>
<xsl:value-of select="ora25"/>
</OEA25>
<TA_OEA008>
<xsl:value-of select="ta_oea008"/>
</TA_OEA008>
<TA_OEA009>
<xsl:value-of select="ta_oea009"/>
</TA_OEA009>
<TA_OEA013>
<xsl:value-of select="ta_oea013"/>
</TA_OEA013>
<TA_OEA014>
<xsl:value-of select="ta_oea014"/>
</TA_OEA014>
<TA_OEA015>
<xsl:value-of select="ta_oea015"/>
</TA_OEA015>
<TA_OEA016>
<xsl:value-of select="ta_oea016"/>
</TA_OEA016>
<TA_OEA017>
<xsl:value-of select="ta_oea017"/>
</TA_OEA017>
<TA_OEA018>
<xsl:value-of select="ta_oea018"/>
</TA_OEA018>
<TA_OEA019>
<xsl:value-of select="ta_oea019"/>
</TA_OEA019>
<TA_OEA020>
<xsl:value-of select="ta_oea020"/>
</TA_OEA020>
<TA_OEA021>
<xsl:value-of select="ta_oea021"/>
</TA_OEA021>
<TA_OEA022>
<xsl:value-of select="ta_oea022"/>
</TA_OEA022>
<TA_OEA028>
<xsl:value-of select="ta_oea028"/>
</TA_OEA028>
<OEAUSER>
<xsl:value-of select="oeauser"/>
</OEAUSER>
<TA_OEANDAY>
<xsl:value-of select="ta_oeanday"/>
</TA_OEANDAY>
<TA_OEAMDAY>
<xsl:value-of select="ta_oeamday"/>
</TA_OEAMDAY>
<TA_OEACDAY>
<xsl:value-of select="ta_oeacday"/>
</TA_OEACDAY>
<OEAUD02>
<xsl:value-of select="oeaud02"/>
</OEAUD02>
<TA_OEA030>
<xsl:value-of select="ta_oea030"/>
</TA_OEA030>
<OEB>
<xsl:for-each select="oeb">
<OEB03>
<xsl:value-of select="oeb03"/>
</OEB03>
<OEB04>
<xsl:value-of select="oeb04"/>
</OEB04>
<OEB05>
<xsl:value-of select="oeb05"/>
</OEB05>
<OEB17>
<xsl:value-of select="oeb17"/>
</OEB17>
<OEB13>
<xsl:value-of select="oeb13"/>
</OEB13>
<OEB15>
<xsl:value-of select="oeb15"/>
</OEB15>
<OEB12>
<xsl:value-of select="oeb12"/>
</OEB12>
<OEB09>
<xsl:value-of select="oeb09"/>
</OEB09>
<TA_OEB001>
<xsl:value-of select="ta_oeb001"/>
</TA_OEB001>
<TA_OEB002>
<xsl:value-of select="ta_oeb002"/>
</TA_OEB002>
<TA_OEB003>
<xsl:value-of select="ta_oeb003"/>
</TA_OEB003>
<TA_OEB004>
<xsl:value-of select="ta_oeb004"/>
</TA_OEB004>
<TA_OEB005>
<xsl:value-of select="ta_oeb005"/>
</TA_OEB005>
<TA_OEB006>
<xsl:value-of select="ta_oeb006"/>
</TA_OEB006>
<OEBUD01>
<xsl:value-of select="oebud01"/>
</OEBUD01>
</xsl:for-each>
</OEB>
</xsl:template>
</xsl:transform>
and I use below ABAP program for a test, but the items from XML can not translate into Interner table gt_orders-oeb[]
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\temp\order02.xml'.
* This is the structure for the data from the XML file
TYPES:
BEGIN OF typ_s_oeb,
oeb03 TYPE string, "
oeb04 TYPE string, "
oeb05 TYPE string, "
oeb17 TYPE string, "
oeb13 TYPE string,
oeb15 TYPE string,
oeb12 TYPE string, "
oeb09 TYPE string, "
ta_oeb001 TYPE string, "
ta_oeb002 TYPE string, "
ta_oeb003 TYPE string, "
ta_oeb004 TYPE string, "
ta_oeb005 TYPE string, "
ta_oeb006 TYPE string, "
ta_oeb013 TYPE string, "
ta_oeb014 TYPE string, "
ta_oeb015 TYPE string, "
ta_oeb016 TYPE string, "
ta_oeb017 TYPE string, "
ta_oeb018 TYPE string, "
ta_oeb019 TYPE string, "
ta_oeb020 TYPE string, "
ta_oeb021 TYPE string, "
ta_oeb022 TYPE string, "
oebud01 TYPE string, "
END OF typ_s_oeb.
TYPES: typ_t_oeb TYPE TABLE OF typ_s_oeb WITH KEY oeb03.
TYPES:
BEGIN OF typ_s_order,
objectid TYPE string, "
azp01 TYPE string, "
oea00 TYPE string, "
ta_oeaecn TYPE string, "
oea03 TYPE string, "
oea02 TYPE string, "
ta_oea002 TYPE string, "
ta_oea001 TYPE string, "
oea14 TYPE string, "
oea15 TYPE string,
oea23 TYPE string, "
oeaconf TYPE string, "
oea10 TYPE string, "
oeaud01 TYPE string, "
ta_oea007 TYPE string, "
oea25 TYPE string, "
ta_oea008 TYPE string, "
ta_oea009 TYPE string, "
oeauser TYPE string, "
ta_oeanday TYPE string, "
ta_oeamday TYPE string, "
ta_oeacday TYPE string, "
oeaud02 TYPE string, "
ta_oea030 TYPE string, "
ta_oea013 TYPE string,
ta_oea014 TYPE string,
ta_oea015 TYPE string,
ta_oea016 TYPE string,
ta_oea017 TYPE string,
ta_oea018 TYPE string,
ta_oea019 TYPE string,
ta_oea020 TYPE string,
ta_oea021 TYPE string,
ta_oea022 TYPE string,
ta_oea025 TYPE string,
oeb TYPE typ_t_oeb,
END OF typ_s_order.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048,
gs_itab LIKE LINE OF gt_itab.
* Table and work ares for the data from the XML file
DATA: gt_orders TYPE STANDARD TABLE OF typ_s_order,
gs_orders TYPE typ_s_order.
* Result table that contains references
* of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
* Get the XML file from your client
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.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IPERSON".
GET REFERENCE OF gt_orders INTO gs_result_xml-value.
gs_result_xml-name = 'ORDERS'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT styleshee
TRY.
CALL TRANSFORMATION zfx_so_xml_to_abap
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 'S'.
ENDTRY.
LOOP AT gt_orders INTO gs_orders.
ENDLOOP.The simplest way seems to me is to use a XSL file for that. The <xsl:output> attributes doctype-system and doctype-public generate the DTD declaration <!DOCTYPE YOUR_ROOT SYSTEM "yourDTDfile.dtd"> and <!DOCTYPE YOUR_ROOT PUBLIC "yourDTDfile.dtd">, respectively.
When calling transformerInstance.transform() the XSLT processor performs the identity transformation - it just copies elements, attributes, content, processing instructions and comments to the result stream.
If you're using an xsl file for your transformation already, simply add <xsl:output doctype-system="yourDTDfile.dtd"/> to your existing XSL file.
If you're only using the identity transformation you'd need to change the line of code where you obtain the transformer instance from the TransformerFactory to:
t_factory.newTransformer(new StreamSource("test.xsl"));
and use this as test.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output doctype-system="yourDTDfile.dtd"/>
<!-- this is the identity transformation -->
<xsl:template match="*|@*|comment()|processing-instruction()|text()">
<xsl:copy>
<xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>Good luck.
Maybe you are looking for
-
Java 1.4.2-where to download?
For a work application accessed over the internet, I need to run java 1.4.2 specifically. I haven't been able to find a site to download this yet--does anyone have a link I could use? (no longer supported by Sun) FYI--using current MBP, Snow Leopard.
-
Need ABAP table/Report for getting trace of error messages
Hi experts, My requirement is to display Detailed Error trace text of the error message, on my screen. Now i need to know, which tables in XI it is stored or is there any abap report available that can provide thsi information. any function module ??
-
Hi, I have created a composite BSP element that outputs a matrix with two cells, the first containing an icon, the second with a description. This works fine when placed in a BSP page. When, however, I try to use the element in a tableView iterator,
-
Hi Folks! I have a small problem in RDI format printing. Does anybody know if RDI format recognises the displayable/non-displayable characters? I mean characters like $, EURO symbol, ~, etc. When I am generating the output the special characters are
-
How does Address Book sharing work? Apple help not specific enough.
I've set up my home and work Macs, both with .Mac accounts, to share Address Book. But how do you actually do it? I don't see my work contacts on my home Mac, or vice-versa. Any help would be appreciated.