Save Table in XML Automatically
Hello,
I need your help...
I want to get in a oracle db one table in xml format. I saw that we have a ORACLE XML DB package, where I can run "select" to obtain tables in xml. What I wan to do now, it is to save the result in a windows folder automatically, for example each hour. Do you know how can I do that? any idea?
Best Regards.
If you can, could you give an example of stored procedure to save file in the server?Yes, here's an example :
1) Create a directory object
create or replace directory test_dir as 'c:\oracle\test';2) The procedure
CREATE OR REPLACE PROCEDURE getEmployees
IS
xmldoc CLOB;
xmlprolog VARCHAR2(80);
BEGIN
-- builds the XML prolog using the database charset for the encoding
SELECT '<?xml version="1.0" encoding="' || utl_i18n.map_charset(value) || '"?>'
INTO xmlprolog
FROM nls_database_parameters
WHERE parameter = 'NLS_CHARACTERSET'
-- generates the XML document
SELECT XMLSerialize(DOCUMENT
XMLElement("Employees",
XMLAgg(
XMLElement("Employee",
XMLAttributes(empno as "id")
, XMLForest(
ename as "name"
, job as "job"
, hiredate as "hireDate"
order by empno
INTO xmldoc
FROM scott.emp
WHERE deptno = 10
-- writes the document to a file in the directory TEST_DIR
DBMS_XSLPROCESSOR.clob2file(xmlprolog || xmldoc, 'TEST_DIR', 'employees.xml');
END;
/When called, it'll create a file "employees.xml" containing :
<?xml version="1.0" encoding="UTF-8"?>
<Employees>
<Employee id="7782">
<name>CLARK</name>
<job>MANAGER</job>
<hireDate>1981-06-09</hireDate>
</Employee>
<Employee id="7839">
<name>KING</name>
<job>PRESIDENT</job>
<hireDate>1981-11-17</hireDate>
</Employee>
<Employee id="7934">
<name>MILLER</name>
<job>CLERK</job>
<hireDate>1982-01-23</hireDate>
</Employee>
</Employees>(formatted)
Similar Messages
-
After generating a table into xml how can i save the result in a XML table?
Hello everyone,
I’ve used this function to generate a table into XML schema :
example :
SELECT xmlelement("State", xmlattributes( 'http://www.opengis.net/gml' as "xmlns:gml"),
xmlforest(name as "Name", population as "Population")) from state;
result:
<Statexmlns:gml="http://www.opengis.net/gml">
<Name>Wilkopolska</Name>
<Population>35000</Population>
</State>
Now I need to insert the result into a XML table, because i need to save the result to use it latter ,I hope that someone can help and if there's other solution to do this it would be great.
Thanks a ot and best regards,
Lama.Just insert into a table....
insert into t
SELECT xmlelement("State", xmlattributes( 'http://www.opengis.net/gml' as "xmlns:gml"),
xmlforest(name as "Name", population as "Population")) from state; and a complete example:
SQL> create table t (test xmltype)
2 /
Table created.
SQL>
SQL> create table state
2 (name varchar2(10)
3 ,population number
4 )
5 /
Table created.
SQL>
SQL> insert into state values ('WI', 35000)
2 /
1 row created.
SQL>
SQL> SELECT xmlelement("State", xmlattributes( 'http://www.opengis.net/gml' as "xmlns:gml"),
2 xmlforest(name as "Name", population as "Population")) from state;
XMLELEMENT("STATE",XMLATTRIBUTES('HTTP://WWW.OPENGIS.NET/GML'AS"XMLNS:GML"),XMLFOREST(NAMEAS"NAME",P
<State xmlns:gml="http://www.opengis.net/gml"><Name>WI</Name><Population>35000</
SQL>
SQL>
SQL> insert into t
2 SELECT xmlelement("State", xmlattributes( 'http://www.opengis.net/gml' as "xmlns:gml"),
3 xmlforest(name as "Name", population as "Population")) from state;
1 row created.
SQL> select *
2 from t
3 /
TEST
<State xmlns:gml="http://www.opengis.net/gml"><Name>WI</Name><Population>35000</ -
Internal table data 1E2 automatically convert to scientific format
Dear all,
I have been searched for solution moths from the forums and tried all possible methods, but still no way to solve my above problem. I found a way to solve it partially for us, but may be very helpful for others who meet similly case like mine, so I posted here.
my problem is when I export my internal table data to Excel, the Cell data with 1E2 auto becomes 1.00E02, and 1E8 becomes 1.00E08, we need it to be 1E2 and 1E8 in excel.
you can recreate my problem by
1, input 1E2 into your Microsoft Excel, then Enter, it will auto change into scientific format. which is we do not want.
2, use any of your SAP system open any table as long as there is a Char (>3) field in that table. add some
data entry in that field in the form "any amount (<15) of numeric 1 to 9"E"any one or two numeric 1 to 9". such as, 123E2, 1234E12 etc. then save this table's data to local file spread sheet, or use any FM to download it to a Excel file, when you open this
file by Excel, the cell with above form will display as scientific. but
if you put three or more numeric after the "E", such as 123E123 it will
display correctly.
what I have done:
I searched in SCN for similar thread:
Export to Excel 2007 - item number problem
Exceding the limit of numbers in Excel at target side
Excel download cell format problem
Formating as Text in excel through SAP
Converting of amount field into excel file through GUI DOWNLOAD
Data downloaded to excel gets converted to exponential format.
Problem with Excel download and scientific number
Re: Issue in displaying numbers in Excel?
CSV Flat File Data Problem (Number converting to Scientific Notation)
Tested accordingly, But none of these works in our case. because our
ultimate receiver of email attachment will be external third party, we cannot ask
them to change anything in their Excel.
Search Microsoft help about Excel, http://support.microsoft.com/kb/214233,
and it says this "Automatic Number Formatting" is a normal behaviour of excel.
no way to turn it off, the "work-around" way that Microsoft provides is not suitable for our
case.
We test CL_iXML recently arrording to weblog http://wiki.sdn.sap.com/wiki/display/Snippets/FormattedExcelasEmailAttachment
it successful controled the format. so this could be a solution for others whose internal table size is small. but our 2MB internal table bocome 6MB when converted to xml file attachment, which cannot be received by our end user's mail box. too big.
So please advise your ideas.
Many thanks in advance!
Peter Ding
Thank you very much for your time!Hi,
You can achieve this by describing the spreadsheet in XML with the help of the DOM classes.
The later releases of Excel can read and save spreadsheets as XML, providing your release supports this you can achieve it.
Check out the following Wiki
[Excel - XML|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/exporting%2bdata%2bto%2bexcel%2b-%2bxml%2bto%2bthe%2brescue]
Regards,
Darren -
Is Acrobat Pro right for us. We have an Employee Handbook that needs editing. Some is current pdf, some from an older version. Want to get all into one handbook, have the table of contents automatically adjust and link to specific pages from the ToC.
You can download the trial version (http://helpx.adobe.com/acrobat/kb/acrobat-downloads.html) to convert the PDF back to WORD if you do not have the original. The conversion may not be perfect, but it is typically better than starting from scratch. You may be lucky and get a good result. You might check the settings (in the save screen) to try retain format versus retain text flow. The format version can be a pain to edit since it creates a bunch of text boxes. The flow version may require you to reformat in WORD, but you likely would want to do that anyway.
-
Export Internal Table to XML in Background
Hi
I need to export a internal table into xml file in background using open dataset. The file is getting created but i am not able to open the file using IE/XML editor . When i open the file uisng wordpad i can see some charcters at the end of file which prevents it from opening in xml editor. if i delete the characters(box like) and save the file. i am able to open the file
When i downalod the same internal table via frontend using ws_downlod it works pefectly. no junk charcters are appended in the end. and hence files opens perfectly
below is the extract of program
START-OF-SELECTION.
PERFORM get_data.
PERFORM create_xml.
FORM get_data.
REFRESH accesos.
CLEAR accesos.
MOVE: '45050' TO accesos-socio-numero,
'MOISES MORENO' TO accesos-socio-nombre,
'0' TO accesos-socio-reposicion.
APPEND accesos.
ENDFORM.
i am using the following function modules
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
name = 'ACCESOS'
dataobject = accesos[]
IMPORTING
data_as_dom = l_dom
CHANGING
document = m_document
EXCEPTIONS
illegal_name = 1
OTHERS = 2.
CHECK NOT l_dom IS INITIAL.
w_rc = m_document->append_child( new_child = l_dom ).
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
document = m_document
IMPORTING
xml_as_string = w_string
size = w_size
TABLES
xml_as_table = it_xml
EXCEPTIONS
no_document = 1
OTHERS = 2.
LOOP AT it_xml INTO xml_tab-d.
APPEND xml_tab.
ENDLOOP.
The following syntax for open datset which does not work
lv_physcial_file = '
hdat03\test.xml'.
OPEN DATASET lv_physcial_file IN BINARY MODE FOR OUTPUT MESSAGE l_msg.
LOOP AT xml_tab.
TRANSFER xml_tab TO lv_physcial_file.
ENDLOOP.
The ws_download function works
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = GK_RUTA
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
many thnaksHi Chetan,
Can you just try changing the syntax to the following, I not sure if that will help but just try and see.
OPEN DATASET lv_physcial_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
Regards
Mohamed -
Convert data from internal table to XML file.
Hi All,
I am selecting data from database into one internal table.
Now I want to convert data from internal table to xml file format and save in to my desktop. Please suggest me how I can achieve my requirement.
Kindly reply me ASAP.Use this FM. SAP_CONVERT_TO_XML_FORMAT
Check this link too -
Re: Data Export in XML format
XML files from ABAP programs -
Data from table in xml Format and Inserting it into Table
Hi All
I have table where xml data is stored in long format with xml tag know i have read the entire xml xoulmn which is xml tag and insert it into diffrent table can any suggest me the code
Thanks & RegardsI believe you are on the wrong forum. You want the XML DB forum.
See:
XML DB -
Hi,
Iam new to the xml,
can u please anyone help me how to write procedure to load the data into a table using xml as input parameter to a procedure and xml file is as shown below which is input to me.
<?xml version="1.0"?>
<DiseaseCodes>
<Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
</DiseaseCodes>.
Regards,
vikram.here is the your XML parse in 11g :
select *
from xmltable('//Entity' passing xmltype
'<?xml version="1.0"?>
<DiseaseCodes>
<Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
</DiseaseCodes>
') columns
"dcode" varchar2(4000) path '/Entity/dcode',
"ddesc" varchar2(4000) path '/Entity/ddesc',
"reauthflag" varchar2(4000) path '/Entity/reauthflag'
dcode ddesc reauthflag
0 (I87)Other disorders of veins - postphlebitic syndrome 0
0 (J04)Acute laryngitis and tracheitis 0
0 (J17*)Pneumonia in other diseases - whooping cough 0
SQL>
Using this parser you can create procedure as
SQL> create or replace procedure myXMLParse(x clob) as
2 begin
3 insert into MyXmlTable
4 select *
5 from xmltable('//Entity' passing xmltype(x) columns "dcode"
6 varchar2(4000) path '/Entity/dcode',
7 "ddesc" varchar2(4000) path '/Entity/ddesc',
8 "reauthflag" varchar2(4000) path '/Entity/reauthflag');
9 commit;
10 end;
11
12 /
Procedure created
SQL>
SQL>
SQL> exec myXMLParse('<?xml version="1.0"?><DiseaseCodes><Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity></DiseaseCodes>');
PL/SQL procedure successfully completed
SQL> select * from MYXMLTABLE;
dcode ddesc reauthflag
0 (I87)Other disorders of veins - postphlebitic syndrome 0
0 (J04)Acute laryngitis and tracheitis 0
0 (J17*)Pneumonia in other diseases - whooping cough 0
SQL>
SQL>
Ramin Hashimzade -
Error while downloading data from internal table into XML file
hi all,
i developed a program to download data from into internal table to xml file like this.
tables: mara.
parameters: p_matnr like mara-matnr.
data: begin of itab_mara occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
aenam like mara-aenam,
vpsta like mara-vpsta,
end of itab_mara.
data: lv_field_seperator type c, " value 'X',
lv_xml_doc_name(30) type c, " string value my xml file,
lv_result type i.
lv_field_seperator = 'x'.
lv_xml_doc_name = 'my xml file'.
types: begin of truxs_xml_line,
data(256) type x,
end of truxs_xml_line.
types:truxs_xml_table type table of truxs_xml_line.
data:lv_tab_converted_data type truxs_xml_line,
lt_tab_converted_data type truxs_xml_table.
data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
select matnr ernam aenam vpsta from mara into table itab_mara up to 5
rows where matnr = p_matnr.
CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = lv_field_seperator
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
I_XML_DOC_NAME = lv_xml_doc_name
IMPORTING
PE_BIN_FILESIZE = lv_result
TABLES
I_TAB_SAP_DATA = itab_mara
CHANGING
I_TAB_CONVERTED_DATA = lt_tab_converted_data
EXCEPTIONS
CONVERSION_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.
open dataset lv_xml_file for output in binary mode.
loop at lt_tab_converted_data into lv_tab_converted_data.
transfer lv_tab_converted_data to lv_xml_file.
endloop.
close dataset lv_xml_file.
this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
will anyone show me the possible solution to rectify this error
thanks and regards,
anil.Hi,
Here is a small sample program to convert data in an internal table into XML format and display it.
DATA: itab TYPE TABLE OF spfli,
l_xml TYPE REF TO cl_xml_document.
* Read data into a ITAB
SELECT * FROM spfli INTO TABLE itab.
* Create the XML Object
CREATE OBJECT l_xml.
* Convert data in ITAB to XML
CALL METHOD l_xml->create_with_data( name = 'Test1'
dataobject = t_goal[] ).
* Display XML Document
CALL METHOD l_xml->display.
Here are some other sample SAP programs to handle XML in ABAP:
BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
Hope this helps,
Sumant. -
Need some help in saving video message from viber to my Iphone 5S with new ios 8's program . I disabled the thing that would save photos and videos automatically then, there comes a video I want to save. After loading and watching it, I press the "save to gallery" thing but it doesn't save in gallery. I tried all, restarting my phone, rebooting then turning on the save automatically thing and when I watch it again, it still wouldn't save.
Probably a good question to ask Viber or look at their support site.
-
How do I save songs in the Automatically Add to iTunes folder
How do I save songs in the Automatically Add to iTunes folder? Is this done via settings somehow?
Stated another way......songs recently added to my music folders in the iTunes libary are not updated in the media library automatically. How do I save songs in the Automatically Add to iTunes folder?
Still another way......I'm trying to backup songs in my iTunes library by dragging them into a flash drive. But I noticed that not all songs are included in the iTunes Media folder from which I am making my backup file. Is there a better way to do a backup? If not, how do I get the iTunes Media file updated to include all songs in my iTunes library?See this Apple support document.
http://support.apple.com/kb/ht1751
B-rock -
Writing from internal table to xml format
Hi,
I searched all the forum and I have a question on writing the data from internal table in xml format to the file on app.server.
Data: ITAB1 TYPE TABLE OF SPFLI,
L_XML TYPE REF TO CL_XML_DOCUMENT.
SELECT * FROM SPFLI INTO TABLE ITAB1.
CREATE THE XML OBJECT
CREATE OBJECT L_XML.
CONVERT THE DATA TO XML
CALL METHOD L_XML->CREATE_WITH_DATA( DATAOBJECT = ITAB1[] ).
after this how to move the XML data in the object to a file on app.server.
Thanksp_ufile is the path of the application server
p_output is the internal table with data to be moved to app serv.
OPEN DATASET p_ufile FOR OUTPUT IN TEXT MODE.
LOOP AT p_output INTO wa_file.
TRANSFER wa_file TO p_ufile.
CLEAR wa_file.
ENDLOOP.
CLOSE DATASET p_ufile.
for XML I guees the path p_ufile ill be <b>sap/usr/tmp/file.xml</b> -
Converting XML as table to XML as string
All,
I am successfully able to convert XML table from Internal Table. Now, I would like to convert this XML Table into XML string.
Any help on this will be appreciated.
Regards,
Salil
Moderator message: please search for available information/documentation before asking.
Edited by: Thomas Zloch on Dec 7, 2010 11:57 AMHowdy,
CONCATENATE LINES OF lt_table into l_string SEPARATED BY cl_abap_char_utilities=>cr_lf.
This will create a string of the lines of the internal table with a carriage return after each line.
Cheers
Alex -
Hallo Experts,
I have retrived a Internal Table from FM.
CALL FUNCTION 'SRTUTIL_CONVERT_XML_TO_TABLE'
EXPORTING
xdoc = lv_xstring
IMPORTING
* ERROR_TEXT =
data = lt_xml
I have manipulated the Tagnames in the Internal Table lt_xml.
Now I want to change the internal table to xml.
Is there any FM or a class. can anyone help me??
Thanks
Kind regards
rana WaseemHallo,
Thanks for your Reply. I am trying to manipulate the xml attributes in print report. I have the data in xstring form. I have changed it to internal Table with following code.
CALL FUNCTION 'SRTUTIL_CONVERT_XML_TO_TABLE'
EXPORTING
xdoc = lv_xstring
IMPORTING
* ERROR_TEXT =
data = lt_xml
After the change in the table lt_xml I am trying to have once again a xstring to give to the Print Report. I have tried it with class
LOOP AT lt_xml INTO ls_xml.
CALL METHOD cl_soap_xml_helper=>transform_to_xml
EXPORTING
tag_name = ls_xml-tag_name
data = ls_xml-tag_value
data_type = ls_xml-tag_type
ignore_init_value = 'X'
* ignore_exception =
CHANGING
xml = lv_xstring_two
* ENDLOOP.
but when I try to check the XML become an error
The XML cannot be showed, when Stylesheet XSL is used Remove the error and try again.
I cannot understand where is the error. Because the orignal xstring from system is shown correct. But when I create the new xstring give error .
Thanks for your help
kind regards
waseem -
Persist XML Data to Database Table - Generic XML Schema
Hi,
I would like to represent data in XML format and persist to any database tables.
The ideal xml is like:
<TABLE NAME="TABLE1">
<TABLEDEF><COLUMN NAME="COLUMN1"/><COLUMN NAME="COLUMN2"/></TABLEDEF>
<ROW><COLUMN VALUE="value1"/><COLUMN VALUE="value2"/></ROW>
<ROW><COLUMN VALUE="value11"/><COLUMN VALUE="value22"/></ROW>
</TABLE>
<TABLE NAME="TABLE2">
</TABLE>
The XML could then be parsed, and saved to database with JDBC by manually composing the statement strings.
To reduce the coding effort (xml parsing, JDBC connection, etc), are there any open source projects available to achieve the above purpose? The popular O/R mapping tools like Hibernate, Castor, etc, can't handle this scanario because they require the knowledge of the tables on the server side in order to create the mapping files in advance.
Thanks for the help!Hi,
I would like to represent data in XML format and persist to any database tables.
The ideal xml is like:
<TABLE NAME="TABLE1">
<TABLEDEF><COLUMN NAME="COLUMN1"/><COLUMN NAME="COLUMN2"/></TABLEDEF>
<ROW><COLUMN VALUE="value1"/><COLUMN VALUE="value2"/></ROW>
<ROW><COLUMN VALUE="value11"/><COLUMN VALUE="value22"/></ROW>
</TABLE>
<TABLE NAME="TABLE2">
</TABLE>
The XML could then be parsed, and saved to database with JDBC by manually composing the statement strings.
To reduce the coding effort (xml parsing, JDBC connection, etc), are there any open source projects available to achieve the above purpose? The popular O/R mapping tools like Hibernate, Castor, etc, can't handle this scanario because they require the knowledge of the tables on the server side in order to create the mapping files in advance.
Thanks for the help!
Maybe you are looking for
-
Help , if there exists a Function Module
Hello everybody, I want a help whether SAP has some Function Module which can take an "Internal Table" as an Import Parameter and give us "CSV File" as an export parameter , more-or-less like the "GUI_DOWNLOAD" Function Module , which downloads th
-
File- XI- Multiple IDOCs scenario
Hi, I am working on File->XI->IDOC scenario. I have a single source file and I need to map it to two IDOCs and post them to ECC. The order of posting is not an issue since it is taken care of by ECC. I need help (detailed) on achieving this in the be
-
How to retrieve the node on which is running an ejb ?
Hi all, I need to retrieve on which node is running and EJB that is deployed on the cluster. Since the cluster is made up of logical addresses on the same machine, I cannot get it with InetAddress.getHostName()
-
Hi, I am using CR 2008. I have a crosstab where I need to show sales for Current & Prior year for Current Week(CW) through 4 previous weeks. I also need a Rolling average of Sales for 8 Previous Weeks from CW. I need to place this field right next
-
i Have an iMac 27 Late 2012 model and it has Mavericks installed. i've never experienced any problems with software up until a few days ago. i have a few apps tht dont want to open up. App Store, Quicktime, Picture Preview, Terminal. can someone help