Reading XML file using BAPI and then uploading that xml file data into SAP

I am getting a xml file from Java server. I need to take
data from this file using BAPI and need to upload into SAP using SAP.
Please tell me how to read XML files using BAPI's.

<b>SDIXML_DATA_TO_DOM</b> Convert SAP data (elementary/structured/table types) into DOM (XML
<b>SDIXML_DOM_TO_XML</b>  Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
<b>SDIXML_DOM_TO_SCREEN</b> Display DOM (XML)
<b>SDIXML_DOM_TO_DATA</b>
data: it_table like t001 occurs 0.
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.
start-of-selection.
  select * from t001 into table it_table.
end-of-selection.
initialize iXML-Framework          ****
  write: / 'initialiazing iXML:'.
  class cl_ixml definition load.
  g_ixml = cl_ixml=>create( ).
  check not g_ixml is initial.
  write: 'ok'.
create DOM from SAP data           ****
  write: / 'creating iXML doc:'.
  m_document = g_ixml->create_document( ).
  check not m_document is initial.
  write: 'ok'.
  write: / 'converting DATA TO DOM 1:'.
  CALL FUNCTION 'SDIXML_DATA_TO_DOM'
    EXPORTING
      NAME               = 'IT_TABLE'
      DATAOBJECT         = it_table[]
    IMPORTING
      DATA_AS_DOM        = l_dom
    CHANGING
      DOCUMENT           = m_document
    EXCEPTIONS
      ILLEGAL_NAME       = 1
      OTHERS             = 2.
  if sy-subrc = 0.  write  'ok'.
  else.             write: 'Err =', sy-subrc.
  endif.
  check not l_dom is initial.
  write: / 'appending DOM to iXML doc:'.
  w_rc = m_document->append_child( new_child = l_dom ).
  if w_rc is initial.  write  'ok'.
  else.                write: 'Err =', w_rc.
  endif.
visualize iXML (DOM)               ****
  write: / 'displaying DOM:'.
  CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
    EXPORTING
      DOCUMENT          = m_document
    EXCEPTIONS
      NO_DOCUMENT       = 1
      OTHERS            = 2.
  if sy-subrc = 0.  write  'ok'.
  else.             write: 'Err =', sy-subrc.
  endif.
convert DOM to XML doc (table)     ****
  write: / 'converting DOM TO XML:'.
  CALL FUNCTION 'SDIXML_DOM_TO_XML'
    EXPORTING
      DOCUMENT            = m_document
    PRETTY_PRINT        = ' '
    IMPORTING
      XML_AS_STRING       = w_string
      SIZE                = w_size
    TABLES
      XML_AS_TABLE        = it_xml
    EXCEPTIONS
      NO_DOCUMENT         = 1
      OTHERS              = 2.
  if sy-subrc = 0.   write  'ok'.
  else.              write: 'Err =', sy-subrc.
  endif.
  write: / 'XML as string of size:', w_size, / w_string.
  describe table it_xml lines w_result.
  write: / 'XML as table of', w_result, 'lines:'..
  loop at it_xml into s_xml.
    write s_xml.
  endloop.
  write: / 'end of processing'.
end of code
Hope this will be useful.
regards
vinod

Similar Messages

  • Using Cursor and FOR LOOP to INSERT the data into table

    Hi all,
    I have SELECT statement that returns 3 rows:
    PROCESSNAME
    PROTDATE
    IMM
    2013-12-18
    Metrology
    2013-11-18
    CT
    2013-12-04
    SELECT  processName, MAX(NVL(protStartDate, protCreateDate)) AS protDate
        FROM TABLE(SEM_MATCH("{
                ?ipc rdf:type s:Protocol .
                ?ipc s:protocolNumber ?protNum .
                ?ipc s:protocolCreateDate ?protCreateDate .
                OPTIONAL {?ipc s:protocolSchedStartDate ?protStartDate }
                ?ipra rdf:type s:ProcessAggregate .
                ?ipra s:hasProtocol ?iprot .
                ?iprot s:protocolNumber ?protNum .
                ?ipra s:processAggregateProcess ?processName.
        }",sem_models("PROTS", "LINEARS"),NULL, SEM_ALIASES(SEM_ALIAS("","http://VISION/Data/SEMANTIC#"),SEM_ALIAS("s","http://VISION/DataSource/SEMANTIC#")),NULL))
            Group by processName
    Now I need to INSERT these values into the table along with the other values.
    these other values come from different table.
           INSERT INTO MODEL_CLASS_COUNTS (MODEL_NAME, CLASS_NAME, INS_COUNT, COUNT_DATETIME, PROCESS_NAME, PROT_DATE)
           VALUES
           ("$MODEL",     
                "${i}",
            (SELECT COUNT (DISTINCT S)  FROM TABLE(SEM_MATCH(
                            "{?s rdf:type :${i} . }",SEM_Models("$MODEL"),NULL, SEM_ALIASES(SEM_ALIAS("","http://VISION/DataSource/SEMANTIC#")),NULL))),
             SYSTIMESTAMP, %%here need to insert PROCESSNAME, PROTDATE%%
    t was giving me error:
    PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    so i enclosed sparql query into single quotes.
    The code is as follows:
    declare
    type c_type is REF CURSOR;
    cur c_type;
    v_process varchar2(200);
    v_pdate varchar2(200);
    begin
    open cur for
           ' SELECT processName,  MAX(NVL(protStartDate, protCreateDate)) AS protDate   <-- it's complaining about this being too long identifier, i think...
            FROM TABLE
              (SEM_MATCH (
                            ?ipc rdf:type s:Protocol .
                            ?ipc s:protocolNumber ?protNum .
                            ?ipc s:protocolCreateDate ?protCreateDate .
                            OPTIONAL {?ipc s:protocolSchedStartDate ?protStartDate }
                            ?ipra rdf:type s:ProcessAggregate .
                            ?ipra s:hasProtocol ?iprot .
                            ?iprot s:protocolNumber ?protNum .
                            ?ipra s:processAggregateProcess ?processName.
                        }",SEM_Models("XCOMPASS", "XPROCESS"),NULL,    
              SEM_ALIASES(SEM_ALIAS("","http://VISION/Data/SEMANTIC#"),
              SEM_ALIAS("s", "http://VISION/DataSource/SEMANTIC#")),NULL))
               Group by processName';  
    loop
    fetch cur into v_process, v_pdate;
    exit when cur%NOTFOUND;
    --here I need to insert v_process , v_pdate into my table along with other values...
    dbms_output.put_line('values for process and prod_date are: ' || v_process || v_pdate );
    end loop;
    close cur;
    end;
    exit;
    Now, I get an error:
    ORA-00972: identifier is too long
    Does anyone know way around this?

    Hi,
      I tested something similar with insert into select  and it worked fine :
    insert into t_countries(ID,CITY ,POPULATION, DESCRIPTION, located, insdate )
    SELECT 1 id, city, o , city||' is a nice city' description,  max(nvl(locatedAt,'unknown')) as located,
      SYSTIMESTAMP
      FROM TABLE(SEM_MATCH(
        '{GRAPH :gCH {<http://www.semwebtech.org/mondial/10/countries/CH/> :hasCity ?cityID .
           ?cityID :name ?city .
           OPTIONAL{?cityID :locatedAt ?locatedAt .}
           ?cityID :population ?o .
        SEM_Models('VIRT_MODEL_MONDIAL'),
        SEM_Rulebases(null),
        SEM_ALIASES(SEM_ALIAS('','http://www.semwebtech.org/mondial/10/meta#'),
        SEM_ALIAS('prv','http://www.semwebtech.org/mondial/10/countries/CH/provinces/')
        null))
        group by city,o
        order by city;
    Or with execute immediate :
    declare
      v_country varchar2(200) :='http://www.semwebtech.org/mondial/10/countries/F/';
      v_text varchar2(2000);
    begin
    v_text := 'insert into t_countries(ID,CITY ,POPULATION, DESCRIPTION, located, insdate )
    SELECT 1 id, city, o , city||'' is a nice city'' description,  max(nvl(locatedAt,''unknown'')) as located,
      SYSTIMESTAMP
      FROM TABLE(SEM_MATCH(
        ''{<'||v_country||'> :hasCity ?cityID .
           ?cityID :name ?city .
           OPTIONAL{?cityID :locatedAt ?locatedAt .}
           ?cityID :population ?o .
        SEM_Models(''VIRT_MODEL_MONDIAL''),
        SEM_Rulebases(null),
        SEM_ALIASES(SEM_ALIAS('''',''http://www.semwebtech.org/mondial/10/meta#'') ),
        null))
        group by city,o
        order by city';
        dbms_output.put_line(v_text);
        delete from t_countries;
        execute immediate v_text ;
        commit;
    end;
    Marc

  • Reading XML file using BAPI  I must use adapters .

    Reading XML file using BAPI and then uploading that xml file data into SAP using BDC.
    I cant take file on to my Application server I am getting the file dynamically from other file server and I need to use BAPis to read data from XML file.please tell me what should be my Import,Export and Tables parameterrs should be.
    Thanks

    Hi,
    Import, export and table parameters for BAPI is required, without that BAPI will not able to collect the data from XML. What you need to do is write a Zprogram and collect the data, store that data in internal table and call the BAPI by passing required parameters.
    Different Scanarios:
    1) Before calling a BAPI write some other program which collects the data from XML and create a UNIX file. Try to get the data from UNIX FILE
    2) If you see the XML tags, data will be in side that tags, try to get the data from XML tags and store that data in one SAP table. You can use the BAPI by fetching the data from table
    3)Create a table and store the data in the table. Use the table in SAP to extract the data.
    BAPI won't work without any parameters, you have to pass some parameters then the BAPI will return some values.
    Hope i am clear.
    Thanks&Regards,
    -Suresh Revuru

  • JSP that converts office extensions to pdf and then upload them

    Hi there !
    Im trying to convert office extensions ( .xls, .ppt, etc) to pdf and then upload the resulting file to a server .
    currectly im using the upload solution posted by the user anna_DRA here : http://forums.sun.com/thread.jspa?threadID=672874
    and as for the conversion im using a solution which uses OpenOffice's lib to do the conversion.I'm going to post the codes of my JSP and my HTML ( which just contains the form to get the file to be converted and uploaded).
    observation: the point which is giving me headaches is how to get the file sent by my form, convert it into a File object, use my conversion tool and then deliver it to my upload tool so it can be stored.... i cant seem to get the File object from the request object ( tried getattribute and it returns null....) .
    observation':I do know about and how to use MVC but my boss asked me to make this work with just one JSP or a JSP and a HTML.
    index.html :
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Upload test</title>
    </head>
    <body>
    <form enctype="multipart/form-data" action="/WSPdfConversion1.1/Conversion.jsp" method=POST>
    <input type="file" name = "FileUp">
    <input type="submit" value="Enviar"/>
    </form>
    </body>
    </html>Conversion.jsp :
    upload portion:
    MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
    OpenOfficeConnection OpenOfficeConnection = new SocketOpenOfficeConnection(8100);
    String newName = "";
    Hashtable files = mrequest.getFiles();
    UploadFile file = (UploadFile) files.get("FileUp");//Give name u r given in the previous page.
    String fileName = file.getFileName();
    upBean.store(mrequest, "FileUp");conversion portion:
    OpenOfficeConnection OpenOfficeConnection = new SocketOpenOfficeConnection(8100);
    try {
        OpenOfficeConnection.connect();
    } catch (ConnectException e) {
        e.printStackTrace();
    File inputFile = new File("C:\\Users\\thiago\\Documents\\"+fileName);
    for(int i = 0; i <= fileName.length() - 4; i++){
        String s = ""+fileName.charAt(i);
        newName = newName.concat(s);
    File outputFile = new File("C:\\Users\\thiago\\Documents\\"+newName+".pdf");
    //convert the spreadsheet
    DocumentConverter ExcelToPDFConverter = new OpenOfficeDocumentConverter(OpenOfficeConnection);
    ExcelToPDFConverter.convert(inputFile, outputFile);
    OpenOfficeConnection.disconnect();Both work just ok when separated but i cant get both to work together....
    Any help is much appreciated!!!
    Thanks in advance
    Edited by: thiagocbalducci on Mar 24, 2010 12:07 PM
    Edited by: thiagocbalducci on Mar 24, 2010 12:09 PM

    Hello TSN,
    Test Screen Name wrote:
    Picking just one point: PDF -> EPS -> PDF. This could not possibly do more than one page, because EPS is absolutely by definition a single page format. Therefore you must choose a page when exporting PDF to EPS.
    Thanks for your response.
    I was thinking Microsoft... which has allowed multi-page eps files for years. But you're correct, this is normally an unsupported .eps format.
    I solved the problem over the weekend by doing the following:
    1) I removed the suspect OTF font family but despite doing so, the folder still had two 'corrupted' but unused copies of an italic font. They refused to remove so I had to boot into Win7 SAFE mode to remove.
    2) After complete removal of the OTF font family. I reinstalled the OTF font *BUT* only from a different repository (oddly, this other OTF font set is slightly larger per font).
    3) Once installed, I tested with Flare, published and uploaded to Crocodoc SUCCESSFULLY. Yeah!
    I don't have anymore time to test but the questions remain, such as, was it one or more of the following issues:
    a) Flare has a problem handling some OTF fonts or cannot error correct (the way other programs do) for marginal fonts or font errors?
    b) Was it the two corrupted fonts in the Windows/fonts folder?
    c) Was it the slightly different OTF fonts that I am no longer using?
    Take care

  • Can I record sound using a microphone and then upload it to server?

    Hello guys I thank you in advance for reading this. What I want to know is if it is possible to record a sound clip using a microphone and then upload it to the server using a swf applet in a webpage. Im an experienced java/javascript programmer but just starting out with flash/action script. What technologies will I need to do this? Can I do this simply using simply an swf file and an apache/php or jsp page? Again, thanks alot for your help.
    -BeWilled

    You can Microphone class in Flash to record the sound and it will directly upload to FMS server .
    Use the Microphone class to capture audio from a microphone attached to a computer . Use the Microphone class to monitor the audio locally. Use the NetConnection and NetStream classes to transmit the audio to Flash Media Server. Flash Media Server can send the audio to other servers and broadcast it to other clients running Swf files .
    Below link might help you in doing this : http://www.adobe.com/devnet/air/flex/articles/using_mic_api.html

  • Is it better to output t master file and then upload to youtube?

    I had to upload 33 videos to youtube today
    This has taken tooo long
    Just wondering, is it better to create a master file and then upload to youtube?
    I could maybe just copy the files to another machine and leave it to upload?
    Thanks
    Omar

    just to add:
    don't try to upload your Masterfile to YouTube!
    usually, the Masterfile is a copy of the projects timeline = proRes.
    that creates incredible large files = time for upload, wasting bandwidth, and YT will complain 'wrong settings'
    After saving a masterfile, which goes fast, you should use a 'Converter' of your choice (QuicktimePro, Mpg Streamclip, Compressor) to transcode into YT's recommended upload settings.-

  • How can I convert a word file into a pdf and then upload to a web site?

    I need to convert a word document into a pdf and then upload it to a web site so people can read it from my
    site. How can I do this? Can anyone please help? I'm only a newbie. Thanking you in anticipation.

    Hi there,
    There's actually an easy streamlined way to do this using Acrobat.com. Here are the steps:
    1. Log in to Acrobat.com with your Adobe ID.
    2. On the left, you'll see a navigation menu that includes the item "Import and Edit". Click that.
    3. Choose the .doc (Word) file you want to convert and upload it to Buzzword.
    4. After making sure that it looks the way you want it to, go to the top menu (still in Buzzword now, not the organizer where all your files live) and click the document menu. There will be an option to "Export" - choose that.
    5. When prompted to select filetype, choose "Adobe PDF" and press OK.
    6. It'll save to your desktop, so now you have to get it into your acrobat.com organizer. To do that, close the Buzzword document by clicking the little "x" in the upper right corner, under the Sign Out button. This'll get you back to your organizer, where you can choose "Import" from the left nav menu again. This time choose your new PDF file.
    7. Select the  file icon in the organizer and click the Share button. Or, select Share  from the file context menu.
    8. Select Allow Anyone With A  Link To Share This Document to set the document to open access, and then  click Copy Embed Code. The necessary HTML code to embed the preview is  copied onto the clipboard.
    9. Open the HTML file and paste  the code into the file. The Flash previewer can display any file type  that you can convert to PDF.
    Hope this helps! Good luck, and let us know how it works out.
    Rebecca

  • How can I create an csv/excel file using pl/sql and then sending that file

    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.

    968776 wrote:
    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
    Whay do you want database (pl/sql) code to do these things?
    Anyhow, you may be interested in :
    {message:id=9360007}
    {message:id=9984244}

  • I am using CS3 and want to save a file as a pdf where someone can then edit the text. How can I do this please? Thank you :)

    I am using CS3 and want to save a file as a pdf where someone can then edit the text. How can I do this please? Thank you

    You might be able to use the newest adobe reader program/application for that.
    You would have to save your pdf out of photoshop cs3 without any text and then add the text to the pdf in adobe reader.
    The text added in adobe reader can't be edited in photoshop, so the other people would have to adobe reader or acrobat to edit the text.
    https://helpx.adobe.com/reader.html

  • Am editing with red files in premier pro and when I export and then upload to youtube it is not showing as an hd video.  can anyone help?

    am editing with red files in premier pro and when I export and then upload to youtube it is not showing as an hd video.  can anyone help?

    Then it's probably YouTube - have you checked here to see that you're watching the hi res version? It could be that YouTube is choosing an easier version to display based on your internet connection.
    You can see on this screenshot that although the video has up to 1080 specs, my connection is making YouTube show me the 360p version by default.

  • I am using Indesign cs5 version 7.0.4 with a mac OS X version 10.9.4. I am having an issue where the save and save as option disappears. I am exporting the file as .idml and then resaving to avoid losing work but has to import all the images which takes a

    I am using Indesign cs5 version 7.0.4 with a mac OS X version 10.9.4. I am having an issue where the save and save as option disappears. I am exporting the file as .idml and then resaving to avoid losing work but has to import all the images which takes ages. Any help out there?

    I believe there are a couple of similar threads about CC or CC2014 behaving this way that might give yo some hints, but CS5 is not supported on your OS and may not run properly regardless of what you do. An in-place OS upgrade or an attempt to migrate the application would both be major problems for ID, so if you did either of those things you'll want to uninstall, run the cleaner tool (CS Cleaner Tool for installation problems | CCM, CS6, CS5.5, CS5, CS4, CS3) and reinstall.

  • I have a separate apple id and my daughter bought a song using my ID rather than hers.  Now I've got this song that I don't care for and have no use for.  Is there a way to get it to her ID short of burning it on to CD and then uploading it to her phone?

    I have a separate apple id and my daughter bought a song using my ID rather than hers. She was playing on my computer and bought it, thinking it would download to her phone through the cloud. Now I've got this song that I don't care for and have no use for.  Is there a way to get it to her ID short of burning it on to CD and then uploading it to her phone?

    sure pretty simple.  make a backup of your current settings
    http://support.apple.com/kb/HT1766?viewlocale=en_US
    then restore device from old backup you need pics off of
    then import pics to computer
    http://support.apple.com/kb/HT4083
    you may need to save pics to camera roll first
    then restore the new backup and sync pics back to phone via itunes
    Peace, Clyde

  • I deleted all my photos and videos and then delete the deleted files but the photo app is still taking up 12 GB of space and I have no room for new stuff.  How can I clear the memory space used by my deleted videos and photos?

    I deleted all my photos and videos and then delete the deleted files but the photo app is still taking up 12 GB of space and I have no room for new stuff.  How can I clear the memory space used by my deleted videos and photos?  I don't know why the photos are still taking up space and if I will have to reset my phone to get rid of the problem.

    Hey there TowneJ,
    Welcome to Apple Support Communities.
    The article linked below provides troubleshooting tips that’ll likely resolve the issue that you’ve described, where deleted files appear to be taking up space on your iPhone 5.
    If you get a "Not enough free space" alert on your iPhone, iPad, or iPod touch - Apple Support
    So long,
    -Jason

  • HT4623 I've updated my iphone4 with iOS 6, but now i am unable to transfer my music videos to iphone.I cant add a music video to itunes using 'add file to library' and then transfer it to my iphone.

    I have updated my iphone 4 with iOS 6, but now i am unable to transfer my music videos to iphone.I cant add a music video to itunes using 'add file to library' and then transfer it to my iphone. Am using itunes 10.7.

    You need to update iTunes to 11.1 on your PC

  • How to edit xml file particular value. and how to send xml file over ip address 192.168.2.10 using ftp

    how to edit xml file particular value. and how to send xml file over ip address 192.168.2.10 device using ftp through Ethernet

    Hello
    For using FTP function in LabVIEW, I recommend you to check this document: FTP Basics
    Also, take a look at FTP Browser.vi, which is available at the Example Finder.
    To edit a XML file, try to use VIs in XML palette. Maybe Write to XML.vi helps you.
    Post your current VI if possible.
    Regards
    Mondoni

Maybe you are looking for

  • Help with scrolling screen

    I am writing a turn based strategy game in Java but I am unable to make a scrolling screen you can "move" your view of the game board around in. I can do every other aspect of the game myself, except for this. Examples of this on the internet are onl

  • HR: ESS report  attendance

    HI, can anybody suggest how to make ESS  report  based on clock in ,clock out , sick leave, RH  etc  with time management for a particular duration period  in ABAP  i.e. If  employee comes very late and goes very earily then i  should   count that  d

  • Trying to Understand Tapeless Workflow

    I know a lot of editors talk about tapeless workflows and it seems that most of the tapeless workflows involve a camcorder or P2 card reader to get footage into your hard drive but I'm curious... what if an editor doesn't shoot footage or own a camer

  • Cannot change graphics mode/Old preference pane

    Just received my new Macbook Pro 2.53. Loaded up just great was able to use all the features, but after transferring all of my old data via ethernet I cannot change the graphics card mode! I no longer have the option to. I have the OLD 'Energy Saver'

  • Changing on the go play lists on ipod

    I currently have three on the go play lists on my ipod. I would like to delete them but can't find how to anywhere. I have successfully remove them from my i tunes. The users manual is not very specific on this topic. Please help. Thanks.