How to count the number of lines dynamically,

In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
after displaying one category contents am displaying a line
which also counts to a line in the internal table.
My question is how to count the number of lines(ULINE) displayed dynamically.
FORM GET_LINES .
  DATA: LV_LINES TYPE I,
        LV_TIMES TYPE I,
        LV_TABIX TYPE SY-TABIX.
  DESCRIBE TABLE IT_REC LINES LV_LINES.
  DO LV_LINES TIMES.
    LV_TIMES = SY-INDEX .
    READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
    IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
      LV_TABIX =  LV_TIMES.
      READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
      IF SY-SUBRC EQ 0.
        APPEND GWA_UPDATE TO GT_UPDATE.
      ENDIF.
    ENDIF.
  ENDDO.
ENDFORM.                    " GET_LINES

In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
after displaying one category contents am displaying a line
which also counts to a line in the internal table.
My question is how to count the number of lines(ULINE) displayed dynamically.
FORM GET_LINES .
  DATA: LV_LINES TYPE I,
        LV_TIMES TYPE I,
        LV_TABIX TYPE SY-TABIX.
  DESCRIBE TABLE IT_REC LINES LV_LINES.
  DO LV_LINES TIMES.
    LV_TIMES = SY-INDEX .
    READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
    IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
      LV_TABIX =  LV_TIMES.
      READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
      IF SY-SUBRC EQ 0.
        APPEND GWA_UPDATE TO GT_UPDATE.
      ENDIF.
    ENDIF.
  ENDDO.
ENDFORM.                    " GET_LINES
The display function is:
FORM DISPLAY_DATA .
  ULINE.
  WRITE :  /1 SY-VLINE, 'check',
            10 SY-VLINE, 'Plant',
           20 SY-VLINE, 'Material number',
           50 SY-VLINE, 'Follow up material',
           70 SY-VLINE, 'Safety stock',
          100 SY-VLINE, 'Partc'.
  ULINE.
  LOOP AT IT_MARC.
    MOVE: IT_MARC-WERKS TO IT_REC-WERKS,
          IT_MARC-MATNR TO IT_REC-MATNR,
          IT_MARC-NFMAT TO IT_REC-NFMAT,
          IT_MARC-EISBE TO IT_REC-EISBE,
          IT_MARC-PARTC TO IT_REC-PARTC .
    APPEND IT_REC.
    CLEAR IT_MARC.
  ENDLOOP.
  DATA: GV_TABIX TYPE SY-TABIX.
  LOOP AT IT_REC.
    GV_TABIX = SY-TABIX.
    READ TABLE GT_TOTAL WITH KEY WERKS = IT_REC-WERKS
                                 NFMAT = IT_REC-NFMAT.
    IF SY-SUBRC EQ 0.
      IT_REC-PARTC = GT_TOTAL-PARTC.
      MODIFY IT_REC INDEX GV_TABIX TRANSPORTING PARTC.
    ENDIF.
  ENDLOOP.
  LOOP AT IT_REC.
    WRITE : /1 SY-VLINE, IT_REC-CHECK AS CHECKBOX,
            10 SY-VLINE, IT_REC-WERKS,
            20 SY-VLINE, IT_REC-MATNR,
            50 SY-VLINE, IT_REC-NFMAT,
            70 SY-VLINE, IT_REC-EISBE,
           100 SY-VLINE, IT_REC-PARTC.
    AT END OF NFMAT.
      ULINE.
    ENDAT.
  ENDLOOP.
  ULINE.
ENDFORM.                    " DISPLAY_DATA
Solved

Similar Messages

  • Count the number of lines in  each file in a directory

    Hello,
    I would like to count the number of lines for each file in my directory and subdirectories.
    I wonder how can I count the lines of the specified files?
    Here is the program which is listed the files in the specified directory:
                        String path = "C:/User/Studies/Pracices/src/Pract1";
           String files;
           File folder = new File(path);
           File[] listOfFiles = folder.listFiles();
           for (int i = 0; i < listOfFiles.length; i++)
            if (listOfFiles.isFile())
         files = listOfFiles[i].getName();
         System.out.println(files);

    Ok so one more question.
    Actually my path is pointing to one Directory and like here I can just read from one file that the name of the file should be specified in the path is it possible to help me in that part?
    File f = new File("C:/User/Studies/Practices/src/Pract1/");
    FileReader fr = new FileReader(f);
          BufferedReader br = new BufferedReader(fr);
          String str = br.readLine();
              LineNumberReader ln = new LineNumberReader(br);
              int count = 0;
              while (ln.readLine()!=null)
                  count++;
              System.out.println("no. of lines in the file = " + count);

  • Count the Number of Lines

    Hi All,
    I want to count the Number of lines that the user had entered in a multi-lined text box.
    Because I want to restrict him up-to 6 lines.
    How Can I don this.
    Thanks in Advance,

    sql>select length('count no
                      of line
                      in the text')-length(replace('count no
                                                  of line
                             in the text',chr(10),'')) lines
        from dual;
    LINES 
    2
    jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Java Program+To count the number of lines in a method excluding comments???

    Hi friends
    can u plz help me out, the java program is counting the number of lines in a method excluding comments.
    The first thing is how to identify a method, then there can be an inner method inside the parent method,
    Please friends its urgent
    Bye
    Sandy

    There's no such thing as an inner method in Java. You can either write the code yourself to parse Java source, or maybe something like ANTLR can do it.

  • How to count the number of rows in a resultser object?

    hi there
    how to count the number of rows in a resultser object which may contains millions of rows? besides using a while loop? thanks

    You don't, you execute a query whose result is the record count of those records that match the search and then you execute the actual query to create your record set. Typically you do
    select count(id) from YourTable where [filter]
    from the resulting ResultSet do
    int res.getInt(1);
    which gives you the count and then
    select id from YourTable where [filter]
    to produce the actual result set.
    in the second query the id part can be substituted with the actual fields you want.

  • Count the number of lines in a txt file

    I need to count the number of lines in a txt file, but I can't do it using readLine(). This is because the txt file is double spaced. readLine() returns null even if it is not the end of the file. thanks for the help

    I need to count the number of lines in a txt file,
    but I can't do it using readLine(). Then just compare each single byte or char to the newline (code 10).
    This is because the txt file is double spaced. readLine() returns
    null even if it is not the end of the file.Errm what? What do you mean by "double spaced"? Method readLine() should only return null if there's nothing more to read.

  • How to count the number of wins?

    I have a tic tac toe simulator that simulates a game of tic tac toe (obviously). I press the 'play' button, and 1 random X and O is placed in 9 of the labels. Then the application says if X or O wins, or if the game was a tie/no winner.  So,
    what I want to do is when I click the 'exit' button, I want a message box telling the user how many times X won, O won, and how many ties there were.  I am not too sure how to count the number of wins.
    -Thanks

    Thanks for the reply.  I could be wrong, but I do not think that is exactly what I am looking for.  Here is the code that I have that determines the winner:
    switch (checkWinner())
    case 'T':
    winnerLabel.Text = "It was a tie!";
    break;
    case 'O':
    winnerLabel.Text = "O Wins!";
    break;
    case 'X':
    winnerLabel.Text = "X Wins!";
    break;
    private char checkWinner()
    char WinnerChar = ' ';
    int winning_line = 0;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[1]) && GameBoardCellChar[0].Equals(GameBoardCellChar[2]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[3].Equals(GameBoardCellChar[4]) && GameBoardCellChar[3].Equals(GameBoardCellChar[5]))
    WinnerChar = GameBoardCellChar[3];
    winning_line++;
    if (GameBoardCellChar[6].Equals(GameBoardCellChar[7]) && GameBoardCellChar[6].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[6];
    winning_line++;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[3]) && GameBoardCellChar[0].Equals(GameBoardCellChar[6]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[1].Equals(GameBoardCellChar[4]) && GameBoardCellChar[1].Equals(GameBoardCellChar[7]))
    WinnerChar = GameBoardCellChar[1];
    winning_line++;
    if (GameBoardCellChar[2].Equals(GameBoardCellChar[5]) && GameBoardCellChar[2].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[2];
    winning_line++;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[4]) && GameBoardCellChar[0].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[2].Equals(GameBoardCellChar[4]) && GameBoardCellChar[2].Equals(GameBoardCellChar[6]))
    WinnerChar = GameBoardCellChar[2];
    winning_line++;
    if (winning_line == 0 || winning_line > 1)
    WinnerChar = 'T';
    return WinnerChar;
    Do I have to include something extra in here to get the count or no?
    The code I posted is the coding in my play button.

  • How to count the number of text boxes that are data entered

    How to count the number of text boxes that are data entered in visual basic form.

    Here is an Iterator that expands on my previous response:
    ''' <summary>
    ''' Iterator for form controls
    ''' </summary>
    ''' <param name="onlyControlsOfType">specify type if a certain type of controls needed</param>
    ''' <param name="onlyTopLevel">if true don't search containers within the form</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Iterator Function AllControls(Optional onlyControlsOfType As Type = Nothing, _
    Optional onlyTopLevel As Boolean = False) As IEnumerable(Of Control)
    Dim ctrl As Control = Me.GetNextControl(Me, True)
    Do Until ctrl Is Nothing
    If onlyControlsOfType Is Nothing OrElse ctrl.GetType = onlyControlsOfType Then
    If TypeOf ctrl.Parent Is Form OrElse Not onlyTopLevel Then
    Yield ctrl
    End If
    End If
    ctrl = Me.GetNextControl(ctrl, True)
    Loop
    End Function
    Some sample uses:
    For Each
    For Each c As Control In AllControls()
    Debug.WriteLine(c.Name)
    Next
    List of all controls, including controls in containers i.e. Groupbox
    Dim l As List(Of Control) = AllControls().ToList
    List of all Textbox controls, including Textboxes in containers i.e. Groupbox
    l = AllControls(GetType(TextBox)).ToList
    List of all Textbox controls, don't include Textboxes in containers i.e. Groupbox
    l = AllControls(GetType(TextBox), True).ToList
    'Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it.'  JohnWein
    Multics
    My Serial Port Answer

  • How to Count the number of TAB chars value '0A' in a line?

    I have a requirement to count the number of TABs in a text file that I am processing (they must equal 75) to ensure that all the fields have been submitted on the file I am reading?
    How do I identify the TABs in a line?
    I have this so far:
             CONCATENATE gv_unix_file gv_lstfiles-name INTO gv_unix_file.
              OPEN DATASET gv_unix_file for INPUT IN TEXT MODE ENCODING NON-UNICODE.
              IF sy-subrc <> 0 .
                message e000(zz) with 'Cannot access in_uk files'.
              ENDIF.
              CONCATENATE gv_unix_file_arc gv_lstfiles-name INTO gv_unix_file_arc.
              OPEN DATASET gv_unix_file_arc FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
              IF sy-subrc <> 0 .
                message e000(zz) with 'Cannot access in_uk files'.
              ENDIF.
              DO.
                READ DATASET gv_unix_file into lv_str.
                IF sy-subrc <> 0.
                  exit. "exit do loop, file is done.
                else.
                  TRANSFER lv_str to gv_unix_file_arc.
                ENDIF.
              ENDDO.

    Here is a sample code:
    DATA: lv_string TYPE string,
          lv_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
          lv_i TYPE i.
    DATA: result_tab TYPE match_result_tab.
    DO 3 TIMES.
      CONCATENATE 'A' lv_string INTO lv_string SEPARATED BY lv_tab.
    ENDDO.
    " this is how you need to find how many tabs are in your transfer work area...
    FIND ALL OCCURRENCES OF lv_tab IN lv_string RESULTS result_tab.
    DESCRIBE TABLE result_tab LINES lv_i.
    WRITE:'No. of tabs found:', lv_i.

  • Help with how to count the number of tokens from the first line

    Hi
    I want to count the number of tokens from the first line of text, from my incoming file and print it out.
    For example i have 12 tokens in the first line, so i want it to print out the number 12
    my code is below
    thanks
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.util.StringTokenizer.*;
    import java.sql.*;
    public class Data {
         public static void main(String[] args) {
                        String token = null;          
                        String currentToken = "";
                        Hashtable hh = new Hashtable();     
              try {
                   Vector v2 = new Vector(100);
                   Vector v = new Vector(100);
                   FileReader file = new FileReader("words.txt");
                   BufferedReader buff = new BufferedReader(file);
                   String line = buff.readLine();
                   StringTokenizer s = null;
                   boolean eof = false;
                   while  (!eof){
                        s = new StringTokenizer(line.trim(),",",true);
                        boolean lastToken = true;
                   while (s.hasMoreTokens()) {
                              token = s.nextToken();
                                  if (lastToken){
                                   if (token.equals(",")) {
                                        v.add("");
                                               lastToken = false;
                                      if (! token.equals(",")) {
                                   v.add(token);
                                  else { if (currentToken.equals(",")) {
                                        v.add("");
                                  currentToken = token;
                        if (token.equals(",")) {
                               v.add("");
                   line = buff.readLine();
                        if (line == null){     
                             eof = true;}
                   buff.close();
              }catch (FileNotFoundException fe) {     
                        System.out.println("Error - - " + fe.toString());
              }catch (NumberFormatException ne) {
                        System.out.println("Error - - " + ne.toString());
              } catch (IOException e) {
                   System.out.println("Error - - " + e.toString());
    }     2.

    I can print out the amount of tokens from each line,
    But i only want the first line to be counted, And i
    also do not want the delimeters to be counted.
    could you please give me some ideas?
    Thanks
    try
       BufferedReader br = new BufferedReader(new FileReader("item.kr"));
       while((str=br.readLine())!= null)
          itemslist.add(str);
    catch(IOException ioe)
       System.out.println("Exception Occurred!!!");
    }This snippet gets one Line from the item.kr file.
    Then i would count (By useing a diffrent String Tokenizer) to count only this line!!!

  • How to count the number of instances a record appears in a string

    I have a move that imports Name, Department and Site from an
    external CSV file, this part I managed to get working after many
    weeks. I would like to be able to count the number of instances of
    a specific Site “Glasgow” appears in the String. This
    way I know how many lines to set.
    Also can you add Dynamic text to a rollover button? I can get
    the the text to display on the root but not on a button.
    I am new to programming and Flash so apologies in
    advance.

    Those which took time to read carefully *_iWork Formulas and Functions User Guide_* are aware of the availability of wildcard characters.
    =COUNTIFI(range;"=text")
    will do the trick.
    Yvan KOENIG (VALLAURIS, France) lundi 26 avril 2010 17:36:34

  • Count the number of Lines with in a method

    I am trying to write a program that will report back the number of methods/types/names and proxies as well as the number of lines of code in each method... I can not figure out how to count each methods line of code separately thanks. each method is commented by
    /* PROXY proxyname type */
    /* METHOD method name*/
    public class Assignment3
    private static BufferedReader userInput = new BufferedReader (new InputStreamReader (System.in));
         * @param args
         * @throws IOException
         * @param args
         * @throws IOException
         public static void main(String[] args) throws IOException
              System.out.print("Enter the .java file name: ");
         String input = userInput.readLine();
         while (!input.equalsIgnoreCase("stop"))
              System.out.println("Total Number of Lines: " + LOC(input) + "\n" + Method(input) + "\n" + Type(input));
              System.out.print("\nEnter file name to search again or \"stop\" to terminate the program: ");
              input = userInput.readLine();
    public static int LOC(String inputFile) throws IOException, FileNotFoundException
         int numLines = 0;
         try
                        FileReader FileIn = new FileReader(inputFile);
                        Scanner scanLines = new Scanner (FileIn);
                        String line;
                             while (scanLines.hasNext())
                                  line = scanLines.nextLine();
                                  if (line.startsWith("/*"))
                                       numLines--;
                                  else if(!line.equals(" "))
                                       numLines++;
                             FileIn.close();
              catch(IOException IOE)
                   System.out.println("\nFile Not Found!");
                   return numLines;
    public static int MethodLOC(String inputFile) throws IOException, FileNotFoundException
         File FileIn = new File(inputFile);
         Scanner scanLines = new Scanner (FileIn);
         String line = null;
         int methodLOC = 0;
         while(scanLines.hasNext())
              line = scanLines.nextLine();
              if(!line.contains("/*"))
                   StringTokenizer st = new StringTokenizer(line, "\n");
                   methodLOC = st.countTokens();
         return methodLOC;
    public static String Method(String inputFile) throws IOException, FileNotFoundException
         String line = null;
         String name = null;
         String info = null;
         File FileIn = new File(inputFile);
         Scanner scanLines = new Scanner (FileIn);
         while(scanLines.hasNext())
              line = scanLines.nextLine();
         if(line.contains("METHOD"))
              StringTokenizer st = new StringTokenizer(line, " ");
              String proxy = st.nextToken();
              String method = st.nextToken();
              name = st.nextToken();
              info = "Name of Method: " + name;
    return info;
    public static String Type(String inputFile) throws IOException, FileNotFoundException
         String line = null;
         String name = null;
         String info = null;
         String count = null;
         File FileIn = new File(inputFile);
         Scanner scanLines = new Scanner (FileIn);
         while(scanLines.hasNext())
         if(line.contains("PROXY"))
              StringTokenizer st = new StringTokenizer(line, " ");
              String proxy = st.nextToken();
              String method = st.nextToken();
              name = st.nextToken();
              String type = st.nextToken();
              info = "Name of Proxy: " + name + "\n" + "Type of Proxy: " + type;
         count = info;
    return count;
    }

    Iterate through the lines and count the opening and closing curly braces. Whenever you see an opening one, increase the counter, when you see a closing one, decrease the counter. When the counter hits 0 again, you reached the end of the method.
    I assume you know how to count lines while moving through a text line by line.

  • How to count the number or rows in file

    Hi Experts,
    I am file as source and Oracle as target. My file containing the some data which is going to load to the target.
    My requirement is that I want to count the number of rows which my file contains. Please help me how to count the total number of rows in file.
    Thx,
    Sahadeva.

    Hi,
    You won't give a name DEST_USER_NAME:ODI will get these information.
    it is important  Command on source and Command on Source side .
    -Pls write jython code on Command on Source side
    -And Command On Target side Choose technology as Oracle and set logical schema to HR_logical
    Sorry my mistake.İt is related jython syntax.Here is code:
    import java.lang as lang
    import java.sql as sql
    import java.lang.String
    import os
    lang.Class.forName("<%=snpRef.getInfo("DEST_JAVA_DRIVER")%>")
    cons=sql.DriverManager.getConnection("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")
    dblinks= cons.createStatement()
    file1=open('EMP.txt','r')
    count=0
    line=file1.readline()
    while line !='':
         count+=1
         line=file1.readline()
    file1.close()
    sqlQuery = "insert into HR.ETL_FILE_LOG (FILE_COUNT) values (count)"
    rqQuery= dblinks.execute(sqlDBLink)
    cons.close()
    Regards

  • How to count the number of rows in a cube!!??

    Experts,
    I can somebody tell me how do I count the number of rows in my cube when i am using listcube???..
    Thanks
    Ashwin

    Hi,
    have a look ath this theard too
    Number of Records in Cube
    regards

  • How to get the number of lines of a FileReader

    I need to calculate the number of lines of a FileReader object. How can I do that ?

    I wrote the following some while ago. It assumes that a line is terminated by '\n' but it should be easy to adapt.
    import java.io.*;
    public class LineCounter
        public static int countLines(File file, String encoding) throws IOException
            int lineCount = 0;
            Reader reader = new InputStreamReader(new FileInputStream(file), encoding);
            char[] buffer = new char[4096];
            for (int charsRead = 0; (charsRead = reader.read(buffer)) >= 0;)
                for (int charIndex = 0; charIndex < charsRead ; charIndex++)
                    if (buffer[charIndex] == '\n')
                        lineCount++;
            reader.close();
            return lineCount;
        public static void main(String[] args)
            try
                File file = new File("/home/sabre/work/dev/maps/EUROPE.RIV");
                long startTime = System.currentTimeMillis();
                int lineCount = countLines(file, "UTF-8");
                double time =  (System.currentTimeMillis() - startTime) / 1000.0;
                System.out.println("File size = " + file.length() + " contains " + lineCount + " lines taking " + time);
            catch (Exception e)
                e.printStackTrace();
    }

Maybe you are looking for

  • Accidentally deleted a purchased song

    I bought a album yesteday, and me being an idiot I accidentally deleted a song off it today. When I go onto iTunes the rest of the album says play next to it but the deleted song just says purchased and when I click on it it just plays the sample of

  • The char '0x0' in 'return code:  500

    Hi All, I am trying to expose a EJB as webservice using AXIS 1.2 Final. When deployed my ear/ejb on WSAD - WAS 5.0 and trying to consume the web service using AXIS 1.2 generated stubs I am getting below error on the server side. Exception in thread "

  • IPod Nano software

    When it is about to finish formatting it, it says that it canot connect and I have to go through the process all over again? I jus received it for my birthday and I would really love to listen to it. Thanks for the help

  • My laptop can not print to my Hp printer /wiefy

    My presario 62 won't let me print to my photosmart D7640 printer. It show thats its offline? I have a brand new XFinity network. What do I do? Bob

  • New lead email

    Is there a way for me to turn off that email message 'you have a new lead assigned email' sent to the salesperson? My rep has the 'No Email' flag set on their user profile. Also it doesn't seem to be always sent - what is the exact trigger?