Count lines in alvgrid.

What I want to do is to write the number om lines that the ALV grid displays.
How do i solv this? Is there a standarsfunction for this?
Best Regards Claes

Where do you want to put it.  In the TOP?  All you need to do is find the number of records in the internal table.
Data: NO_OF_LINES type i.
DESCRIBE TABLE ITAB LINES NO_OF_LINES.
Then you can use this sample program to learn how to use the ALV TOP.
report zrich_0001
       no standard page heading.
* Global ALV Data Declarations
type-pools slis.
data: begin of i_alv occurs 0,
      matnr type mara-matnr,
      end of i_alv.
* Miscellanous Data Declarations
data: fieldcat type slis_t_fieldcat_alv,
      events   type slis_t_event,
      list_top_of_page type slis_t_listheader,
      top_of_page  type slis_formname value 'TOP_OF_PAGE'.
start-of-selection.
  perform initialization.
  perform get_data.
  perform call_alv.
end-of-selection.
*  Form  Initialization
form initialization.
  clear i_alv.       refresh i_alv.
  perform eventtab_build using events[].
endform.
*  Form  Get_Data
form  get_data.
  select matnr into table i_alv
              from mara up to 100 rows.
endform.
*  CALL_ALV
form call_alv.
  data: variant type  disvariant.
  data: repid type sy-repid.
  data: layout type  SLIS_LAYOUT_ALV.
  repid = sy-repid.
  variant-report = sy-repid.
  variant-username = sy-uname.
  perform build_field_catalog.
  perform comment_build using list_top_of_page[].
* Call ABAP List Viewer (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            it_fieldcat        = fieldcat
            i_callback_program = repid
            is_variant         = variant
            it_events          = events[]
            IS_LAYOUT          = layout
            i_save             = 'U'
       tables
            t_outtab           = i_alv.
endform.
* EVENTTAB_BUILD
form eventtab_build using events type slis_t_event.
* Registration of events to happen during list display
  data: tmp_event type slis_alv_event.
  call function 'REUSE_ALV_EVENTS_GET'
       exporting
            i_list_type = 0
       importing
            et_events   = events.
  read table events with key name = slis_ev_top_of_page
                           into tmp_event.
  if sy-subrc = 0.
    move top_of_page to tmp_event-form.
    append tmp_event to events.
  endif.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog.
  clear: fieldcat. refresh: fieldcat.
  data: tmp_fc type slis_fieldcat_alv.
  tmp_fc-reptext_ddic = 'Material'.
  tmp_fc-fieldname    = 'MATNR'.
  tmp_fc-tabname      = 'I_ALV'.
  tmp_fc-outputlen    = 18.
  append tmp_fc to fieldcat.
endform.
* COMMENT_BUILD
form comment_build using list_top_of_page type
                                        slis_t_listheader.
  data: tmp_line type slis_listheader.
  clear tmp_line.
  tmp_line-typ  = 'H'.
  tmp_line-info = 'Here is a line of text'.
  append tmp_line to list_top_of_page.
  clear tmp_line.
  tmp_line-typ  = 'S'.
  tmp_line-key  = 'Key1'.
  tmp_line-info = 'Here is a value'.
  append tmp_line to list_top_of_page.
  clear tmp_line.
  tmp_line-typ  = 'S'.
  tmp_line-key  = 'Key2'.
  tmp_line-info = 'Here is another value'.
  append tmp_line to list_top_of_page.
endform.
* TOP_OF_PAGE
form top_of_page.
  call function 'REUSE_ALV_COMMENTARY_WRITE'
       exporting
            i_logo             = 'ENJOYSAP_LOGO'
            it_list_commentary = list_top_of_page.
endform.
Regards,
Rich Heilman

Similar Messages

  • Count lines of code present in methods of a class

    Hi Friends,
    Can anyone suggest how to count lines of abap code in methods of a class?I have used the function module  'SEO_CLASS_GET_INCLUDE_SOURCE' but this function module doesnt counts the code for methods of a class.
    Kindly help.
    Regards
    ST

    Hi siji,
    once try the below info.
    data: itab type table of string.
    data: w_lines type i.
    read report <reportname> into itab.
    describe table itab lines w_lines.
    write: / 'Report lines:', w_lines.
    It is however important to find the exact report name.
    For standard ABAP reports it is easy, it is the name of the report itself.
    For classes and function modules this is somewhat different.
    Correct report name for function modules can be found as follows :
    Use table TFDIR, field FUNCNAME is your function module.
    PNMAME contains the main program name of the function group, not of the function module.
    Function module report can be created as follows PNAME+3 concatenated with 'U' and field INCLUDE.
    Example for the function module RFC_PING this will be
    'LSRFC' + 'U' + 07 = report name LSRFCU07
    Also take a look at the function module FUNCTION_INCLUDE_CONCATENATE
    Hint: lines( ) is a built-in (system class) static function returning the number of lines in a given internal table. You will like it much better than old-fashioned DESCRIBE TABLE statement where you make us of a count variable an need one more statement for the summing up.
    Note:  If you dont want to count blank line and comments, try this code
         delete itab where table_line is initial or table_line(1) = '*'.
           add lines( itab ) to total_linecount.
    Regards,
    Ravi

  • Count lines in table

    hallow
    i have internal table and i wont to count lines with key
    example
    data
    001
    001
    002
    003
    001
    i wont in some fiels to now how much number of 001 i have here 3
    regards

    Hi Shnya,
    first sort the internal table based on the field that u want to have count...
    Example: lets suppose that the field name itself is data and the internal table name is l_itab and it has the values that u have given in your post...
    Sample code:
    sort l_itab by data.
    loop at l_itab into wa_itab.
      lv_counter = lv_counter + 1.
      at end of data.
      Each time it triggers, lv_counter will be having the *   value for a particular value in data field.. for the *   first time it will be having counter for 001, second *   time 002 and so on...
      write code according to your requirement.. and then *   clear lv_counter...  
      endat.
    endloop.
    Hope this helps u...
    Regards,
    Phani.

  • Counting lines problem. Please help!!

    Hi all,
    I just have a small problem i cannot resolve, here it is: I read through a file and i like to count the lines of the file there is before a special word.
    E.g
    My file contains:
    "hi
    how are you
    my name is john
    and i live
    britain"
    I'd like to count how much lines there are in the file before the word LIVE ==> result would be 4.
    I proceed with StreamTokenizer, but i don't knor how to specify the word. Here is my code:
         try {FileReader fr = new FileReader("test2.dat");
                   BufferedReader br = new BufferedReader(fr);
                   StreamTokenizer stk = new StreamTokenizer(br);
                   do {
                   n = stk.nextToken();
                   li = stk.lineno();
                   if (n == stk.TT_NUMBER) {
                        n = stk.nextToken();
                   if (n == stk.TT_EOL) {
                        li++;
                        n = stk.nextToken();
                   if (n == stk.TT_WORD) {
                        String str = stk.sval;
                        if ("entier".equals(str)) {
                             System.out.println(li);
                        else {
                             n = stk.nextToken();
                   while (??????????????);
    I want here to specify the word "entier" but how to do this??
    Thanks very much for your precious help....

A: Counting lines problem. Please help!!

Use LineNumberReader, which counts lines for you. Here's a complete program in 16 lines:
import java.io.*;
public class test4 {
  public static void main(String[] argv) {
    if (argv.length < 2) { System.err.println("no arg"); System.exit(0); }
    try {
      LineNumberReader in = new LineNumberReader(new FileReader(argv[1]));
      String line;
      while((line = in.readLine()) != null)
        if (line.indexOf(argv[0]) != -1)
          System.out.println("Found match at line " + in.getLineNumber());
    } catch (IOException e) {
      e.printStackTrace();
}If you want case insensitivity, you can make both lines lower-case before searching. Or you can use regular expressions.

Use LineNumberReader, which counts lines for you. Here's a complete program in 16 lines:
import java.io.*;
public class test4 {
  public static void main(String[] argv) {
    if (argv.length < 2) { System.err.println("no arg"); System.exit(0); }
    try {
      LineNumberReader in = new LineNumberReader(new FileReader(argv[1]));
      String line;
      while((line = in.readLine()) != null)
        if (line.indexOf(argv[0]) != -1)
          System.out.println("Found match at line " + in.getLineNumber());
    } catch (IOException e) {
      e.printStackTrace();
}If you want case insensitivity, you can make both lines lower-case before searching. Or you can use regular expressions.

  • Counting lines in a text/csv file.

    Can you advice me, how I can get the total number of lines in a text/csv file please using java code.
    I will get the text/csv file content in a string variable not as a file.
    EX: string var = "123\n234\n123\n3456\nsdfsd\n" here \n is in the new line.
    for this I have to get the total lines as 5.
    Please advice.
    Thanks.

    Kayaman wrote:
    user12679330 wrote:
    Oh ok.. ignore the last one, Any idea on this please.Count the newline characters like morgarl told you. You're being very difficult to help for such a simple problem.Thats because nobody has posted the code yet dude ;)
    I'm pretty sure that once the OP finally takes the hint and writes the two lines of code needed to solve this question, he'll come up with something that sometimes gives the correct answer and other times gives a count that is one-off.

  • Count lines in text file

    Folks:
    What's the best way to count the number of lines in a text file?
    thanks,
    Kevin

    You can also skip the open/create, you'll still get a file dialog. I guess EOL conversion is also not needed.
    So the most minumalistic code is as follows.
    Has anyone done any benchmarks? Somehow I have the feeling that temporarily creating that big array of strings might not be the most efficient compared to reading all as one string and counting linefeeds. Who knows...? How big are your files?
    Message Edited by altenbach on 09-29-2006 04:03 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    CountLines.png ‏1 KB

  • Counting Line items in FBL3N

    Hi Gurus,
    If we execute a report FBL3N and system shown 110 items. We use a filter to filter out 15 items so how can we see in a system that how many items are remaining. Is there any facility to count these items?
    Please revert asap.
    Thank You

    Hi
    There is no standard functionality to count the line item. U have to download the data into Excel and do the excercse manually there.
    Thanks
    GG

  • How can i count line wich begins with NCOUNT word

    I want to make a loop to count first a number of lines in file after that to count number of block data wich begins with NCOUNT word

    Look at the discussion on a similar thread here from a week ago and see if it helps.

  • Counting line breaks

    Hello,
    I have a text field which can display up to 4 lines in Arial, size 9.
    I want to change the font size when there are more than 4 lines in it. Is there a way to count carriage returns in a field?
    e.g.
    IF string.count(:RECIPES, "<cr><lf>") > 3 THEN
    srw.set_font_size(7)
    END IF
    Thank you
    Edit: I found out how to determine how often one string contains another one. This makes the font size smaller when there are at least 5 "%" in the text:
    IF (INSTR(:RECIPES, '%', 1, 5) > 0) THEN
    srw.set_font_size(7)
    END IF
    My Question now: What do I have to search to find line breaks?
    I am completely new to Oracle.
    Thank you,
    Thomas
    Message was edited by:
    Wieczo

    Great, thank you for the answer.
    It didn't work with chr(13), so I changed it to chr(10) and it works.

  • Counting Lines/Char/Words in a txt file

    I created this method that counts the mount of lines/words/ and char in a file. But for somereason, its not working correctly. Its giving me numbers that are a little off.
         // Method countLineWordChar counts the number of lines, words, and chars, in
         // a file given as a parameter. This method returns an array of intergers. In
         // the array, the first position is the amount of lines, the second posistion
         // is the amount of words, and the third is the amount of chars.
         public static int[] countLineWordChar(File f)
              int[] countInfo = new int[3];
              int lineCount = 0;
              int wordCount = 0;
              int charCount = 0;
              try
                   FileReader fr = new FileReader(f);
                   StreamTokenizer st = new StreamTokenizer(fr);
                   st.eolIsSignificant(true);
                   while(st.nextToken() != StreamTokenizer.TT_EOF)
                        switch(st.ttype)
                             case StreamTokenizer.TT_WORD:
                             wordCount++;
                             String wordRead = st.sval;
                             charCount += wordRead.length();
                             break;
                             case StreamTokenizer.TT_EOL:
                             lineCount++;
                             break;
                             default:
                             break;
              catch (FileNotFoundException fnfe)
                   UserInterface.showFileNotFoundError();
              catch (IOException ioe)
                   JOptionPane.showMessageDialog(null, ioe.toString(), "Error",
                   JOptionPane.ERROR_MESSAGE);
              countInfo[0] = lineCount;
              countInfo[1] = wordCount;
              countInfo[2] = charCount;
              return countInfo;
         // Based on the countLineWordChar method, returns the amount of lines.
         public static int getLineCount(int[] countInfo)
              return countInfo[0];
         // Based on the countLineWordChar method, returns the amount of words.
         public static int getWordCount(int[] countInfo)
              return countInfo[1];
         // Based on the countLineWordChar method, returns the amount of chars.
         public static int getCharCount(int[] countInfo)
              return countInfo[2];
         }

    Well, for one thing, you're adding the number of characters in words, not the number of characters overall. Are you sure it's not supposed to be the latter?
    Otherwise, how is it off?
    Basically the way you fix this kind of thing is to add debugging code, then give it a small data sample and watch the debugging messages.
    By the way, returning an array of different kinds of values like that isn't ideal. In this case it's not so bad, because the kinds of values are actually really similar -- they could be viewed as a tuple. But don't make a habit of it. An example of a bad application of this would be if you were returning an array that counted, say, the weight of a ship, the length of its hull, and the distance it travelled in the last year. The alternative is to create a class that encapsulates the data being returned, or to move functionality around so the data isn't being returned at all.

  • PXI 6602 shared DIO Counter lines

    Hi,
    I have a question regarding the PXI-6602. From the manual I see that some of its PFI channels are shared. If I wanted to use a counter to generate a timed pulse. Can I use the associated gate and source PFI as digital output lines without affecting the counter?
    Here's a concrete example: Let's say I'm using the counter 7 to generate a timed pulse on PFI 8 which is the CTR OUT. Can I simultaneously use PFI 10, which is listed in the manual as having possible signals CTR 7 Gate and P0.10, as a digital output? Can I simultaneously use PFI 11, which is listed in the manual as having possible signals CTR 7 Source and P0.11, as a digital output?
    Thank you!

    Hi,
    Take a look at this example related to routing counter signals through the RTSI lines.
    http://www.ni.com/example/27109/en/
    Reference Table:
    http://zone.ni.com/reference/en-XX/help/370466W-01/mxdevconsid/tiosigconcounters/
    Luis S
    Application Engineer
    National Instruments

  • Count lines in sapscript

    i have this
    matnr meng
    23333  3
    34445  4
    44444  4
    total   3 lines. how i can count the lines?

    Hi yehiel,
    1. since it is sap standard as u said,
      then FROM WHERE
      do u want to count the number of lines ?
    regards,
    amit m.

  • Need script or Program to count lines of source code

    Hello, I need a script or a program that can count how many lines are there in a directory contains source code as well as other directories(contain code as well), there are .java files in these directories, the script or program should count number of lines with/without comments(starts with // or surrounded by /**/)
    Thanks a lot!!!

    I wrote a quick python program to count the lines in a file, you could just adapt it to your needs, or use the second program I have in this post that condenses all the .java files in a directory into a single text file, which you can then use a line-count on (useful if you need to print it as well - I wrote it for my IB dossier java project), if you'd like a proper script for your needs, otherwise check the other suggestions.
    Run it by copying the code into a text file and saying it as script.py (change script to whatever you want) and running it with python /path/to/script.py
    #!/usr/bin/env python
    #Program to tally the lines in a file
    #Author: lswest
    import os
    home=os.path.expanduser("~")
    endPath=raw_input("Path to file relative to your home directory (include file name and extension): ")
    count=0
    ff=open(os.path.join(home, endPath))
    for x in ff:
    count+=1
    values={'name': os.path.join(home,endPath), 'count' : count}
    print "The file %(name)s contains %(count)s lines." % values
    #!/usr/bin/env python
    #Script to condense the multiple files of a project into one for easy printing/copying
    #Author: lswest
    import os
    home=os.path.expanduser("~")
    endPath=raw_input("Path relative to your home directory to the project folder: ")
    extension=raw_input("Extension of files you want to condense: ")
    outPath=raw_input("Path to output file relative to home directory: ")
    outFile=raw_input("Output file name (including extension): ")
    ff=open(os.path.join(home+outPath,outFile), "wt")
    for root, dirs, files in os.walk(os.path.join(home,endPath), "true", "none", "true"):
    for infile in [f for f in files if f.endswith(extension)]:
    fh=open(os.path.abspath(os.path.join(root,infile)))
    for line in fh:
    ff.write(line,)
    fh.close()
    ff.close()
    Last edited by lswest (2009-03-10 16:23:52)

  • Count lines of code in WDA component

    Is there a way to count the lines of own code (or otherwise measure the "size") in a WDA component on a 7.01 system? Please don't make me go through every single method one by one

    If you load the Web Dynpro Component in SE80 and then choose Web Dynpro Component->Check->Generation Limits, this will give you the load size in bytes of the WD Component. It also has some breakdown liek the number of variables declared.  However nothing that gives you the exact lines of code.
    The source code of all WD methods is stored in table WDY_CTLR_COMPO, so I supposed if if you really needed to you could write a small program to count the number of lines of code or the number of characters.

  • Counting lines of code

    Does anyone know a way to count the lines code in a package
    excluding comments? The following are commenting styles:
    * comment1
    -- comment 2
    /* comment 3 */
    comment 4

    CREATE OR REPLACE PROCEDURE count_code(p VARCHAR2) Is
    CURSOR c1 IS SELECT * FROM user_source WHERE name=UPPER(P);
    l_count number :=0;
    l_tot_count number:=0;
    comment_flag boolean:=false;
    BEGIN
    for crec in c1 loop
    l_tot_count := l_tot_count+1;
    IF substr(trim(crec.text),1,2) not IN ('--','/*') and not
    comment_flag THEN
    l_count := l_count+1;
    ELSIF substr(trim(crec.text),1,2)='/*' THEN
    comment_flag := true;
    end if;
    IF comment_flag and instr(trim(crec.text),'*/')>0 THEN
    comment_flag:=false;
    end if;
    END LOOP;
    dbms_output.enable(100000);
    dbms_output.put_line('Object
    Name : '||p);
    dbms_output.put_line('Total number of lines
    Code : '||l_tot_count);
    dbms_output.put_line('Total number of lines Code with out
    comments : '||l_count);
    END;
    Suresh Vemulapalli

  • Maybe you are looking for

    • Convert iPhone photo to JPG before upload to server?

      The issue I'm having is that I'm trying to have the user upload a photo from their iPhone to my server. However, I don't want their raw, large file size photo. Is there a way I can encode the photo to a smaller quality JPG before the user uploads it?

    • "App store" not showing up in main menu

      When I click menu, there is no option for me to go to the app store, how do i get it back so it shows on the main menu?

    • Error when logging 'system' user.

      Hi All, i tried to connect system/manager, but oracle throwing error 'ORA 24315', how to rectify the error, to login successfully,?

    • Problems after updating to belle on n8

      working is very slow and touch sensitivity has decreased and even i have provlem with my cam, wen ever i open my cam it shows me some error then i have to restart my phone for cam to work.. Pls help me solve this and my phone memory is also very low

    • Moo Fix in Software Update!

      Anyone with a Mooing MacBook will love this. It got rid of my Moo immediately. It sounds as if the fan runs permanently at a really low speed but it's so much better than the Moo. If you dont have any fan/Moo issues, you may not want to install this.