Creating N Copies of a Row using "CONNECT BY CONNECT_BY_ROOT"

This isn't a question. I just wanted to share a technique I stumbled upon while
jamming with Vadim Tropashko on his blog recently.
Occasionally the ability to create n copies of a row is required.
For example, given a table with this data
create table t ( key integer, string varchar2(10), qty integer );
insert into t values ( 1, 'a', 2 );
insert into t values ( 2, 'b', 3 );
commit;
       KEY STRING            QTY
         1 a                   2
         2 b                   3
sometimes we need queries that produce 2 copies of row 1 and 3 copies of row 2,
like this.
       KEY STRING            QTY
         1 a                   2
         1 a                   2
         2 b                   3
         2 b                   3
         2 b                   3
A query like the following would be ideal, but unfortunately Oracle doesn't
like the existence of a CONNECT BY loop.
select key, string, qty, level from t
CONNECT BY STRING = PRIOR STRING AND LEVEL <= QTY
order by 1, 4 ;
select key, string, qty, level from t
ERROR at line 1:
ORA-01436: CONNECT BY loop in user data
Without the CONNECT BY loop we won't get the right number of rows however.
select key, string, qty, level, sys_connect_by_path( string, '/' ) path
from t
CONNECT BY LEVEL <= QTY
order by 1, 4 ;
       KEY STRING            QTY      LEVEL PATH
         1 a                   2          1 /a
         1 a                   2          2 /b/a
         1 a                   2          2 /a/a
         2 b                   3          1 /b
         2 b                   3          2 /b/b
         2 b                   3          2 /a/b
         2 b                   3          3 /b/a/b
         2 b                   3          3 /b/b/b
         2 b                   3          3 /a/a/b
         2 b                   3          3 /a/b/b
The final solution employs CONNECT_BY_ROOT to yield the desired result
without triggering an error.
select key, string, qty, level, sys_connect_by_path( string, '/' ) path
from t
CONNECT BY CONNECT_BY_ROOT KEY = KEY AND LEVEL <= QTY
order by 1, 4 ;
       KEY STRING            QTY      LEVEL PATH
         1 a                   2          1 /a
         1 a                   2          2 /a/a
         2 b                   3          1 /b
         2 b                   3          2 /b/b
         2 b                   3          3 /b/b/b
Here's an example of this "CONNECT BY CONNECT_BY_ROOT" technique in action.
It splits a comma separated value string into one row per value.
delete from t;
insert into t values( 1, 'a,bb,ccc'  , null );
insert into t values( 2, 'dddd,eeeee', null );
commit;
select
  string ,
  level as position ,
  regexp_substr( string, '[^,]+', 1, level ) as val
from
  t
connect by
  connect_by_root key = key and
  regexp_substr( string, '[^,]+', 1, level ) is not null
order by
  1, 2
STRING       POSITION VAL
a,bb,ccc            1 a
a,bb,ccc            2 bb
a,bb,ccc            3 ccc
dddd,eeeee          1 dddd
dddd,eeeee          2 eeeee--
Joe Fuda
SQL Snippets

Nice approach.
BTW it is just another way of workaround for CONNECT BY LOOP error.
You can also do this like:
SQL> select key, string, qty, level
  2    from t
  3  CONNECT BY STRING = PRIOR STRING
  4         AND LEVEL <= QTY
  5         and prior dbms_random.value is not null
  6   order by 1, 4;
                                    KEY STRING                                         QTY      LEVEL
                                      1 a                                                2          1
                                      1 a                                                2          2
                                      2 b                                                3          1
                                      2 b                                                3          2
                                      2 b                                                3          3
S

Similar Messages

  • Materialized view refresh using connected user db links

    I have a general question. I have a materialized view that more or less joins tables from 2 databases.
    For example I have a table X in database A, and a table Y in database B. I create the materialized view in the schema owning table X in database A. Tables A & B from both database are in the same schema with a synchronized password. My materialized view is created to join tables A & B using connected user DB links, and everything works when I create the view, however, it appears that the refresh is failing. I suspect this is because of the connected user link and there is no "logged" in user when the refresh occurs.
    Does anyone know if it is possible to create a materialized view between 2 tables in different databases to refresh using a connected user DB link?
    Thanks.

    sybrandb
    Why does it not make sense to have materialized views accross databases?
    If a materialized view is essentially a remote copy, then wouldn't that imply accross databases? The only thing I did was to take it a step further and join it with a local table in the owning database.
    About not being right about not having a connected user., that may be right, but I have a thought/question..... I equated this as using connected user links in jobs scheduled via dbms_job or dbms_scheduler, as when this runs there is no user connected to the database to provide remote credentials for the link... Essentially this seems to be like a cron job that fires on some schedule (whether a user is connected or not), it would seem to me that it might need to have credentials defined in order to be able to connect to the remote database.
    Thanks

  • Creating rows Using BC4J Data Tags

    Hi!
    I want to create rows using BC4J data tags.
    I have 2 jsp pages: one containig forms and one to insert data.
    Is it possible to insert new rows into 2 or more tables?
    How can I differ the attributes to one table and to another?
    How can I do this?
    Thanks!

    The path is:
    Select "File/New" in the menu.
    Select "BC4J JSP" in the gallery.
    Select "Browse & Edit Form" wizard.
    This is in JDeveloper 9.0.2.
    Charles.

  • My iPhone 4 using iOS 6 is creating multiple copies of random voicemail messages

    My iPhone 4 using iOS 6 is creating multiple copies of random voicemail messages. How can I correct this I am deleting up to 10 - 15 duplicate voicemail messages daily.

    Had the same problem... talked to a Genius and he contacted Verizon Wireless (my carrier). Turns out the problem is Verizon's.  Contact Support and tell them you'd like your VoiceMail RESET (you will lose all your current voicemails).  Should correct the problem.

  • How to find the id of the node given the path using connect by?

    I have a table like this:
    CREATE TABLE tab1 (Id INTEGER, Name VARCHAR2(100), ParentId INTEGER)
    Let's say I have the following rows:
    Id name ParentId
    1 X NULL
    2 Y 1
    3 Z 2
    4 A 3
    Now, given the path /X/Y/Z/A, I need to return 4
    Is it possible to achieve this using CONNECT BY?
    If it helps, I have over simplified the scenario - that a node has only one child. In reality, a node can have many children.
    Thanks.

    Hi,
    user2888313 wrote:
    Thanks for the suggestions - will follow from now on. Here's one way to post the sample data, given the CREATE TABLE statement you posted earlier:
    -- Basic data:
    INSERT INTO tab1 (id, name, parentid) VALUES (1,  'X', NULL);
    INSERT INTO tab1 (id, name, parentid) VALUES (2,  'Y', 1);
    INSERT INTO tab1 (id, name, parentid) VALUES (3,  'Z', 2);
    INSERT INTO tab1 (id, name, parentid) VALUES (4,  'A', 3);
    -- To test branching (i.e., multiple children for the same parent):
    INSERT INTO tab1 (id, name, parentid) VALUES (11, 'P', 1);
    INSERT INTO tab1 (id, name, parentid) VALUES (12, 'Q', 1);
    INSERT INTO tab1 (id, name, parentid) VALUES (13, 'R', 12);Alternatively, you could post a WITH clause, as someone did above.
    I am not clear how to use the LEVEL pseudo column. Should I just start from the root, find all paths up to the level I am looking for? Could you please give me the syntax? Sorry, I'm still not clear what you want, or why you want it.
    Do you want 4 because 'A' is the 4th generation in this family tree (that is, because 'A' has 3 ancestors), or do you want 4 because id=4 is on the same row as name='A'? In the former case, use LEVEL; in the latter, use the id column.
    This query shows both:
    SELECT  SYS_CONNECT_BY_PATH (name, '/')          AS name_path
    ,     LEVEL                                AS lvl
    ,     id
    FROM     tab1
    START WITH     parentid     IS NULL
    CONNECT BY     parentid     = PRIOR id
    ;Output from the expanded sample data:
    NAME_PATH                   LVL         ID
    /X                            1          1
    /X/Y                          2          2
    /X/Y/Z                        3          3
    /X/Y/Z/A                      4          4
    /X/P                          2         11
    /X/Q                          2         12
    /X/Q/R                        3         13

  • ORA-22990 ( Cannot span lob... ) while using connection pooling...

    Hi all, I am maintaining a web site that has lots of requests ( about 10 requests a second ) to an Oracle table that has a BLOB field. Those requests create new blobs, updates them and reads them... My program worked fine until I started using connection pooling ( Before that, I used a single connection that was initialized at startup ). Although I had to synchronized the methods that interact with blob field, everything worked great. So now, to optimize my site, I want to use connection pooling so that even if my methods are synchonized on the connection object, there will be more than one connection available so it will not affect performance.
    So once I introduced my connection pooling system with the oracle.jdbc.pool.OracleConnectionCacheImpl class, I started getting ORA-22990 ( Cannot span lob objects... ). I get the error on the flush() method when I try to write the blob to the database. Here is my function that writes a row in the databse.
      private synchronized void writeSession(CapSession pSession) throws Exception
            javax.sql.PooledConnection pc = pool.getPooledConnection();
            Connection conn = pc.getConnection();
            CallableStatement stmt=conn.prepareCall(writeObjSQL);
            stmt.setString(1,pSession.getSessionId()+pSession.getPassword());
            stmt.setLong(2,pSession.getLastAccess());
            stmt.setLong(3,pSession.getTimeout());
            stmt.registerOutParameter(4,java.sql.Types.BLOB);
            stmt.executeUpdate();
            oracle.sql.BLOB blob=(BLOB)stmt.getBlob(4);
            OutputStream os=blob.getBinaryOutputStream();
            ObjectOutputStream oop=new ObjectOutputStream(os);
            oop.writeObject(pSession);
            oop.flush();
            oop.close();
            os.close();
            stmt.close();
            conn.commit();
            conn.close();
            pc.close();
      } If anyone could help me, I would deeply appreciate it!
    Thank you for your time.

    kalle
    Thank you very much for your advice!!!
    Like you said, I started to check whether the connections are fine before giving them from the pool.I am executing a simple "select 'anil' from dual" and if its fine only then I return the connection. So far it seems to be fine. Also I am reopening the connections(closing the old ones and opening new connections) after every 12 hours.
    As far as the JDBC driver is concerned, I already tried with Oracle 8i driver, it gave the same problems. I read that 9i driver might solve this problem, so I changed to the latest 9i driver (classes12_g.zip).
    Sometimes before(before I started checking whether the connection is good )the application used to hang up at the point where I am issuing setAutoCommit(false).It never comes out from that statement.Is this something to do with theconnections being closed?
    What I am afraid is, will the appilation get hung up even after I check the connection with select query and then issue autocommit(false)??
    Or will it hang up while I check with a select query??
    As long as it doesn't hung up, I am fine. Because i am cathching the exceptions.
    Thanks In ADVANCE
    Anil

  • SQL code returns triple copies of each row

    I want to select from my schema and another schema, and sum(total period_activity_a). the code returns triplicate copies of each row, how can I avoid the triplicate rows. I need just one row for each row.
    select a.segment3, b.descr, b.leader, sum(a.period_activity_a) from payman.snp_op_detail a,
    hrman.organisation_t b
    where a.segment3 = b.org_member_id and
    a.segment3 between 4000 and 5999 and
    a.segment2 != 6651 and
    a.segment2 between 5400 and 8999 and
    a.period_name in ('JAN-11', 'FEB-11', 'MAR-11', 'APR-11', 'MAY-11', 'JUN-11',
    'JUL-11', 'AUG-11', 'SEP-11','OCT-11','NOV-11', 'DEC-11')
    group by ROLLUP(a.segment3,b.descr, b.leader);
    result
    SEGMENT3     DESCR     LEADER     SUM(A.PERIOD_ACTIVITY_A)
    4001     CLOSED: RF-CASSAVA MOSAIC DIS.      S.SHOLOLA     0
    4001     CLOSED: RF-CASSAVA MOSAIC DIS.           0
    4001               0
    4005     Closed: BELG. STRAT MUSA-ESARC      S.SHOLOLA     0
    4005     Closed: BELG. STRAT MUSA-ESARC           0
    4005               0
    4006     Closed: BELG. STRATEG MUSA KUL      S.SHOLOLA     0
    4006     Closed: BELG. STRATEG MUSA KUL           0
    4006               0
    4007     Closed: BELG STRATEG MUSA ONNE     S.SHOLOLA     0
    4007     Closed: BELG STRATEG MUSA ONNE          0
    4007               0
    4009     Closed: EEC-OFAR II REIMB EXPs      S.SHOLOLA     0
    4009     Closed: EEC-OFAR II REIMB EXPs           0
    4009               0
    Edited by: OlaTunde on 19-Jan-2012 04:41

    Hi,
    OlaTunde wrote:
    I want to select columns and total only not subtotal. the only thing I can think about is rollup. but rollup brings rollup for each column. how can I get total without repeating the rows?Sorry, it's unclear what you want. Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. Explain how you get those results from that data.
    If you can show your problem using commonly available tables (such as scott.emp) then you don't need to post any sample data; just the results and the explanation.
    Always say which version of Oracle you're using.
    As Johan said, GROUP BY (without ROLLUP) produces only one row for each combination of the values in the GROUP BY clause.
    Analytic functions can produce the same total as aggregate functions, without changing the number of rows at all.
    GROUP BY GROUPING SETS is very flexible about getting subtotals and totals in the same query.
    It all depends on your data, what you want from that data, and your version. If you're willing to share what you know about those things, other people will share what they know about SQL.

  • Creating a list with different row sizes...

    I'm new to AS 3.0 and CS4 and I've been getting up to speed
    on all of it. I've used the List component before with my own
    CellRenderer. I now need to create a list with different row
    heights. The List component is great and does everything that I
    want but it requires all rows to be the same height.
    I'm unsure of where to go. Creating my own class seems like a
    lot of work. The TileList and Grid components don't allow different
    sized (and dynamically changing) row heights either. Is there some
    base class (SelectableList? BaseScrollPane?) that I should extend
    or do I need to just bite the bullet and write it all from scratch?
    I need each row to have it's own height and interaction with
    a row could change the height of the row. The main use is a list of
    data. If the user clicks in an item, it turns the display into
    something they can edit (which will need more height).
    Thanks for any thoughts on a direction I should think about.
    By the way, I really like that AS 3.0 is much more consistent of a
    programming language than previous MX versions that I've used.
    We're doing a lot of AS/Flash/AIR work with it and it's turning
    into a wonderful environment...

    Any ideas about this??

  • Powershell use Connection String to query Database and write to Excel

    Right now I have a powershell script that uses ODBC to query SQL Server 2008 / 2012 database and write to EXCEL
    $excel = New-Object -Com Excel.Application
    $excel.Visible = $True
    $wb = $Excel.Workbooks.Add()
    $ws = $wb.Worksheets.Item(1)
    $ws.name = "GUP Download Activity"
    $qt = $ws.QueryTables.Add("ODBC;DSN=$DSN;UID=$username;PWD=$password", $ws.Range("A1"), $SQL_Statement)
    if ($qt.Refresh()){
    $ws.Activate()
    $ws.Select()
    $excel.Rows.Item(1).HorizontalAlignment = $xlCenter
    $excel.Rows.Item(1).VerticalAlignment = $xlTop
    $excel.Rows.Item("1:1").Font.Name = "Calibri"
    $excel.Rows.Item("1:1").Font.Size = 11
    $excel.Rows.Item("1:1").Font.Bold = $true
    $filename = "D:\Script\Reports\Status_$a.xlsx"
    if (test-path $filename ) { rm $filename }
    $wb.SaveAs($filename, $xlOpenXMLWorkbook) #save as an XML Workbook (xslx)
    $wb.Saved = $True #flag it as being saved
    $wb.Close() #close the document
    $Excel.Quit() #and the instance of Excel
    $wb = $Null #set all variables that point to Excel objects to null
    $ws = $Null #makes sure Excel deflates
    $Excel=$Null #let the air out
    I would like to use connection string to query the database and write results to EXCEL, i.e.
    $SQL_Statement = "SELECT ..."
    $conn = New-Object System.Data.SqlClient.SqlConnection
    $conn.ConnectionString = "Server=10.10.10.10;Initial Catalog=mydatabase;User Id=$username;Password=$password;"
    $conn.Open()
    $cmd = New-Object System.Data.SqlClient.SqlCommand($SQL_Statement,$conn)
    do{
    try{
    $rdr = $cmd.ExecuteReader()
    while ($rdr.read()){
    $sql_output += ,@($rdr.GetValue(0), $rdr.GetValue(1))
    $transactionComplete = $true
    catch{
    $transactionComplete = $false
    }until ($transactionComplete)
    $conn.Close()
    How would I read the columns and data for $sql_output into an EXCEL worksheet. Where do I find these tutorials?

    Hi Q.P.Waverly,
    If you mean to export the data in $sql_output to excel document, please try to format the output with psobject:
    $sql_output=@()
    do{
    try{
    $rdr = $cmd.ExecuteReader()
    while ($rdr.read()){
    $sql_output+=New-Object PSObject -Property @{data1 = $rdr.GetValue(0);data2 =$rdr.GetValue(1)}
    $transactionComplete = $true
    catch{
    $transactionComplete = $false
    }until ($transactionComplete)
    $conn.Close()
    Then please try to use the cmdlet "Export-Csv" to export the data to excel like:
    $sql_output | Export-Csv d:\data.csv
    Or you can export to worksheet like:
    $excel = New-Object -ComObject Excel.Application
    $excel.Visible = $true
    $workbook = $excel.Workbooks.Add()
    $sheet = $workbook.ActiveSheet
    $counter = 0
    $sql_output | ForEach-Object {
    $counter++
    $sheet.cells.Item($counter,1) = $_.data1$sheet.cells.Item($counter,2) = $_.data2}
    Refer to:
    PowerShell and Excel: Fast, Safe, and Reliable
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

  • How do i use Connection pool in JSP pages

    Hey everyone,
    I am using a connection pool in my web application. I am using DbConnectionBroker from Javaexchange.com. It has a class that creates a connection pool available for the servlets. I am trying to figure out that how to use connection pool within the JSP pages if I want to connect to the database. In the servlets i am using DBConnectionBroker pool = (DbConnectionBroker) getServletContext().getAttribute("dbPool") to get database connection. How Can i use this in JSP page to get a db connection.
    Thanks

    If the reference to the connection pool is already stored as an ServletContex attribute, try:
    <jsp:useBean id="dbPool" scope="application" class="com.javaexchange.dbConnectionBroker" />
    <%
    Connection con = dbPool.getConnection();
    %>

  • How can i create a grid with summary row

    Hello Professionals,
    I'm wondering how could i create a grid like the grid below, i want to create a grid with summary row,
    i have tried to create it using collapsing but it didn't work as required.
    Any suggestions?, i want to know just the starting point so i can make deep investigations.
    Thanks in Advance,

    Hi Karem,
    this can be achieved by just assigning a datatable containing the data plus some formatting of grid. Meaning there is no feature for that.
    The datatable can be filled manually or by sql query. Then you have to attach some events for updating the values ( validate after for gid item ).
    A small example for a sql query showing last month quotations and orders with summary :
    select 1 as Sort,cast(DocNum as varchar) as DocNum,DocTotal,convert(varchar, DocDate,104) from OQUT where DocDate between  DATEADD(month, -1, GETDATE()) AND GETDATE()
    UNION ALL
    Select 2 as Sort,'Summary ( Quotation ) : ',sum(DocTotal), convert(varchar,  DATEADD(month, -1, GETDATE()),104)+' - '+convert(varchar,   GETDATE(),104) from OQUT where DocDate between  DATEADD(month, -1, GETDATE()) AND GETDATE()
    UNION ALL
    select 3 as Sort,cast(DocNum as varchar) as DocNum,DocTotal,convert(varchar, DocDate,104) from ORDR where DocDate between  DATEADD(month, -1, GETDATE()) AND GETDATE()
    UNION ALL
    Select 4 as Sort,'Summary ( Order ) : ',sum(DocTotal), convert(varchar,  DATEADD(month, -1, GETDATE()),104)+' - '+convert(varchar,   GETDATE(),104) from ORDR where DocDate between  DATEADD(month, -1, GETDATE()) AND GETDATE()
    ORDER by Sort
    regards,
    Maik

  • How to create a table in the file using java code.?

    HI,
    I should export the data from the view objects to a word document. I have done that but I should
    display the data in the form of a table.
    Kindly come up with the necessary information on how to create a table in the file using java.
    Thanks,
    Phani

    Hi, Thank you for responding to my query.
    The below are the details of my code.
    DCBindingContainer dcBindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding StudentDetailsContent =
    (DCIteratorBinding)dcBindings.get("StudentView1Iterator");
    OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
    Row currentRow =
    StudentDetailsContent.getRowSetIterator().first();
    Object a[]= currentRow.getAttributeValues();
    int i;
    for(i=0 ;i<=a.length;i++){
    w.write(a.toString());
    w.write(" ");
    w.flush();
    I am usning this coding to achieve the task of exporting data to file.
    I need to display this information in the table that is where I need help from you people.
    Thanks,

  • Get selected rows using the fm REUSE_ALV_GRID_DISPLAY_LVC

    FYI ... for all those developers trying to select multiple rows in an ALV report, and get the selected rows - without using the OO approach to display to ALV, and without using checkboxes in the function module approach.  First off, you need to use the function module REUSE_ALV_GRID_DISPLAY_LVC instead of the standard REUSE_ALV_GRID_DISPLAY.  This allows you to select multiple rows using the toggle, line selection buttons, at the start of each row (with 'select all' button).  See the sample code below.  If you are converting from the one fm to the other, you will have to change the type of 2 of the structures to the 'LVC' structures and make minor code changes.  The example code below was initially using the REUSE_ALV_GRID_DISPLAY fm, and was converted to use REUSE_ALV_GRID_DISPLAY_LVC  to allow for multiple row selection.  The next step is to create a custom status, with a new custom button, that will start the processing of the selected rows.  Go to tcode SE41, press Copy Status, and copy program SAPLKKBL, status STANDARD, to your custom program (same name as the custom ALV rpt) and a new status name (ie STANDARD1).  In the new STANDARD1 status for the custom ALV program/rpt (tcode SE41), add a new button ('&EXE') at the end of the std buttons (items 29-35).  Assign the new button a Text, Icon and a Function Key. Thats it!
    Here's the code:
    FORM display_data.
    DATA:
      wa_callback_program LIKE sy-repid,
      wa_layout      TYPE lvc_s_layo,  "was  slis_layout_alv,       "D01K913690
      t_fieldcat        TYPE lvc_t_fcat,   "was  slis_t_fieldcat_alv,  "D01K913690
      wa_fieldcat    TYPE lvc_s_fcat,  "was  slis_fieldcat_alv,     "D01K913690
      t_excluding     TYPE slis_t_extab,
      wa_excluding TYPE slis_extab,
      wa_variant     LIKE disvariant.
    * Setup Field Catalog
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname  = 'ZBUKR'.
      wa_fieldcat-ref_field    = 'ZBUKR'.
      wa_fieldcat-ref_table   = 'REGUT'.
      APPEND wa_fieldcat TO t_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname = 'BANKS'.
      wa_fieldcat-ref_field   = 'BANKS'.
      wa_fieldcat-ref_table  = 'REGUT'.
      APPEND wa_fieldcat TO t_fieldcat.
    * Setup other ALV fm parameters
      CLEAR wa_excluding.
      wa_excluding-fcode = '&F12'.
      APPEND wa_excluding TO t_excluding.
      CLEAR wa_excluding.
      wa_excluding-fcode = '&F15'.
      APPEND wa_excluding TO t_excluding.
    * Callback program
      wa_callback_program = sy-repid.
    * List layout
      wa_layout-zebra = 'X'.
      wa_layout-sel_mode = 'A'.
    * variant
      wa_variant-variant  = p_var.
    * Display the ALV report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'                "D01K913690
           EXPORTING
                i_callback_program             = wa_callback_program
                i_callback_pf_status_set    = 'SET_PF_STATUS'              "D01K913690
                i_callback_user_command  = 'USER_COMMAND'
                is_layout_lvc                       = wa_layout                          "D01K913690
                it_fieldcat_lvc                      = t_fieldcat                            "D01K913690
                it_excluding                         = t_excluding
                i_save                                 = 'A'
                is_variant                            = wa_variant
           TABLES
                t_outtab                              = t_regut
    *      EXCEPTIONS
    *           PROGRAM_ERROR            = 1
    *           OTHERS                             = 2
    ENDFORM.                               " DISPLAY_DATA
    FORM user_command
      USING
        r_ucomm     LIKE sy-ucomm
        rs_selfield TYPE slis_selfield.
      DATA: wa_text(80) TYPE c.
      CASE r_ucomm.
        WHEN '&EXE'.   "User pressed custom Execute button
          DATA ref1 TYPE REF TO cl_gui_alv_grid.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              e_grid = ref1.
          DATA: lt_index_rows TYPE lvc_t_row,
                     lt_row_no TYPE lvc_t_roid,
                     lw_row_no TYPE lvc_s_roid.
          CALL METHOD ref1->get_selected_rows
            IMPORTING
              et_index_rows = lt_index_rows
              et_row_no     = lt_row_no.
          LOOP AT lt_row_no
             INTO lw_row_no.
             *** CODE TO PROCESS EACH RECORD FROM MULTIPLE SELECTED***
          ENDLOOP.  "loop at lt_row_no
        WHEN '&IC1'.  "User double-clicked on row
          *** CODE TO PROCESS SINGLE RECORD SELECTED ***
        WHEN '&F03' .          " back
          SET SCREEN 0. LEAVE SCREEN.
        WHEN '&F15' .          " exit
          SET SCREEN 0. LEAVE SCREEN.
        WHEN '&F12' .          " cancel
          SET SCREEN 0. LEAVE SCREEN.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'STANDARD1'.
    ENDFORM. " set_pf_status
    Hope this helps ...
    Regards,
    Kevin
    Moderator message - Welcome to SCN.
    However, as you can see, the forum software was unable to format this because of the 2,500 character posting limit. since this looks interesting, would you please try to edit to conform to that limitation? You may try to split it into an initial post and a response.
    Edited by: Rob Burbank on Jul 8, 2009 1:39 PM

    Hi ,
         Make it use in your code and let me know if u have any concerns...
        Use "Subtotal_text" in events table.
    here GTOTAL is field in itab on which we sortindf data, and use your own field on which field u want to sort...
    refresh gt_event.
    clear gw_event.
    call function 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type = 0
       IMPORTING
         et_events   = gt_event.
    Subtotal
    read table gt_event with key name = slis_ev_subtotal_text into gw_event.
    if sy-subrc = 0.
       move 'SUBTOTAL_TEXT' to gw_event-form.
       append gw_event to gt_event.
    endif.
         form subtotal_text using uw_subtot_line type ty_main
                    uv_subtottxt type slis_subtot_text.  "#EC CALLED
    if uv_subtottxt-criteria = 'GTOTAL'.
       uv_subtottxt-display_text_for_subtotal = 'TOTAL'.
    endif.
         *FORM build_sort .
    refresh gt_sort.
    gw_sort-spos      = 1.
    gw_sort-fieldname = 'GTOTAL'.
    gw_sort-tabname   = 'GT_MAIN'.
    gw_sort-up        = 'X'.
    gw_sort-subtot    = 'X'.
    APPEND gw_sort TO gt_sort.
    CLEAR gw_sort.
    Reward points once its useful..

  • Failed while creating virtual Ethernet switch. Failed to connect Ethernet switch port

    Hello Folks
    I am completely stuck with the configuration of my virtual networks. I have one logical switch left to add to one of my Hyper-V 2012 R2 hosts when I started getting the error below when I try to add logical switches to either Hyper-V Host. I have been using
    the document. 'Hybrid Cloud with NVGRE (Cloud OS)' to implement the virtual networking. Basically using the exact configuration that is in the document. I have added the PA Logical Network and the Network adapters and added the logical switch for it to my
    hyper-v 2012 R2 host and everything was fine. I am now trying to add my ISCSI Logical Switch to the host and this is the error I get. My other Hyper-V host I get this error for any logical switch I am trying to add. Can someone help me with this error. I haven't
    been able to find any information about it.
    Also a some quick info on tracing an error like this so I can figure out what is causing it.
    Thsi is my configuration so far
    So as far as I know everything is peachy untill the error below. Dead stop now
    Error (12700)
    VMM cannot complete the host operation on the 08-NY-VHOST01.accounts.ccac-ont.ca server because of the error: Failed while creating virtual Ethernet switch.
    Failed to connect Ethernet switch port (switch name = '******', port name = '88C16766-ED02-4AC0-8CD7-660AC9D424DD', adapter GUID = '{FAF431D8-0124-4E40-BB3B-9234BAA02973}'): The system cannot find the file specified. (0x80070002).
    Unknown error (0x800b)
    Thank you for your time
    Christopher
    Christopher Scannell

    notice your GUID?  you may want to consider ensuring that is the same GUID associated in your database.  Sometimes during data corruption theres a smidge of a chance your sql database kind of either pulls old guids esp if this was reverted to snapshot
    without it being powered off etc.  
    I would try that first.  then i would consider if you get to configure that with your current liscense associated with the host.  I would need way more info to help any further

  • Received HTTP response code 500 : Internal Server Error using connection Fi

    Hi everybody,
    I have configured a file-webservice-file without BPM scenario...as explained by Bhavesh in the following thread:
    File - RFC - File without a BPM - Possible from SP 19.
    I have used a soap adapter (for webservice) instead of rfc .My input file sends the date as request message and gets the sales order details from the webservice and then creates a file at my sender side.
    I monitored the channels in the Runtime work bench and the error is in the sender ftp channel.The other 2 channel status is "not used" in RWB.
    1 sender ftp channel
    1 receiver soap channel
    1 receiver ftp channel.
    2009-12-16 15:02:00 Information Send binary file "b.xml" from ftp server "10.58.201.122:/", size 194 bytes with QoS EO
    2009-12-16 15:02:00 Information MP: entering1
    2009-12-16 15:02:00 Information MP: processing local module localejbs/AF_Modules/RequestResponseBean
    2009-12-16 15:02:00 Information RRB: entering RequestResponseBean
    2009-12-16 15:02:00 Information RRB: suspending the transaction
    2009-12-16 15:02:00 Information RRB: passing through ...
    2009-12-16 15:02:00 Information RRB: leaving RequestResponseBean
    2009-12-16 15:02:00 Information MP: processing local module localejbs/CallSapAdapter
    2009-12-16 15:02:00 Information The application tries to send an XI message synchronously using connection File_http://sap.com/xi/XI/System.
    2009-12-16 15:02:00 Information Trying to put the message into the call queue.
    2009-12-16 15:02:00 Information Message successfully put into the queue.
    2009-12-16 15:02:00 Information The message was successfully retrieved from the call queue.
    2009-12-16 15:02:00 Information The message status was set to DLNG.
    2009-12-16 15:02:02 Error The message was successfully transmitted to endpoint com.sap.engine.interfaces.messaging.api.exception.MessagingException: Received HTTP response code 500 : Internal Server Error using connection File_http://sap.com/xi/XI/System.
    2009-12-16 15:02:02 Error The message status was set to FAIL.
    Please help.
    thanks a lot
    Ramya

    Hi Suraj,
    You are right.The webservice is not invoked.I see the same error in the sender channel and the receiver soap channel status is "never used".
    2009-12-16 15:52:25 Information Send binary file  "b.xml" from ftp server "10.58.201.122:/", size 194 bytes with QoS BE
    2009-12-16 15:52:25 Information MP: entering1
    2009-12-16 15:52:25 Information MP: processing local module localejbs/CallSapAdapter
    2009-12-16 15:52:25 Information The application tries to send an XI message synchronously using connection File_http://sap.com/xi/XI/System.
    2009-12-16 15:52:25 Information Trying to put the message into the call queue.
    2009-12-16 15:52:25 Information Message successfully put into the queue.
    2009-12-16 15:52:25 Information The message was successfully retrieved from the call queue.
    2009-12-16 15:52:25 Information The message status was set to DLNG.
    2009-12-16 15:52:27 Error The message was successfully transmitted to endpoint com.sap.engine.interfaces.messaging.api.exception.MessagingException: Received HTTP response code 500 : Internal Server Error using connection File_http://sap.com/xi/XI/System.
    2009-12-16 15:52:27 Error The message status was set to FAIL.
    what can I do about this?
    thanks,
    Ramya

Maybe you are looking for

  • Lsmw sales order

    hi folks, Can any one send me with screenshots how to upload sales order records using LSMW bapi method ,will be rewarded with points.

  • Hi, everyone, question about abap query? thank you in advance!

    Hi everyone, there is an information message that "Do all fields used have a name? (use help)" after I click the button "Generate" in tcode(infoset) sq02 with my infoset. can anyone tell me what is wrong? Before I click "generate" my infoset I added

  • Get count of officers for each company

    Hi, all. I need to get the count of officers from each company from the following data, CompanyID OfficerID 1234 4456 1234 2087 1234 1298 7765 2376 9987 5423 9987 2965 What I need is the following for the above data, CompanyID OfficerCount 1234 4 776

  • The service name is invalid (NET HELPMSG 2185)

    I tried to install the SAP Netweaver 2004s ABAP Trial Version on my PC (Vista). I went through the steps: 1) Install SAP Management Console (sapmmc\sapmmcX86u.msi) 2) Start the Installer (image\setup.exe) 3) Start Application Server by selecting Star

  • Leopard Upgrade from Panther Forgot Mail Messages

    I just upgraded from Panther to Leopard. My iPhotos, Word documents, Bookmarks, everything except email messages made it thru the upgrade and are accessible. My problem is that although all of the Mail user settings are fine, and I can send and recei