How to count the total lines of code in Java project in NWDS

Hi,
I have created a simple web application in java using NWDS. For audit purposes, I need to know the total lines of java code in this project.
We use Netweaver Development Studio (NWDS) to build & deploy the Java applications
Is there any tool available in NWDS that cant do this job quickly ?
Thanks in advance.
Vikram

Hi All,
I have found out the solution to this problem.
There is a SAP tool - Jlin thats available in NWDS.
Further reference, see this
http://help.sap.com/saphelp_nw04/helpdata/EN/f7/3d9d3c838436428a154abc3816fd9c/frameset.htm
Cheers
Vikram

Similar Messages

  • How to count the total lines of the file (including the file header)

    Hi all,
    I am working with Idoc to file scenario(FCC).
    I need to map one of the field with a recound count ie.., count of the total lines of the file (including the file header).
    Eg:Record Count-- mapping area:Total number of records in the file including file header     The total line of the file (including the file header).
    Can i get a help on this.
    Thanks and Regards,
    Manoj

    Hi !
    If there is a tag of your IDOC that occurs the same quantity of times as file lines you have to create in your target file, you could make a Java user defined function in graphical mapping that "caches the entire queue" (use the corresponding option button), that receives as input that field of the IDOC, and returns the "lenght" (.length property value) of that input parameter (it is an array) as output..that should be the file line quantity..you may also add 1 to that count, for the header.
    Hope it helps.
    Regards,
    Matias.

  • How can I count the total number of keyframes in a project in After effects?

    I would just like to know how to get the quantity of how many keyframes I have in my project. I've always thought counting keyframes is pretty interesting xD

    That's a new one!  I don't think anyone's ever been curious about that.  Which means it's an excellent bet that there isn' any automated way to do it: it may be interesting from an academic viewpoint, but I'm stumped about a practical use.  I think you'd just have to count layer by layer, and hope you don't get interrupted.

  • OCCAS, How to count the total invite request hit the server.

    Hi All ,
    I wanted to count the incoming (invite) request hit the sever.How can i do the same.
    Do we have any facility available in OCCAS by which we can count the request.
    I believe there should be some monitoring system available but i am not sure.
    Plz reply, its URGENT.

    You can define a logging servlet, see for an example here: http://download.oracle.com/docs/cd/E13209_01/wlcp/wlss40/operations/pdulogging.html

  • 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

  • Count the total val of the column in matrix

    hi
    how to count the total value of the column in matrix
    eg:
    id     name     points
    10    sachin    100
    12     rama        80
    count the total points in the matrix
    180

    Hi Hareesh,
    Try This....
      Dim finaltot As Integer = 0
                    Dim i As Integer
                    For i = 1 To omatrix.RowCount
                        oedittot = omatrix.Columns.Item("points").Cells.Item(i).Specific
                        finaltot = finaltot + oedittot.value
                    Next
    Thanks
    Shafi

  • 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

  • How can hide the command line of a t.code in the portal

    Dear Experts.
    I have the following doubt:
    How can hide the Command Line of a Report that is called with a T.Code in the portal?
    Attach Image:
    [Image T.Code|http://www.freeimagehosting.net/uploads/eab3b6a03c.jpg]
    When I created a service using the T.Code SICF for the T.Code , I can hide buttons and the filed command line  using
    ~webgui_simple_toolbar
    ~singletransaction
    ~NOHEADEROKCODE
    With notes 1010519, "SAP GUI for HTML: Simplified Title Area Without Menu and OK Code" and 959417.
    But the problem is that when I create the service in the T.Code SICF, I also have that create an Iview IAC in the portal.
    The Question is : How can hide this fields and buttons if I want Publish the T.code using an Iview Transaction in the portal?
    In this moment I have used the two options:
    1 option) I created a service using the t.Code SICF for my Transaction and I also created an Iview IAC in the portal for call the service.
    RESULT:
    SAP Web Application Server
             500 Connection timed out
            Error: -5
           Version: 7000
           Component: ICM
           Date/Time: Sat Jun 12 20:26:39 2010 
           Module: icxxthr_mt.c
           Line: 2698
           Server: xyxab...
    Error Tag: {-}
    Detail: Connection to partner timed out after 60s
    2)  created an Iview Transaction  in the portal and  call my transaction.
    RESULT.
    [Image T.Code|http://www.freeimagehosting.net/uploads/eab3b6a03c.jpg]
    But not can hide the field Command Line and other buttons.
    I think that the command :
    ~webgui_simple_toolbar
    ~singletransaction
    ~NOHEADEROKCODE
    Only can be used if I create a service using the T.Code SICF .
    Best Regards
    Carmen.

    Hi Carmen,
    The bottom line is that this cannot be done for transaction iviews without modifying the standard webgui service in SICF, which is probably not a good idea (since it affects everyone using SAP GUI for HTML). (You could hack the appintegrator to add the ~webgui_simple_toolbar parameter to the transaction URL template in the portal, but again its not a recommended thing to do ...). Better to create an IAC service in SICF with ~webgui=1 where you set the required appearance using an appropriate value for ~webgui_simple_toolbar, and then create an IAC iview to point at this service.
    You can even override the ~transaction value configured in the new service in individual IAC iviews by entering the appropriate value in the application parameter of the iview, for example:
    ~okcode=/nSU01
    And you can pass parameters in the same way:
    ~okcode=/nSU01 USR02-BNAME=xyz;USREFUS-USERALIAS=abc;
    By the way, it would not be recommended to create a URL iview to access an IAC, since you are likely to encounter session management issues in this scenario - better to use an IAC iview.
    Regards, Rory

  • How to Determine the "Total" Page Count on HP 2575 All-in-one printer?

    Looking at how to determine the "Total" Page Count on HP 2575 All-in-one printer?   I've seen directions for other HP printers but can't seem to find any for the HP 2575 All-in-one printer.  I am trying to find approximately how many pages my printer has printed since I've owned it.    Any help is much appreciated. 

    The manual says you should be able to use the Embedded Web Server to view statistics. 
    Say thanks by clicking the Kudos Thumbs Up to the right in the post.
    If my post resolved your problem, please mark it as an Accepted Solution ...
    I worked for HP but now I'm retired!

  • How would I go about adding multiple rectangles using the same lines of code?

    How would I go about adding multiple rectangles using the same lines of code? I would prefer to just run through a set of code every time I need a polygon. If I just have to create multiple polygon adding statements that's fine but I'd prefer just 1.

    >>How would I go about adding multiple rectangles using the same lines of code?
    You could create a method that creates and returns x number of Rectangle elements:
    public IEnumerable<Rectangle> CreateRectangles(int numberOfRectsToCreate)
    for (int i = 0; i < numberOfRectsToCreate; ++i)
    Rectangle rect = new Rectangle();
    rect.Fill = Brushes.Blue;
    rect.Width = 100;
    rect.Height = 100;
    yield return rect;
    ..and then call this method from anywhere in your code:
    IEnumerable<Rectangle> rects = CreateRectangles(5);
    foreach (Rectangle rect in rects)
    //add to StackPanel or do whatever with the Rectangle elements:
    yourStackPanel.Children.Add(rect);
    >>If I just have to create multiple polygon adding statements that's fine but I'd prefer just 1.
    When adding Point objects to a Polygon you can only add one per call to the Add method but you could call the Add method inside a loop, e.g:
    for(int i = 0; i < 10; ++i)
    //add to StackPanel or do whatever with the Rectangle elements:
    Polygon p = new Polygon();
    p.Points.Add(new Point());
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't post several questions in the same thread.

  • How count the total number of instances ?

    I have 2 scenarios :-
    1. How to get the total number of instances of  the node  in a BO?
    eg :
    businessobject BO1   {
    element BO_ID;
                       node NODE1 [0..n]
                         element Node_ID;
                         element Status ;
                         element value:
    I want to get total number of the NODES instances in the particular instance of the BO1.   !!!?????
    2. I want to  make some calculations based on the attributes of the NODE1 , in the   BeforeSave .absl  of the Business Object BO1.
    eg:
    something like this :-
    In BeforeSave of BO1.absl -
    for ( all the instances in NODE1 )
    {   if (NODE1.status == true)
                 sum = sum + NODE1.value
    Please help !!!!

    Your approach is correct.
    You can use a standard Query or create your own Query to run through Datainstances.
    Documentation with examples for Queries in ABSL see here: https://my020062.sapbydesign.com/sap/ap/ui/repository/SAP_BYD_WEKTRA/CP/sapLSUIContentPlayerTestPage.html?manifest=067D03A7602B1D490899DF46B5082089&COMPONENT=A1S_PDI&RELEASE=260&LANGUAGE=en&REGION=&INDUSTRY=&TASK=CR_VIEW&sap-language=EN
    Looking / Clincking  for "SAP Business ByDesign Scripting Language" and "Syntax for Implementation of Actions and Events" and "Query"

  • How to delete the logical lines in JTextArea

    Hi all,
    Now that I know how to find the logical line count in JTextArea as
    I found the following in the forum.
    public static int getLineCount (JTextArea _textArea)
    boolean lineWrapHolder = _textArea.getLineWrap();
    _textArea.setLineWrap(false);
    double height = _textArea.getPreferredSize().getHeight();
    _textArea.setLineWrap(lineWrapHolder);
    double rowSize = height/_textArea.getLineCount();
    return (int) (_textArea.getPreferredSize().getHeight() / rowSize);
    I want to delete the 4th line to the last line and append ... at the 4th, if the getLineCount exceeds 3. Does any body know how to do so?
    The intention is for the multiline tooltip as I just want to show
    the first three logical line and ... if the string is too long.
    Thanks
    Pin

    The code looks good to me. The only thought I have is that the y coordinate for the rowThree point is wrong and is referencing row four.
    I've been playing around with using a JTextArea as a renderer for a JTable. I have it working so that "..." appear when the text exceeds 2 rows. Try clicking on "B" in the letter column and then the update cell button a few times to add text. My code is slightly different than yours.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TestTable extends JFrame
         private final static String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
         JTable table;
         Vector row;
         public TestTable()
              Object[][] data = { {"1", "A"}, {"2", "B"}, {"3", "C"} };
              String[] columnNames = {"Number","Letter"};
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              table = new JTable(model)
                   public String getToolTipText( MouseEvent e )
                        int row = rowAtPoint( e.getPoint() );
                        int column = columnAtPoint( e.getPoint() );
                        if (row == 0)
                             return null;
                        else
                             return row + " : " + column;
              table.setRowSelectionInterval(0, 0);
              table.setColumnSelectionInterval(0, 0);
              table.setRowHeight(0,34);
              table.setRowHeight(1,34);
              table.setRowHeight(2,34);
              table.setDefaultRenderer(Object.class, new TextAreaRenderer(2));
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
              JPanel buttonPanel = new JPanel();
              getContentPane().add( buttonPanel, BorderLayout.SOUTH );
              JButton button2 = new JButton( "Update Cell" );
              buttonPanel.add( button2 );
              button2.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        int row = table.getSelectedRow();
                        int column = table.getSelectedColumn();
                        String value = (String)table.getValueAt(row, column);
                        value += value;
                        table.setValueAt( value, row, column );
                        DefaultTableModel model = (DefaultTableModel)table.getModel();
                        model.fireTableCellUpdated(row, column);
                        table.requestFocus();
         public static void main(String[] args)
              TestTable frame = new TestTable();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
         private class TextAreaRenderer extends JTextArea implements TableCellRenderer
              public TextAreaRenderer(int displayRows)
                   setRows(displayRows);
                   setLineWrap( true );
              public Component getTableCellRendererComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             boolean hasFocus,
                                             int row,
                                             int column)
                   setText( value.toString() );
                   Dimension d = getPreferredSize();
                   int maximumHeight = getRows() * getRowHeight();
                   if (d.height > maximumHeight)
                        setSize(d);
                        int offset = viewToModel( new Point(d.width, maximumHeight - 1) );
                        replaceRange( "...", offset-3, getDocument().getLength() );
                   return this;
    }

  • How to find the total number of pair under particular parent according to pattern 1:2or2:1,1:1 day to day maximum up to 5 pair caping daily

    Dear friends,
    I provide full details here ,my database table structure ,data and stored procedure and my problem ,
    please review it and provide the solution or any idea to solve my problem.
    I am working on a project in which members are added in a tree pattern, and get the payment accordingly.
    below is my table structure ,data and stored procedure
    CREATE TABLE Associate_Income
    ID varchar(30) NOT NULL,
    ParentID varchar(30) NULL,
    IsLeft tinyint NULL,
    IsRight tinyint NULL,
    joingdate datetime NOT NULL
    go
    INSERT Associate_Income
    (ID, ParentID, IsLeft, IsRight, joingdate)
    SELECT 'Ramesh123', NULL, NULL, NULL '2014-01-03 16:31:15.000' UNION ALL
    SELECT 'Sonu', 'Ramesh123', 1, NULL, '2014-01-03 16:45:21.000' UNION ALL
    SELECT 'Pawan kumar', 'Ramesh123', NULL, 1, '2014-01-04 16:50:23.000' UNION ALL
    SELECT 'Ravi123', 'Sonu', 1, NULL, '2014-01-04 17:03:22.000' UNION ALL
    SELECT 'Vineet123', 'Sonu', NULL, 1, '2014-01-04 17:26:01.000' UNION ALL
    SELECT 'dev123', 'Ravi123', 1, NULL, '2014-01-05 19:35:16.000' UNION ALL
    SELECT 'Mukesh123', 'Ravi123', NULL, 1, '2014-01-05 19:40:41.000' UNION ALL
    SELECT 'poonam123', 'Vineet123', 1, NULL, '2014-01-05 19:49:49.000' UNION ALL
    SELECT 'monu', 'Pawan kumar', 1, NULL, '2014-01-05 17:32:58.000' UNION ALL
    SELECT 'Arti123', 'Pawan kumar', NULL, 1, '2014-01-05 19:54:35.000' UNION ALL
    My  database table Associate_Income  structure and data is as follow:
    ID ParentID IsLeft IsRight joingdate
    Ramesh123 NULL NULL NULL 2014-01-03 16:31:15.000
    Sonu Ramesh123 1 NULL 2014-01-03 16:45:21.000
    Pawan kumar Ramesh123 NULL 1 2014-01-04 16:50:23.000
    Ravi123 Sonu 1 NULL 2014-01-04 17:03:22.000
    Vineet123 Sonu NULL 1 2014-01-04 17:26:01.000
    dev123 Ravi123 1 NULL 2014-01-05 19:35:16.000
    Mukesh123 Ravi123 NULL 1 2014-01-05 19:40:41.000
    poonam123 Vineet123 1 NULL 2014-01-05 19:49:49.000
    monu Pawan kumar 1 NULL 2014-01-05 17:32:58.000
    Arti123 Pawan kumar NULL 1 2014-01-05 19:54:35.000
    by using below stored procedure i can count the total number of pairs under particular node in 2:1,1:1 ratio means first pair is completed when two node added to the left side of given parent node and one node added
    right side of given parent node after that all pairs are completed when one node added left side and one node added right side of parent node (1:1 ratio)
    example if i execute my stored procedure as follows it would return following.
    EXEC count_pairs 'Ramesh123'
    3
    so there is 3 pairs as shown in my figure.
    when we execute my stored procedure for ParentID 'sonu' it would return following.
    EXEC count_pairs 'sonu'
    2
    so there is 2 pairs as shown in my figure.
    My problem is to find the query which can return the total number of pair under particular node any given parent  node. day to
    day maximum 5 pairs in a day please any one can suggest us
    CREATE proc [dbo].[count_pairs]
    @ParentID nvarchar(50)
    as
    begin
    Declare @ParentSUM SMALLINT = 0
    Declare @SubLeftID nvarchar(50)
    Declare @SubRightID nvarchar(50)
    SELECT @SubLeftID = CASE WHEN [IsLeft] = 1 THEN [ID] ELSE @SubLeftID END
    ,@SubRightID = CASE WHEN [IsRight] = 1 THEN [ID] ELSE @SubRightID END
    FROM Associate_Income
    WHERE ParentID = @ParentID
    IF @SubLeftID IS NOT NULL AND @SubRightID IS NOT NULL AND EXISTS(SELECT 1 FROM Associate_Income WHERE [IsLeft] = 1 AND ParentID = @SubLeftID)
    BEGIN
    SET @ParentSUM = 1
    ;WITH Associate_Income_CTE AS
    SELECT [ID], [ParentID], [IsLeft], [IsRight], 0 AS [Level]
    FROM Associate_Income
    WHERE [ParentID] = @ParentID
    UNION ALL
    SELECT RecursiveMember.[ID], RecursiveMember.[ParentID], RecursiveMember.[IsLeft], RecursiveMember.[IsRight], Level + 1
    FROM Associate_Income RecursiveMember
    INNER JOIN Associate_Income_CTE AnchorMember
    ON RecursiveMember.[ParentID] = AnchorMember.[ID]
    SELECT @ParentSUM = @ParentSUM + COUNT([ParentID])
    FROM
    SELECT [ParentID]
    ,'IsLeft' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsLeft] = 1
    AND [ID] <> @ParentID --AND [ID] NOT IN (@SubLeftID, @ParentID)
    AND [ParentID] NOT IN (@ParentID, @SubLeftID)
    UNION ALL
    SELECT [ParentID]
    ,'IsRight' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsRight] = 1
    AND [ParentID] <> @ParentID
    ) AS Associate_Income
    PIVOT
    MAX([Value]) FOR [Direction] IN ([IsLeft], [IsRight])
    ) PVT
    WHERE [IsLeft] IS NOT NULL AND [IsRight] IS NOT NULL
    END
    SELECT @ParentSUM
    Jitendra Kumar Sr. Software Developer at Ruvixo Technologies 7895253402

    I don't think this is homework, I am not sure how helpful it was by Kalman to merge the two threads. It appears that two different persons posted the questions. It could be though, that it is the same problem and Jitendra has taken over Chandra's
    task.
    However, I was not able to understand the problem nor the figure. And nor the definition of pairs in this context. My assumption is that what Jitendra posted is an abstraction of the actual problem in order to not reveal intellecutal property. Possibly this
    makes the problem more difficult to understand for us outsiders.
    I've come so far that I worked out a table definition and INSERT statements with sample data, as well as a call to the procedure which returns 3 and this appears to map to the figure, but I don't know what it means. Since I don't know what this
    is about, I have not made any attepmts to understand the code, but I would appreciate clarification about the underlying business rules as well as the expected results for various test cases.
    CREATE TABLE Associate_Income(ID varchar(30) NOT NULL,
    ParentID varchar(30) NULL,
    IsLeft tinyint NULL,
    IsRight tinyint NULL,
    joingdate datetime NOT NULL)
    go
    INSERT Associate_Income (ID, ParentID, IsLeft, IsRight, joingdate)
    SELECT 'Ramesh123', NULL, NULL, NULL, '2014-01-03 16:31:15.000' UNION ALL
    SELECT 'Sonu', 'Ramesh123', 1, NULL, '2014-01-03 16:45:21.000' UNION ALL
    SELECT 'Pawan kumar', 'Ramesh123', NULL, 1, '2014-01-04 16:50:23.000' UNION ALL
    SELECT 'Ravi123', 'Sonu', 1, NULL, '2014-01-04 17:03:22.000' UNION ALL
    SELECT 'Vineet123', 'Sonu', NULL, 1, '2014-01-04 17:26:01.000' UNION ALL
    SELECT 'dev123', 'Ravi123', 1, NULL, '2014-01-05 19:35:16.000' UNION ALL
    SELECT 'Mukesh123', 'Ravi123', NULL, 1, '2014-01-05 19:40:41.000' UNION ALL
    SELECT 'poonam123', 'Vineet123', 1, NULL, '2014-01-05 19:49:49.000' UNION ALL
    SELECT 'monu', 'Pawan kumar', 1, NULL, '2014-01-05 17:32:58.000' UNION ALL
    SELECT 'Arti123', 'Pawan kumar', NULL, 1, '2014-01-05 19:54:35.000'
    go
    CREATE proc [dbo].[count_pairs]
    @ParentID nvarchar(50)
    as
    begin
    Declare @ParentSUM SMALLINT = 0
    Declare @SubLeftID nvarchar(50)
    Declare @SubRightID nvarchar(50)
    SELECT @SubLeftID = CASE WHEN [IsLeft] = 1 THEN [ID] ELSE @SubLeftID END
    ,@SubRightID = CASE WHEN [IsRight] = 1 THEN [ID] ELSE @SubRightID END
    FROM Associate_Income
    WHERE ParentID = @ParentID
    IF @SubLeftID IS NOT NULL AND @SubRightID IS NOT NULL AND EXISTS(SELECT 1 FROM Associate_Income WHERE [IsLeft] = 1 AND ParentID = @SubLeftID)
    BEGIN
    SET @ParentSUM = 1
    ;WITH Associate_Income_CTE AS
    SELECT [ID], [ParentID], [IsLeft], [IsRight], 0 AS [Level]
    FROM Associate_Income
    WHERE [ParentID] = @ParentID
    UNION ALL
    SELECT RecursiveMember.[ID], RecursiveMember.[ParentID], RecursiveMember.[IsLeft], RecursiveMember.[IsRight], Level + 1
    FROM Associate_Income RecursiveMember
    INNER JOIN Associate_Income_CTE AnchorMember
    ON RecursiveMember.[ParentID] = AnchorMember.[ID]
    SELECT @ParentSUM = @ParentSUM + COUNT([ParentID])
    FROM
    SELECT [ParentID]
    ,'IsLeft' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsLeft] = 1
    AND [ID] <> @ParentID --AND [ID] NOT IN (@SubLeftID, @ParentID)
    AND [ParentID] NOT IN (@ParentID, @SubLeftID)
    UNION ALL
    SELECT [ParentID]
    ,'IsRight' AS [Direction]
    ,1 AS [Value]
    FROM Associate_Income
    WHERE [IsRight] = 1
    AND [ParentID] <> @ParentID
    ) AS Associate_Income
    PIVOT
    MAX([Value]) FOR [Direction] IN ([IsLeft], [IsRight])
    ) PVT
    WHERE [IsLeft] IS NOT NULL AND [IsRight] IS NOT NULL
    END
    SELECT @ParentSUM
    END
    go
    EXEC count_pairs 'Ramesh123'
    go
    DROP PROCEDURE count_pairs
    DROP TABLE Associate_Income
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Having Percentage on the Totals line instead of SUM

    Hi,
    I have a report with several number columns and several percentage columns. I need to show a totals line with grand totals for the number columns, and overall percentage for the percentage columns - how can I achieve this? I guess there is a more general question about showing any non-SUM summary function on the totals line, such as AVG, COUNT, MIN, MAX etc.
    I could do it as a UNION I suppose but then I have the problem of formatting the totals line, and this wouldn't really work for break groups, only a grand total.
    Any ideas?
    Steve

    You might want to look into the CUBE, ROLLUP and GROUPING SETS (OLAP) extensions to the GROUP BY clause in SQL. They generate intermediate subtotals, break totals, grand totals, etc using plain SQL.
    Here is a quick example of what I mean
    http://htmldb.oracle.com/pls/otn/f?p=24317:190
    I have chosen to use SUM(SAL), AVG(COMM) and MAX(SAL) as the aggregates, you can modify this as per your requirements.
    The query is
    select
    empno,ename,job,deptno,
    sum(sal) sum_sal,
    avg(comm) avg_comm,
    max(sal) max_sal
    from emp
    group by rollup(empno,ename,job,deptno)
    having  grouping_id(empno,ename,job,deptno) in (0,15)The GROUPING_ID gives a binary "bitmap" of which columns are showing a detail row vs. a aggregate/super-aggregate row. In this case, we want to show the lowest level of detail (0) and the highest grand total (15=binary 1111 or all bits turned on)
    Again, you can tweak this to show intermediate subtotals, just take out that HAVING clause to see what you get and modify as needed.
    Hope this helps.
    Message was edited by:
    Vikas

  • How to count the no of record in grid.

    Hi Experts,
    I have one database block & this is bolck has contain 4 non database item is there. In database block has contain the id and description is non database block item. While i m querying the data description is shown depends up on ID. It is in grid. How to count the no of record in grid. My code is
    LV_CUR_ITM :=:SYSTEM.CURSOR_RECORD;
    FOR I IN 1.. LV_CUR_ITM LOOP
    LAST_RECORD;
    SELECT NSN_NO INTO :ORD_DIS_NSN_ITEM_DET.NSN_NO
    FROM NSN_MST WHERE NSN_ID= :ORD_DIS_NSN_ITEM_DET.NSN_ID;
    SELECT FOB_PRICE INTO :ORD_DIS_NSN_ITEM_DET.FOB_PRICE
    FROM PRODUCT_SUPPLIER WHERE PRD_ID_NUMBER= :ORD_DIS_NSN_ITEM_DET.PRD_ID_NUMBER
    AND BAS_ORG_ID_NUMBER=:ORD_DIS_NSN_ITEM_DET.ORG_ID_NUMBER;
    SELECT DESCRIPTION INTO :ORD_DIS_NSN_ITEM_DET.PRD_DESC
    FROM PRODUCT WHERE ID_NUMBER= :ORD_DIS_NSN_ITEM_DET.PRD_ID_NUMBER;
    SELECT FULL_NAME INTO :ORD_DIS_NSN_ITEM_DET.SUPP_NAME
    FROM ORGANISATION WHERE ID_NUMBER=:ORD_DIS_NSN_ITEM_DET.ORG_ID_NUMBER;
    NEXT_record;
    END LOOP;
    Thx in advance.

    Hai,
    Add a Non database item to that block, and set the Calculation Mode as Summary, and Summary Function to Count.
    Then u will get the total no of records from this text. ( You can hide this, so that the use won't see it. )
    OR
    go to the Last Record, then
    LV_CUR_ITM :=:SYSTEM.CURSOR_RECORD; This will also work.
    Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

Maybe you are looking for

  • Multiple device in one household help with iCloud

    My son and I both have Iphones. We have separate Apple ID's for icloud. Is there any way that we both connect to my existing Itunes account with separate Apple ID's?

  • Search and replace elements in a 2D Array

    Hello, i have a programming problem in Labview 7.1 under Win XP. I want replace elements in a 2D Array. The code works fine but I want replace elements in the 2D Array (for example all elements between 2 and 5 should replace to zero). Thank you in ad

  • File attachments with Jdeveloper - SOAP

    Hi ! I am using JDev 10.1.3. I need to send file attachments via SOAP call. I have a soap service sending text files. I have a wsdl from the client. I am able to read the wsdl and create a client proxy using Jdev. I can see the contents of the file u

  • DOC.getMimeType() is null

    Hello Gurus, Getting DOC.getMimeType() as null when using ORADOC after Import , Unable to find the document type. Importing is done through a URL using ordsys.orddoc.import(), the filename is an ID, we call the document using that ID, will not know t

  • Installation stop at check DDIC password.

    Hello everybody, I am trying to install the IDES SR3 on windows (x64) and oracle. but my installation is stop on the Check DDIC password phase. I can log on using the user name DDIC and password 19920607. So please suggest me How to solve the problem