XML transformation -- abap
Hi Experts, I need help with this XSLT for call transformation. I have defined an internal table and intend to use it as a source for Call Tranformation. But I have Problems to defining my internal table to get the resut of the function transformation.(SAP 4.7)
In my case i have a xml with attibutes and i can't store these attibutes in internal table.
Hope to hear from any of u soon!
CMA
<--XSLT--
>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/abapxml" version="1.0">
<xsl:template match="//Catalog">
<asx:abap xmlns:asx="http://www.sap.com/abapxml">
<asx:values>
<CATALOG>
<!-- Boucle catalogue -->
<xsl:for-each select="EnTete">
<ENTETE>
<EMETTEUR>
<xsl:value-of select="Emetteur"/>
</EMETTEUR>
<DATEPUBLICATION>
<xsl:value-of select="DatePublication"/>
</DATEPUBLICATION>
<!-- Suite -->
<xsl:for-each select="Univers">
<UNIVERS>
<LIBELLE>
<xsl:value-of select="@libelle"/>
</LIBELLE>
<OBJREF>
<xsl:value-of select="@objref"/>
</OBJREF>
<OBJID>
<xsl:value-of select="@objid"/>
</OBJID>
<EMETTEUR>
<xsl:value-of select="Emetteur"/>
</EMETTEUR>
</UNIVERS>
</xsl:for-each>
</ENTETE>
</xsl:for-each>
<!-- ENTETE-->
</CATALOG>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
<--XML--
>
<?xml version="1.0" encoding="UTF-8"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml">
<asx:values>
<Catalog>
<EnTete>
<Emetteur>UGAP</Emetteur>
<DatePublication>27/06/2007 09:20:02</DatePublication>
<Univers libelle="Nettoyage, hygine et entretien" objref="08" objid="374417o.bemp" >
<Emetteur>UGAP</Emetteur>
</Univers>
<Univers libelle="Nettoyage, hygine et entretien" objref="09" objid="374417o.bemp" >
<Emetteur>UGAP</Emetteur>
</Univers>
</EnTete>
</Catalog>
</asx:values>
</asx:abap>
<--abap--
>
TYPES: BEGIN OF t_universs,
libelle(35),
objref(35),
objid(35),
boutique TYPE t_boutique,
END OF t_universs.
TYPES: t_univers TYPE t_universs OCCURS 0.
UNIVERS *
TYPES: BEGIN OF t_entetes,
Emetteur(20),
DatePublication(30),
UNIVERS TYPE t_univers,
END OF t_entetes.
*TYPES: t_entete TYPE t_entetes OCCURS 0.
DATA: it_data TYPE STANDARD TABLE OF t_entetes,
wa_data TYPE t_entetes.
PARAMETER p_file(200) DEFAULT '/tmp/catalogue4.xml' LOWER CASE .
start-of-selection.
DATA: dsn(20) VALUE '/usr/catalogue2.xml',
msg(100).
data : l_sysubrc like sy-subrc.
*OPEN DATASET p_file FOR INPUT MESSAGE msg
IN TEXT MODE ENCODING DEFAULT.
OPEN DATASET p_file FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
CLEAR : gv_read_xml.
clear l_sysubrc.
READ DATASET p_file INTO gv_read_xml.
Transformation XML en ABAP-DATA
PERFORM check_xml USING gv_read_xml.
CLOSE DATASET p_file.
ENDIF.
*& Form check_xml
FORM check_xml USING p_xml TYPE string.
DATA: cx_runtime_error TYPE REF TO cx_xslt_runtime_error.
DATA: cx_format_error TYPE REF TO cx_xslt_format_error.
DATA: err_text TYPE string.
DATA: lt_xml TYPE STANDARD TABLE OF typ_xml,
ls_xml TYPE typ_xml,
source_xml TYPE string,
lt_result_xml TYPE abap_trans_resbind_tab,
ls_result_xml TYPE abap_trans_resbind.
TRY.
CALL TRANSFORMATION ZUGAP
SOURCE XML p_xml
RESULT CATALOG = it_data.
ENDTRY.
LOOP AT it_data INTO wa_data.
ENDLOOP.
i'm wonder if is it possible to get attribute from xml with abap function transformation...
Hope to hear from any of u soon!
Hi Marcelo,
Thanks a lot for your reply, your code is very usefull but my problem is located around the XSLT file.
With my progam (abap), I can't read the attibutes from a XML file correctly because the XSLT have not the suitable tags.
In my XML i have 2 rows of "Univers" and after use the function transformation from abap i can store only 1 rows in internal table :
<Catalog>
<EnTete>
<Emetteur>UBB</Emetteur>
<b><Univers libelle="Nettoyage, hygine et entretien" objref="08">
</Univers>
<Univers libelle="Nettoyage, hygine et entretien" objref="09">
</Univers></b>
</EnTete>
</Catalog>
XSLT :
<xsl:for-each select="EnTete">
<ENTETE>
<EMETTEUR>
<xsl:value-of select="Emetteur"/>
</EMETTEUR>
<xsl:for-each select="Univers">
<UNIVERS>
<UNIVERS1>
<LIBELLE> <xsl:value-of select="@libelle"/></LIBELLE>
<OBJREF> <xsl:value-of select="@objref"/> </OBJREF>
</UNIVERS1>
</UNIVERS>
</xsl:for-each>
</ENTETE>
</xsl:for-each>
My question is : How can i do to define attributes in XSLT to allow read them by a program abap ?
In my example, the program abap get only 1 attribute in my iternal table, what is the suitable syntax in the xslt to read all the attributes ?
Hope to hear from any of u soon!
Christophe.
Similar Messages
-
Simple Transformation - ABAP 2 XML
Dear all,
Finally I was able to transform an internal table to xml using ST. The question is: Can I create different structured XML-files using the same (structured) internal table. Or is there some kind of a 1:1 relationship (between an ITAB structure + XML structure)?
1) Data declaration
TYPES: BEGIN OF ty_curr,
tcurr TYPE tcurr_curr,
gdatu TYPE gdatu_inv,
ukurs TYPE ukurs_curr.
TYPES: END OF ty_curr.
DATA: gt_tcurr TYPE TABLE OF ty_curr.
2) Data selection
Select * into corresponding fields of table gt_tcurr from tcurr where...
3) Transformation ABAP 2 XML
CALL TRANSFORMATION z_tcurr
SOURCE root = gt_tcurr
RESULT XML g_xml_string.
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<tt:serialize>
<rates>
<tt:loop name="line" ref=".ROOT">
<currency>
<tt:value ref="$line.tcurr"/>
</currency>
<date>
<tt:value ref="$line.gdatu"/>
</date>
<rate>
<tt:value ref="$line.ukurs"/>
</rate>
</tt:loop>
</rates>
</tt:serialize>
</tt:template>
</tt:transform>
Result (XML)
<?xml version="1.0" encoding="utf-8" ?>
- <rates>
<currency>USD</currency>
<date>01.01.2010</date>
<rate>-1.1868</rate>
<currency>EUR</currency>
<date>01.01.2010</date>
<rate>-1.1791</rate>
<currency>USD</currency>
<date>02.01.2010</date>
<rate>-1.1864</rate>
<currency>EUR</currency>
<date>02.01.2010</date>
<rate>-1.1864</rate>
</rates>:
so far so good... BUT; if I want to get another XML structure
Example 1) -> sorted by currency
<?xml version="1.0" encoding="utf-8" ?>
- <rates>
<currency>USD
<date>01.01.2010</date>
<rate>-1.1868</rate>
<date>02.01.2010</date>
<rate>-1.1868</rate>
</currency>
<currency>EUR
<date>01.01.2010</date>
<rate>-1.1868</rate>
<date>02.01.2010</date>
<rate>-1.1868</rate>
</currency>
</rates>
Example 2) -> sored by date
<?xml version="1.0" encoding="utf-8" ?>
- <rates>
<date>01.01.2010</date>
<currency>USD</currency>
<rate>-1.1868</rate>
<currency>EUR</currency>
<rate>-1.1868</rate>
<date>02.01.2010</date>
<currency>USD</currency>
<rate>-1.1868</rate>
<currency>EUR</currency>
<rate>-1.1868</rate>
</rates>
How can I achieve output example 1+2 using the same internal table as a source? Is this possible? I guess this can be solved within the transformation, right? Any help appreciated.
Best regards
BennoThanks for all answers so far. Changing the sequence is not a "problem". What I want to achieve is to change hierarchy of the xml. I'll try to explain again with a simple example:
ITAB (structure):
name; birthday; ***; first name
ITAB (content):
Smith; 01.01.1970; M; Paul
Smith; 01.01.1970; F; Stefanie
Smith; 01.02.1980; F; Barbara
White; 01.02.1980; M; Steve
I want to pass the itab exactly the way it is (ok, sorting is allowed). Question: Can I achieve the following XML's using ST? I guess/hope this can be solved with variables/groups/condition statements within the transformation coding?
Example xml- 1) Sorted/Grouped by Name/***
<person>
<name>Smith
<***>M
<birthday>01.01.1970</birthday><first name>Paul</first name>
</***>
<***>F
<birthday>01.01.1970</birthday><first name>Stefanie</first name>
<birthday>01.02.1980</birthday><first name>Barbara</first name>
</***>
</name>
<name>White
<***>M
<birthday>01.02.1980</birthday><first name>Steve</first name>
</***>
</name>
</person>
Exampe xml-2 ) Sorted/Grouped by Birthday (Names only)
<person>
<birthday>01.01.1970
<first name>Paul</first name>
<first name>Stefanie</first name>
</birthday>
<birthday>01.02.1980
<first name>Barbara</first name>
<first name>Steve</first name>
</birthday>
</person> -
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. -
XML to ABAP Structure transformation
Hi SAP,
Can anyone tell how to transform from XML to ABAP structure. The ABAP structure i'm getting in runtime.
Please do the needful.
Thanks in advance
Vinod.using XSLT or ST you can do that check this thread
https://forums.sdn.sap.com/click.jspa?searchID=5585367&messageID=1661688
and also search ABAP forum for more code samples -
Optional attributes in XML to ABAP transformation
Hi,
I have to deserialize (transformation xml to abap) an xml input file.
I want to use SAP ST (Simple Transformations).
This xml format is using attributes
Such attributes can be transformed in ST with
<tt:attribute name="item_id" value-ref="MATNR"/>
I realized 2 problems:
1. If the xml file does not contain every attribute which is in the transformation.
This can be solved by tt:cond
Sample
<tt:cond>
<tt:attribute name="uom" value-ref="BASE_UOM"/>
</tt:cond>
Now attribute uom is optional. Without the tt:cond the ST prragrom would throw exception if it is not in the file.
2. If the xml file contains an attribute which is not used in the transformation.
I tried to use tt:skip but it is not working for "<tt:attribute name= ... value-ref=... name" but only for "<tt:value-ref=...".
I only want to get the values I need out of the parameter list.
How can I achieve this without defining a transformation for every parameter in the xml file?
Thanks and regards
MichaelHi,
thanks for reply. It took me into the right direction. You have to distinguish between elements (ordered structured nodes) and attributes (unordered structured nodes). In my case they are using attributes for the values of a material master.
Here is a snippet (sample of the XML):
<?xml version="1.0" encoding="utf-8"?>
<TcPLMXML>
<TCifEngPart item_id="1-3000-3630-00"
seMaterialType="HALB"
uom="ST"
seWeight="2000.0" seWeightUnit="KG">
</TCifEngPart>
<TCifEngPart item_id="1-30000-41002-00"
seMaterialType="HALB"
uom="ST"
</TCifEngPart>
</TcPLMXML>
and my transformation:
<tt:loop ref="MATERIAL_LIST">
<TCifEngPart>
<tt:attribute name="item_id" value-ref="MATNR"/>
<tt:attribute name="object_name" value-ref="MATL_DESC"/>
<tt:attribute name="seMaterialType" value-ref="MATL_TYPE"/>
<tt:attribute name="uom" value-ref="BASE_UOM"/>
<tt:cond>
<tt:attribute name="seLength" value-ref="LENGTH"/>
<tt:attribute name="seWidth" value-ref="WIDTH"/>
<tt:attribute name="seHeight" value-ref="HEIGHT"/>
</tt:cond>
<tt:skip>
<tt:attribute name="seWeight" />
<tt:attribute name="seVolume" />
</tt:skip>
</TCifEngPart>
</tt:loop>
Length, width and hight are optional in the XML and will be transferred to the corresponding SAP fields if they are in the input file Weight and volume will be ignored.
This means all attributes I don't need I have to put within the tt:skip.
Without this skip the transformation throws an error.
In consequence if the partner system add new attributes I have to enhance the transformation in SAP.
Is there any other way? -
XML Transformation error (ABAP -- XML)
Hi,
I'm getting the foll. error while doing a XML Transformation, Can anyone help me in this regard..
<FIN_WT>56.0</FIN_WT>
<FIN_WT_UNIT>KG</FIN_WT_UNIT>
<ZZQMNUM />
<ZZHOLD />
<ZZDUMATNR
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
The following tags were not closed: asx:abap, asx:values, OUTPUT, item. Error processing resource 'file:///C:/Documents and...
> />
<PSP_NR>U5/0626-HT-193-1-36-344</PSP_NR>
<ZZCRTNAME>ALFI</ZZCRTNAME>
<ZZAPPNAME>ALFI</ZZAPPNAME>
Regards
Jikuare you trying to transform XML to itab?
is the xml well formed one - you can check this by running the xml file in webbrowser, if it doesnt display, then it means the xml is not well formed.
Regards
Raja -
Testing XML Transformation in ABAP
Hi,
I am trying to convert one XML file into ABAP structure.
Once I enter into transformation editor, I am unable to test the transformation.
Please let me know, how can I test the same.
Thanks
NikhilThanks for your response
Here is the complete Scenario
1) we are receiving the XML file as the input to our RFC
2) we are populating the data from XML in to ABAP Structures using the ABAP Transformations.
Bellow is my doubts
I want to know how I can test the transformation passing the XML file as input in Transformation Editor.
Is there any Standard routine or simple procedure in ABAP to convert the XML into ABAP? Simple documentation on transformations will be helpful me.
Is there any direct Transaction code to test the Transformation if so please help me how I can test the Transformation passing the XML file.
Regards
Nikhil.B -
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 -
Create XML transformation in SAP R/3 4.7
Hi Experts,
Kindly let me know the transaction for creating xml transformation in sap r/3 4.7, if there is any.
Though i could not find anything through tstc or se93.
Is there any other way of creating xml transformation in r/3 4.7. There is a tcode STRANS in ecc6.0 but not in 4.7.
Also, please help me resolving this issue of converting abap data to xml file: -
is the following xml structure possible with transformation or by any other method.
<Process_Order>
<item>
<PO Number> PO123334 </PO Number>
<Header_mat> Mat123 </Header_mat>
<BOM>
<PDLabels>
<PDLabel>
<PCode>P123456</PCode>
<Batch>123ABC</Batch>
<Quantity>6000</Quantity>
<PDDCode>1234567890</PDDCode>
</PDLabel>
<PDLabel>
<PCode>P234567</PCode>
<Batch>567DEF</Batch>
<Quantity>6000</Quantity>
<PDDCode></PDDCode>
</PDLabel>
</PDLabels>
<PDCartons>
<PDCarton>
<PCode>P556677</PCode>
<Batch>589GFT</Batch>
<Quantity>1200</Quantity>
<PDDCode></PDDCode>
</PDCarton>
</PDCartons>
</BOM>
</item>
<item>
<PO Number> PO123334 </PO Number>
<Header_mat> Mat123 </Header_mat>
<BOM>
<PDLabels>
<PDLabel>
<PCode>P123456</PCode>
<Batch>123ABC</Batch>
<Quantity>6000</Quantity>
<PDDCode>1234567890</PDDCode>
</PDLabel>
<PDLabel>
<PCode>P234567</PCode>
<Batch>567DEF</Batch>
<Quantity>6000</Quantity>
<PDDCode></PDDCode>
</PDLabel>
</PDLabels>
<PDCartons>
<PDCarton>
<PCode>P556677</PCode>
<Batch>589GFT</Batch>
<Quantity>1200</Quantity>
<PDDCode></PDDCode>
</PDCarton>
</PDCartons>
</BOM>
</item>
</Process_Order>
What i mean to ask is, is the hierarchy to this structural level is attainable using either transfomation or any other alternative.
Thanks a lot in advance !
Shreyaoops the message structure has gone bad ........
What i meant was : --
<Process_Order>
<item>
<PO Number> PO123334 </PO Number>
<Header_mat> Mat123 </Header_mat>
<BOM>
<PDLabels>
<PDLabel>
<PCode>P123456</PCode>
<Batch>123ABC</Batch>
<Quantity>6000</Quantity>
<PDDCode>1234567890</PDDCode>
</PDLabel>
<PDLabel>
<PCode>P234567</PCode>
<Batch>567DEF</Batch>
<Quantity>6000</Quantity>
<PDDCode></PDDCode>
</PDLabel>
</PDLabels>
<PDCartons>
<PDCarton>
<PCode>P556677</PCode>
<Batch>589GFT</Batch>
<Quantity>1200</Quantity>
<PDDCode></PDDCode>
</PDCarton>
</PDCartons>
</BOM>
</item>
</Process_Order> -
File size problem when performing XML Transformation into Excel
Hi All,
We are performing XML Transformation in ABAP which can open in Excel and saving to common share. But the file size of excel is around 50MB. After opening the excel and save with diffrent name the file is getting compressed and its below 1MB. So what kind of settings does we need to make to the transformation code which will create the excel files with less memory/size??
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="AAAAAAA"/>
<tt:root name="BBBBBBBB"/>
<tt:root name="CCCCCCCC"/>
<tt:template>
<?mso-application progid="Excel.Sheet"?>
<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:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<ProtectObjects>True</ProtectObjects>
<ProtectScenarios>True</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
</tt:template>
</tt:transform>
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
</DocumentProperties>
<CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<ContentTypeId dt:dt="string">0x01010049B4763FE606154C9C9BC639FE7EE179</ContentTypeId>
</CustomDocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<Colors>
<Color>
<Index>0</Index>
<RGB>#FF0000</RGB>
</Color>
<Color>
<Index>1</Index>
<RGB>#FFE4B5</RGB>
</Color>
<Color>
<Index>2</Index>
<RGB>#FFF8DC</RGB>
</Color>
<Color>
<Index>3</Index>
<RGB>#000000</RGB>
</Color>
</Colors>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>7305</WindowHeight>
<WindowWidth>11340</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>0</WindowTopY>
<TabRatio>334</TabRatio>
<ProtectStructure>True</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
</DocumentProperties>
<CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<ContentTypeId dt:dt="string">0x01010049B4763FE606154C9C9BC639FE7EE179</ContentTypeId>
</CustomDocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">Hi Raghu,
have a look at the XLSX file generated by Excel, you'll see that it's simply a zipped file. So you can't do it with a transformation, but you need CL_ABAP_ZIP class. I advise you to look at the abap2xslx project ABAP code (currently 3.0) to see how it works.
Best regards,
Sandra -
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. -
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?...
ThanksHi,
I just catch the exception.
Regards,
Mathi -
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. -
Using XSLT to link XML and ABAP data
Hi Experts,
I am using XSLT to deal with XML and ABAP data.
I using the following statement to convert a Internal Table to XML String:
CALL TRANSFORMATION id SOURCE root = lt_sflight RESULT XML l_xml_string.
And I get the XML String:
<?xml version="1.0" encoding="utf-16" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<SFLIGHT>
</SFLIGHT>
<SFLIGHT>
</SFLIGHT>
</ROOT>
</asx:values>
</asx:abap>
But What I expected is:
<?xml version="1.0" encoding="utf-16" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<DATA>
</DATA>
<DATA>
</DATA>
</ROOT>
</asx:values>
</asx:abap>
Could you tell me how to get my dream format using XSLT?
Best Regards,
Guo Guo Qing
Edited by: guoqing guo on Jun 11, 2008 9:58 AMHi Experts,
I am using XSLT to deal with XML and ABAP data.
I using the following statement to convert a Internal Table to XML String:
CALL TRANSFORMATION id SOURCE root = lt_sflight RESULT XML l_xml_string.
And I get the XML String:
<?xml version="1.0" encoding="utf-16" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<SFLIGHT>
</SFLIGHT>
<SFLIGHT>
</SFLIGHT>
</ROOT>
</asx:values>
</asx:abap>
But What I expected is:
<?xml version="1.0" encoding="utf-16" ?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ROOT>
<DATA>
</DATA>
<DATA>
</DATA>
</ROOT>
</asx:values>
</asx:abap>
Could you tell me how to get my dream format using XSLT?
Best Regards,
Guo Guo Qing
Edited by: guoqing guo on Jun 11, 2008 9:58 AM -
Debugging a XML Transformation Program
Hi,
We are converting incoming XML into ABAP structure and checking if the data has any future effective changes. If there is a future effective update, then it is converted back to XML string and stored in a custom table as a XML string. A job which runs picks up the record on the given date and process the changes that are to be applied. We are facing issues during the transformation which happens on this day(effective date. Though the XML string has data when the transformation is called, there is no ABAP output after transformation. Interesting things to note are:
. No Transformation error is thrown
When the same scenario with same XMLs is repeated in other regions(Dev & Quality), there are no issues at all
What I would like to know is
>> Is there any file encoding & xml string conversions issues?
>> is it possible to debug within the transfomation(ie transformation program) We tried STRANS, but were not able?
Any help is this regard is appreciated.
Thanks
GaneshRich,
I tried to do what you suggested but it didn't allow me to stop at the break-point.
Here is why I need to debug the program. Our sales orders just crossed over the number range for ITOs (inter company transfer orders). Where we are including the header text of the sales order it is pulling the header info of the ITO that has the same order number (from the numbers crossing). I need to figure out where/how to pull the header information based on the order type. The Order Confirmation is pulling the correct header text but I am unsure how it is doing that. I need to determine what the text name is from the Order Confirmation. On the Picklist the text name is the sales order number.
I hope that made sense.
Davis
Maybe you are looking for
-
Can I Upgrade to CS5 At All?
Hi, I have been running my Mac version of Creative Suite 2 Premium on both my iMac G5 running Tiger 10.4.11 as well as just the Photoshop & Bridge components on my MacBook Pro (Unibody Late 2009) running Leopard 10.5.8. But I have now installed a com
-
I'm tring to delete the webpage history and it's impsoible. I've done it the way it's told here on the webpage, I've deleted all the cockies etc and they are all gone but the webpages still stays in the search line. I've tried to delete all of it a c
-
I've got the problem of the system I want to add shortcuts for words, but for those who want to be added and saved can not be saved with Alkhtsar I got another system for iPhone I hope to resolve this issue, please as soon as possible because I'm wri
-
The folder that I added to the bookmarks menu has disappeared (along with the subfolders in it). The bookmarks I have that were not organized in a folder (just listed on the bookmarks menu) are still on the bookmarks menu. Tags from the lost bookmark
-
Exporting text only from specific paragraph style
Hi, Is there a way to export text from Indesign to txt or preferably Excel from specific paragraph style ? I am trying to export only item numbers and prices to excel spread sheet so I can compare against original excel spreadsheet. Thank you !