Rows to be displayed as Columns with SQL

I have a select statment
SQL> SELECT T.CODE,T.DESCRIPTION from tmp t;
CODE DESCRIPTION
1 1-1
1 1-2
1 1-3
1 1-4
I want with SQL not SQL*PLUS nor Cursors to see the output of my SQL statment as
1 1-1 1-2 1-3 1-4
Please Help

You could try something like that :
SQL> with tbl as
  2  (select 1 code, '1-1' descr from dual union all
  3   select 1 code, '1-2' descr from dual union all
  4   select 1 code, '1-3' descr from dual union all
  5   select 1 code, '1-4' descr from dual) -- end of data sample
  6  select code, max(sys_connect_by_path(descr,' ')) keep (dense_rank last order by length(sys_connect_by_path(descr,' '))) descr
  7  from   tbl
  8  connect by code = prior code and descr > prior descr
  9  group by code
10  /
      CODE
DESCR
         1
1-1 1-2 1-3 1-4Nicolas.

Similar Messages

  • To display chinese characters with SQL Developer

    I have created one table on the Oracle Express Database. In this table ther is one field Nchar tipe.
    The NLS_CHARACTERSET of the d.b. is WE8MSWIN1252, the NLS_NCHAR_CHARACTERSET is AL16UTF16.
    I have done an insert on the table and in this field i have inserted this word: 了解更多
    When i do a select comand with sql developer, on the results i see this only this •••• .
    But if i copy this and cut on the Sql Developer editor, i see the corret word.
    How could i configurate ?
    Regards
    Mario

    Hi
    The following works but there may be better solutions:
    http://totierne.blogspot.com/2008/05/issuesquare-boxes-as-text-characters.html
    Issue:Square boxes as text characters Solution:Add fonts
    Chinese characters in Linux see Debian Chinese How To [1] basically:
    1. create a jre/lib/fonts/fallback directory if necessary and
    2. copy or link the fonts files into this directory. (On my Linux system: /usr/share/fonts/truetype/arphic/gbsn00lp.ttf )
    -Turloch

  • Rows to be displayed as columns

    DB : 10.2.0.4.0
    Os : solaris 5.10
    I have a table with the below rows and columns
    EARNINGS     EARNINGS_VALUE
    Allowance     97.28
    Salary     3,404.80
    Allowance_1     875.52
    Allowance_2     194.56
    Allowance_3     291.84
    {code}
    I want to display this as follows :
    {code}
    Allowance     Salary     Allowance_1     Allowance_2     Allowance_3
    97.28     3,404.80     875.52     194.56     291.84
    {code}
    Please suggest
    Kai                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hello, try:
    WITH your_table AS (SELECT 'Allowance' EARNINGS, 97.28 EARNINGS_VALUE FROM DUAL UNION ALL
    SELECT 'Salary', 3404.80 FROM DUAL UNION ALL
    SELECT 'Allowance_1', 875.52 FROM DUAL UNION ALL
    SELECT 'Allowance_2', 194.56 FROM DUAL UNION ALL
    SELECT 'Allowance_3', 291.84 FROM DUAL)
    -- end test data
    SELECT Allowance, Salary, Allowance_1, Allowance_2, Allowance_3
    FROM (
    SELECT MAX(CASE EARNINGS WHEN 'Allowance' THEN EARNINGS_VALUE ELSE NULL END) Allowance,
       MAX(CASE EARNINGS WHEN 'Salary' THEN EARNINGS_VALUE ELSE NULL END) Salary,
       MAX(CASE EARNINGS WHEN 'Allowance_1' THEN EARNINGS_VALUE ELSE NULL END) Allowance_1,
       MAX(CASE EARNINGS WHEN 'Allowance_2' THEN EARNINGS_VALUE ELSE NULL END) Allowance_2,
       MAX(CASE EARNINGS WHEN 'Allowance_3' THEN EARNINGS_VALUE ELSE NULL END) Allowance_3
      FROM your_table
    ALLOWANCE     SALARY ALLOWANCE_1 ALLOWANCE_2 ALLOWANCE_3
          97.28     3404.8      875.52      194.56      291.84

  • Hide columns with sql

    I am creating a table where there is a column for the particular row to be hidden. What do I do to make that particular row to stay hidden?
    Ex:
    ID Name Hide
    1 joe N
    2 john N
    Now after I edit the data of joe to Hide=Y I want the table to display:
    ID Name Hide
    2 john N
    anyone know what statements i need to do? thanks

    Here is one way. You could create a view for the table.
    SQL> select * from mytable1;
            ID NAME                           H
             1 joe                            N
             2 john                           N
             2 harry                          Y
    SQL>  create view myview as
      2   select * from mytable1
      3   where hide = 'N';
    View created.
    SQL> select * from myview;
            ID NAME                           H
             1 joe                            N
             2 john                           N

  • Display a column with a list of values from DUAL;

    Hello, how can I display something like:
    COL1
    A
    B
    C
    D
    E
    F

    On my planet these are 'words' ;) :
    SQL> select dbms_random.string('a', level)
      2  from   dual
      3  connect by level <= 10;
    DBMS_RANDOM.STRING('A',LEVEL)
    r
    BB
    pmE
    bHri
    aZZDC
    FzOZBf
    fXfPyIP
    LOqrQbnK
    AYzNgHcGc
    lvxRvflHXj
    10 rows selected.
    SQL> select dbms_random.string('a', dbms_random.value(10, 50))
      2  from   dual
      3  connect by level <= 10;
    DBMS_RANDOM.STRING('A',DBMS_RANDOM.VALUE(10,50))
    AKExSSzIJOkabCT
    VCHHRTcgtnBSlZyRmsITqzWqVNgDnPdnxmt
    qLnuyGQErxZvHttRBpWrPoLEiGUra
    rcllLkyZXiwvlcGaUoEAeMbEdZSHlZBIgdilgGTQzxlIUW
    ftnGzDCzUBEsxKzhDLfgS
    aqUmpIzjqkWMZGpbAchhbiqFBUKdRaDwFAgdP
    nskqNdzmlAKlsGOJpbKfQHiCfvkDpoFcTkTvKaUcGLFDkgjsX
    fwkxBSoVuDSEOFldgDhilvm
    iAnSvDMQzamGvIFNydfjhr
    lHRPUnKgOxYQwWAltdELJNqqfgMRSmbBpSDnjOsfx
    10 rows selected.http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_random.htm#CDEJAHCB

  • ALV Display dynamic column with multiline header

    Hi All.
    I need to create alv display with dynamic number of columns. Also, it contains two header line. Kindly help me in coding.
    The required format is this format.
    Product | Week1 | Week2 |.......| WeekN
    |--||---|--
                | Sales   | Sales   |.......| Sales
    |--| |---|--
    PRD1   | value    | Value    |.......| Value
    PRD2   | value    | Value    |.......| Value
    PRD3   | value    | Value    |.......| Value
    Thanks.
    Sadhna

    Hi Sadhana,
    You mean to say that your internal Table contains
    ABCDEF are the fields in your Internal table.
    A--BCD---E-----F
    1--12---13---a11----1
    2--11---01---b9-----0
    3--01---00---c32----0
    4--14---01---d21----0
    Now using Dynamic Internal Table it should display the output as follow :
    A--BCF---a---b-c----d
    1--12---13---111-9-32--21
    Here you want to display the the fields of D as header and E as its corresponding values...?
    Please let me knwo if you mean the same..
    Regards,
    Kittu

  • Updating Object Type Columns with SQL

    Please note that is a re-post from a different forum. I thought I would try this forum as reading through it, it made more sense to post here. Problem:
    I am trying to update a column inside a Nested Table Type in my Table.
    This is what I got from some documentation I found from Oracle.
    UPDATE TABLE(SELECT PROGRAMS FROM TB_ITEM_MASTER WHERE ITEM_NO_ID =1748) IM
    SET IM.PROGRAM_ID = 1;
    WHERE IM.ITEM_NO_ID = 1748;
    Where PROGRAM_ID is a field from the nested table (ITEMS_IN_PROGRAMS_NT) and ITEM_NO_ID is the Primary Key in my TB_ITEM_MASTER table. When I run this it gives me an error of:
    ORA-22908: REFERENCE TO NULL TABLE VALUE
    I assume this is because PROGRAM_ID is currently NULL, and when it pulls the record back, I am pulling a NULL value. Currently all the values will be NULL in the table, but I would like to create a UPDATE Statement that I will call that will update that value, from NULL to whatever ID.
    Here are my def'n's of all my objects for this problem:
    --Object Type def'n
    CREATE OR REPLACE TYPE ITEMS_IN_PROGRAMS_TY AS OBJECT(
    PROGRAM_ID NUMBER(38));
    --Object Type def'n for Nested Table
    CREATE OR REPLACE TYPE ITEMS_IN_PROGRAMS_NT
    AS TABLE OF ITEMS_IN_PROGRAMS_TY;
    --Table def'n
    CREATE TABLE TB_ITEM_MASTER
    (ITEM_NO_ID NUMBER(38) NOT NULL,
    ITEM_NO VARCHAR2(75) NOT NULL,
    NOMENCLATURE VARCHAR2(100) NULL,
    PROGRAMS DMISDBA.ITEMS_IN_PROGRAMS_NT NULL);
    Can someone please help me....I am pulling my hair out on this problem!!! All I want to do is update the column inside a Nested Table. This can not be that hard!!!

    Save your hair...
    SQL> CREATE OR REPLACE TYPE items_in_programs_ty AS OBJECT(
      2  program_id NUMBER(38));
      3  /
    Type created.
    SQL> CREATE OR REPLACE TYPE items_in_programs_nt
      2  AS TABLE OF items_in_programs_ty;
      3  /
    Type created.
    SQL> CREATE TABLE tb_item_master
      2  (item_no_id number(38) not null,
      3  item_no varchar2(75) not null,
      4  nomenclature varchar2(100) null,
      5  programs items_in_programs_nt )
      6  NESTED TABLE programs STORE AS nested_programs
      7  /
    Table created.
    SQL>
    SQL> INSERT INTO tb_item_master (item_no_id, item_no, nomenclature)
      2  VALUES (1748, 'APC/1748', 'Gizmo')
      3  /
    1 row created.
    SQL> UPDATE tb_item_master tmi
      2  SET    tmi.programs =  items_in_programs_nt(items_in_programs_ty( 1))
      3  WHERE  tmi.item_no = 'APC/1748'
      4  /
    1 row updated.
    SQL>
    SQL> Cheers, APC

  • How to load selected column with sql loader

    Hi all
    I want to load only few columns from a datafile not all columns and i don't know how to do from SQL LDR.
    I know we can use position but the data is not fixed length.
    I'm working with Oracle 11g and Linux OS.
    Here is an example of my data file and table.
    Data file is and the field is separated by | :
    3418483|VOU|20120609090114|555208363|0|2858185502059|1000|0||
    3418484|SR|20120609090124|551261956|0|4146314127759|200000|0||
    SQL> desc TBL1
    Name                                      Null?    Type
    CTYPE                                              VARCHAR2(5)
    BDATE                                              DATE
    PARTNUM                                             VARCHAR2(60)
    SERIALNO                                           NUMBER
    FVALUE                                             NUMBER
    I want to have:
    SQL> select * from TBL1
    CTYPE     BDATE          PARTNUM          SERIALNO          FVALUE
    VOU     09/06/2012     555208363     2858185502059          1000
    SR     09/06/2012     551261956     4146314127759          200000Thank you.

    look at FILLER
    http://www.orafaq.com/wiki/SQL*Loader_FAQ#Can_one_skip_certain_columns_while_loading_data.3F
    --add sample
      num1 FILLER,
      ctype,
      bdate "to_date(:bdate, 'YYYYMMDDHH24MISS')",
      PARTNUM,
      num2 FILLER,
      SERIALNO,
      FVALUE, 
      num3 FILLER
      )Edited by: AlexAnd on Jun 9, 2012 4:29 AM

  • SQL Azure - query with row_number() executes slow if columns with nvarchar of big size are included

    I am linking my question from Stack Overflow here. The link: http://stackoverflow.com/questions/27943913/sql-azure-query-with-row-number-executes-slow-if-columns-with-nvarchar-of-bi
    Appreciate your help!
    Gorgi

    Hi,
    Thanks for posting here.
    I suggest you to check this link and optimize your query on sql azure.
    http://www.sqlusa.com/articles/query-optimization/
    http://sqlblog.com/blogs/paul_white/archive/2011/02/23/Advanced-TSQL-Tuning-Why-Internals-Knowledge-Matters.aspx
    Also check this blog which had similar issue.
    https://social.msdn.microsoft.com/Forums/en-US/c1da08b4-265d-4ec8-a252-8d7090234e3e/simple-select-query-takes-long-time-to-execute-with-nvarchar-columns?forum=transactsql
    Girish Prajwal

  • Hyperlink column with link parameters as region column values

    On my APEX page i have region which has sql query as source and it displays as HTML table the query result to the user.
    I want to display addinonal column with a hyperlink inside, and that hyperlink would have CGI/URL-parameters which contains the other values of the HTML row.
    So, let's say my APEX region queryes columns as "select c1, c2, c3, c4 ..." and displays out values "V1, V2, V3, V4" then i want to have addional output column with such hyperlink:
        a href="f?p=100:7:13467554876288::NO::c1,c2,c3,c4:v1,v2,v3,v4">My link column with CGI-parameters</aHow can i create such hyperlink?
    The overall idea is that the link would forward to a page which loads those values "v1,v2,v3,v4" into form fields and user can proceed from there.
    "Application Express 4.2.1.00.08"
    Edited by: CharlesRoos on 10.04.2013 14:55
    Edited by: CharlesRoos on 10.04.2013 14:55
    Edited by: CharlesRoos on 10.04.2013 14:55

    CharlesRoos wrote:
    On my APEX page i have region which has sql query as source and it displays as HTML table the query result to the user.Is this a standard report region or interactive report region? Or something else? Using standard APEX terms makes it easier to understand your problem.
    I want to display addinonal column with a hyperlink inside, and that hyperlink would have CGI/URL-parameters which contains the other values of the HTML row.
    So, let's say my APEX region queryes columns as "select c1, c2, c3, c4 ..." and displays out values "V1, V2, V3, V4" then i want to have addional output column with such hyperlink:
    a href="f?p=100:7:13467554876288::NO::c1,c2,c3,c4:v1,v2,v3,v4">My link column with CGI-parameters</aHow can i create such hyperlink?This is typically done by creating a column link. This is a very basic APEX technique, covered in the <i>2 Day + Application Express Developer's Guide</i> tutorial.
    <li>Creating a Column Link in an Interactive Report
    <li>Creating a Column Link in a Classic Report

  • MS SQL - Add column with all rows being "0"

    Add column with all rows being "0"

    nevermind
    "lee" <[email protected]> wrote in message
    news:e3b5kt$mch$[email protected]..
    > Add column with all rows being "0"
    >
    >
    >

  • How can I display multiple column results of a sql query?

    I'm wanting to display the results of a query selecting from multiple columns, but I can't seem to find an item type that will allow this. I've tried LOV, multiselect, display as text and others. Any ideas on how to do this. Here is my basic query:
    Select ul.meaning,
    rqa.submission_date,
    rqa.location_num
    from
    cfa_rqa_doc_submit_dates rqa,
    cfa_user_lookups ul
    where
    rqa.location_num in (Select location_num from cfa_current_locations_mv
    where operator_person_id = :P1_PERSON_ID and substr(location_num,1,1) = '8')
    and
    ul.lookup_type_id='1269'
    and
    to_char(rqa.submission_date, 'month') = to_char(sysdate, 'month')
    and
    rqa.submission_date >= (SYSDATE-365)
    and ul.lookup_ID= rqa.document_type_id
    ;

    Hi,
    Do you just wish to display the result of the query? If so, you can simply parse it out in HTML.
    You can then choose if you want to use tables or css.
    Multiple column layout in tables are based on <tr> and <td>.
    <tr> is a table row, where <td> is a column.
    All tags should be closed.
    Example:
    <table>
    <tr>
    <td>col1</td><td>col2</td>
    </tr>
    <tr>
    <td colspan="2">spans over 2 cols</td>
    </tr>
    </table>If you want to do the same in css:
    (Seems this forum removes the styles!):
    float:left; width:50; << first div and 2 div (col 1 and col 2 style)
    float:left;clear:both; width:100%; << clear both, double width (spans over 2)
    <div>
    <div style="float:left; width:50;">col1</div><div style="float:left;width:50%;">col2</div>
    <div style="float:left;clear:both; width=100%;">Spans over 2 cols</div>
    </div>The div might look more complicated, but if you refrain from styling in the tags them selves, you can define different styles in the .css file.
    You need the clear:both to start a new line with the divs that float.
    I usually run a dedicated "new line" div, without content.. (exception beeing the html-entities version of ' ' (& nbsp ; << without the spaces)).
    eg.:
    <div style="cls"> </div>Parsing out the values from the PL SQL you do like so:
    begin
    declare
       cursor c_search is 
    Select ul.meaning,
    rqa.submission_date,
    rqa.location_num
    from
    cfa_rqa_doc_submit_dates rqa,
    cfa_user_lookups ul
    where
    rqa.location_num in (Select location_num from cfa_current_locations_mv
    where operator_person_id = :P1_PERSON_ID and substr(location_num,1,1) = '8')
    and
    ul.lookup_type_id='1269'
    and
    to_char(rqa.submission_date, 'month') = to_char(sysdate, 'month')
    and
    rqa.submission_date >= (SYSDATE-365)
    and ul.lookup_ID= rqa.document_type_id
    begin  
    htp.p('<div style="width:80%;">');
    for v_search in c_search loop
    htp.p('<div style="float:left;clear:none;">'||v_search.location_num||'</div>');
    htp.p('<div style="float:left;clear:none;">'||v_search.submission_date||'</div>');
    end loop;
    htp.p('</div>');
      end;
    end;Ps. hope I understood you correctly, also this code is untested.. but I hope it can still help.
    Edited by: Olav Alexander Mjelde on May 12, 2010 9:36 AM

  • Best way to give a default value to a New Column with existing rows

    Adding some columns to SQL tables with existing data rows. There are also views created from these tables. The views are used in some report/query software so NULL values are not good. Interested in learning about the best way to set a default value. 
    These are the ways that I can think of
    1) ALTER TABLE using the DEFAULT to add the column and set the default value
    ++ Adds a constraint which is not terrible. Constraints are just not used much in this shop.
    2) ALTER TABLE to add the column then do an UPDATE statement to update the values
    ++ might be an issue for tables with millions of rows
    3) ALTER TABLE to add the column then use ISNULL in the CREATE VIEW

    It is a large table with 444 columns and max row size of 2268. 907k records took 1 minute 38 seconds to UPDATE the column. I have about 12 fields to add to this table and about 44 tables (not all this large of course) so it will take some time to
    UPDATE.  Although ... i just tried updating 3 columns in a single UPDATE and it took 1 minute 36 seconds. So If I did all 12 fields in a single UPDATE it would be about the same time as a single Field.  I will think about it.

  • Sql query slowness due to rank and columns with null values:

        
    Sql query slowness due to rank and columns with null values:
    I have the following table in database with around 10 millions records:
    Declaration:
    create table PropertyOwners (
    [Key] int not null primary key,
    PropertyKey int not null,    
    BoughtDate DateTime,    
    OwnerKey int null,    
    GroupKey int null   
    go
    [Key] is primary key and combination of PropertyKey, BoughtDate, OwnerKey and GroupKey is unique.
    With the following index:
    CREATE NONCLUSTERED INDEX [IX_PropertyOwners] ON [dbo].[PropertyOwners]    
    [PropertyKey] ASC,   
    [BoughtDate] DESC,   
    [OwnerKey] DESC,   
    [GroupKey] DESC   
    go
    Description of the case:
    For single BoughtDate one property can belong to multiple owners or single group, for single record there can either be OwnerKey or GroupKey but not both so one of them will be null for each record. I am trying to retrieve the data from the table using
    following query for the OwnerKey. If there are same property rows for owners and group at the same time than the rows having OwnerKey with be preferred, that is why I am using "OwnerKey desc" in Rank function.
    declare @ownerKey int = 40000   
    select PropertyKey, BoughtDate, OwnerKey, GroupKey   
    from (    
    select PropertyKey, BoughtDate, OwnerKey, GroupKey,       
    RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]   
    from PropertyOwners   
    ) as result   
    where result.[Rank]=1 and result.[OwnerKey]=@ownerKey
    It is taking 2-3 seconds to get the records which is too slow, similar time it is taking as I try to get the records using the GroupKey. But when I tried to get the records for the PropertyKey with the same query, it is executing in 10 milliseconds.
    May be the slowness is due to as OwnerKey/GroupKey in the table  can be null and sql server in unable to index it. I have also tried to use the Indexed view to pre ranked them but I can't use it in my query as Rank function is not supported in indexed
    view.
    Please note this table is updated once a day and using Sql Server 2008 R2. Any help will be greatly appreciated.

    create table #result (PropertyKey int not null, BoughtDate datetime, OwnerKey int null, GroupKey int null, [Rank] int not null)Create index idx ON #result(OwnerKey ,rnk)
    insert into #result(PropertyKey, BoughtDate, OwnerKey, GroupKey, [Rank])
    select PropertyKey, BoughtDate, OwnerKey, GroupKey,
    RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
    from PropertyOwners
    go
    declare @ownerKey int = 1
    select PropertyKey, BoughtDate, OwnerKey, GroupKey
    from #result as result
    where result.[Rank]=1
    and result.[OwnerKey]=@ownerKey
    go
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to display the column header in two rows?

    Hi Experts,
    I am using ALV_LIST_DISPLAY i neeed to display the column header in two rows.. How can i do that?
    Ex: purchase order i  need to display "purchase" in one row and "order" in second row.
    Thanks in advance,
    Sarath.j

    REPORT zpwtest .
    TYPE-POOLS slis .
    DATA : layout TYPE slis_layout_alv .
    CONSTANTS : c_len TYPE i VALUE 20 .
    TYPES : BEGIN OF ty_t100          ,
              sprsl TYPE t100-sprsl   ,
              arbgb TYPE t100-arbgb   ,
              msgnr TYPE t100-msgnr   ,
              text  TYPE t100-text    ,
              fline TYPE t100-text    ,
            END OF ty_t100            .
    TYPES : BEGIN OF ty_wrd   ,
             text TYPE char20 ,
            END OF ty_wrd     .
    DATA : it_t100     TYPE TABLE OF ty_t100 ,
           it_sentence TYPE TABLE OF ty_wrd  ,
           wa_t100     TYPE ty_t100          ,
           wa_word     TYPE ty_wrd           ,
           v_repid     TYPE syst-repid       ,
           v_tabix     TYPE syst-tabix       .
    DATA : it_fld TYPE slis_t_fieldcat_alv ,
           it_evt TYPE slis_t_event        ,
           wa_fld TYPE slis_fieldcat_alv   ,
           wa_evt TYPE slis_alv_event      .
    INITIALIZATION .
      v_repid = sy-repid .
    START-OF-SELECTION .
    * Get data
      SELECT *
        INTO TABLE it_t100
        FROM t100
       WHERE sprsl = 'EN'
         AND arbgb = '00' .
      LOOP AT it_t100 INTO wa_t100 .
        v_tabix = sy-tabix .
        CLEAR : it_sentence .
        CALL FUNCTION 'RKD_WORD_WRAP'
             EXPORTING
                  textline  = wa_t100-text
                  outputlen = c_len
             TABLES
                  out_lines = it_sentence.
        IF NOT it_sentence IS INITIAL .
          READ TABLE it_sentence INTO wa_word INDEX 1 .
          wa_t100-fline = wa_word-text .
          MODIFY it_t100 FROM wa_t100 INDEX v_tabix .
        ENDIF.
      ENDLOOP.
    * Prepare fieldcatelog
      CLEAR wa_fld .
      wa_fld-fieldname = 'SPRSL' .
      wa_fld-ref_tabname = 'T100' .
      wa_fld-ref_fieldname = 'SPRSL' .
      APPEND wa_fld TO it_fld .
      CLEAR wa_fld .
      wa_fld-fieldname = 'ARBGB' .
      wa_fld-ref_tabname = 'T100' .
      wa_fld-ref_fieldname = 'ARBGB' .
      APPEND wa_fld TO it_fld .
      CLEAR wa_fld .
      wa_fld-fieldname = 'MSGNR' .
      wa_fld-ref_tabname = 'T100' .
      wa_fld-ref_fieldname = 'MSGNR' .
      APPEND wa_fld TO it_fld .
      CLEAR wa_fld .
      wa_fld-fieldname = 'FLINE' .
      wa_fld-inttype      = 'CHAR' .
      wa_fld-outputlen = 20 .
      wa_fld-intlen    = 20.
      wa_fld-seltext_l = 'Text' .
      wa_fld-ddictxt = 'L' .
      APPEND wa_fld TO it_fld .
    * Get event.. we will handle BOFORE and AFTER line output
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           IMPORTING
                et_events = it_evt.
      READ TABLE it_evt INTO wa_evt
      WITH KEY name = slis_ev_after_line_output .
      wa_evt-form = slis_ev_after_line_output .
      MODIFY it_evt FROM wa_evt INDEX sy-tabix .
      READ TABLE it_evt INTO wa_evt
      WITH KEY name = slis_ev_top_of_page .
      wa_evt-form = slis_ev_top_of_page .
      MODIFY it_evt FROM wa_evt INDEX sy-tabix .
      layout-no_colhead = 'X' .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_callback_program = v_repid
                it_fieldcat        = it_fld
                is_layout          = layout
                it_events          = it_evt
           TABLES
                t_outtab           = it_t100.
    *       FORM top_of_page                                              *
    FORM top_of_page .
        uline .
        WRITE: / sy-vline     ,
               10 sy-vline    ,
               11 'line1'     ,
               31 sy-vline    ,
               37 sy-vline    ,
               58 sy-vline    .
        WRITE: / sy-vline     ,
               10 sy-vline    ,
               11 'line2'     ,
               31 sy-vline    ,
               37 sy-vline    ,
               58 sy-vline    .
        WRITE: / sy-vline     ,
               10 sy-vline    ,
               11 'line3'     ,
               31 sy-vline    ,
               37 sy-vline    ,
               58 sy-vline    .
    ENDFORM.
    *       FORM AFTER_LINE_OUTPUT                                        *
    FORM after_line_output   USING rs_lineinfo TYPE slis_lineinfo .
      CLEAR : it_sentence ,
              wa_t100     .
      READ TABLE it_t100 INTO wa_t100 INDEX rs_lineinfo-tabindex .
      CHECK sy-subrc = 0 .
      CALL FUNCTION 'RKD_WORD_WRAP'
           EXPORTING
                textline  = wa_t100-text
                outputlen = c_len
           TABLES
                out_lines = it_sentence.
      DESCRIBE TABLE it_sentence LINES v_tabix .
      CHECK v_tabix > 1 .
      LOOP AT it_sentence INTO wa_word FROM 2 .
        WRITE: / sy-vline     ,
               10 sy-vline    ,
               31 sy-vline    ,
               37 sy-vline    ,
               38 wa_word-text ,
               58 sy-vline .
      ENDLOOP.
    ENDFORM .

Maybe you are looking for