Deleting XML element in ABAP mapping
hi All
I Have I huge xml filen that has to go to an Idoc , but I only want to use the header data.
is there a way of deleting the unwanted xml elements and their children elements in ABAP mapping.
Thanks.
Hi Ravi and all
Actually I did as you said, but I get this error.
<Trace level="1" type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
XMLParser: Prefix 'ns1' is not mapped to a namespace(:main:, row:177, col:25)
This position 177 , is the element that is not needed , so I thought if I can delete it , I can get rid of this error and move forward.
May be you have antoher suggestion to get rid of this error.
Thank you.
Similar Messages
-
File to IDoc : XML parsing in ABAP mapping
Hi,
In ABAP mapping I want to parse all of the incoming XML strings to internal table.Later I add few more fields to this table and transfer them to IDOC adapter in IDOC-XML format.In thsi case how do i get all of the input file data(converted from XML) into internal table using XML parsing in ABAP Mapping?
Thansk in advance,
RPHi Amil,
I insert into table but not immediately,I want all the parsed xml data into internal table and do something before I insert into DB /send it to IDOC.
I knwo how to get single Xml parsing,but how to get multple records(looping xml parse) to internal table?
Thanks,
RP
Edited by: RP@261 on Jun 3, 2009 2:14 PM -
Checking Well-Formed XML files with ABAP Mapping
Hi guys,
Anybody knows which is the best way to check (well-formed) incoming XML files trough XI?
Im using ABAP Mapping and before I check the value of the XML fields I want to check if the XML is well-formed. For this reason I need to know which is the class or classes that I need to use to checking the format of XML using an XSD file?
That is also possible using a DTD file instead of XSD?
Which is better XSD or DTD?
Thanks in advance,
Ricardo.Hi Ricardo,
try out these links.
/people/r.eijpe/blog/2005/11/04/using-abap-xslt-extensions-for-xi-mapping
/people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi
/people/sap.user72/blog/2003/09/18/xsl-and-abap
Thanks and Regards
Vishal Kumar -
Delete xml element not used in document
Hi,
If you have a number of texts tagged with an xml element and then delete the text, the element still exist in the structure.
You can see the element still connected to a text, by the blue diamond on the element symbol.
But i want do delete the elements that have no connection to texts, but cant find the right property to look for.
In Java script CS4.
Anyone knows?
/MikaelIf the (text) element is unplaced, its parentStory will be an XmlStory rather than a Story.
So try:
var elements = app.activeDocument.xmlElements[0].xmlElements.everyItem().getElements();
for (var i = elements.length - 1;i >= 0;i--){
if(elements[i].parentStory.constructor.name === "XmlStory"){
elements[i].remove();
This is untested. If you have tagged graphics frames it will need to be modified to not error on those.
Jeff -
Getting XML info with ABAP mapping
Hi everyone.
I'm near to finish my abap mapping demo. The problem is that i don't know how i can retrieve the values of a kind of node.
I would like to retrieve this data into a internal table. I've done the output XML.
How can i get that values from SOURCE parameter into an internal table?
Regards.Hi!
First of all you have a little bit of XML parsing to do using the SIXML package in ABAP (see example reports in same dev class).
Then you can travers your "document" with methods like
get_elements_by_tag_name or get_root_element.
There are also 2 function modules to convert a document into an ABAP internal table.
SDIXML_DATA_TO_DOM and SDIXML_DOM_TO_DATA.
Regards
Michael -
I have a query here
SELECT XMLELEMENT("emp",CHR(10),chr(9),XMLELEMENT("empno",XMLATTRIBUTES(EMPNO AS "value"),CHR(10),chr(9),null),CHR(10)) FROM EMP
WHERE EMPNO=7369
the output is
<emp> <empnovalue="7369">
</empno>
</emp>
here I dont want to show </empno>
my output shold be like this
<emp> <empnovalue="7369">
</emp>
Please help me.
Thanks.my output shold be like this
<emp>
<empno value="7369"/>
</emp>
SQL> SELECT XMLELEMENT ("emp", XMLFOREST (XMLELEMENT ("empno", xmlattributes (empno "value")) "empno", NULL AS "empno").EXTRACT ('empno/*')).extract('*') xml
FROM emp
WHERE empno = 7369
XML
<emp>
<empno value="7369"/>
</emp>
1 row selected. -
Get fields of XML structure in abap mapping
Hi,
I have next structure:
get_next( ).
endwhile.
But it returns all fields of a node: all fields of EAN or all fields of LIN in a string without structure.
How can I get each value of codigo, ean, desc ?
Thanks, in advance.
CarmeHI,
Can u please go through the below odf for help.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5c46ab90-0201-0010-42bd-9d0302591383
Thnx
Chirag
Reward points if it helps. -
How to write a log using abap mapping
Hi all.
in PI 7.1 environment I need to use abap mapping and I wish to write some XML data into a table that I created for logging the data.
I know that using the abap mapping I can parse an XML file. My question is how to write this table defining a specific method, if it is necessary.
Any help or suggestion is well appreciated.
Many thanks in advance for your kind cooperation.
Regards,
Giovannihi,
>> My question is how to write this table defining a specific method, if it is necessary.
just like to normal table (insert statement)
parse XML and get the data you need and just insert into the DB table
there are many tutorials showing how to parse xml file inside abap mapping
so just do a little search on sdn
Regards,
Michal Krawczyk -
on release function i am inserting this value
"(&-box*&", "&*box-&
" in to my text box,
in text box will display like this (squarebox), when i am
trying to delete
squarebox ,
box deleting but
(&-box*&", "&*box-&
these xml elements are showing , what i have to
do ? it has to delete,
it amy have multipule box in my equation. how do delete xml
elements in this case, this is my xml code. how to delete? any one
can help me?Then you should provide more details on what you want this new script should do.
To "delete XML tags in already tagged text", all you need is use the "untag" command on an XML Element. But how would the script "know" what XML Element should be untagged?
Disclaimer: This reply is in no way enforceable, legally binding, a promise or contract, an agreement (written, verbal, or otherwise), a commitment, obligation, or free or paid-for offer of any kind to further help, guide, aid, tip, or not hinder you, or contribute to, correct, investigate, comment on or assist with any existing, forthcoming, or planned project. -
XSLT samples for XML- ABAP mapping
Hi all,
Does anyone have a XSLT samples for XML->ABAP mapping ?
regardsfirst create XSLT program by copy pasting the below given code and give the program name as "Y_TEST"
<b>XSLT code</b>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>
<xsl:template match="NewDataSet">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<OUTTAB>
<xsl:for-each select="Table">
<OUTTAB1>
<AIRPORTCODE>
<xsl:value-of select="AirportCode"/>
</AIRPORTCODE>
<CITYOFAIRPORTNAME>
<xsl:value-of select="CityOrAirportName"/>
</CITYOFAIRPORTNAME>
<COUNTRY>
<xsl:value-of select="Country"/>
</COUNTRY>
<COUNTRYABBRIVATION>
<xsl:value-of select="CountryAbbrviation"/>
</COUNTRYABBRIVATION>
<COUNTRYCODE>
<xsl:value-of select="CountryCode"/>
</COUNTRYCODE>
<GMTOFFSET>
<xsl:value-of select="GMTOffset"/>
</GMTOFFSET>
<RUNWAYLENGTHFEET>
<xsl:value-of select="RunwayLengthFeet"/>
</RUNWAYLENGTHFEET>
<RUNWAYELEVATIONFEET>
<xsl:value-of select="RunwayElevationFeet"/>
</RUNWAYELEVATIONFEET>
<LATITUDEDEGREE>
<xsl:value-of select="LatitudeDegree"/>
</LATITUDEDEGREE>
<LATITUDEMINUTE>
<xsl:value-of select="LatitudeMinute"/>
</LATITUDEMINUTE>
<LATITUDESECOND>
<xsl:value-of select="LatitudeSecond"/>
</LATITUDESECOND>
<LATITUDENPEERS>
<xsl:value-of select="LatitudeNpeerS"/>
</LATITUDENPEERS>
<LONGITUDEDEGREE>
<xsl:value-of select="LongitudeDegree"/>
</LONGITUDEDEGREE>
<LONGITUDEMINUTE>
<xsl:value-of select="LongitudeMinute"/>
</LONGITUDEMINUTE>
<LONGITUDESECONDS>
<xsl:value-of select="LongitudeSeconds"/>
</LONGITUDESECONDS>
<LONGITUDEEPERW>
<xsl:value-of select="LongitudeEperW"/>
</LONGITUDEEPERW>
</OUTTAB1>
</xsl:for-each>
</OUTTAB>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:stylesheet>
<b>just create a type 1 program and paste the below given code.</b>
report y_consume_webservice .
data: wf_user type string .
data: wf_password type string .
types: begin of outtab1 ,
airportcode(6) ,
cityofairportname(50),
country(30) ,
countryabbrivation(10),
countrycode(6) ,
gmtoffset(10) ,
runwaylengthfeet(15),
runwayelevationfeet(15),
latitudedegree(10) ,
latitudeminute(10) ,
latitudesecond(10) ,
latitudenpeers(10) ,
longitudedegree(10) ,
longitudeminute(10) ,
longitudeseconds(10) ,
longitudeeperw(10) ,
end of outtab1 .
data: outtab type table of outtab1.
data: wf_o like line of outtab .
data: g_okcode like sy-ucomm .
data: my_container type ref to cl_gui_custom_container .
data: g_dock type ref to cl_gui_docking_container .
data: mygrid type ref to cl_gui_alv_grid .
data: wf_field_cat type lvc_t_fcat .
data: wf_field_cat_wa like line of wf_field_cat ,
wf_is_layout type lvc_s_layo .
data: wf_fld_cat type slis_t_fieldcat_alv .
data: wf_fld_cat_wa like line of wf_fld_cat .
data: wf_repid like sy-repid .
data: int_tab_name type slis_tabname .
data: xslt_err type ref to cx_xslt_exception .
constants:
* encoding for download of XML files
encoding type string value 'utf-8' .
data: rlength type i,
txlen type string .
data: http_client type ref to if_http_client .
data: wf_string type string .
data: wf_string1 type string .
data: wf_proxy type string ,
wf_port type string .
selection-screen: begin of block a with frame .
parameters: uri2(132) type c lower case .
selection-screen skip 1.
parameters: user(50) lower case,
password(50) lower case ,
p_proxy(100) lower case default 'proxy.xxx.com' ,
p_port(4) default '80'.
selection-screen: end of block a .
at selection-screen output.
loop at screen.
if screen-name = 'PASSWORD'.
screen-invisible = '1'.
modify screen.
endif.
endloop.
start-of-selection .
clear wf_string .
concatenate
'<?xml version="1.0" encoding="utf-8"?>'
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
'<soap:Body>'
'<GetAirportInformationByCountry xmlns="http://www.webserviceX.NET">'
'<country>' uri2 '</country>'
'</GetAirportInformationByCountry>'
'</soap:Body>'
'</soap:Envelope>'
into wf_string .
clear :rlength , txlen .
rlength = strlen( wf_string ) .
move: rlength to txlen .
clear: wf_proxy, wf_port .
move: p_proxy to wf_proxy ,
p_port to wf_port .
call method cl_http_client=>create
exporting
host = 'www.webservicex.net'
service = '80'
scheme = '1'
proxy_host = wf_proxy
proxy_service = wf_port
importing
client = http_client.
http_client->propertytype_logon_popup = http_client->co_disabled.
wf_user = user .
wf_password = password .
call method http_client->authenticate
exporting
proxy_authentication = 'X'
username = wf_user
password = wf_password.
call method http_client->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.
call method http_client->request->set_header_field
exporting
name = '~server_protocol'
value = 'HTTP/1.1'.
call method http_client->request->set_header_field
exporting
name = '~request_uri'
value = '/airport.asmx'.
call method http_client->request->set_header_field
exporting
name = 'Content-Type'
value = 'text/xml; charset=utf-8'.
call method http_client->request->set_header_field
exporting
name = 'Content-Length'
value = txlen.
call method http_client->request->set_header_field
exporting
name = 'SOAPAction'
value = 'http://www.webserviceX.NET/GetAirportInformationByCountry'.
call method http_client->request->set_cdata
exporting
data = wf_string
offset = 0
length = rlength.
call method http_client->send
exceptions
http_communication_failure = 1
http_invalid_state = 2.
call method http_client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
clear wf_string1 .
wf_string1 = http_client->response->get_cdata( ).
replace all occurrences of
'<' in wf_string1 with '<' .
replace all occurrences of
'>' in wf_string1 with '>' .
replace all occurrences of
'xmlns=' in wf_string1 with 'xmlns:xsl=' .
try .
call transformation (`Y_TEST`)
source xml wf_string1
result outtab = outtab.
catch cx_xslt_exception into xslt_err.
data: s type string.
s = xslt_err->get_text( ).
write: ': ', s.
stop.
endtry .
break-point .
Try this and give me your feedback.
Regards
Raja -
Processing xml in abap mapping
Hi all,
I use abap mapping to create XML from Idoc, I use if_ixml interface to do it.
In my code I use method get_elements_by_tag_name (on object if_ixml_document)
to find all elements with the same name:
I checked my mapping in SXI_MAPPING_TEST and it is working when I put formatted idoc
(with many lines, one tag in one line).
But when I put one long line with all tags in one line (XI receives idoc in such format from ECC)
method get_elements_by_tag_name does not return any result.
I checked also others searching methods but without results.
It looks like only first 255 characters are processed. When element, which I am looking for,
is in further position, it is not finding.
Does anyone know what is a root cause of such situation and how can I resolve my problem?
Best Regards,
PrzemekHi,
get_elements_by_tag_name work fine for all my abap mappings so you must be doing wrong something else
the code from this page works for IDOCs also:
http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm
with small changes to the nodes so maybe compare it with yours
Regards,
Michal Krawczyk -
ABAP mapping XML inside another XML
<b>Cross posted to ABAP Objects</b>
From XI we want to make an abap mapping.
The input xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:mt_dummy xmlns:ns0="http://kmd.dk/phh/externalEventEngine/pfhaen">
<details>
<Navn>Nielsen</Navn>
<Adresse><![CDATA[><?xml version="1.0" encoding="UTF-8"?><ns0:mt_dummy2 xmlns:ns0="http://kmd.dk/phh/externalEventEngine/pfhaen"><Details2><Vej>tingvej</Vej><Husnr>75</Husnr></Details2></ns0:mt_dummy2>]]></Adresse>
</details>
</ns0:mt_dummy>
One of the fields in this structure <Adresse> contains another xml structure. It is this structure we want as a result of our ABAP mapping. First we get the value of the field <Adresse>. This field contains the actual xml structure that we want to map. We convert the structure to xstring and run it through a new parser and create our output document.(See code below).
The code works fine if we just use a normal xml structure, but when one of the fields contains a XML structure and we want to parse this structure, we get the error. Is there anything we have missed, or is this not possible in ABAP mapping ?
If we test the code with SXI_MAPPING_TEST we get no errors, but in runtime we get the following error in SXMB_MONI:
The XML page document can not be shown
The XML document must have an element at the top level
method IF_MAPPING~EXECUTE.
initialize xml
type-pools: ixml.
class cl_ixml definition load.
*create main factory
data: ixmlfactory type ref to if_ixml.
ixmlfactory = cl_ixml=>create( ).
*create stream factory
data: streamfactory type ref to if_ixml_stream_factory.
streamfactory = ixmlfactory->create_stream_factory( ).
*create input stream
data: istream type ref to if_ixml_istream.
istream = streamfactory->create_istream_xstring( source ).
*initialize input document
data: idocument type ref to if_ixml_document.
idocument = ixmlfactory->create_document( ).
*parse input document
data: iparser type ref to if_ixml_parser.
iparser = ixmlfactory->create_parser( stream_factory = streamfactory
istream = istream
document = idocument ).
iparser->parse( ).
data: pnode type ref to if_ixml_node,
pnode2 type ref to if_ixml_node,
pnode3 type ref to if_ixml_node.
data: l_blob type string,
l_xml type string,
l_length type i.
pnode = idocument.
pnode2 = pnode->get_first_child( ).
pnode2 = pnode2->get_first_child( ).
pnode2 = pnode2->get_last_child( ).
l_blob = pnode2->get_value( ).
data: l_blob2 type xstring.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = l_blob
MIMETYPE = ' '
ENCODING =
IMPORTING
BUFFER = l_blob2
EXCEPTIONS
FAILED = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*2. parse
*create main factory
data: ixmlfactory2 type ref to if_ixml.
ixmlfactory2 = cl_ixml=>create( ).
*create stream factory
data: streamfactory2 type ref to if_ixml_stream_factory.
streamfactory2 = ixmlfactory2->create_stream_factory( ).
*create input stream
data: istream2 type ref to if_ixml_istream.
istream2 = streamfactory2->create_istream_xstring( l_blob2 ).
*initialize input document
data: idocument2 type ref to if_ixml_document.
idocument2 = ixmlfactory2->create_document( ).
*parse input document
data: iparser2 type ref to if_ixml_parser.
iparser2 = ixmlfactory2->create_parser( stream_factory = streamfactory2
istream = istream2
document = idocument2 ).
iparser2->parse( ).
data: odocument type ref to if_ixml_document.
odocument = idocument2.
data: irc type i.
*render document----
*create output stream
data: ostream type ref to if_ixml_ostream.
ostream = streamfactory2->create_ostream_xstring( result ).
*create renderer
data: renderer type ref to if_ixml_renderer.
renderer = ixmlfactory2->create_renderer( ostream = ostream
document = odocument ).
irc = renderer->render( ).
endmethod.Hey,
It seems like the output is not a valid XML,
(I guess that the input XML is different from your test).
XML must have one element at the top level,
for example:
<A>
Ilan
</A>
<B>
Shani
</B>
is not a valid XML,
A valid XML should look like:
<mt_dummy>
<A>
Ilan
</A>
<B>
Shani
</B>
</mt_dummy>
In order to see the in-valid XML, press on the right-click mouse on the i.e error text,
and chose "view source". -
How to convert xml file into internal table in ABAP Mapping.
Hi All,
I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
<BookingCode>2KY34R</BookingCode>
- <Passenger>
<Name>SARVESH</Name>
<Address>THANE</Address>
</Passenger>
- <Passenger>
<Name>RAJESH</Name>
<Address>POWAI</Address>
</Passenger>
- <Passenger>
<Name>CARRON</Name>
<Address>JUHU</Address>
</Passenger>
- <Flight>
<Date>03/03/07</Date>
<AirlineID>UA</AirlineID>
<FlightNumber>125</FlightNumber>
<From>LAS</From>
<To>SFO</To>
</Flight>
</ns0:MTO_ABAP_MAPPING>
AT the receiver side I wnat to concatenate the NAME & ADDRESS.
I tried Robert Eijpe's weblog (/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach)
but couldnt succeed to convert the xml file into internal table perfectly.
Can anybody help on this.
Thanks in advance!!
SarveshHi Sarvesh,
The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
Just in case you have not seen this
regards
Vijaya -
XML to internal table conversion within ABAP mapping class
I am doing a ABAP mapping for file to Idoc. My requirement is to convert XML file into ABAP internal table (within ABAP mapping class). Is there any standard FM, method, transformation etc, which can be used here.
Thanks, DehraDehra,
Have you seen this weblogs which talks about this:
/people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
/people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
/people/r.eijpe/blog/2006/02/20/xml-dom-processing-in-abap-part-iiib150-xml-dom-within-sap-xi-abap-mapping
Hope this helps you....
---Satish -
XML to ABAP - where the ABAP mapping?
Dear experts,
I have to do an ABAP mapping which I have never done before.
I found blog:
/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
which shows the ABAP code.
I use PI 7.1
Questions:
- But where in XI/PI do I implement this code?
- How can I test the code while I write it?
- Can I pick up the XML file to map from an FTP server?
Thank you very much for your help!
Best regards,
PeterHi,
I dont think you really need to develop ABAP Mapping , you can achive this requirement using standard Graphical Mapping.
But let me know which IDoc/rfc or table you want to update information.
if it is bapi use RFC IDoc go with IDoc adapter.
elase try with proxies.
normally it is not a best practive to implement ABAP Mapping,sometimes you experience perfromace issues.
Regards,
Raj
Maybe you are looking for
-
Gnome 3.10: New naulilus windows no longer cascade
Hi, I'm not sure whether this change in behavior happened with Gnome 3.8 or 3.10, but here goes: Whenever I open a new nautilus window, the window no longer opens in cascade. Instead, it always opens up in top left corner of the desktop. So instead o
-
I can't find where to download the creative cloud
so i started out with the free trial and then signed up for the monthly plan. I tried to open photoshop on my desktop and it kept saying my free trial was over. I uninstalled it and illustrator but couldn't download them again. It said in the creativ
-
My podcasts are not showing the latest episodes in the iTunes store
Hi All, The latest episodes of two of my podcast feeds have not yet updated in the iTunes store; both feeds had episodes posted Friday, May 10th but the new episodes are not yet appearing in the store directory. Does anyone have any idea why this mig
-
Find SCN number of a transaction
Is it possible to find SCN number of a transaction made yesterday?
-
[..\..\Src\EMS\WSEMUtil.cpp-675] keeps popping up when i try to open adobe premiere elements 12? before this it wouldn't launch and kept showing the launch screen, but wouldn't launch.