Store a txt file in war

Can i include a file.txt in war package and read it from servlet classes post deployment? I thow, but the jboss generate the error: file not found. What is the correct path specification?

I'm not familiar with JBoss, but typically this would accessable from the from the WebApp's root directory. Depending on the platform (OS & App Server) other directories may or may not be accessable.
I usually use this little helper class to drop a file in the WebApps root.
import java.io.IOException;
import java.io.FileWriter;
import java.util.Date;
import java.text.DateFormat;
* A helper class that can be used to mark directories
public class DirectoryUtils {
   * mark the default data directory with a
   * marker derived from the calss name.
   * Usage
   *   <CODE>
   *     DirectoryUtils.markDirectory( this ) ;
   *     DirectoryUtils.markDirectory( getClass().getName() ) ;
   *   </CODE>
   * @param that object from which to derive class name
   * @return <tt>true</tt> if sucessfull
   * @deprecated this is redundant calls may be removed.
  public static boolean markDirectory( Object that ) {
    return markDirectory( that.getClass().getName() ) ;
   * Marks the data directory with a marker.
   * Usage
   *   <CODE>
   *     DirectoryUtils.markDirectory( this ) ;
   *     DirectoryUtils.markDirectory( getClass().getName() ) ;
   *   </CODE>
   * @param dataFileName the class name to be used as a filename
   * @return <CODE>true</CODE> if sucessfull
   * @deprecated this is redundant calls may be removed.
  public static boolean markDirectory( String dataFileName ) {
    boolean bRetVal = false ;
    String _dataFileName = dataFileName + ".cwd" ;
    String content = "# " + _dataFileName ;
    String timeStamp = "# " + DateFormat.getDateTimeInstance().format( new Date() ) ;
    try {
      FileWriter fileWriter = new FileWriter( _dataFileName ) ;
      fileWriter.write( content, 0, content.length() ) ;
      fileWriter.write( timeStamp, 0, timeStamp.length() ) ;
      fileWriter.flush() ;
      fileWriter.close() ;
      bRetVal = true;
    catch ( IOException e) {
      System.err.println( "markDirectory() : " + e.toString() ) ;
      e.printStackTrace() ;
    return bRetVal ;

Similar Messages

  • How to store txt file into Oracle 7 Database using Pro*C

    Hi,
    I want to store a txt file into Oracle 7 database table using
    Pro*C application. But do not know what type of column to use.
    At first glance it appeared to me as LONG can serve the purpose
    but later I noticed that I can not do the sequential read/write
    in LONG type of column. That is, I have to use chunks of max of
    2GB (or file lenght) to read/write into such columns.
    I want something simiar to CLOB of Oracle 8.
    I would appreciate if you can provide me solution.
    Thanks,
    Anurag

    You store images in a BLOB column in the database.
    However, inserting image in that column and displaying data/image from that column are 2 very different tasks.
    If you are using Oracle forms, displaying is easy. Default block sitting on the table with BLOB column, can be easily mapped to image box (or similar control), which will display that image.
    Inserting images will be a different ball game. If your forms are web based (i.e. run from browser) and you want to insert images from client machine, some special arrangements are required.
    If images are on database server and you want to insert them in database, the stored procedure given in the earlier thread (posted above) will do the job.

  • How to store the datas in a .txt file in to a JTable in Java Swing

    Hi sir,
    Here i want to know how to store the data's of a .txt file
    in to a JTable in java swing.
    Where here the .txt file like for eg,spooler.txt is in the server and from there it will come to my client machine what i have to do is to take that .txt file and store the datas of the .txt file
    in a JTable.This is what i want.So pls. do help and provide the code as well.I will be thankful.Since i am involved in a project which involves this it is Urgent.
    Thanx,
    m.ananthu

    You can't just display data from a text file in a JTable. You have you understand the structure of the data so that you can parse the data and create a table model that can access the data in a row/column format. Here is an example of a simple program that does this:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=315172

  • C# WPF read a .txt file line by line and store it to listview with GridViewColumn

    I have a .txt file with text in the following format:
    Name Pid CPU Thd Hnd Priv CPU Time Elapsed Time
    Idle 0 99 8 0 0 203:18:16.647 26:02:53.315
    I want to store it in a listview with a GridViewColumn. Name is one GridViewColumn and in this I want to store, for example, Idle. How can I do this?

    Unfortunately your post is off topic as it's not specific to Microsoft Training and Certification.  
    This is a standard response I’ve written in advance to help the many people who post their question in this forum in error, but please don’t ignore it.  The links I provide below will help you determine the right forum to ask your question in.
    For technical issues with Microsoft products that you would run into as an end user, please visit the Microsoft Answers forum ( http://answers.microsoft.com ) which has sections for Windows, Hotmail,
    Office, IE, and other products.
    For Technical issues with Microsoft products that you might have as an IT professional (like technical installation issues, or other IT issues), please head to the TechNet Discussion forums at http://social.technet.microsoft.com/forums/en-us, and
    search for your product name.
    For issues with products you might have as a Developer (like how to talk to APIs, what version of software do what, or other developer issues), please head to the MSDN discussion forums at http://social.msdn.microsoft.com/forums/en-us, and
    search for your product or issue.
    If you’re asking a question particularly about one of the Microsoft Dynamics products, a great place to start is here: http://community.dynamics.com/
    If you think your issue is related to Microsoft Training and Certification and I've flagged it as Off-topic, I apologise.  Please repost your question and include as much detail as possible about your problem so that someone can assist you further. 
    If you really have no idea where to post your question please visit the Where is the forum for…? forum http://social.msdn.microsoft.com/forums/en-us/whatforum/
    When you see answers and helpful posts, please click Vote As Helpful,
    Propose As Answer, and/or Mark As Answer
    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCSA, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID:
    Microsoft Transcript

  • Array to store .txt file data

    I have a .txt file containing lines like the following:
    1,50000.343,2000.745
    2,25645.856,4600,856
    3,24356.756,8766,345
    I'd like to store the strings as numbers and place them into an array, but I'm unsure how to do so.
    Any help would be appreciated

    The StreamTokenizer class will help you read the input, separating numbers from commas. Once you have the number as a String, the classes like Double and Integer have constructors that accept String arguments and do the hard work for you:
    // someString came from the file
    // you checked to see if it had a "." and it didn't, so
    // you know it's an integer
    Integer myInteger = new Integer( someString );
    int myInt = myInteger.getInt();

  • Txt file missing after deploying war

    All,
    i've encountered weird problem when i'm deploy new war to the server. i want my class read the txt file. so that i've put the txt file at the same path as class as well at src/javapackage. here is the path..
    F:/myapp/voip/src/clientpkg
    so that i assumed when i deploy the war file to the server all classess & txt file will be kept at the ...
    webapps/voip/WEB-INF/classes/clientpkg/
    but when i checked at the clientpkg directory, the txt file is missing. what shud i do now?
    here is my code to read the txt file..
    private boolean migration25Cpes() throws Exception {
    boolean status = false;
    try {
    System.out.println(System.getProperty("user.dir"));
    System.out.println("read the file again/");
    InputStream in = this.getClass().getResourceAsStream("list25cpe.txt");
    Reader rin = new InputStreamReader(in);
    BufferedReader inputFile = new BufferedReader(rin);
    String readSource = "";
    while ( (readSource = inputFile.readLine()) != null) {
    System.out.println(readSource);
    System.out.println("the input now : " +inputFile.read());
    inputFile.close();
    catch (FileNotFoundException e) {
    e.printStackTrace();
    return status;
    }

    Then you have to find a way to tell JBuilder to include the text file in the jar. I don't know JBuilder, but I'm guessing that right now it is probably building the jar from the compiler output directory, which contains only class files.
    There may be a setting to copy non-java files to the compiler output directory, or you may need to put stuff you want to appear in WEB-INF/classes in some other location for it to be picked up by the JBuilder war-creator.

  • Store txt file to 2darray

    I make afunction that save a 2darray into atx using this code
        private boolean saveArray(File filename, double[][] output_veld) {
            try {
               PrintWriter out =
               new PrintWriter (new BufferedWriter (new FileWriter (filename)));
               out.print (Arrays.deepToString(output_veld));
               out.flush ();
               out.close ();
            catch (IOException e) {
               return false;
            return true;
    }I want to store again the data in txt file into the 2darray I tried this code
    public String readFile (File file) {
    double a [][] = new double [3][3];
        StringBuffer fileBuffer;
        String line;
        try {
          FileReader in = new FileReader (file);
          BufferedReader dis = new BufferedReader (in);
          fileBuffer = new StringBuffer () ;
          while ((line = dis.readLine ()) != null) {
                fileBuffer.append (line + "\n");
          in.close ();
          a =  the problem is here !! how I can insert the data on the array
        catch  (IOException e ) {
          return null;
        return fileString;
      }

    hi,
    I tried it like that ...
        boolean saveFile () {
          File file = null;
          JFileChooser fc = new JFileChooser ();
          fc.setCurrentDirectory (new File ("."));
          fc.setFileFilter (fJavaFilter);
          fc.setSelectedFile (fFile);
          int result = fc.showSaveDialog (this);
          if (result == JFileChooser.CANCEL_OPTION) {
              return true;
          } else if (result == JFileChooser.APPROVE_OPTION) {
              fFile = fc.getSelectedFile ();
              if (fFile.exists ()) {
                  int response = JOptionPane.showConfirmDialog (null,
                    "Overwrite existing file?","Confirm Overwrite",
                     JOptionPane.OK_CANCEL_OPTION,
                     JOptionPane.QUESTION_MESSAGE);
                  if (response == JOptionPane.CANCEL_OPTION) return false;
              String content = fFile.toString();
              return saveArray (content,drawLines1);
          } else {
            return false;
        public boolean saveArray(String filename, double[][] output_veld) {
                 try {
                    FileOutputStream fos = new FileOutputStream(filename);
                    ObjectOutputStream out = new ObjectOutputStream(fos);
                    out.writeObject(output_veld);
                    out.flush();
                    out.close();
                 catch (IOException e) {
                     System.out.println(e);
                     return false;
                  return true;
              }but when I opened the saved txt file I didnt get data I get some things liek that!!
    ? ur [[D?dgE  xp  ?ur [D>?cZ  xp   @V      @F      @g?     @[?     ?                       uq ~    @p?     @b     @w@     @m      ?                       uq ~    @{`     @u0     @{      @x0     ?                       uq ~    @s      @y      @j@     @u      ?                       uq ~    @uP     @r?     @|?     @p     ?                       uq ~    @     @b?     @sp     @O      ?                       uq ~    @n@     @f      @f      @p?     ?                       uq ~    @t      @w      @x?     @y`     ?                       uq ~    @y      @}?     @??     @v     ?                       uq ~    @?      @rP     @{?     @f`     ?                       uq ~    @a     @j`     @l      @q     @                      uq ~    @l      @q     @up     @g      @                      uq ~    @up     @g      @o      @|     @                      uq ~    @o      @|     @d      @t     @                      uq ~    @d      @t     @z      @q?     @                      uq ~    @z      @q?     @~     @f      @                      uq ~    @xp     @s      @rP     @xP     @                      uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~                                                            uq ~    

  • Can I store .txt files in a jar and read them?

    I have searched the forum and didn't find exactly what I needed.
    I have multiple .txt files that will most likely not change over time. I have a class that reads them as needed. I need to do this in a jar file but can not seem to read the .txt files.
    Any help?

    You should be able to read them using an idiom like this:
    URL textURL = MyClass.class.getResource("res/txt/TextResourceFile.txt");where MyClass is the name of a class, and the specified path is relative to the location of that class.
    I haven't actually tried this for text files, but I do use it to load images, so it ought to work for this too.

  • How to store the data typed in flash to .txt file?

    Hi all,
    I have a query to all, I have created a notepad in flash, if I typed something in that and save that file as .txt format in my local drive. So, any help on the same....
    Thanks in advance
    Santhosh Kumar M

    i don't think this is complicated enough for anyone to write a tutorial.  but i could be wrong about that.
    you have 2 steps:
    1.  use the urlloader class to send data to a server-side php script that saves your data to a .txt file
    2.  use the filereference class to download that file.
    they're both pretty easy if you use the flash help files to start you off.

  • How to store a data on txt file through java program

    that means i want a coding for write data on txt file using java program.that storing data is stored like this formate,
    sathees
    krishnan
    rama
    suresh
    Stored on one by one. not like this
    sathees krishnan rama suresh.........

    import java.io.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    public class rsk1{
    public static void main (String argv []){
    try {
    String sr[] = new String[100];
                   String s1=" ";
                   int j=0;
                   DataInputStream in = new DataInputStream(System.in);
                   OutputStream f1 = new FileOutputStream("file1.txt");
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document doc = docBuilder.parse (new File("book.xml"));
    // normalize text representation
    doc.getDocumentElement ().normalize ();
    System.out.println ("Root element of the doc is " +
    doc.getDocumentElement().getNodeName());
    NodeList listOfPersons = doc.getElementsByTagName("person");
    int totalPersons = listOfPersons.getLength();
    System.out.println("Total no of people : " + totalPersons);
    for(int s=0; s<listOfPersons.getLength() ; s++){
    Node firstPersonNode = listOfPersons.item(s);
    if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){
    Element firstPersonElement = (Element)firstPersonNode;
    NodeList firstNameList = firstPersonElement.getElementsByTagName("first");
    Element firstNameElement = (Element)firstNameList.item(0);
    NodeList textFNList = firstNameElement.getChildNodes();
    sr[++j]=((Node)textFNList.item(0)).getNodeValue().trim();
    NodeList lastNameList = firstPersonElement.getElementsByTagName("last");
    Element lastNameElement = (Element)lastNameList.item(0);
    NodeList textLNList = lastNameElement.getChildNodes();
    sr[++j]=((Node)textLNList.item(0)).getNodeValue().trim();
    NodeList ageList = firstPersonElement.getElementsByTagName("age");
    Element ageElement = (Element)ageList.item(0);
    NodeList textAgeList = ageElement.getChildNodes();
    sr[++j]=((Node)textAgeList.item(0)).getNodeValue().trim();
    NodeList stuList = firstPersonElement.getElementsByTagName("stu");
    Element stuElement = (Element)stuList.item(0);
    NodeList textstuList = stuElement.getChildNodes();
    sr[++j]=((Node)textstuList.item(0)).getNodeValue().trim();
    }//end of if clause
    }//end of for loop with s var
    System.out.println("Process completed");
    for(int i=1;i<=j;i++)
                   byte buf[] = sr.getBytes();
                                       byte buf1[] = s1.getBytes();
         f1.write(buf);
                                       f1.write(buf1);
    f1.close();
    }catch (SAXParseException err) {
    System.out.println ("** Parsing error" + ", line "
    + err.getLineNumber () + ", uri " + err.getSystemId ());
    System.out.println(" " + err.getMessage ());
    }catch (SAXException e) {
    Exception x = e.getException ();
    ((x == null) ? e : x).printStackTrace ();
    }catch (Throwable t) {
    t.printStackTrace ();
    }//end of main

  • Auto delete everything but specified folder contents from txt file

    Hey Guys,
    I am brand new to using Powershell (like 48 hours into using it for work) and I've run into a bit of an issue.  I've only taken a programming concept classes so some of the stuff makes sense to me but a lot of it is new.  Basically I've made a
    script that automatically deletes any files over X amount of days.  My next step is to have an exceptions text that will have a list of folders that should not have its contents deleted.  This is what I have so far.
    $Date= Get-Date 
    $Days = "7"
    $Folder = "C:\publicftp\users"
    $LastWrite = $Now.AddDays(-$Days)
    #----- getting DO NOT DELETE listing from TXT ----#
    $Exceptions = Get-Content "c:\exclude.txt"
    $Files = Get-Childitem $Folder -Recurse -Exclude "c:\exclude.txt" | Where {$_.LastWriteTime -le "$LastWrite"}
    foreach ($File in $Files)
        if ($File -ne $NULL)
            Remove-Item $File.FullName -Exclude $Exceptions | out-null
    I've seen a lot of threads that show how to auto delete contents or how to exclude specific file types but I haven't seen an answer to my particular problem.  Any help would be greatly appreciated!  Thanks!

    Hi Rabbot,
    The script below may be also helpful for you, and uses the -whatif parameter in Remove-Item cmdlet, which doesn’t actually remove anything but simply tells you what would happen if you did call Remove-Item.
    $Exceptions = @()
    Get-Content "c:\exclude.txt" | foreach{
    $Exceptions += $_} #store the exception file to array
    $Folder = "C:\publicftp\users"
    $LastWrite = (get-date).adddays(-7) #over 7 days.
    $Files = Get-Childitem $Folder -Recurse | Where {$_.LastWriteTime -le $LastWrite} #filter files which over 7 days.
    Foreach ($file in $files){
    if ($Exceptions -notcontains $file.fullname){ #if the file is not listed in the exception array.
    Remove-Item $File.FullName -whatif} #use -whatif to test
    I hope this helps.

  • Is there any way to take backed up files from an old OS and get them onto a new phone?  They are backed up as txt files.

    I have a six year old lap top with an old OS and itunes 10.  I backed up my i phone 4 on it.  I got an I phone 5 and the version of Itunes compatible is not supported by the laptop.  I installed itunes on a different computer and when trying to sync the iphone 4 to the desktop, updated the iphone 4 software.  Now my iphone 4 is no longer compatible with my laptop.  I am interested in getting my contacts and photos from my old laptop to either iphone at this point.  I have the backed up files but they are txt files in the Mobile Sync Back ups.  Any suggestions would be appreciated!

    Generally when moving from one phone to another, individuals will make a backup of the one device and then restore to the second device. However, it seems you are no longer using the computer you made the backup on, so that can be a problem. There is no way for you to take information out of the backup and insert it in the iPhone. It is an all or none proposition. But, just moving the backup folder from one computer to another doesn't work either.
    Did you sync the contacts to a supported application on the computer? Also, if you are referring to the photos in the camera roll, you can import them to the computer by connecting the phone to the computer. You do not need iTunes to do that. Just plug in and let the computer photo import utility take the pictures and put them on the computer. Then you would sync the photos back to the photo library on the new phone,
    Contacts you can look at a 3rd party app that might help. MCBackup is in the app store and converts your contacts to a file you can email to yourself and then click on it and open it. Suggest syncing contacts/calendar to a supported application on the computer, or to iCloud so you can recover a lot easier.

  • Data from itab to be store in text file in desktop

    hi
    i am tyring to store the data from itab into a text file in desktop,but its now owrking.
    i am using open dataset statment,but no where data is storing.My code:
    TYPES : BEGIN OF ST_DEMO,
    REG_NO(10) TYPE C,
    NAME(20)   TYPE C,
    ADDR(20)   TYPE C,
    END OF ST_DEMO.
    DATA : WA_DEMO TYPE ST_DEMO,
    IT_DEMO TYPE TABLE OF ST_DEMO,
    L_FNAME TYPE dxfile-filename .
    PARAMETERS: P_FNAME(128) TYPE C DEFAULT '\usr\sap\put\vipin.txt' OBLIGATORY.
    L_FNAME = P_FNAME.
    WA_DEMO-REG_NO = '100001'.
    WA_DEMO-NAME = 'ANAND'.
    WA_DEMO-ADDR = 'NAGARKOVIL'.
    APPEND WA_DEMO TO IT_DEMO.
    OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    WRITE :5 'REG NUM',16 'NAME',37 'ADDRESS' .
    LOOP AT IT_DEMO INTO WA_DEMO.
      IF SY-SUBRC = 0.
        TRANSFER WA_DEMO TO L_FNAME.
        WRITE :/5 WA_DEMO-REG_NO,16 WA_DEMO-NAME,37 WA_DEMO-ADDR.
      ENDIF.
    ENDLOOP.
    close DATASET L_FNAME.
    please tell me where is the prob?I wan to schedule it for background job.
    regds
    vipin

    hi
    here is the code for :  "data from itab to be store in text file in desktop"
    TABLES: vbak.    " standard table
    *                           Type Pools                                 *
    TYPE-POOLS: slis.
    *                     Global Structure Definitions                     *
    *-- Structure to hold data from table CE1MCK2
    TYPES: BEGIN OF tp_itab1,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           werks LIKE vbap-werks,
           lgort LIKE vbap-lgort,
           END OF tp_itab1.
    *-- Data Declaration
    DATA: t_itab1 TYPE TABLE OF tp_itab1.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
    *                    Selection  Screen                                 *
    *--Sales document-block
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
    SELECTION-SCREEN END OF  BLOCK b1.
    *--Display option - block
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS: alv_list RADIOBUTTON GROUP g1,
                alv_grid RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF  BLOCK b2.
    *file download - block
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
    PARAMETERS: topc AS CHECKBOX,
                p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF  BLOCK b3.
    *                      Initialization.                                *
    *                      At Selection Screen                            *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
        EXPORTING
          dynpfield_filename = 'P_FILE'
          dyname             = sy-cprog
          dynumb             = sy-dynnr
          filetype           = 'P'      "P-->Physical
          location           = 'P'     "P Presentation Srever
          server             = space.
    AT SELECTION-SCREEN ON s_vbeln.
      PERFORM vbeln_validate.
    *                           Start Of Selection                         *
    START-OF-SELECTION.
    *-- Fetching all the required data into the internal table
      PERFORM select_data.
    *                           End Of Selection                           *
    END-OF-SELECTION.
      IF t_itab1[] IS NOT INITIAL.
        IF topc IS NOT INITIAL.
          PERFORM download.
          MESSAGE 'Data Download Completed' TYPE 'S'.
        ENDIF.
        PERFORM display.
      ELSE.
        MESSAGE 'No Records Found' TYPE 'I'.
      ENDIF.
    *                           Top Of Page Event                          *
    TOP-OF-PAGE.
    *& Form           :      select_data
    * Description     : Fetching all the data into the internal tables
    *  parameters    :  none
    FORM select_data .
      SELECT vbeln
         posnr
         werks
         lgort
         INTO CORRESPONDING  FIELDS OF TABLE t_itab1
         FROM vbap
         WHERE  vbeln IN s_vbeln.
      IF sy-subrc <> 0.
        MESSAGE 'Enter The Valid Sales Document Number'(t04) TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " select_data
    *& Form        : display
    *  decription  : to display data in given format
    * parameters   :  none
    FORM display .
      IF alv_list = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                               USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
       'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
       'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
       'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
       'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            i_callback_program       = sy-repid
    *        i_callback_pf_status_set = c_pf_status
            i_callback_user_command  = 'USER_COMMAND '
    *        it_events                = t_alv_events[]
            it_fieldcat              = i_fieldcat[]
          TABLES
            t_outtab                 = t_itab1[]
          EXCEPTIONS
            program_error            = 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.
      ENDIF.
      IF alv_grid = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                                 USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
         'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
         'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
         'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
         'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program       = sy-repid
    *        i_callback_pf_status_set = c_pf_status
            i_callback_user_command  = 'USER_COMMAND '
            it_fieldcat              = i_fieldcat
          TABLES
            t_outtab                 = t_itab1[]
        EXCEPTIONS
       program_error                     = 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.
      ENDIF.
    ENDFORM.                    " display
    *& Form        : vbeln_validate
    *  description : to validate sales document number
    * parameters   :  none
    FORM vbeln_validate .
      DATA: l_vbeln TYPE vbak-vbeln.
      SELECT SINGLE vbeln
        FROM vbak
        INTO l_vbeln
        WHERE vbeln IN s_vbeln.
      IF sy-subrc NE 0.
        MESSAGE 'ENTER THE VALID SALES DOCUMENT NO:' TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " vbeln_validate
    *& Form       :build_fieldcat
    * Description : This routine fills field-catalogue
    *  Prameters  : none
    FORM build_fieldcat TABLES  fpt_fieldcat TYPE slis_t_fieldcat_alv
                        USING   fp_field     TYPE slis_fieldname
                                fp_table     TYPE slis_tabname
                                fp_length    TYPE dd03p-outputlen
                                fp_ref_tab   TYPE dd03p-tabname
                                fp_ref_fld   TYPE dd03p-fieldname
                                fp_seltext   TYPE dd03p-scrtext_l
                                fp_col_pos   TYPE sy-cucol.
    *-- Local data declaration
      DATA:   wl_fieldcat TYPE slis_fieldcat_alv.
    *-- Clear WorkArea
      wl_fieldcat-fieldname       = fp_field.
      wl_fieldcat-tabname         = fp_table.
      wl_fieldcat-outputlen       = fp_length.
      wl_fieldcat-ref_tabname     = fp_ref_tab.
      wl_fieldcat-ref_fieldname   = fp_ref_fld.
      wl_fieldcat-seltext_l       = fp_seltext.
      wl_fieldcat-col_pos         = fp_col_pos.
    *-- Update Field Catalog Table
      APPEND wl_fieldcat  TO  fpt_fieldcat.
    ENDFORM.                    "build_fieldcat
    *& Form        : download
    *  description : To Download The Data
    *  Parameters  :  none
    FORM download .
      DATA: l_file TYPE string.
      l_file = p_file.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = l_file
          filetype                = 'ASC'
        TABLES
          data_tab                = t_itab1
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " download
    hope it will help you
    regards
    rahul

  • How to update a table AUTOMATICALY with data from a .txt file??

    HI ,
    I want to upload data which is in a notepad file and Create a table. This notepad file stores a string of datas. Here, the data comes in to the .txt file every second.
    (The data is actually stored into the notepad file when a program is executed in Processing.js software)
    Is it possible to do the following using APEX ? ?
    1. This table has to be updated automatically once in 2 minutes (I want this completely automatic, no human intervention -- no update buttons)
    2. A report is to be created in a apex application with this table, it should reflect the updates in the table every 2 minutes.
    Is it possible?? give your ideas.. I want to do this soon for my engineering project :) Any help from you is appreciated. :)
    Edited by: user13301695 on 28-Mar-2011 10:09

    And how do you expect your database server to access a local file in your machine ?
    Is the file accessible from outside your machine say inside a webserver folder so that some DB process can poll on the file ?
    Or, is your DB server in the same machine where you have the text file ?
    You will have to figure out the file acess part before automating user interaction or even auto-refreshing.

  • Java code to create a new .txt file in FTP server  --- Help

    Hi,
    I wrote a standalone java app which creates a .txt file in my local machine and transfers it to FTP server. But my requirement now is to create a new .txt file with the same content in FTP server itself instead of creating locally with basic java code.
    I'm aware of transfering file from local machine to the FTP server using STOR command of FTP. But i never tried creating a new file & writing content into that in FTP server.
    So, if any one did this before please help me out with source code or any idea ???
    Thank you.
    Vj.

    simply_vijay wrote:
    thanks for your reply. yes i've seen the Apache Commons NET API , but there is no method or class to create a new file in FTP server. I'm really worried how to solve this problem ???Sure there is.
    There's a method where you can write data to a file on the server using an OutputStream, right? Well, instead of writing to a FileOutputStream, write to that OutputStream instead. Remember to close the OutputStream and call the method which says you're finished with the command (I forget what it's called).

Maybe you are looking for