Throwing away data after BufferedReader().readline()

I'm reading very large files - over 1GB. I'm reading sequentially and then writing to another file to create smaller files. Since the input file is so big, I'd like to just remove from memory the already read lines. Is there a way to do this using BufferedReader()?
Here is my BufferedReader line:
      br = new BufferedReader(new FileReader(new File(rawBill)));Then I have the standard while loop:
               while ((line = br.readLine()) != null) {
                                   ... write to another file here once all required data is read.
                        }Thanks.

jverd: I didn't realized the line variable would be
eligible for GC. Seems like it's just getting
rewritten to with the next line from the input file.
It's always holding some data it is not nulled out.Variables are never eligible for GC. Objects are.
Every time through that loop, a String object is created, and the variable line is pointed at it. The next time through, a new object is created, and line is pointed at the new string. Since line is now no longer pointing at the previous String object, that object is now eligible for GC, unless you pointed some other reference varialbe to it, that survives across loop iterations.
As long as you don't do something to "save" that String object, at any given time, there's only one that's not eligible for GC. All the previous ones are eligible.
My issue is with the input file. I assume
BufferedReader just continuously reads/stores the
data from the file when all the readLine calls get to
the end of the designated buffer size? No. BufferedReader just does physical reads in relatively large chunks, the size of which is independent of how many bytes you're actually trying to read. For example, when you call readLine, it may physically read 512 bytes from the file, but the line you're reading may only be 80 bytes long. This helps minimize the overhead of physical reads from the network or file system.
I don't think
the previously read data is purged upon the next IO
read from the file. It would be great if there was
a method on BufferedReader which would purge all
previously held data. I don't know what you mean by "purging" data. I don't think that's an issue that applies here.

Similar Messages

  • Bug with InputStream.read after BufferedReader.readLine in a Thread ?

    I just found something strange when reading bytes on a socket after reading lines.
    I'll show you an example :
    In this example, when a connexion is established, I launch a thread where a single line of String then 3 bytes are read from the socket. I use BufferedReader.readLine for the String line then just InputStream.read to read the 3 bytes.
    The results are quite random. Sometimes it works, sometimes not (most times it doesn't)... it seems to always work under linux (but haven't tested it as many times than on windows). Most of the time the program is stuck on the "socket.getInputStream().read(bytes);" line with 0 bytes available. I tried to do the same thing outside of a thread, I thought it worked better beaucause I was able to run it without any problem but it doesn't work anymore when I test it again.
    I can't say if I'm doing something wrong or if it's a java bug (I've got JDK 1.6.0_03-b05).
    Can you please have a look a this little example and maybe test it and let me know if it works or not. I tried to code my own readLine function and it seems to work with it but I'd like to know if it's a bug or what. Thank you.
    Server side :
    import java.io.*;
    import java.net.*;
    public class testServer extends Thread {
         private Socket socket;
         public testServer(Socket testSocket)
              socket = testSocket;
         public void readData() throws Exception
              BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
              String str;
              str = br.readLine();
              System.out.println(str);
              System.out.println("Bytes available : " + socket.getInputStream().available());
                    //Try to read the bytes
                    byte[] bytes = new byte[3];
                    //STOPS THERE UNDER WINDOWS, BUT WORKS WITH LINUX
              socket.getInputStream().read(bytes);
                    //Simple "ack" to say to the client that he can close the connexion
              socket.getOutputStream().write(0);
              socket.getOutputStream().flush();
                    //Print the bytes values
              for(byte value : bytes)
                   System.out.println(value);
         public void run()
              try {
                   readData();
              } catch (Exception e) {
                   e.printStackTrace();
         public static void main(String[] args) {
              try {
                   ServerSocket welcomeSocket = new ServerSocket(3333);
                   while(true)
                        new testServer(welcomeSocket.accept()).start();
              } catch (Exception e) {
                   e.printStackTrace();
    }client side :
    import java.io.*;
    import java.net.*;
    public class testClient {
         public static void main(String[] args) {
              try {
                            //Some test values
                   byte[] testValues = new byte[]{1,2,3};
                   Socket socket = new Socket(InetAddress.getLocalHost(), 3333);
                            //Send the line through the socket
                   BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
                   bw.write("HELLO WORLD\r\n");
                   bw.flush();
                            //then the bytes
                   socket.getOutputStream().write(testValues);
                   socket.getOutputStream().flush();
                            //Just waits for the server's ack to close the connexion
                   socket.getInputStream().read();
                   socket.close();
              } catch (Exception e) {
                   e.printStackTrace();
    }

    It's your bug.
    When you create a BufferedReader and ask it to read a line, the first thing it does is to read a whole buffer full of data (hence the name of the class) from its underlying input stream. That's probably about 4000 characters or something like that. It stores that internally and then starts doling it out in response to calls to readLine() and so on.
    Then when you go back to reading from the underlying input stream, those 4000 or so characters are already gone from it. You have no access to the data the BufferedReader is hanging on to this way. All you can do is to start reading at the point after that whole buffer, which is not what you want.

  • Throws IllegalArgumentException when use BufferedReader.readLine()

    hi
    when i use BufferedReader.readLine() to read a html file of Internet,it throws IllegalArgumentException like blow:
    java.lang.IllegalArgumentException
    at java.nio.Buffer.position(Buffer.java:218)
    at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:575)
    at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:442)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at java.io.BufferedReader.fill(BufferedReader.java:136)
    at java.io.BufferedReader.readLine(BufferedReader.java:299)
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    but it occured sometimes or occured never in a long time!
    Why?

    It does it because of this bit of code in java.nio.Buffer.position
    if ((newPosition < 0) || (newPosition > limit))
          throw new IllegalArgumentException ();So for some reason a bit of the java code has tried to set the position to either less than zero or greater than the limit of the buffer. Not a good idea in either case.
    Since this is not your code you can't really do much about it. Try catching the exception and handling it.

  • Can not pass data after while loop

    Hello.
    I have created a VI for my experiment and am having problem passing data outside a while loop to save on an excel file. The VI needs to first move a probe radially, take data at 1mm increment, then move axially, take data radially at 1mm increment, then move to the next axial position and repeat. It would then export these data to an excel file. The VI is a little complicated but it's the only way I know how to make it for our experiment. I have tested it and all the motion works correctly, however I can not get it to pass the data after the last while loop on the far right of the VI where I have put the arrows (Please see the attached VI ). Is it because I'm using too many sequence, case, and while loops?  If so, what other ways can I use to make it export data to the excel file?
    Any help would be appreciated. 
    Thank you,
    Max
    Attachments:
    B.Dot.Probe.Exp.vi ‏66 KB

    Ummmm .... gee, I'm not even sure where to begin with this one. Your VI is well .... ummmm... You have straight wires! That's always nice to see. As for everything else. Well... Your fundamental problem is lack of understanding of dataflow programming. What you've created is a text program. It would look fantastic in C. In LabVIEW it makes my heart break. For a direct answer to your question: Data will not show up outside a while loop until the while loop has completed. This means your most likely problem is that the conditions to stop that specific loop are not being met. As for what the problem is, I don't even want to start debugging this code. Of course, one way to pass data outside of loops is with local variables, and hey, you seem to be having so much fun with those, what's one more?
    This may sound harsh, and perhaps be somewhat insulting, but the brutal truth is that what I would personally do is to throw it out and to start using a good architecture like a state machine. This kind of framework is easy to code, easy to modify, and easy to debug. All qualities that your code seems to lack.
    Message Edited by smercurio_fc on 08-17-2009 10:00 PM

  • Is the nano worth throwing away my old ipod mini?

    I just bought a ipod mini 1 month before the nano came out. So now i'm feeling kinda ticked off as you can imagine.
    The month that i did have an up to date ipod, i was enjouying it alot. In fact i currently have 200 songs on it and listen to them all frequently. So now the big question for me is if i should sell my current ipod mini so that i can buy a ipod nano.
    Is the ipod nano worth it?

    Yes. Throw away the Mini. Not literally; give it to a 7 year old just starting to appreciate music. Or, better yet, donate it to kids playing street hockey as it will glide better than a roll of electrical tape.
    The nano is that good. It's that much of a breakthrough. It re-sets the bar for all portable electronics.
    It boils down to light weight vs. capacity. If you can't listen to 4000 songs in a week, what's the point of carrying around an iBrick on the train, bus, or plane? Use iTunes, that's what it's for. It's there to be your library of all 4000 songs that you own. Once a week (or month) just dock the nano with iTunes and tweak your song choices a little bit.
    It's like carrying around a carton of cigarettes when you can only smoke a pack a day. Lots of extra weight and complexity that can be eliminated when you can have a more simple device that can do a better job.
    Ditch the Mini, grab a nano, and don't look back.
    BJ

  • Customizing Calendar to disable all dates After Sysdate (Current Date)

    Hi All,
    I have a Requirement In OAF to Disable All Dates in the Calendar After the Sysdate
    Ex: In Air Ticket Booking We can't Enter  Previous Dates in the Calendar Like that I need to make the
    my calendar dates after Sysdate Non Entarable
    Please let me know if you have any sample code or We can fire any action before selecting a date to disable a particular set of Dates
    Thanks,
    Krishna

    Hi ,
    As per my opinion ,u shud put a check in PFR method at select event fire of date field ,capture the selected date anc check it shud be <= sysdate else throw a message using
    throw new OAException ("this date should not exceed current date", OAException.ERROR);
    Thanks
    Pratap

  • How to get next date or date after n th day of a given date ?

    I want to get the date after n th day of a given date.
    Here a date and an integer will be the input.
    suppose 15/12/2007 and 3 are the inputs and the output will be 18/12/2007
    Is there any method to solve this purpose ?
    Plz its urgent !!

    javagalaxy.com wrote:
    I didn't feel this is a home work for them. I feel the OP is trying to learn.Well, that is a part of what homework is. Now, tell me how doing it for them helps them learn? They might run it once, to make sure it does what it is suppossed to do, then simply turn it in. In the process, they haven't learned a thing. Only a very small fraction of posters will study the posted code to figure it out, as evidenced by the fact, that if the code is not 100% cut-n-paste capable for their assignment, they will come back and complain that this or that does not work, or was not done.
    >
    This will be good learning for the OP, why don't you point out what is done badly.
    Did you mean using
    now.add(Calendar.DAY_OF_MONTH, daysToAdd);
    instead of
    now.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)+daysToAdd);?
    That is the main crux of it, yes, but homework or not, you should actually attempt to catch and handle the exceptions, rather than simply declaring "throws Exception". Handling exceptions in the homework assignments will cause that to become a habit and you will actually do it correctly without thinking about it. Just like constantly declaring "throws Exception" in your homework will also make that a habit, and guarnatee that you will someday also do that when it counts, thereby causing all sorts of problems (usually for coworkers).
    if its something else then please do let us know.
    I can also learn how to do it good :)

  • Minimising throw away rows?

    Friends,
    I am trying to tune a query that is taking too long to return it's results.
    One of the things I have noticed when looking at the explain plan is that during some parts of the execution it retrieves up to 70,000 records however the first line of the plan reads
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 6138 | 18M | | 8965 (0)|
    Which I understand is the total number of records used by this query.
    I know with SQL tunning that there are no hard and fast answers, however any pointers on how best to minimise the number of throw away rows would be appreciated.
    Thanks in advance.

    Ian,
    As you mentioned, it is rather difficult to say anything, that too by looking at just one line of execution plan. Are you expecting the query to return 6138 rows as result ? Minimizing number of rows flowing out of each step is one way to look for tuning. If you are seeing 70,000 rows being flown out of some step in execution plan, that might be area to concentrate on. Is it some SORT step which is throwing out 70,000 rows ? It may be possible for you to defer the SORT by restructuring the query (ofcourse, without affecting end result). Pushing WHERE predicates i.e. filtering data as much as possible before joining or processing it further is also a an option to reduce large number of rows seen in execution plan.

  • How much code do you throw away?

    Every now and then I have some slow time when I have punted everything to the testing team and I start looking at the next thing to attack. In these process I kick around ideas and implement them to see if they are any better then the current way of doing things. Some times I get 80% the way down the path and hit an unforeseen limitation. Other times when finished it is not as good or better enough to justify implementing over the current way. The worst is when I believe it is better but am unable to convince folks it is worth the effort. Occasionally time runs out and the idea withers on the vine.
    I would say about 80% of these skunk work projects end up tossed out. Probably, only about 30 - 50% of the code gets tossed the bit bucket since inevitably a bunch of new stuff is learned that is useful.
    How much code do y'all throw away, or am I an odd ball this way?

    TexMark wrote:
    Great, I thought it had to be the way things needed to be done. I actually would change careers if I could not experiment it is what makes the job fun. Now for the second and more difficult part, how do you break it to someone when the idea and code they have been diligently working on for the past two weeks is an interesting idea and even cool to see work BUT it is an overly complicated way to solve a simple problem. They are already complaining that their solution should be used since they spent so much time on it and hate to have wasted it. They created their solution in a vacuum with out calling a meeting of the minds. The ultimate problem is that this is the second or third time in a row the idea will get shot down.
    My favorite quote from him is "I don't know what this solves but it has to solve something I just need to find where to use it.", it's maddening.Turn it around so that the time wasn't wasted, after all. Which it probably wasn't anyway. Then just tell them it's overly complicated, show him why and show your simpler alternative. If he's too thin-skinned to accept the facts, it's about time he learnt. Or, just live with it. Or just replace it without asking, if your culture allows it. Where I am, we all own the codebase, there's absolutely nothing to stop someone doing that, and it happens all the time. It then puts the onus on the guy to justify his more complex solution. An upshot of that is often that one or other of the solutions is actually proven to be the better, for a previously unseen reason, usually ease of ongoing maintenance

  • The message "iPad Not Backed Up" appears on the screen and will not go away, even after I push the "OK" button. What can I do?

    The message "iPad Not Backed Up" appears on the screen and will not go away, even after I push the "OK" button. What can I do?

    rodrocket wrote:
    ... What can I do?
    Perform a Reset...
    Reset  ( No Data will be Lost )
    Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
    http://support.apple.com/kb/ht1430

  • Why does Firefox Update throw away all customization?

    Every time Firefox updates, it completely throws away all of the toolbar arrangements and other customizations I have worked hard to optimize.
    If you want people to update for "security reasons," why do you muck around with my GUI?
    I spend a lot of effort trying to get the buttons where I want them and I configured plenty of little hidden features in about:config so that the browser works right, all for nothing....
    Guess I will have to reinstall the old version I had and totally start over, this time turning update to "Never check for updates" to avoid wasting my time in the future.
    Sorry for being pissed off. I appreciate security updates, but there is no reason to force a funky GUI on everyone, and this really is a humongous waste of time needing to redo all of my settings yet again.

    Hey,
    Sorry about this issue with GUI changes, I hadn't heard of it before :/ The people who answer questions here, for the most part, are other Firefox users volunteering their time (like me), not Mozilla employees or Firefox developers.
    If you want to leave feedback for Firefox developers, you can go to the Firefox ''Help'' menu and select ''Submit Feedback...'' or use [https://input.mozilla.org/feedback this link]. Your feedback gets collected at http://input.mozilla.org/, where a team of people read it and gather data about the most common issues. Hopefully they'll be able to do something about this.
    Thanks!
    Curtis Parfitt-Ford
    Mozilla Support

  • The ADO NET Source was unable to process the data. ORA-64203: Destination buffer too small to hold CLOB data after character set conversion.

     We developed a SSIS Package to pull the data From Oracle source to Sql Server 2012. Here we used ADO.Net source to pull the records from Source but getting the below error after pulling some 40K records.
      [ADO NET Source [2]] Error: The ADO NET Source was unable to process the data. ORA-64203: Destination buffer too small to hold CLOB data after character set conversion.
    [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. 
     The PrimeOutput method on ADO NET Source returned error code 0xC02090F5. 
     The component returned a failure code when the pipeline engine called PrimeOutput(). 
    The meaning of the failure code is defined by the component, 
    but the error is fatal and the pipeline stopped executing. 
     There may be error messages posted before this with more 
    information about the failure.
    Anything that we can do to fix this?

    Hi,
      Tried both....
      * Having schema type as Nvarchar(max). - Getting the same error.
      * Instead of ADO.Net Source used OLEDB Source with driver as " Oracle Provide for OLE DB" Getting error as below.
           [OLE DB Source [478]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
           [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on OLE DB Source returned error code 0xC0202009.  The component returned a failure
    code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the
    failure.
    Additional Info:
       * Here the Source task is getting failed not the conversion or destination task.
    Thanks,
    Loganathan A.

  • Issue with list saving data after sites upgrade from sharepoint 2010 to sharepoint 2013

    Issue with list saving data after sites upgrade from sharepoint 2010 to sharepoint 2013 
    Newform.aspx of list:-
    Custom List is not saving data sometimes in the new form after 15 minutes and only blank entry record got created without saving data, even though some columns are mandatory fields?

    Hello dcakumar,
    Sounds like a strang issue. If you can reproduce this can you see some errors in the ULS logs?
    - Dennis | Netherlands | Blog |
    Twitter

  • How to stored data after clicking checkbox  save in database table

    TYPE-pools: slis.
    tables:mkpf,mseg,mard,COWB_COMP.
    TYPES: BEGIN OF tp_data,
          mblnr LIKE mseg-mblnr,
         matnr LIKE mseg-matnr,
         werks LIKE mard-werks,
         lgort LIKE mard-lgort,
         lgpbe LIKE mard-lgpbe,
         charg LIKE mseg-charg,
         bwart LIKE mseg-bwart,
         budat LIKE mkpf-budat,
         menge LIKE mseg-menge,
         meins LIKE mseg-meins,
         kostl LIKE mseg-kostl,
         aufnr LIKE mseg-aufnr,
         rsnum LIKE mseg-rsnum,
         endkz like COWB_COMP-endkz,
    END OF tp_data,
    tp_tbl_data TYPE STANDARD TABLE OF tp_data.
    *data: t_data like ztable occurs 0 with header line.
    Constants
    Data objects (variable declarations and definitions)
    Report data to be shown.
    DATA: it_data TYPE STANDARD TABLE OF tp_data.
    Heading of the report.
    DATA: t_heading TYPE slis_t_listheader.
    ========================== Selection Screen ==========================
      SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:smblnr FOR mseg-mblnr MODIF ID m1,
                   smatnr FOR mseg-matnr MODIF ID m2,
                   swerks FOR mard-werks MODIF ID m3,
                   slgort FOR mard-lgort MODIF ID m4,
                   slgpbe FOR mard-lgpbe MODIF ID m5,
                   scharg FOR mseg-charg MODIF ID m6,
                   sbwart FOR mseg-bwart MODIF ID m7,
                   skostl FOR mseg-kostl MODIF ID m8,
                   saufnr FOR mseg-aufnr MODIF ID m9,
                   srsnum FOR mseg-rsnum MODIF ID m10.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS:pre RADIOBUTTON GROUP radi USER-COMMAND ucomm DEFAULT 'X',
               pse RADIOBUTTON GROUP radi,
               bps RADIOBUTTON GROUP radi.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
    PARAMETER:layout TYPE i.
    SELECTION-SCREEN END OF BLOCK b3.
    =========================== Event Blocks =============================
    AT selection-SCREEN.
    start-OF-selection.
    PERFORM get_data USING it_data.
    END-OF-selection.
    PERFORM build_alv USING it_data t_heading.
    =========================== Subroutines ==============================
    *&      Form  get_data
          Gets the information to be shown in the report.
    FORM get_data USING t_data TYPE tp_tbl_data.
      SELECT msegmblnr msegmatnr mardwerks mardlgort mardlgpbe msegcharg msegbwart mkpfbudat
        msegmenge  msegmeins msegkostl msegaufnr mseg~rsnum
      INTO CORRESPONDING FIELDS OF TABLE t_data
      FROM mseg
      JOIN mard ON mardmatnr EQ msegmatnr
                   JOIN mkpf ON msegmblnr EQ mkpfmblnr
                   WHERE mseg~matnr IN smatnr.
    ENDFORM.                    " get_data
    *&      Form  build_alv
          Builds and display the ALV Grid.
    FORM build_alv USING t_data TYPE tp_tbl_data
          t_heading  TYPE slis_t_listheader.
    ALV required data objects.
      DATA: w_title   TYPE lvc_title,
            w_comm    TYPE slis_formname,
            w_status  TYPE slis_formname,
            x_layout  TYPE slis_layout_alv,
            t_event    TYPE slis_t_event,
            t_fieldcat TYPE slis_t_fieldcat_alv,
            t_sort     TYPE slis_t_sortinfo_alv.
      REFRESH t_fieldcat.
      REFRESH t_event.
      REFRESH t_sort.
      CLEAR x_layout.
      CLEAR w_title.
    Field Catalog
      PERFORM set_fieldcat2 USING:
            1 'MBLNR' 'MBLNR' 'MSEG' space space space space space space space space space space space space t_fieldcat ,
            2 'MATNR' 'MATNR' 'MSEG' space space space space space space space space space space space space  t_fieldcat ,
            3 'WERKS' 'WERKS' 'MARD' space space space space space space space space space space space space  t_fieldcat,
            4 'LGORT' 'LGORT' 'MARD' space space space space space space space space space space space space t_fieldcat ,
            5 'LGPBE' 'LGPBE' 'MARD' space space space space space space space space space space space space t_fieldcat ,
            6 'CHARG' 'CHARG' 'MSEG' space space space space space space space space space space space space t_fieldcat ,
            7 'BWART' 'BWART' 'MSEG' space  space space space space space space space space space space space t_fieldcat,
            8 'BUDAT' 'BUDAT' 'MKPF' space  space space space space space space space space space space space t_fieldcat,
            9 'MENGE' 'MENGE' 'MSEG' space  space space space space space space space space space space space t_fieldcat,
            10 'MEINS' 'MEINS' 'MSEG' space  space space space space space space space space space space space t_fieldcat,
            11 'KOSTL' 'KOSTL' 'MSEG' space  space space space space space space space space space space space t_fieldcat,
            12 'AUFNR' 'AUFNR' 'MSEG' space  space space space space space space space space space space space t_fieldcat,
            13 'RSNUM' 'RSNUM' 'MSEG' space  space space space space space space space space space space space t_fieldcat,
        14 'ENDKZ' 'ENDKZ' 'COWB_COMP' space space 'select' 'Select this row' 'Sel' 'Select this row' space space space 'X' 'X' space t_fieldcat.
    Layout
      x_layout-zebra = 'X'.
    Top of page heading
      PERFORM set_top_page_heading USING t_heading t_event.
    Events
      PERFORM set_events USING t_event.
    GUI Status
      w_status = ''.
    User commands
      w_comm   = 'USER_COMMAND'.
    Order
    Example
    PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
      PERFORM set_order USING 'MBLNR' 'IT_DATA' 'X' space 'X' t_sort.
    PERFORM set_order USING 'EBELN' 'IT_DATA' 'X' space 'X' t_sort.
    PERFORM set_order USING 'EBELP' 'IT_DATA' 'X' space space t_sort.
    Displays the ALV grid
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program       = sy-repid
        it_fieldcat              = t_fieldcat
        is_layout                = x_layout
        it_sort                  = t_sort
        i_callback_pf_status_set = w_status
        i_callback_user_command  = w_comm
        i_save                   = 'X'
        it_events                = t_event
        i_grid_title             = w_title
      TABLES
        t_outtab                 = t_data
      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.
    ENDFORM.                    " build_alv.
    *&      Form  set_top_page_heading
          Creates the report headings.
    FORM set_top_page_heading USING t_heading TYPE slis_t_listheader
          t_events  TYPE slis_t_event.
      DATA: x_heading TYPE slis_listheader,
            x_event   TYPE LINE OF slis_t_event.
    Report title
      CLEAR t_heading[].
      CLEAR x_heading.
      x_heading-typ = 'H'.
      x_heading-info = 'Reporte Prueba'(001).
      APPEND x_heading TO t_heading.
    Program name
      CLEAR x_heading.
      x_heading-typ = 'S'.
      x_heading-KEY = 'Program: '.
      x_heading-info = sy-repid.
      APPEND x_heading TO t_heading.
    User who is running the report
      CLEAR x_heading.
      x_heading-typ = 'S'.
      x_heading-KEY = 'User: '.
      x_heading-info = sy-uname.
      APPEND x_heading TO t_heading.
    Date of execution
      CLEAR x_heading.
      x_heading-typ = 'S'.
      x_heading-KEY = 'Date: '.
      WRITE sy-datum TO x_heading-info.
      APPEND x_heading TO t_heading.
    Time of execution
      CLEAR x_heading.
      x_heading-typ = 'S'.
      x_heading-KEY = 'Time: '.
      WRITE sy-uzeit TO x_heading-info.
      APPEND x_heading TO t_heading.
    Top of page event
      x_event-name = slis_ev_top_of_page.
      x_event-FORM = 'TOP_OF_PAGE'.
      APPEND x_event TO t_events.
    ENDFORM.
    *&      Form  set_events
          Sets the events for ALV.
          The TOP_OF_PAGE event is alredy being registered in
          the set_top_page_heading subroutine.
    FORM set_events USING t_events TYPE slis_t_event.
      DATA: x_event   TYPE LINE OF slis_t_event.
    Example
    clear x_event.
    x_event-name = .
    x_event-form = .
    append x_event to t_event.
    ENDFORM.
    *&      Form  set_order
          Adds an entry to the order table.
    FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
          t_sort TYPE slis_t_sortinfo_alv.
      DATA: x_sort TYPE slis_sortinfo_alv.
      CLEAR x_sort.
      x_sort-fieldname = p_fieldname.
      x_sort-tabname   = p_tabname.
      x_sort-UP = p_up.
      x_sort-down = p_down.
      x_sort-subtot = p_subtot.
      APPEND x_sort TO t_sort.
    ENDFORM.                    "set_order
    *&      Form  set_fieldcat2
          Adds an entry to the field catalog.
    FORM set_fieldcat2 USING p_colpos p_fieldname p_ref_fieldname p_ref_tabname
          p_outputlen p_noout
          p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
          p_hotspot p_showasicon p_checkbox p_edit
          p_dosum
          t_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      CLEAR wa_fieldcat.
    General settings
      wa_fieldcat-fieldname = p_fieldname.
      wa_fieldcat-col_pos = p_colpos.
      wa_fieldcat-no_out = p_noout.
      wa_fieldcat-HOTSPOT = p_hotspot.
      wa_fieldcat-CHECKBOX = p_checkbox.
      wa_fieldcat-ICON = p_showasicon.
      wa_fieldcat-do_sum = p_dosum.
    Set reference fieldname, tablenam and rollname.
    If p_ref_tabname is not given, the ref_fieldname given is a data element.
    If p_ref_tabname is given, the ref_fieldname given is a field of a table. In case ref_fieldname is not given, it is copied from the fieldname.
      IF p_ref_tabname IS INITIAL.
        wa_fieldcat-rollname =   p_ref_fieldname.
      ELSE.
        wa_fieldcat-ref_tabname = p_ref_tabname.
        IF p_ref_fieldname EQ space.
          wa_fieldcat-ref_fieldname =   wa_fieldcat-fieldname.
        ELSE.
          wa_fieldcat-ref_fieldname =   p_ref_fieldname.
        ENDIF.
      ENDIF.
    Set output length.
      IF NOT p_outputlen IS INITIAL.
        wa_fieldcat-outputlen = p_outputlen.
      ENDIF.
    Set text headers.
      IF NOT p_seltext_m IS INITIAL.
        wa_fieldcat-seltext_m = p_seltext_m.
      ENDIF.
      IF NOT p_seltext_l IS INITIAL.
        wa_fieldcat-seltext_l = p_seltext_l.
      ENDIF.
      IF NOT p_seltext_s IS INITIAL.
        wa_fieldcat-seltext_s = p_seltext_s.
      ENDIF.
      IF NOT p_reptext_ddic IS INITIAL.
        wa_fieldcat-reptext_ddic = p_reptext_ddic.
      ENDIF.
      IF NOT p_ddictxt IS INITIAL.
        wa_fieldcat-ddictxt = p_ddictxt.
      ENDIF.
    Set as editable or not.
      IF p_edit IS NOT INITIAL.
        wa_fieldcat-INPUT     = 'X'.
        wa_fieldcat-EDIT     = 'X'.
      ENDIF.
      APPEND wa_fieldcat TO t_fieldcat.
    ENDFORM.                   "set_fieldcat2
    =========================== Subroutines called by ALV ================
    *&      Form  top_of_page
          Called on top_of_page ALV event.
          Prints the heading.
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        i_logo             = 'XXXXX'
        it_list_commentary = t_heading.
    ENDFORM.                    " alv_top_of_page
    *&      Form  user_command
          Called on user_command ALV event.
          Executes custom commands.
    FORM user_command USING r_ucomm     LIKE sy-ucomm
          rs_selfield TYPE slis_selfield.
    ENDFORM.                    "user_command
    this is my code, how to store data after clicking checkbox in databasetable,
    how to write that cide.
    plz send me code.

    hi!,
    use MODIFY to update data into the data base table.
    regards
    anjali

  • How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

Maybe you are looking for

  • Bridge halts on program start

    CS6 (revision number unknown -- it's the latest), 64-bit on Windows 7. Start program, freezes, throws error: "Adobe Bridge CS6 has stopped working and will now stop." Have tried trouble-shooting suggestions to no avail. (Even the ones that make no se

  • IMac monitor for MacBook Pro

    Hi. I have a 2008 iMac and a 2012 Mac Book Pro. Am I able to use the iMac as a secondary monitor for my Mac Book Pro? Thaks for yor help!

  • Two 23" HD or two DELL 24" LCD ???

    Hi guys, I am thinking on buying either two Apple 23" HD or two 24" DELL (2407WFP 1:1000 contrast; ready for High Definition input!) I'm still using a PC but my question is more in terms of quality; Currently I'm using two 19" monitors (almost 10 hou

  • How to rid smart playlist of all video and keep selected music in it only?

    I tried making a smart playlist that would be the source to Party Shuffle. I was successful in putting all the music into the playlist that I wanted, including exclude the music I didn't want. The one thing that's bugging me is that I put edited the

  • YouTube Podcasting in iWeb

    Can i post a youtube widget video in an iWeb podcast page and it show up on iTunes? Im trying to save space on my website but i want to still be able to have space and have my podcast on iTunes.(Specification-->) Is there anyway i can upload a video