Why we need to conver Context Node data into XML file----Export to Excel
Hi All,
Let me clarify my dought........today i have gone through the concept of "Exporting Context Data Using the Webdynpro Binary cache" in SAP Online Help.
From the SAP Online Help pdf document, i have found that, the context node data has been converted first in to XML file,after that file had been stored in the web dynpor binary cache...bla....bla.........
Here my qtn is why they had converted context node data into XML file. With out doing that can not we export context node data to excel file..?
Regards
Seshu
Edited by: Sesshanna D on Dec 19, 2007 7:25 AM
Hi Sesshanna,
it is not neccessary to do that but xml has the advantage, that it can be easily transformed into every output format that might occur in later project stages.
If it's simply about blowing out some Excel, I suggest using an OSS library such as jexcelAPI or Jakarta POI and building the Excel how you need it.
regards,
Christian
Similar Messages
-
How to conver the oracle data into xml files
Hi All,
I have a table for ex emp, now i want to generate every row into an xml file. could anyone pls help...
ex:- emp table
eno ename sal
1 bond 3000
2 kiran 2000
3 jai 1000
4 henry 500
o/p :- i have to get a column in 4 different files for this 4 rows.
1.xml file should contain data <ID>1</ID><eNAME>bond</eNAME><sal>3000</sal>
2.xml file should contain data <ID>2</ID><eNAME>kiran</eNAME><sal>2000</sal>
3.xml file should contain data <ID>3</ID><eNAME>jai</eNAME><sal>1000</sal>
4.xml file should contain data <ID>1</ID><eNAME>bond</eNAME><sal>500</sal>
regards,
Badri.You can do it like this :
begin
for r in (
select empno
, xmlserialize(content xmlforest(empno as "ID", ename, sal)) as xmlcontent
from scott.emp
loop
dbms_xslprocessor.clob2file(r.xmlcontent, 'TEST_DIR', to_char(r.empno) || '.xml');
end loop;
end; -
Outbound oracle data into xml file
Hi Odie,
Your previous inputs for xml inbound was working fine, in the similar way now I need outbound the oracle apps data into .xml file format. For that I've written one sample script like this. I thought of making use of the utl_file option in Oracle apps.
declare
l_log_handle UTL_FILE.FILE_TYPE;
l_log_name varchar2(50);
l_path_2 varchar2(40);
l_global_file varchar2(50);
l_time number:=1;
cursor cur1 is
select xmltype(cursor(select * from fnd_menus where rownum <101)) a from dual;
--select menu_id from fnd_menus where rownum<100;
begin
BEGIN
SELECT DECODE (INSTR (VALUE, ','),
0, VALUE,
SUBSTR (VALUE, 1, (INSTR (VALUE, ',', 1)) - 1)
INTO l_path_2
FROM v$parameter
WHERE NAME = 'utl_file_dir';
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error while getting Unix Path ' || SQLERRM);
END;
l_log_name := 'XGBIZ_'||TO_CHAR (SYSDATE, 'YYMMDD')||l_time;
l_log_name := CONCAT(l_log_name,'.xml');
l_global_file := l_log_name;
l_log_handle := UTL_FILE.FOPEN(l_path_2,l_log_name,'W');
for cur2 in cur1 loop
UTL_FILE.PUT_LINE(l_log_handle, cur2);
end loop;
utl_file.fclose_all;
EXCEPTION
WHEN UTL_FILE.INVALID_OPERATION THEN
dbms_output.put_line('Invalid Operation For '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_PATH THEN
dbms_output.put_line('Invalid Path For '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_MODE THEN
dbms_output.put_line('Invalid Mode For '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
dbms_output.put_line('Invalid File Handle '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.WRITE_ERROR THEN
dbms_output.put_line('Invalid Write Error '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.READ_ERROR THEN
dbms_output.put_line('Invalid Read Error '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INTERNAL_ERROR THEN
dbms_output.put_line('Internal Error');
UTL_FILE.FCLOSE_ALL;
WHEN OTHERS THEN
dbms_output.put_line('Other Error '||'SQL CODE: '||SQLCODE||' Messg: '||SQLERRM);
UTL_FILE.FCLOSE_ALL;
end;
when running this script I am getting error
ERROR at line 30:
ORA-06550: line 30, column 2:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 30, column 2:
PL/SQL: Statement ignored
if in the cursor declaration happen to use 'select menu_id from fnd_menus ' a plain record then it is successfully creating.
If tried again revert to actual select statement ' select xmltype(cursor(select * from fnd_menus where rownum <101)) a from dual'
then its erring out as above said.
Please give me your valuable inputs in this regard.
Thanks & Regards
NagendraHi,
There are multiple ways to generate XML documents from relational data.
Here are some :
-- SQL/XML functions : XMLElement, XMLAgg, XMLAttributes etc.
-- DBMS_XMLGEN package
select dbms_xmlgen.getXML('SELECT * FROM scott.emp')
from dual;-- XMLType constructor over a REF CURSOR (the one you chose)
select xmlserialize(document
xmltype(
cursor(
select *
from scott.emp
as clob
from dual;-- From a DBUriType
select xmlserialize(document
dburitype('/SCOTT/EMP').getXML()
as clob
from dual;-- From XQuery using ora:view function
select xmlserialize(document
xmlquery('<ROWSET>{ora:view("SCOTT","EMP")}</ROWSET>' returning content)
as clob indent size = 1
from dual;If a column is NULL in the result set, those methods (except XMLElement) won't create the corresponding element.
There's an option available for the XQuery method, but only in version 11.2.
So if you want to output empty elements, you'll have to use DBMS_XMLGEN with setNullHandling method :
DECLARE
ctx DBMS_XMLGEN.ctxHandle;
v_out CLOB;
rc SYS_REFCURSOR;
BEGIN
OPEN rc FOR
SELECT *
FROM scott.emp
ctx := DBMS_XMLGEN.newContext(rc);
DBMS_XMLGEN.setNullHandling(ctx, DBMS_XMLGEN.EMPTY_TAG);
v_out := DBMS_XMLGEN.getXML(ctx);
DBMS_XMLGEN.closeContext(ctx);
CLOSE rc;
DBMS_XSLPROCESSOR.clob2file(v_out, 'TEST_DIR', 'test_out.xml');
END;
I thought of making use of the utl_file option in Oracle apps.You could, but you might find DBMS_XSLPROCESSOR.clob2file procedure more convenient for that (see above).
All you have to do is serializing the XML in a CLOB variable, and call the procedure.
WHERE NAME = 'utl_file_dir';The "utl_file_dir" init. parameter is deprecated since 10g, use directory objects instead. -
How to download internal table data into xml file?
Hi,
Experts,
I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
Thank you,
Shabeer ahmed.check this
data : gd_repid type sy-repid.
GD_REPID = SY-REPID.
DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
data : l_element type ref to if_ixml_element,
xml_ns_prefix_sf type string,
xml_ns_uri_sf type string.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'REPAIRDATA'
DATAOBJECT = IT_FINAL_LAST1[]
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 ).
*Start of code for Header
* namespace
t_mnr = sy-datum+4(2).
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
LANGU = 'E'
MONTH = t_mnr
IMPORTING
T247 = wa_t247
concatenate sy-datum+6(2)
wa_t247-ktx
sy-datum(4) into t_var1.
concatenate sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2) into t_var2.
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
l_element = m_document->get_root_element( ).
xml_ns_prefix_sf = 'TIMESTAMP'.
concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
clear : t_var1,
t_var2,
t_mnr,
wa_t247.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'FILECREATOR'.
xml_ns_uri_sf = 'SAP'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMGROUP'.
xml_ns_uri_sf = '1'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
clear : xml_ns_prefix_sf,
xml_ns_uri_sf.
xml_ns_prefix_sf = 'CLAIMTYPES'.
xml_ns_uri_sf = 'W'.
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = ' '
value = xml_ns_uri_sf ).
*End of Code for Header
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.
*Start of Code for File name
concatenate p_file
'\R'
'000_119481'
sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
sy-uzeit(2) sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
*End of Code for File name
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = p_file
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Hi all,
I am extracting data from one table into an XML file using a procedure.
This procedure is executing fine.
But one problem is that, once the file size get 34KB, no more data is writing into that file.
No exceptions also. I can see the partial data in that XML file.
Please share your inputs.
Thanks
Rajeev.Sure...
CREATE OR REPLACE PROCEDURE extractToXML(pTname varchar2,rowSettag varchar2,rowTag varchar2,filename varchar2)
IS
BEGIN
declare
v_ctx dbms_xmlquery.ctxtype;
v_file utl_file.file_type;
v_xml clob;
v_more boolean := true;
BEGIN
-- create xml context.
v_ctx := dbms_xmlquery.newcontext('select * from '||pTname);
dbms_xmlquery.setRowSetTag(v_ctx,rowSettag);
dbms_xmlquery.setRowTag(v_ctx,rowTag);
v_xml := dbms_xmlquery.getxml(v_ctx);
dbms_xmlquery.closecontext(v_ctx);
-- output html document to file
v_file := utl_file.fopen('C:\oraload', filename, 'W',32767);
while v_more loop
utl_file.put(v_file, substr(v_xml, 1, 32767));
dbms_output.put_line('Length of XML '||length(v_xml));
if length(v_xml) > 32767
then
v_xml := substr(v_xml, 32768);
dbms_output.put_line('Inside IF Length of XML '||length(v_xml));
else
v_more := false;
end if;
end loop;
utl_file.fclose(v_file);
dbms_output.put_line('Coke Completed Successfully');
exception
when others then
dbms_output.put_line(substr(sqlerrm,1,1000));
utl_file.fclose(v_file);
end;
END; -
How to fetch data into xml file trom sql table.
Hi,
We r now working in oracle 9iAS portal.
We have installed xdk along with 9iAS.
I would like to know how to and where to run an xsql file,preferably with an example to fetch data from a database table to a xml file.Please download the latest version of XDK for Java at:
http://otn.oracle.com/tech/xml/xdk_java
In the downloaded package, there are demos for XSQL Servlet. The demo "emp" and "empdept" are good start. -
i need a procedure that reads data from xml file and stores into an oracle table.
Hi,
Check the below links:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:27523665852829
http://www.experts-exchange.com/Database/Oracle/Q_20932242.html
Best regards,
Rafi.
http://rafioracledba.blogspot.com -
Help needed in removing the duplicate nodes in an xml file
Hi Friends,
I need some help in removing the duplicates from a xml file using the Excel Spreadsheet. The xml Im using does not have any schema.
Can some one please let me know the steps.
Thanks a lot.Hi,
I got the answer.
Go to the developers Tab and click on export.
Select the column where we want to delete the duplicates and click on Remove Duplicates from Data Tab.
OR go to Home Tab> Conditional Formatting> High light Cell Rules> Duplicate Values. It will highlight all the duplicate values and then remove them manually.
Thanks. -
Problem converting data in XML file to internal table data
Hi all,
I have a requirement. I need to convert an XML file to internal table data and based on that data do Goods Receipt in SAP.
With the help of this blog /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
I am able to convert the XML file to data in SAP. But this blog will display the output on screen as ELELEMNT = nodename VALUE= value of that node.
But I donu2019t want in that way, I want to store all the data in XML file in an internal table so that I can make use of those values and do Goods Recipt in SAP.
Can some one suggest how should I read the data in an internal table.
Here is my code..what changes should I make?
*& Report z_xit_xml_check
REPORT z_xit_xml_check.
TYPE-POOLS: ixml.
TYPES: BEGIN OF t_xml_line,
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xmldata TYPE string.
DATA: l_elem TYPE REF TO if_ixml_element,
l_root_node TYPE REF TO if_ixml_node,
l_next_node TYPE REF TO if_ixml_node,
l_name TYPE string,
l_iterator TYPE REF TO if_ixml_node_iterator.
DATA: l_xml_table TYPE TABLE OF t_xml_line,
l_xml_line TYPE t_xml_line,
l_xml_table_size TYPE i.
DATA: l_filename TYPE string.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'c:\temp\orders_dtd.xml'.
Validation of XML file: Only DTD included in xml document is supported
PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
IF pa_val EQ 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
Parse the stream
IF l_parser->parse( ) NE 0.
IF l_parser->num_errors( ) NE 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
PERFORM process_dom USING l_document.
ENDIF.
*& Form get_xml_table
FORM get_xml_table CHANGING l_xml_table_size TYPE i
l_xml_table TYPE STANDARD TABLE.
Local variable declaration
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = pa_file.
upload a file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
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.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
ENDFORM. "get_xml_table
*& Form process_dom
FORM process_dom USING document TYPE REF TO if_ixml_document.
DATA: node TYPE REF TO if_ixml_node,
iterator TYPE REF TO if_ixml_node_iterator,
nodemap TYPE REF TO if_ixml_named_node_map,
attr TYPE REF TO if_ixml_node,
name TYPE string,
prefix TYPE string,
value TYPE string,
indent TYPE i,
count TYPE i,
index TYPE i.
node ?= document.
CHECK NOT node IS INITIAL.
ULINE.
WRITE: /.
WRITE: /' DOM-TREE'.
WRITE: /.
IF node IS INITIAL. EXIT. ENDIF.
create a node iterator
iterator = node->create_iterator( ).
get current node
node = iterator->get_next( ).
loop over all nodes
WHILE NOT node IS INITIAL.
indent = node->get_height( ) * 2.
indent = indent + 20.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
IF NOT nodemap IS INITIAL.
attributes
count = nodemap->get_length( ).
DO count TIMES.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
value COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
WRITE: / 'VALUE :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
advance to next node
node = iterator->get_next( ).
ENDWHILE.
ENDFORM. "process_dom
Any help would be highly apperciated.
regards,
Jessica SamPavel Vera,
With your example i tries doing the following .....
I tried to convert the data of XML file to internal table data. I am collecting the data in internal table to do goos recipt with that data.
Please find my XML file, ABAP pgm and XSLT pgm . I donu2019t know what I am missing I am not getting any output. I donu2019t know what is wrong please help me with this
Below is my XML file, My code and XSLT Program. In the below XML file I need to collect Vendor Number, Order Number, and Date tags which occur only once for one XML file.
I also need to collect the following tags from <Shipmentdetail>
<Shipmentdetail> has following child nodes and I need to collect them
TrackingNumber
Freight
Weight
ShipmentDate
ShipmentMethod
Need to collect to collect the following tags from <ProductInformation>
<ProductInformation> has following child nodes and I need to collect them
LineNumber
SKUNumber
OrderedQuantity
ShippedQuantity
UOM
The <Shipmentdetail> and <ProductInformation> are child nodes of <OrderShipment>
The <Shipmentdetail> occurs only ones but the <ProductInformation> can occur once or many times and will be dynamic and differs depening on the input file.
My XML file is as follows
<?xml version="1.0" encoding="iso-8859-1" ?>
- <ShipmentHeader>
<AccountID />
- <OrderShipment>
<VendorNumber>1000</VendorNumber>
<OrderNumber>P00009238</OrderNumber>
<OrderType>Stock</OrderType>
<Company />
<Division />
<Department />
<Date>20061120</Date>
<CartonCount>2</CartonCount>
<ShipAllProducts>No</ShipAllProducts>
- <ShipmentDetail>
<TrackingNumber>1ZR3W891PG47477811</TrackingNumber>
<Freight>000000010000</Freight>
<ShipmentDate>20061120</ShipmentDate>
<ShipmentMethod>UPS1PS</ShipmentMethod>
</ShipmentDetail>
- <ProductInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<OrderedQuantity>00000001000000</OrderedQuantity>
<ShippedQuantity>00000001000000</ShippedQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</ProductInformation>
- <ProductInformation>
<LineNumber>000000002</LineNumber>
<SKUNumber>938EN</SKUNumber>
<AdvSKUNumber>001 7294</AdvSKUNumber>
<SKUID />
<OrderedQuantity>00000000450000</OrderedQuantity>
<ShippedQuantity>00000000450000</ShippedQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</ProductInformation>
- <CaseInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<SSCCNumber>00000001668000002487</SSCCNumber>
<CaseQuantity>00000001000000</CaseQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</CaseInformation>
<CaseInformation>
<LineNumber>000000001</LineNumber>
<SKUNumber>110FR</SKUNumber>
<AdvSKUNumber>003 4518</AdvSKUNumber>
<SKUID />
<SSCCNumber>00000001668000002487</SSCCNumber>
<CaseQuantity>00000001000000</CaseQuantity>
<UOM>EA</UOM>
<Factor>1</Factor>
</CaseInformation>
- </OrderShipment>
</ShipmentHeader>
My Program
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\temp\test.xml'.
* This is the structure for the data from the XML file
TYPES: BEGIN OF ts_shipment,
VendorNumber(10) TYPE n,
OrderNumber(20) TYPE n,
OrderType(8) TYPE c,
Date(8) TYPE c,
END OF ts_shipment.
TYPES: BEGIN OF ts_shipmentdetail,
TrackingNumber(30) TYPE n,
Freight(12) TYPE n,
Weight(14) TYPE n,
ShipmentDate(8) TYPE c,
ShipmentMethod(8) TYPE c,
END OF ts_shipmentdetail.
TYPES: BEGIN OF ts_productinformation,
LineNumber(9) TYPE n,
SKUNumber(20) TYPE c,
OrderedQuantity(14) TYPE n,
ShippedQuantity(14) TYPE n,
UOM(4) TYPE c,
END OF ts_productinformation.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
* Table and work ares for the data from the XML file
DATA: gt_shipment TYPE STANDARD TABLE OF ts_shipment,
gs_shipment TYPE ts_shipment.
DATA: gt_shipmentdetail TYPE STANDARD TABLE OF ts_shipmentdetail,
gs_shipmentdetail TYPE ts_shipmentdetail.
DATA: gt_productinformation TYPE STANDARD TABLE OF ts_productinformation,
gs_productinformation TYPE ts_productinformation.
* 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
* "ISHIPMENT".
GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
gs_result_xml-name = 'ISHIPMENT'.
APPEND gs_result_xml TO gt_result_xml.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "ISHIPDET".
GET REFERENCE OF gt_shipmentdetail INTO gs_result_xml-value.
gs_result_xml-name = 'ISHIPDET'.
APPEND gs_result_xml TO gt_result_xml.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IPRODDET".
GET REFERENCE OF gt_productinformation INTO gs_result_xml-value.
gs_result_xml-name = 'IPRODDET'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION z_xml_to_abap3
SOURCE XML gt_itab
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
* Writing the data from file for gt_shipment
*Collecting the Shipping Data from the XML file to internal table gt_shipment
*and writing the data to the screen
LOOP AT gt_shipment INTO gs_shipment.
WRITE: / 'VendorNumber:', gs_shipment-VendorNumber.
WRITE: / 'OrderNumber :', gs_shipment-OrderNumber.
WRITE: / 'OrderType :', gs_shipment-OrderType.
WRITE: / 'Date :', gs_shipment-Date.
WRITE : /.
ENDLOOP. "gt_shipment.
LOOP AT gt_shipmentdetail INTO gs_shipmentdetail.
WRITE: / 'TrackingNumber:', gs_shipmentdetail-TrackingNumber.
WRITE: / 'Freight :', gs_shipmentdetail-Freight.
WRITE: / 'Weight :', gs_shipmentdetail-Weight.
WRITE: / 'ShipmentDate :', gs_shipmentdetail-ShipmentDate.
* WRITE: / 'ShipmentMethod :' gs_shipmentdetail-ShipmentMethod
WRITE : /.
ENDLOOP. "gt_shipmentdetail.
LOOP AT gt_productinformation INTO gs_productinformation.
WRITE: / 'LineNumber:', gs_productinformation-LineNumber.
WRITE: / 'SKUNumber :', gs_productinformation-SKUNumber.
WRITE: / 'OrderedQuantity :', gs_productinformation-OrderedQuantity.
WRITE: / 'ShippedQuantity :', gs_productinformation-ShippedQuantity.
WRITE: / 'UOM :', gs_productinformation-UOM.
WRITE : /.
ENDLOOP. "gt_productinformation.
XSLT Program
<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:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ISHIPMENT>
<xsl:apply-templates select="//OrderShipment"/>
</ISHIPMENT>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="OrderShipment">
<item>
<VENDORNUMBER>
<xsl:value-of select="VendorNumber"/>
</VENDORNUMBER>
<ORDERNUMBER>
<xsl:value-of select="OrderNumber"/>
</ORDERNUMBER>
<ORDERTYPE>
<xsl:value-of select="OrderType"/>
</ORDERTYPE>
<DATE>
<xsl:value-of select="Date"/>
</DATE>
</item>
</xsl:template>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ISHIPDET>
<xsl:apply-templates select="//OrderShipment/ShipmentDetail"/>
</ISHIPDET>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="ShipmentDetail">
<item>
<TRACKINGNUMBER>
<xsl:value-of select="TrackingNumber"/>
</TRACKINGNUMBER>
<FREIGHT>
<xsl:value-of select="Freight"/>
</FREIGHT>
<SHIPMENTDATE>
<xsl:value-of select="ShipmentDate"/>
</SHIPMENTDATE>
<SHIPMENTMETHOD>
<xsl:value-of select="ShipmentMethod"/>
</SHIPMENTMETHOD>
</item>
</xsl:template>
</xsl:transform> .
Any help is highly appreciated. If anyone encountered this situation before please let me know where i am going wrong in my XSLT transformation.
Any Help will be highly apppreciated. Thanks in advance
Regards,
Jessica Sam -
Comparing nodes in two xml files
I need help with a flex app i am making. My skill level in flex is pretty much basic, so some of the questions may seem easy but they r not to me
I need an application that will load two external xml files and compare nodes. The xml files are pretty much identical except for the values ofcourse. After that i need to write this data to a new xml file which my flex app will generate. Can anyone plz give me an example code which i can later modify for my own application. You can give me any type of an example with the simplest xml files.
Thank you in advance"for in" and "for each in" statements can be used to iterate through the nodes. If the two xml files are of same structure , you can easily compare the node attributes. Here is the link to the livedocs page for looping through xml nodes
http://livedocs.adobe.com/flex/3/html/help.html?content=13_Working_with_XML_08.html
Create xml from string
http://www.cflex.net/showFileDetails.cfm?ChannelID=1&ObjectID=784
Message was edited by: Subeesh Arakkan -
How can i query oracle database data to xml file with c++?
I want query data to xml file directly in my c++ application .
I know the oracle XSU provide interferce for query data to xml
file directly.
But XSU for oracle8i does not support c++.
I do not know if XSU for oracle9i support c++.
can you tell me?
If i do not use XSU to finish my applicayion.
what interface that oracle provide can help me do my work?
thank you !BTW why do you want to migrate oracle database data to db2 database? Any specific project requirement like Parallel run with Oracle database (e.g data replication)? Or any other issues - Cost? Manageability? Availability? Business requirements?
Do you need to do a day-to-day data transfer or it is for permanent migration? -
Pls Help me with steps to add data from xml file to SAP B1 through B1iSN.
Pls Help me with steps to add data from xml file to SAP B1 through B1iSN. I am getting stuck in xsl transformation. not able to understand where the mapping code needs to be added.
Pls explain me the steps for adding data from xml to B1 quotation step by step.
thanks and regards
PriyaHi,
Have you checked this: https://sap.na.pgiconnect.com/p45508295/?launcher=false&fcsContent=true&pbMode=normal ?
Thanks,
Gordon -
Problem in converting table data into CSV file
Hi All,
In my Process i need to convert my error table data into csv file,my data is converted as csv file by using OdisqlUnload function,but the column headers are not converted,i use another procedure for converting column headers but iam getting below error ...
com.sunopsis.sql.SnpsMissingParametersException: Missing parameter string.find, string.find
SQL: import string import java.sql as sql import java.lang as lang import re sourceConnection = odiRef.getJDBCConnection("SRC") output_write=open('C:/Oracle/Middleware/Oracle_ODI2/oracledi/pro/PRO.txt','r+') myStmt = sourceConnection.createStatement() my_query = "select * FROM E$_LOCAL_F0911Z1" my_query=my_query.upper() if string.find(my_query, '*') > 0: myRs = myStmt.executeQuery(my_query) md=myRs.getMetaData() collect=[] i=1 while (i <= md.getColumnCount()): collect.append(md.getColumnName(i)) i += 1 header=','.join(map(string.strip, collect)) elif string.find(my_query,'||') > 0: header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',') else: header = my_query[7:string.find(my_query, 'FROM')] print header old=output_write.read() output_write.seek(0) output_write.write (header+'\n'+old) sourceConnection.close() output_write.close()
And i used below code for converting.......
import string
import java.sql as sql
import java.lang as lang
import re
sourceConnection = odiRef.getJDBCConnection("SRC")
output_write=open('C:/Oracle/Middleware/Oracle_ODI2/oracledi/pro/PRO.txt','r+')
myStmt = sourceConnection.createStatement()
my_query = "select FROM E$_COMPANY"*
*my_query=my_query.upper()*
*if string.find(my_query, '*') > 0:*
*myRs = myStmt.executeQuery(my_query)*
*md=myRs.getMetaData()*
*collect=[]*
*i=1*
*while (i <= md.getColumnCount()):*
*collect.append(md.getColumnName(i))*
*i += 1*
*header=','.join(map(string.strip, collect))*
*elif string.find(my_query,'||') > 0:*
*header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',')*
*else:*
*header = my_query[7:string.find(my_query, 'FROM')]*
*print header*
*old=output_write.read()*
*output_write.seek(0)*
*output_write.write (header+'\n'+old)*
*sourceConnection.close()*
*output_write.close()*
Any one can you help regarding this
Edited by: 30021986 on Oct 1, 2012 6:04 PMThis may not be an option for you but in pinch you may want to consider outputing your data to an MS Spreadsheet, then saving it as a CSV. It's somewhat of a cumbersome process, but it will get you by for now.
You will need to change your content type to application/vnd.ms-excel.
<% response.setContentType("application/vnd.ms-excel"); %> -
To Get the value of a node in a XML file which is outside the envelope
Hi Everyone,
I am uploading data in a XML file into Oracle tables. I am using oracle 9i release 2. How to get a value of a node outside the envelope.
Here is my xml file.
<Response>
<TaskNo>14</TaskNor>
<ZoneResponse>
<GetServiceStatusResponse xmlns="http://mws.zonemws.com/Shipment/2010-10-01/">
<GetServiceStatusResult>
<Status>GREEN</Status>
<Date>2011-06-03</Date>
</GetServiceStatusResult>
<Metadata>
<Id>c9488a06</Id>
</Metadata>
</GetServiceStatusResponse>
</ZoneResponse>
</Response>
This is the response xml we are getting from the supplier. I do want to store all the values in an oracle table, including TaskNo(14). TaskNo is the main value
here. I am using dbms_xmlparser and dbms_xmldom in PL/SQL. I am able to get the values inside the envelope, but not the outside(taskno). It is not showing any errors. It is processing all
other values. I Posted this in the XML DB section also. Please help me to solve this issue. Any help,tips and suggesstion will be highly appreciated. Thanks in advance
--VimalHi,
I am providing some additional info like procedure, table structure and sample xml file so that you can get a clear idea about my problem and help me.
My Procedure
PROCEDURE xml_upload (
p_directory IN VARCHAR2,
p_server_directory IN VARCHAR2,
p_filename IN VARCHAR2
AS
l_bfile BFILE;
l_clob CLOB;
l_parser DBMS_XMLPARSER.parser;
l_doc DBMS_XMLDOM.domdocument;
l_noderowset DBMS_XMLDOM.domnode;
l_noderow DBMS_XMLDOM.domnode;
l_nodecount NUMBER;
l_Resultlist DBMS_XMLDOM.domnodelist;
l_request_id VARCHAR2 (300);
l_task_number NUMBER;
l_tasknum_list DBMS_XMLDOM.domnodelist;
l_service_list DBMS_XMLDOM.domnodelist;
l_time_list DBMS_XMLDOM.domnodelist;
l_tasknode DBMS_XMLDOM.domnode;
l_servicenode DBMS_XMLDOM.domnode;
l_temp VARCHAR2 (1000);
l_table_name VARCHAR2 (100);
l_cmd_execution VARCHAR2 (1000);
l_orig_file_with_path VARCHAR2 (1000);
l_dest_file_with_path VARCHAR2 (1000);
l_status custom.task_status.status%TYPE;
l_time custom.task_status.timestamps%TYPE;
l_rows NUMBER;
l_message SYS.XMLTYPE;
l_return_status NUMBER;
TYPE tab_type IS TABLE OF custom.task_status%ROWTYPE;
t_tab tab_type := tab_type ();
PROCEDURE write_exception (
p1_filename VARCHAR2,
p_comments VARCHAR2,
p_rows_created NUMBER
IS
BEGIN
read_xml_file (p_directory, p_filename, l_message, l_return_status);
-- Convert the xml to a clob
l_clob := l_message.getclobval();
-- Create a parser.
l_parser := DBMS_XMLPARSER.newparser;
-- Parse the document and create a new DOM document.
DBMS_XMLPARSER.parseclob (l_parser, l_clob);
l_doc := DBMS_XMLPARSER.getdocument (l_parser);
-- Free any resources associated with the CLOB and Parser
-- dbms_lob.freetemporary(v_clob);
DBMS_XMLPARSER.freeparser (l_parser);
l_noderowset :=
DBMS_XMLDOM.item
(DBMS_XMLDOM.getchildnodes (DBMS_XMLDOM.makenode (l_doc)),
0
l_nodecount :=
DBMS_XMLDOM.getlength (DBMS_XMLDOM.getchildnodes (l_noderowset))
- 1;
t_tab.EXTEND;
FOR i IN 0 .. l_nodecount
LOOP
l_noderow :=
DBMS_XMLDOM.item (DBMS_XMLDOM.getchildnodes (l_noderowset), i);
l_Resultlist :=
DBMS_XMLDOM.getelementsbytagname
(DBMS_XMLDOM.makeelement (l_noderow),
'RequestId'
l_request_id :=
DBMS_XMLDOM.getnodevalue
(DBMS_XMLDOM.getfirstchild
(DBMS_XMLDOM.item (l_Resultlist,
0
END LOOP;
FOR i IN 0 .. l_nodecount
LOOP
l_noderow :=
DBMS_XMLDOM.item (DBMS_XMLDOM.getchildnodes (l_noderowset), i);
l_service_list:=
DBMS_XMLDOM.getelementsbytagname
(DBMS_XMLDOM.makeelement (l_noderow),
'Status'
l_status:=
DBMS_XMLDOM.getnodevalue
(DBMS_XMLDOM.getfirstchild
(DBMS_XMLDOM.item (l_service_list,
0
l_time_list:=
DBMS_XMLDOM.getelementsbytagname
(DBMS_XMLDOM.makeelement (l_noderow),
'Timestamp'
l_time:=
DBMS_XMLDOM.getnodevalue
(DBMS_XMLDOM.getlastchild
(DBMS_XMLDOM.item (l_time_list,
0
END LOOP;
select
extractvalue(column_value,'/Response/TaskNumber') into l_task_number
from
table(xmlsequence(xmltype('<Response>
<TaskNumber>14</TaskNumber>
<ZoneResponse>
<GetServiceStatusResponse xmlns="http://mws.zoneaws.com/InboundShipment/2010-10-01/">
<GetServiceStatusResult>
<Status>GREEN</Status>
<Timestamp>2011-06-03T22:17:17.313Z</Timestamp>
</GetServiceStatusResult>
<Metadata>
<RequestId>c9488a06-73c6-474e-b356-51d5f8feec00</RequestId>
</Metadata>
</GetServiceStatusResponse>
</ZoneResponse>
</Response>
t_tab (t_tab.LAST).status:= l_status;
t_tab (t_tab.LAST).timestamps:= l_time;
t_tab (t_tab.LAST).amz_request_id:= l_request_id;
t_tab (t_tab.LAST).tasknumber:= l_task_number;
-- Insert data into the real Staging table from the table collection.
FORALL i IN t_tab.first .. t_tab.last
INSERT INTO custom.task_status VALUES t_tab(i);
COMMIT;
DBMS_XMLDOM.freedocument (l_doc);
DBMS_LOB.freetemporary (l_clob);
DBMS_XMLPARSER.freeparser (l_parser);
DBMS_XMLDOM.freedocument (l_doc);
DBMS_LOB.freetemporary (l_clob);
DBMS_XMLPARSER.freeparser (l_parser);
DBMS_XMLDOM.freedocument (l_doc);
END rrs_xml_upload;
Sample File:
<Response>
<TaskNumber>14</TaskNumber>
<ZoneResponse>
<GetServiceStatusResponse xmlns="http://mws.zoneaws.com/InboundShipment/2010-10-01/">
<GetServiceStatusResult>
<Status>GREEN</Status>
<Timestamp>2011-06-03T22:17:17.313Z</Timestamp>
</GetServiceStatusResult>
<Metadata>
<RequestId>c9488a06-73c6-474e-b356-51d5f8feec00</RequestId>
</Metadata>
</GetServiceStatusResponse>
</ZoneResponse>
</Response>
Table: task_status
tasknumber number,
status varchar2(100),
timestamps varchar2(100),
requestid varchar2(100)
all I want is to populate the data from xml file to the particulare table. I can do that with the above procedure.
But In this below mentioned part of my procedure , I want to pass the file name instead of giving the entire content.
select
extractvalue(column_value,'/Response/TaskNumber') into l_task_number
from
table(xmlsequence(xmltype('<Response>
<TaskNumber>14</TaskNumber>
<ZoneResponse>
<GetServiceStatusResponse xmlns="http://mws.zoneaws.com/InboundShipment/2010-10-01/">
<GetServiceStatusResult>
<Status>GREEN</Status>
<Timestamp>2011-06-03T22:17:17.313Z</Timestamp>
</GetServiceStatusResult>
<Metadata>
<RequestId>c9488a06-73c6-474e-b356-51d5f8feec00</RequestId>
</Metadata>
</GetServiceStatusResponse>
</ZoneResponse>
</Response>
Alex or any other oracle pl/sql experts please help me to solve this issue.
FYI : I am using Oracle 9.2.0.8.0
Thanks,
Vimal..
Edited by: Vimal on Jun 13, 2011 4:10 PM -
BCP data into a file using Runtime class
Hi,
I have a problem in using the Runtime class.
I am trying to bcp a table's data into a file.I am working on a Unix environment.
My bcp is not getting completed fully.The total records to be bcped is 1 million,but only one lakh records is getting bcped and then it hangs up..But if i issue the bcp command from my telnet session it is bcping it to the file without any problem.Can anyone help me out on how to overcome this..
Is there anything specific with Runtime class..I am pasting the code that i tried out below.
String l_s_bcpQuery="bcp mubstage.dbo.HousingUnitSampleMarket out /dun/d3nmb0/mariaps/subracheckprototype -c -t~ -Umariaps -Prykwz5ba -SD3NMB_MUB";
try{
Runtime time=Runtime.getRuntime();
Process p=time.exec(l_s_bcpQuery);
p.waitFor();
System.out.println("The exit value is:"+p.exitValue());
}catch(Exception ioe){
ioe.printStackTrace();
System.out.println("IOException"+ioe.getMessage());you might need to capture the stout & sterr from the process. see http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Process.html, or many other similar questions on this forum.
try this:
try{
Runtime time=Runtime.getRuntime();
Process p=time.exec(l_s_bcpQuery);
BufferedReader stout = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader sterr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String out = stout.readLine();
String err = sterr.readLine();
while((out != null)||(err != null))
if(out != null)
System.out.println(out);
if(err != null)
System.err.println(err);
out = stout.readLine();
err = sterr.readLine();
int exit_value = p.waitFor();
System.out.println("The exit value is:"+ exit_value);
}catch(Exception ioe){
ioe.printStackTrace();
System.out.println("IOException"+ioe.getMessage());
}
Maybe you are looking for
-
Airport card does not work with Airport Extreme when security is turned on
I have an iMac running OSX 10.4.11 with an Airport card installed (firmware version 9.52). I recently replaced my Netgear wireless router with an Apple Extreme Base station and now I am not able to connect my iMac to the wireless network when WEP sec
-
After reinstalling mountain lion i got the question mark on the screen
hi everyone, after reinstalling mac os x 10.8 from internet recovery, mac restarts itself which is normal. but when it starts there is a question mark on a folder symbol on the gray screen. what should i do?
-
How do I download ichat onto my macbook pro?
I just got a macbook pro and I have imessages, not ichat. How can I replace it or download ichat?
-
Password doesn't work after iOS upgrade
I upgraded my iPad to the latest iOS version, and now my password to unlock it no longer works. Has anyone else had this problem? How do I unlock it now?
-
4S won't maintain stereo output to earphones
My iPhone 4S keeps losing the left channel output when I am using earphones. I originally thought it was a fault with the earphones themselves but I have tried several pairs and gotten fairly consistent results. I have found that twisting the jack a