How to generate .txt file from data in internal table

Hi I am using the program below to load .txt file into SAP table.
I am moving the records from a .txt file into internal table final and then into ZOUT_CCFOBS table.
How do I load records from internal table final back to another .txt file with the same layout? Pls advice.
REPORT  ZOUP_LOAD_CCF_OBS.
TABLES: ZOUT_CCFOBS.
TYPES: BEGIN OF tline, "structure to store a line of each row
    line(1000) TYPE c,
END OF tline.
TYPES: BEGIN OF i_split, "structure to store split record of each row
      t_ZOTFACIL(100)    TYPE c,
      t_ZOTCCF(8)    TYPE c,
      t_ZOTOBSCAT(100)    TYPE c,
END OF i_split.
DATA: itab TYPE TABLE OF tline WITH HEADER LINE.
DATA: idat TYPE TABLE OF i_split WITH HEADER LINE.
DATA: final TYPE STANDARD TABLE OF ZOUT_CCFOBS WITH HEADER LINE.
DATA: file_str TYPE string.
DATA: c_fnh_mask TYPE dxfields-filemask VALUE '.',
      c_search_dir TYPE dxfields-longpath.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
PARAMETERS p_file LIKE rlgrap-filename.                "file location
SELECTION-SCREEN END OF BLOCK a1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM f4_dxfilename USING p_file.
START-OF-SELECTION.
Download data from application server
  PERFORM download_data.
  file_str = p_file.
  LOOP AT itab.
    CLEAR idat.
this will split the line at every delimeter into single field
    SPLIT itab-line AT ',' INTO idat-t_ZOTFACIL
    idat-t_ZOTCCF
    idat-t_ZOTOBSCAT.
    APPEND idat.
  ENDLOOP.
copying the internal table into final table which compatible with table tcurr
  LOOP AT idat.
    final-ZOTFACIL = idat-t_ZOTFACIL.
    final-ZOTCCF = idat-t_ZOTCCF.
    final-ZOTOBSCAT = idat-t_ZOTOBSCAT.
    APPEND final.
  ENDLOOP.
  LOOP AT final.
    MODIFY ZOUT_CCFOBS FROM final.
    IF sy-subrc EQ 0.
      MESSAGE S001(ZCURR).
    ELSE.
      MESSAGE A000(ZCURR).
    ENDIF.
  ENDLOOP.
FORM f4_dxfilename USING p_file.
addition TAICK 15/07/2008.
*maintain application server default search path.
  IF sy-sysid = 'BWP'.
    c_search_dir = '//rdmsbw/prd/data/output/all'.
  ELSEIF sy-sysid = 'BWQ'.
    c_search_dir = '//rdmsbw/uat/data/output/all'.
  ELSEIF sy-sysid = 'BWD'.
    IF sy-mandt = '900'.
      c_search_dir = '//rdmsbw/sit/data/output/all'.
    ELSE.
      c_search_dir = '//rdmsbw/dev/data/output/all'.
    ENDIF.
  ENDIF.
  DATA: wa_file LIKE dxfields-longpath.
  CLEAR: wa_file.
  CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
    EXPORTING
      i_location_flag = 'A'
      i_server        = ' '
      i_path          = c_search_dir
      filemask        = c_fnh_mask
      fileoperation   = 'R'
    IMPORTING
      o_path          = wa_file
    EXCEPTIONS
      rfc_error       = 1
      error_with_gui  = 2
      OTHERS          = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    p_file = wa_file.
  ENDIF.
addition end TAICK 15/07/2008.
ENDFORM. " f4_dxfilename
FORM download_data .
  OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  DO.
    IF sy-subrc <> 0.
      exit.
    ENDIF.
    READ DATASET p_file INTO itab.
    if sy-subrc = 0.
      APPEND itab.
    clear itab.
    endif.
  ENDDO.
  CLOSE DATASET p_file.
  delete itab index 1. "remove column header
ENDFORM.                    " download_data
Edited by: RebekahMBB on Feb 20, 2012 12:56 PM

Hi I am using this piece of code to download my internal table into an .xls file on my pc.
FORM Z_CONVERT_EXCEL .
  "This part of code to add column name in the downloaded file.
  data : begin of int_head occurs 0,
  Filed1(20) type c,                     " Header Data
  end of int_head.
  int_head-Filed1 = 'ZOTOUS'.
  APPEND int_head.
  CLEAR int_head.
  int_head-Filed1 = 'ZOTOUS'.
  APPEND int_head.
  CLEAR int_head.
  int_head-Filed1 = 'ZOTOGCUR'.
  APPEND int_head.
  CLEAR int_head.
Select ZOTOUS ZOTSYORGU ZOTOGCUR from ZOUT_ORG_CURR into CORRESPONDING FIELDS OF TABLE itab.
  v_filetype = '.xls'. "I just manipulate the file name using XLS file type.
  v_filename = 'C:\Documents and Settings\00088592\Desktop\OUs automation\development'.
  CONCATENATE v_filename v_filetype INTO lv_filename.
  CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = lv_filename
        filetype         = 'ASC'
      APPEND           = 'X'
        write_field_separator = 'X'
      CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = itab
        FIELDNAMES       = int_head
   EXCEPTIONS
        file_open_error  = 1
        file_write_error = 2
        OTHERS           = 3.
  IF sy-subrc <> 0.
  ENDIF.
ENDFORM.                    "Z_CONVERT_EXCEL
As you can see the code specifies the header row separately and appends it in int_head.
What if I have 76 fields or more? I cant be specifying each like that.
Is there any other way to do this? To move the 76 field headers into int_head?
Pls help.
Thanks!

Similar Messages

  • How to generate .DTD file from IDOC?

    Dear All,
    On behalf of my colleague,
    How to generate .DTD file from IDOC? I want to generate this file for importing into the WebMethod Tool. Please share relevant content regarding the same.
    IDOC name is: BOMMAT01
    Let me know if you need any other information.
    Regards,
    JK

    Hi Jitendra,
    When PI receives idoc from ECC it will be in xml format.
    Are you telling that you want to convert this xml to .dtd file?
    check this for converting xml into .dtd file.
    How to convert XML file into DTD or XSD
    could you please explain about what you are doing in this requirement?
    After importing into WebMethod what is the next action?
    do they want to send the file to PI?

  • How to generate XML file from SQL file !

    I am new to XML publisher. I known one way to generate XML file is register one report file in concurrent manager.
    But I want to generate XML file from sql file.
    Could someone show me how to code in sql file, how to register is in concurrent manager.
    Thanks !

    Hi
    Phew ... not sure we have the space here. So I can point you in the right direction:
    1. XML data generation - there are two packages in the db you can use with a plsql procedure, XMLGEN and SQL XML. You can also use java APIs too. Try checking the db documentation and search for the above methods.
    2. Registering the report - the system administrators guide will provide this info. Hooking the program up with XMLP is covered here - http://www.oracle.com/technology/products/applications/publishing/resource/CM%20Whitepaper5.0.pdf
    Regards, Tim

  • How to generate .java file from xml?

    Does anyone have an idea of how i can generate .java file from xml file? Tools like jakrata digester, JOX are there but both of them are useful in populating java beans from xml. My requirement is to generate .java file from .xml with getters and setters methods for xml elements/attributes. I also tried JAXB. But JAXB generates bunch of files and most of them are interfaces, which is not going to work for me.
    For e.g. i have following xml file and i want to generate Address.java file with getters/setters. Any ideas?
    <?xml version='1.0' encoding='UTF-8' ?>
    <Address>
    <FirstName type="String"/>
    <PoBox type="int"/>
    </Address>
    Thanks,
    Vicky

    Crosspost.
    http://forum.java.sun.com/thread.jsp?thread=475564&forum=4&message=2205846

  • How to generate MT files from Oracle EBS Payables

    Hi, does anyone has experience in generating MT files from Oracle Payables?
    All contributions are welcome...

    Hi,
    are you talking about MT-940 format files? If so, what is the use case behind this issue?
    I created a custom loader process to upload MT-940 bank statements into Cash Management
    some time ago, but as far as i understood your question, you want to create those files based
    on payables data?
    Regards

  • How to generate java file from WSDL file

    Hi friends,
    I am new to this thing, so that's why I need some guidence .
    I need to generate java file programatically from existing wsdl file.
    I thought the ways - to use xmlbeans apache library or jaxb.
    Can you suggest what will be better way to generate java file from wsdl? can you please be more descriptive and can you direct me to appropriate link?
    Thanks.
    Harshit

    xmlbeans apache provides easiest way to create java file from wsdl there is very good link for that
    http://www.ibm.com/developerworks/webservices/library/ws-soa-clientxmlbeans.html
    If you want more programmatic approach then Jaxb will be a better option

  • How to generate a file from JSP form

    Hi,
    I want to generate a file from the informations of a form(JSP).
    Which classes do I have to use ?
    Thanks.

    Of course you have to use the standard servlet classes to retrieve the request parameters from the form.
    ie request.getParameter();
    package "java.io" gives you File input/output ability.
    If you are generating a text file, thats probably the BufferedWriter and FileWriter classes.
    Cheers,
    evnafets

  • Generate XML file from an Oracle Database Table

    Hello All,
    I want to generate a xml file from an Oracle Database table which contains a blob column.
    Can somebody give pointers on this please.
    Thanks in advance
    Sulakshana

    Use the DBMS_XMLGEN package.

  • How to generate PDF file from HTML file using Acrobat API's

    Hi,
    I want to generate a PDF file from an HTML file on server side(C# .Net).
    Their is a COM interop called "AcrobatWeb2PDF" availaible but could not find any document regarding how to use it.
    I cant use "Adobe live cycle PDF Generator" as we just have license for Adobe Acrobat 8 Professional.
    Please help...
    Thanks and Regards,
    Anand Mahadik.

    > It is hard to believe that Adobe doesn't provide a toolkit for generating PDF files, so many web based applications have vector based content that needs to be converted to PDF!!!!
    They do, it's just not free (A company in business to make money? I'm sure IBM would never think this way... ;)). As mentioned you have Adobe LiveCycle PDF Generator, which you can customize and extend with Java. You also have the Adobe PDF Library SDK, which is written for use with C/C++ although if you license it from Datalogics (the only company in NA Adobe allows to license the PDF Library) you will also get .NET and Java interfaces (part of the DLE - DataLogics Extensions).
    > There must be a way to generate PDF dynamically on a server or from Javascript!
    JavaScript? Not really, no. As far as I'm aware JavaScript has no file system access capabilities without some form of intermediary (like sending the data to a webservice that writes it out to file). How would you create a PDF file with JavaScript?
    The PDF Standard is also in ISOs hands now (ISO 32000-1:2008), it is no longer owned by Adobe - you can download a copy of the specification from them and write your own library based on that as well.

  • Best Practices:: How to generate XML file from a ResultSet

    Hi all,
    Could someone please suggest the best practices of how to generate an XML file from a resultset? I am developing a web application in Java with Oracle database and one of my tasks is to generate an XML file when the user, for example, click a "download as XML" button on the JSP. The application is basically like an Order with line items. I am using Struts and my first thought has been to have an action class which will extend struts's DownloadAction and through StAX's Iterator API to create an XML file. I intend to have a POJO which will have properties of all columns of my order and line items tables so that for each order I get all line items and:
    1. Write order details then
    2. Through an iterator write line items of that order to an XML file.
    I will greatly appreciate for comments or suggestions on the best way to do this through any pointers on the Web.
    alex

    Use a OracleWebRowSet in which an XML representation of the result set may be obtained.
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/oracle10g/webrowset/Readme.html
    http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/jcrowset.htm

  • How to generate a file from a package

    Hello Guru's,
    I oracle knowledge is very limited. I am given a task.
    A package already written is given to me. I need to generate a file of few given columns and from this package.
    How can I generate the file. Please, help.
    Thanks in advance,

    use UTL_FILE
    (do a search, or read the pl/sql supplied packages manual)

  • How to Generate XML File from Java Code.

    I want to generate the xml file from the java code.
    Could you plz suggest any webSite address with example?

    Here is the code
    import java.io.File;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    public class CreateXML {
         private DocumentBuilderFactory factory = null;
         private DocumentBuilder builder = null;
         private Document document = null;
         public CreateXML() {
              try {
                   factory = DocumentBuilderFactory.newInstance();
                   builder = factory.newDocumentBuilder();
                   document = builder.newDocument();
              } catch (FactoryConfigurationError e) {
                   e.printStackTrace();
              } catch (ParserConfigurationException e) {
                   e.printStackTrace();
         /** Creates the document for xml. */
         public Document createDocument(){
              try{               
                   Element root = document.createElement("Root");
                   Element child = document.createElement("child");
                   root.appendChild(child);
                   document.appendChild(root);
              }catch(RuntimeException e){
                   e.printStackTrace();
              return document;
         /** Saves the document as xml. */
         public void saveDocument(Document document){
              try{
                   TransformerFactory transFactory = TransformerFactory.newInstance();
                   Transformer transformer = transFactory.newTransformer();
                   DOMSource source = new DOMSource(document);
                   StreamResult stream = new StreamResult(new File("sample.xml"));
                   transformer.transform(source, stream);
                   System.out.println("XML Created !!");
              }catch(TransformerConfigurationException e){
                   e.printStackTrace();
              } catch (TransformerException e) {
                   e.printStackTrace();
         public static void main(String args[]){
              CreateXML createXML = new CreateXML();
              Document document = createXML.createDocument();
              createXML.saveDocument(document);
    }

  • How to generate .PRN file from a ReportDocument object in Crystal Reports 10.

    Hi,
    I have reports created in Crystal 10 version. From the VB .Net code I am able to load the report to ReportDocument object and able to print it to the local printer. Now I need to generate .PRN file of the report for faxing purpose.
    Can anyone help me one this?.
    Thanks,
    Srini.

    Hi Joanne,
    Boxes do not actually have a 'name'. When you add a Box in a report, it will be called 'Box 1' by default. And the only place this name is visible is under the Report Explorer.
    Or do you mean to say 'Text Object'?
    -Abhilash

  • How to generate trace file from different session?

    I have a cron job which starts several Oracle stored proc (Oracle 9.2). I want to generate a trace file when the job is running. I know I can use this alter session command before I start this job. But this is my session not the job session. So this command won't generate trace file for job's session.
    ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 8';
    Appreciate any ideas.
    Thanks.
    S.

    Easiest way is to use database control/grid control - click trace session button!
    The 'old fashioned way is'
    begin
    DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(SID,serial#,TRUE);
    end;
    find sid and serial# in a select from v$session
    There are other ways too but this is probably the easiest.
    You'll need appropriate privileges to run this .
    Cheers,
    Harry

  • How to generate class files from wsdl

    I have upgraded weblogic from 9.1 to 10.3.5 and java from 1.5.0_06 to 1.6.0_27
    Do I have to regenerate my webservices classes like the stub ,impl and service class.
    also there are a few changes in the wsdl .
    Please help me how to generate classfiles from wsdl ?
    Please help.
    Thanks,

    Did you ever get an answer to this question? Did you proceed forward with the use of WSIF or did you select an alternative.
    Ernie :)

Maybe you are looking for

  • Can not read data from URL!

    Hello, I want to read data from URL (http://84.100.130.82:8000/;stream.nsv). But can not do it. Because when try to call function openDataInputStream() shows this error: java.io.IOException: response does not start with HTTP it starts with: ICY. How

  • How can i set a global error page for all error cod

    how can i set a global error page for all error code? i don't want to leave a long list in the web.xml file.could any one help me? thanks

  • IPhone no longer syncs with computer--"Cannot access the iTunes store"

    My iPhone 2G has decided to no longer sync with my iTunes. I do not have internet on my computer (I'm doing this on a friend's), so when I connect my iPhone to my computer, an error message pops up that says "Cannot access the iTunes store". Since my

  • Help with user 'rotating' gallery

    Hi all, I'm trying to emulate the interactive movie as seen here http://tinyurl.com/ykuasrt I have all the images of the model I've rendered out, but I'm a bit stuck onto where to start with the flash. Does anyone know a good starting point? I've sea

  • Qty zero in MIGO

    A vendor sends a delivery note which has 2 materials. MAT1 100 pc MAT2 50 pcs But in actual only MAT1 was delivered. Now when I am doing MIGO, I entered 0 pcs in delivered qty field and in qty in Unit of Entry field ZERO. But MIGO doesnt takes ZERO v