Spatial Tables to Shape Files

Can someone tell me how I can create shape files from spatial tables. I see a lot of examples for the reverse, but not for create shape files from spatial tables. The federal government has requested this, so I'm kind of stuck. Thanks.

Hi Tomek,
I am new to Oracle spatial and ESRI. I have read conversion to and from ESRI shape file. What I need to do is to convert Oracle spatial coordinate to ESRI coordinate and output ESRI coordinate to external third party software.
I have registered ESRI to Oracle as below:
INSERT INTO SDO_COORD_REF_SYSTEM
SRID, COORD_REF_SYS_NAME, COORD_REF_SYS_KIND,
COORD_SYS_ID, DATUM_ID, GEOG_CRS_DATUM_ID,
SOURCE_GEOG_SRID, PROJECTION_CONV_ID, CMPD_HORIZ_SRID,
CMPD_VERT_SRID, INFORMATION_SOURCE,
DATA_SOURCE, IS_LEGACY,
LEGACY_CODE,
LEGACY_WKTEXT,
LEGACY_CS_BOUNDS,
IS_VALID,
SUPPORTS_SDO_GEOMETRY
VALUES
1000000, 'USGS Albers Conical Equal Area NAD83', 'PROJECTED',
4400, NULL, 10076,
2000006 , NULL, NULL,
NULL, 'USGS',
NULL, 'TRUE',
NULL,
'PROJCS["Equal-Area Projection (United States)",
GEOGCS[ "NAD 83", DATUM ["NAD 83",
SPHEROID ["GRS 80",6378137,298.2572221010002]],
PRIMEM ["Greenwich",0], UNIT["Decimal degree",0.0174532925199433]],
PROJECTION ["Albers Conical Equal Area"],
PARAMETER ["Standard_Parallel_1",29.5],
PARAMETER ["Standard_Parallel_2",45.5], PARAMETER ["Latitude_of_Origin",23],
PARAMETER ["Central_Meridian",-96], UNIT ["Meter",1]]',
NULL,
'TRUE',
'TRUE'
I ran the following:
select MDSYS.SDO_CS.TRANSFORM(
MDSYS.SDO_GEOMETRY(2001,
82473,
MDSYS.SDO_POINT_TYPE(2510416,
2413881,NULL
NULL,NULL
1000000
) from dual
The output is:
(-14497847,5126972)
Is the output in valid ESRI coordinate?
How do you do the conversion otherwise?
Please advise,
Thanks,
Regards,
Michael

Similar Messages

  • Oracle spatial to shape file

    hi everyone
    How to convert oracle spatial data to shape file
    pls share your thoughts

    Howdy,
    fdo2fdo - http://sl-king.com/fdo2fdo/download/download.html
    Lots of conversion options, free and open source.
    r,
    dennis
    Edited by: djonio on Sep 14, 2011 1:16 PM

  • Create a spatail table using a shape file (.shp) in SQL DB

    Hi All,
    I am trying to load shape file into a sql spatial table. A execution process task is used to run the ogr2ogr.exe program.
    This is how the process tab looks like .
    Executable : C:\gdal_ogr2ogr\bin\gdal\apps\ogr2ogr.exe
    Argument :  -f MSSQLSpatial   MSSQL:server=SQL-ABC-DEV;database=MYSIMPLE_Dev;Trusted_Connection=True;\\mypath\files\shares\Data\www.mypage.htm\my_sample_file.shp
    Success value : 1 (I am not sure why I need to change this value from 0 to 1.
    For above settings, package runs fine. However the spatial table is not created always. It is created once in a while after switching Success value from 1 to 0 and 0 to 1 again. (After the spatial table is created, it is dropped using a execute sql statement).
    If I run this command SDKShell.bat file, it always works.
    I am running this in VS 2012.I saw in an article that we need to convert shp file to csv before we load it into sql server.I even tried to convert shp to csv using execute sql task and ogr2ogr.exe. Still the package runs successfully after changing Success
    value from 0 to 1 but no csv file is created. If the success value is 0, it throws the following error.
    [Execute Process Task] Error: In Executing "C:\gdal_ogr2ogr\bin\gdal\apps\ogr2ogr.exe" " -f CSV \\xxxxxxxxr.rdn\files\shares\xxx_Data\ImportData\www.xxxxxxx.hapepage.htm\xxxxxx\Watches\Warnings\myfile\CSV \\xxxxxxxxr.rdn\files\shares\xxx_Data\ImportData\www.xxxxxxx.hapepage.htm\xxxxxx\Watches\Warnings\myfiles\www.shp"
    at "", The process exit code was "1" while the expected was "0".
    Could long file name be a problem too?
    Thanks for your help in advance..
    shamen

    Thank you Andreas
    Yes I can run it manually without getting any error.I am also new to ogr2ogr.exe. This is used to load shape files into sql server.
    Actually this execute process task was located inside a for each loop. As no parameter is passed from for each loop to execute process task, I placed the execute process task outside of for each loop. Now it is working.
    Every time when the package is run, execute process task create a spatial table in the db.
    Still I don't know why it is not working when I place it inside the for each loop container.
    Thanks
    shamen http://stalkingnightmare.wordpress.com/about/

  • Can Oracle Spatial read shape files?

    Hi,
    I need to read some shape files into Oracle spatial and was wondering how (or indeed if) there is a way of doing this. I don't know much about the shape files, except that they can be used with ARCView. Any help would be greatly appreciated.
    Thanks
    Steve

    Steve,
    I've done this 4 ways:
    1. If you have ArcGIS 8.1, you can use ESRI's shp2sde which can create spatial tables containing SDO_GEOMETRY objects.
    2. If you have GeoMedia Pro 4.0, you can convert shape files to Oracle Spatial tables containing SDO_GEOMETRY objects either with a direct write or you can generate scripts.
    3. FME Universal Translator by Safe Software (www.safe.com) can translate shape files to Oracle Spatial tables containing SDO_GEOMETRY objects.
    4. Oracle's shp2sdo utility can also translate them, but there is added cleanup. You have to then migrate your table to 8.1.7.
    Hope that helps.
    Dave

  • Esri Shape-File to Geo-Spatial Image Search

    Dear All
    I am developing a c# desktop application in which user have to provide a Shape-File for geo-spatial image search. I have a back-end database in SQL server 2012 in which I am saving metadata of each image, that also includes lat/ long of corner point of each
    image. Now the user will provide its shape-file from the desktop application and it will searches SQL database geo-spatial images repository to fetch all images that comes inside provided shape-file. Ad I am new to SQL spatial data handling feature and just
    read about STIntersection method available through which this task can be performed.
    The main problem that I am facing is that how can handle shape-file passing from front end application in SQL to make a query that will check each geo-spatial images that whether it comes inside shape-file or not?
    I have also a KML file of each image, will I have to make a shape file of each image and store them in database and then query STIntersection to check whether the shape-files overlap/ intercept each other or not?
    Thanks in Advance
    Engr. Mudassar Ali Software Engineer

    ok thats nice. I have meta data of my geo-spacial images in sql database. i will get the corner points(latt/long) from there and use the following query to check whether it resides in provided shapefile of not
    DECLARE @g geography;
    DECLARE @h geography;
    SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326);
    SET @h = geography::STGeomFromText('POLYGON(-122.360 47.656, -122.343 47.656,-122.348 47.658, -122.358 47.658, -122.358 47.653)', 4326);SELECT CASE @g.STIntersects(@h)WHEN 1 THEN '@g intersects @h'ELSE '@g does not intersect @h'END;Now the problem is this how can I get lat/long from Esri Shape-file and pass them to this SQL query to check each image?
    Engr. Mudassar Ali Software Engineer

  • Import a shape file to oracle spatial format within an oracle pl/sql proced

    hi,
    My task is to import an esri sde shape file to oracle sdo format within pl/sql procedure.
    i am using oracle 10g, arcgis 9 and arcsdo, geometry type is line, please anyone could help how can i achieve this task, would be very thankful
    Best Regards,

    There are no "in database" tools around that do this AFAIK. Most/all tools are external to the database and have to be invoked externally.
    If you created an external "batch file" that did the right processing, you would still have to work out how to execute this batch file from within Oracle. AFAIK the standard method is to use create custom code that uses DBMS_PIPE to communicate with the operating system to execute the batch file. DBAs hate this approach and it does require programming.
    The other method could be to write a trivial piece of Java that when passed the full path to the batch file executes the file. You would then load the compiled Java class into the Oracle JVM and then create a simple PL/SQL wrapper around it. I can't do it at the moment, but can come back with the code and instructions later on in the week.
    <SHAMELESS PLUG>
    As an aside (it seems appropriate to mention this now), I have been developing tools that do run inside the Oracle JVM an can export Oracle data (including sdo_geometry) to a number of formats:
    * xSV (ie comma separated, tab separated, any other single character)
    * Excel Spreadsheet
    * ESRI Shapefile (including the writing of the PRJ file using a user supplied PRJ string and also I write a MapInfo TAB file to "wrap" the shapefile).
    When exporting to xSV or Excel Spreadsheet one can chose to encode the SDO_GEOMETRY data as GML or WKT.
    (I am working on a KML exporter as well.)
    However, note that these tools EXPORT data and do not IMPORT data.
    The tools, currently are running in production at a customer site (tabbed shapefile export option) and work well. Export jobs are defined and given to the Oracle JOB or SCHEDULER and correctly run at the appropriate time writing the data to an operating system directory defined internally (with appropriate permissions) as an Oracle Directory object.
    I am now considering selling the exporter tool and am looking for testers. (The pricing of these tools will be exceedingly low.)
    </SHAMELESS PLUG>
    Now, while I hadn't planned to write any importer for a shapefile for my Exporter, I might consider it if you get stuck and can't find a satisfactory tool.
    regards
    Simon

  • Invalid geometry after shp2sdo on generalized shape files

    I have a very specific problem that I really could use help on. I new to spatial so please excuse any mistakes on my part.
    We are trying to take shape files and convert them to sdo.
    Using shp2sdo on our zip shape file and loading it results in no invalid geometries.
    My shp2sdo command looks like: shp2sdo.exe -o zip zip -g geom -d -x \(-180,180\) -y \(-90,90\) -t 0.000000005 -v
    I use this query to validate:
    SELECT zip, status
    FROM(SELECT zip,
    sdo_geom.validate_geometry_with_context (geom, diminfo) status
    FROM zip a,
    user_sdo_geom_metadata b
    WHERE b.table_name = 'ZIP'
    AND b.column_name = 'GEOM')
    WHERE status != 'TRUE';
    The first problem I am running into is that sdo data produced from these shape files is just way to big and cause performance issues with mapviewer. So I've been trying to generalize the zip code shape file and then run shp2sdo on the generalized shape files.
    This results in invalid objects (13349 self intersecting polygon) when I run my validate query above.
    I've tried two generalization methods on the zip. One using a script found in ARCView and the other using FME workbench. In FME workbench i've tried AreaGeneralizer and LineGeneralizer. When I loaded the sdo conversion of the shape ran through AreaGeneralizer and LineGenralizer (as well as the one from ArcView) I now had invalid geometries. So I these shape files through SelfIntersector in FME workbench in hopes of correcting gaps and overlaps. The output always says that there is nothing wrong in the shape files. But I tried to load them anyway and again no luck.
    Is there something I'm missing in the process I've described above? Has anyone else had luck with generalizing a shape file, converting it to sdo and having all valid geometries after the load? If so could you please describe your process.
    Any advice or help would so greatly be appreciated.
    -- Ilango

    Have you also asked in the Adobe forums?  To have people read your post, best not to include long crash reports until asked to do so.

  • Shape file - BEx Map

    Hi gurus
    can anybody tell how do i work with the shape files in BEx Map.
    I am using BEx Map to display the geographics information of country, sales organization and region.
    But i am facing a problem in editing the shape files.
    Any help....
    thanks in advance
    vijaykumar

    Vijay,
    There will be three files you will need.
    .shp - this is the shape file and PLEASE DO NOT DO ANYTHING TO THIS FILE
    .inx - Index file - PLEASE DO NOT EDIT OR TRY OPENING THIS FILE
    .dbf- this will read as a foxpro table and can be opened in Excel.
    Open the same and against the characteristic values displayed - input the corresponding values you will be using.
    Example for Delhi your master data code might be DEL.
    put in the corresponding codes in the BWMAP column or similar column and save the file.
    Now upload the file into the Bex Tab of InfoObject. Check the character is geo relevant and then upload the files.
    Now you can get the map. One way to test the same is to open the query containing the Geo relevant InfoObject and then clicking on the BeX toolbar and selecting map. You should be able to see your map.
    Arun Varadarajan

  • Update table form local file as background Job

    Hi Expert,
         I have a requirement to update a database table through Text file in a background. I am trying to do through OPEN Database to upload the file to Application server and then triggerind a event for background job. please provide method to update the table in background job.
    Regards,
    Kapil.

    hi,
    if i have understood you can try this:
    1) create a custom event with transaction SM62.
    2) schedule the update job ( with the update program in its step )  trigging the event set in (1) .
    3) execute the program that upload the local file from presentation server to application server  .  The last istruction of this program has to be the call ot the custom event using BP_event raise fn module in the uplaoad is ok..
    4) if the event has been raised, the background job has been executed.
    Regards, luigi.

  • How to transfer the tables from one file group to another file group in SQL 2008.?

    Hello all,
    I have few issues regarding the transfer of the tables from one file group to another file group  in SQL 2008 and also How can we  backup
    and restore the particular database based on file group level.
    Let’s say I have a tables stored within the different FG. such as
    Tables                                                    
      File group
    Dimension tables                                              
                                                                     Primary
    Fact tables                                               
                                                                              FG1
               FG2…
    zzz_tables                                               
                                                                              DEFAULT_FG    
    dim.table1                                                                                                                          DEFAULT_FG
    dim.table2                                                                                                                          DEFAULT_FG
    Here all I want to transfer the dim.table1 ,dim.table2  from  DEFAULT_FG to the Primary File
    group .So is there simple methods for transfer the dim.table1,2  from one FG to another .I have tried somewhat but I couldn’t get the exact way .So if someone have better idea please share your knowledge that would be really appreciated.
    Secondly after moving those dim.table1 ,dim.table2 from DEFAULT_FG to Primary ,All I want to backup and restore the database only containing  the Primary and FG1,FG2… not
    a DEFAULT_FG.Is it possible or not.?
    Hope to hear from the one who knows better approach for this kind of task .Your simple help will be much appreciated.
    Regards,
    Anil Maharjan

    Well after all my full day research on this topic had paid off, I finally got the solution and am so happy to research on these things. It makes
    us feel really happy after all our research and hard work doesn't goes as waste.
    Finally I got what I am looking for and want to make sure that I am able to transfer the tables from DEFAULT_FG to another FG without tables
    having clustered index on that tables .
    With the help of the link below I finally got my solution where Roberto’s coded store procedure simply works for this.
    Really thanks to him for his great post and thanks to all for your response and your valuable time.
    http://gallery.technet.microsoft.com/scriptcenter/c1da9334-2885-468c-a374-775da60f256f
    Regards,
    Anil Maharjan

  • How to create a table in the file using java code.?

    HI,
    I should export the data from the view objects to a word document. I have done that but I should
    display the data in the form of a table.
    Kindly come up with the necessary information on how to create a table in the file using java.
    Thanks,
    Phani

    Hi, Thank you for responding to my query.
    The below are the details of my code.
    DCBindingContainer dcBindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding StudentDetailsContent =
    (DCIteratorBinding)dcBindings.get("StudentView1Iterator");
    OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
    Row currentRow =
    StudentDetailsContent.getRowSetIterator().first();
    Object a[]= currentRow.getAttributeValues();
    int i;
    for(i=0 ;i<=a.length;i++){
    w.write(a.toString());
    w.write(" ");
    w.flush();
    I am usning this coding to achieve the task of exporting data to file.
    I need to display this information in the table that is where I need help from you people.
    Thanks,

  • In PL-SQL archive data from a table to a file

    I am currently developing a vb app where I need to archive data from a table to a file. I was hoping to do this with a stored procedure. I will also need to be able to retrieve the data from the file for future use if necessary. What file types are available? Thanks in advance for any suggestions.

    What about exporting in an oracle binary format? The export files cannot be modifiable. Is there a way to use the export and import utility in PL/SQL?
    null

  • How to export data from a Dynpro table to Excel file?

    Hi
    Here I go again. I read the post <b>Looking for example to export data from a DynPro table to Excel file</b> and put the code lines into a Web Dynpro Project where we need to export a dynpro table to Excel file but exactly at line 23 it doesn't recognize <b>workBook = new HSSFWorkbook();</b>
    1     //Declare this in the end between the Begin others block.
    2     
    3     private FileOutputStream out = null;
    4     private HSSFWorkbook workBook = null;
    5     private HSSFSheet hsSheet = null;
    6     private HSSFRow row = null;
    7     private HSSFCell cell = null;
    8     private HSSFCellStyle cs = null;
    9     private HSSFCellStyle cs1 = null;
    10     private HSSFCellStyle cs2 = null;
    11     private HSSFDataFormat dataFormat = null;
    12     private HSSFFont f = null;
    13     private HSSFFont f1 = null;
    14     
    15     //Code to create the Excel.
    16     
    17     public void onActionExportToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    18     {
    19     //@@begin onActionExportToExcel(ServerEvent)
    20     try
    21     {
    22     out = new FileOutputStream("C:/mydirectory/myfiles/testexcel.xls");
    23     workBook = new HSSFWorkbook();
    24     hsSheet = workBook.createSheet("My Sheet");
    25     cs = workBook.createCellStyle();
    26     cs1 = workBook.createCellStyle();
    27     cs2 = workBook.createCellStyle();
    28     dataFormat = workBook.createDataFormat();
    29     f = workBook.createFont();
    30     f1 = workBook.createFont();
    31     f.setFontHeightInPoints((short) 12);
    32     // make it blue
    33     f.setColor( (short)HSSFFont.COLOR_NORMAL );
    34     // make it bold
    35     // arial is the default font
    36     f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    37     
    38     // set font 2 to 10 point type
    39     f1.setFontHeightInPoints((short) 10);
    40     // make it red
    41     f1.setColor( (short)HSSFFont.COLOR_RED );
    42     // make it bold
    43     f1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    44     f1.setStrikeout(true);
    45     cs.setFont(f);
    46     cs.setDataFormat(dataFormat.getFormat("#,##0.0"));
    47     
    48     // set a thick border
    49     cs2.setBorderBottom(cs2.BORDER_THICK);
    50     
    51     // fill w fg fill color
    52     cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
    53     cs2.setFillBackgroundColor((short)HSSFCellStyle.SOLID_FOREGROUND);
    54     // set the cell format to text see HSSFDataFormat for a full list
    55     cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
    56     cs2.setFont(f1);
    57     cs2.setLocked(true);
    58     cs2.setWrapText(true);
    59     row = hsSheet.createRow(0);
    60     hsSheet.createFreezePane(0,1,1,1);
    61     for(int i=1; i<10;i++)
    62     {
    63     cell = row.createCell((short)i);
    64     cell.setCellValue("Excel Column "+i);
    65     cell.setCellStyle(cs2);
    66     }
    67     workBook.write(out);
    68     out.close();
    69     
    70     //Read the file that was created.
    71     
    72     FileInputStream fin = new FileInputStream("C:/mydirectory/myfiles/testexcel.xls");
    73     byte b[] = new byte[fin.available()];
    74     fin.read(b,0,b.length);
    75     fin.close();
    76     
    77     wdContext.currentContextElement().setDataContent(b);
    78     }
    79     catch(Exception e)
    80     {
    81     wdComponentAPI.getComponent().getMessageManager().reportException("Exception while reading file "+e,true);
    82     }
    83     //@@end
    84     }
    I don't know why this happen? Any information I will appreciate it.
    Thanks in advance!!!
    Tokio Franco Chang

    After test the code lines appears this error stacktrace:
    [code]
    java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
         at com.sap.tc.webdynpro.progmodel.api.iwdcustomevent.ExportToExcel.onActionAct1(ExportToExcel.java:232)
         at com.sap.tc.webdynpro.progmodel.api.iwdcustomevent.wdp.InternalExportToExcel.wdInvokeEventHandler(InternalExportToExcel.java:147)
         at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
         at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:252)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:392)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:159)
    Thanks in advance!!!
    Tokio Franco Chang
    [/code]

  • How to load spatial data from .shp file

    Could anyone suggest an easy to use, free tool to upload spatial data from .shp file (or/and other open source spatial file sources) into an Oracle Locator database?
    We have licensing for ArcGIS10, but nobody (including ArcGIS) have been able to successfully create a direct connection from their software to our Oracle 10.2 database.
    Client desktops here are Windows 7 64bit, which further complicates matters (tend to find neither ArcGIS nor Oracle support 64bit OS in a cogent fashion)

    790951,
    . . . .You can also try Oracle's ShapeFile Converter (shp2sdo). It's a command line utility so there's automation potential.
    . . . .Note that ESRI's tools may (depending on how they're used) store spatial content in Oracle Spatial as BLOBs containing their ST_GEOMETRY data-type (rather than Oracle's SDO_GEOMETRY type).
    Regards,
    Noel

  • 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.

Maybe you are looking for