Alv report with varying number of columns

hi all,
I am new to abap. I am writing this to get a brief idea of what i wanted to do in system.
I have to do a report using alv.  The format of the report looks like this.
acc no     acc. name     amt_sum_april   amt_sum_may   amt_sum_june. ............. total_months
the colum amt_sum_ depends on user input period(month interval).
if the user selects 4 to 6 = 3 columns ,if the user selects 4 to 10 = 7 columns
so on.......
Anyone have idea how to do it, because in the
initial structure or itab, the number of columns depends on the user input.. i am stucking here ...
pls help.
thanks and regards
jose

Hi friend,
It's very complicated to do that, I'm sure there's a way to do it but I really don't know it. Once I had a similar requirement and I did something else that solved my problem without making a fussy complicated code. I added a colum MONTH or PERIOD (depending on your requirement) and then I make a subtotal by that column. So you need:
acc no acc. name amt_sum_april amt_sum_may amt_sum_june. ............. total_months
Now you would have:
acc no acc. name    month     amount
In the SORT table, in the sorting condition by MONTH you specify SUBTOTAL = 'X'. So the output will be:
acc no acc. name    month     amount
123123        John      2            100.00
123124        Paul      2            200.00
Month  2                                300.00
123123        John      3            300.00
123124        Paul      3            400.00
123125        Jane      3            100.00
Month  3                                 800.00
123123        John      4            123.54
Month   4                                123.54
Total                                      1223.54
You can change the subtotal text for a more adequate one (if you want). Also if you only need the subtotals you can specify in the layout that only those lines are to be output.
I hope I've helped, I you have any question let me know!
Regards,
Pablo

Similar Messages

  • How to create a table with varied number of columns?

    I am trying to create a balance table. The colunms should include years between the start year and end year the user will input at run time. The rows will be the customers with outstanding balance in those years.
    If the user input years 2000 and 2002, the table should have columns 2000, 2001, 2002. But if the user input 2000 and 2001, the table will only have columns 2000 and 2001.
    Can I do it? How? Thanka a lot.

    Why did you create a new thread for this?
    How to create a table with varied number of columns?

  • Table with varying number of columns

    Hello experts,
    my issue:
    I need to print a table with varying number of columns. Depending on if all cells of a certain column are initial the
    whole column should disappear. Hiding is not enough.
    If this columns is in the middle of the table the following columns should move left to fill the gap.
    my approach: (maybe there is an easier one)
    There are 4 different possible situations. My approach was to create 4 different tables with different amount of
    columns. In the interface I fill the table that is really needed from the source table data and fill a flag that characteristics
    the situation, possible values (1,2,3,4).
    In the form I'd like to print the appropriate table depending on the situations.
    my problem:
    How to place all 4 possible tables lying upon each other in the form and print only the needed one depending on the flag value?
    my question:
    Is my approach ok? Or is there an easier one?
    If it is ok. How can I solve the problem regarding printing the right table.
    Thanks in advance!
    Heinz

    Hi Heinz,
    You can handle it with FormCalc Script at initialization.
    Suppose you have a table with name TABLE having a header HEADER and data row DATA:
    TABLE-->HEADER(Cell1...Cell2...Cell3...Cell4)
              --->DATA(Cell1...Cell2...Cell3...Cell4)
    Suppose you want to hide Cell3 for null values, then write below code at initialization of DATA:
    if(DATA[*].Cell3.rawValue eq null)
    then
    DATA[*].Cell3.presence = "hidden"
    HEADER.Cell3.presence = "hidden"
    else
    DATA[*].Cell3.presence = "visible"
    HEADER.Cell3.presence = "visible"
    endif
    Hope it would help.
    Regards,
    Vaibhav

  • Can we create JTable with multiple rows with varying number of columns ?

    Hi All,
    I came across a very typical problem related to JTable. My requirement is that cells should be added dynamically to the JTable. I create a JTable with initial size of 1,7 (row, columns) size. Once the 7 columns are filled with data, a new row should be created. But the requirement is, the new row i.e. second row should have only one cell in it initially. The number of cells should increase dynamically as the data is entered. The table is automatically taking the size of its previous row when new row is added. I tried by using setColumnCount() to change the number of columns to '1' for the second row but the same is getting applied to the first row also.
    So can you please help me out in this regard ? Is it possible to create a JTable of uneven size i.e. multiple rows with varying number of columns in each row ?
    Thanks in Advance.

    Well a JTable is always going to paint the same number of columns for each row. Anything is possible if you want to rewrite the JTable UI to do this, but I wouldn't recommend it. (I certainly don't know how to do it).
    A simpler solution might be to override the isCellEditable(...) method of JTable and prevent editing of column 2 until data in column 1 has been entered etc., etc. You may also want to provide a custom renderer that renderers the empty column differently, maybe with a grey color instead of a white color.

  • ALV report shows fixed number of columns for a user ?

    Hello,
    I have an issue wherein I have created an ABAP ALV grid display in a WD ABAP application and hosted it onto portal. Now, all the users can see the correct number of columns for the report which are determined dynamically. But just for one user, irrespective of which report she launches it shows her only 4 columns.
    Can anybody suggest why this kind of behavior.
    Appreciate your help.
    Regards,
    Samta.

    Hi,
    Right, click the button "manage layout" or "save layout" and remove any default user settings...
    added: didn't read carefully sorry ;)... better check user settings in SU01 if no ALV parameter is used.
    Kr,
    m.
    Edited by: Manu D'Haeyer on Oct 21, 2011 8:53 PM

  • Report with indefinite number of columns

    Hello,
    I'm using VB.NET and Crystal Reports 2008 for my Windows application.
    I've a new report to implement. It's a budgetting report in a table form, which shows the amount of money allocated to a certain projects over a range of years. In each row I show the different projects, in each column I show the budget of each project per year. Users can select the number of years to print (as a parameter), that means, the number of columns is dynamic.
    My question is, how am I going to design this report? Will cross-tab help? My report will be in landscape format. The page width is enough for 8 columns, i.e. 8 years can be printed per table. If users choose to print more than 8 years, the "extra" columns should be printed on a new table underneath the one with the first 8 years, or on a new page if there's not enough space underneath.
    Your help and suggestions would be much appreciated. Thank you very much.
    Agnes

    use conditional supressions on the fields in the colums so based upon parameter selection it will display what is shown
    insert a section below the other and then use the conditional supression based upon the selection of 8+
    cross tabs have limitations and are hard to read.

  • Report with undefined number of columns

    Hello,
    I'm using VB.NET and Crystal Reports 2008 for my Windows application.
    I've a new report to implement. It's a budgetting report in a table form, which shows the amount of money allocated to a certain projects over a range of years. In each row I show the different projects, in each column I show the budget of each project per year. Users can select the number of years to print (as a parameter), that means, the number of columns is dynamic.
    My question is, how am I going to design this report? Will cross-tab help? My report will be in landscape format. The page width is enough for 8 columns, i.e. 8 years can be printed per table. If users choose to print more than 8 years, the "extra" columns should be printed on a new table underneath the one with the first 8 years, or on a new page if there's not enough space underneath.
    Your help and suggestions would be much appreciated. Thank you very much.
    Agnes

    Please note, this forum is dedicated to topics related to custom application development or deployment with Crystal Reports in .Net. This includes full versions of Crystal Reports as well as those versions of Crystal Reports bundled with Microsoft Visual Studio .Net.
    As your query concerns design of an actual report, you should be posting your query to the Crystal Reports Design forum:
    SAP Crystal Reports
    Ludek
    Moved to Report Design Forum
    Edited by: Don Williams on Nov 24, 2008 7:23 AM

  • Reports with varying number of variables

    Hi all
    I am new to the Forum. I have already searched the db for answers to my question but was unsucessful so far.
    I want to create a report in html which I open in Excel for my colleagues to edit. One report contains a varying number of variables, such as years. I want to be able to order the records by the years in different blocks, i.e. blocks of projects which are carried out in 2006, 2007, etc. Is there a way of generating such a report with a dynamic number of years without using pl/sql?
    Thanks for any help!
    Cheers.

    do you mean you want to use plain sql and sqlplus?
    you can maybe try something like
    set feedb off head off
    break on year skip 1
    col year nopri
    select ename, hiredate, extract(year from hiredate) year from emp order by year;
    SMITH      17.12.80
    WARD       22.02.81
    JONES      02.04.81
    MARTIN     28.09.81
    BLAKE      01.05.81
    ALLEN      20.02.81
    CLARK      09.06.81
    FORD       03.12.81
    JAMES      03.12.81
    KING       17.11.81
    TURNER     08.09.81
    MILLER     23.01.82
    ADAMS      23.05.87
    SCOTT      19.04.87

  • PLSQL-generated SQL report with variable number of columns

    I created an app to track college football bowl picks:
    http://apex.oracle.com/pls/otn/f?p=21723
    The main report region includes columns for the various games as well as a column for each participant. In order not to hard code the number of participants, I used PLSQL to generate the SQL so that new columns could be added on the fly.
    However, whenever I add a new user I get this result -
    report error:
    ORA-01403: no data found
    If I copy and paste the PLSQL into a new report region and then delete the old one, however, all is well.
    Is there something I can do to overcome this?
    Thanks.
    Bill

    Roberto
    <br><br>
    Here are the tables:
    <br><br>
    BOWL_GAMES<br>
    ID     NUMBER<br>
    NAME     VARCHAR2(30)<br>
    FAV     VARCHAR2(20)<br>
    DOG     VARCHAR2(20)<br>
    BDATE     DATE<br>
    LINE     NUMBER(3,1)<br>
    FAV_SCORE     NUMBER(4,0)<br>
    DOG_SCORE     NUMBER(4,0)<br>
    <br>
    BOWL_USERS<br>
    ID     NUMBER<br>
    USERNAME     VARCHAR2(20)<br>
    PW     VARCHAR2(20)<br>
    NAME     VARCHAR2(20)<br>
    EMAIL     VARCHAR2(50)<br>
    <br>
    BOWL_PICKS<br>
    ID     NUMBER(5,0)<br>
    USERID     NUMBER(10,0)<br>
    GAMEID     NUMBER(10,0)<br>
    PICK     NUMBER(1,0)<br>
    <br>
    <br>
    Below is my PLSQL. Feel free to try out the app. Thanks.
    <br><br>
    Bill<br><br>
    declare<br>
    p_sql varchar2(32767);<br>
    cursor c1 is select * from bowl_users order by id;<br>
    begin<br>
    p_sql := q'! select to_char(b.bdate, 'Mon FMdd') "Date", b.name, '< a href="javascript$pickEm(''' || b.fav || ''')">' || b.fav || '</ a> -' || b.line || ' < a href="javascript$pickEm(''' || b.dog || ''')">' || b.dog || '</ a>' "Line" !';<br>
    for a1 in c1 loop<br>
    p_sql := p_sql || q'! , bowl_strike(b.id, !' || a1.id || q'! , 0) || (select decode(p.pick, 0, substr(b.dog,1,4), 1, substr(b.fav,1,4), 'No pick') from bowl_picks p where p.userid = !' || a1.id || q'! and p.gameid = b.id) || bowl_strike(b.id, !' || a1.id || q'! , 1) "!' || upper(a1.name) || q'!" !';<br>
    end loop;<br>
    p_sql := p_sql || q'! , bowl_score(b.id) "SCORE" from bowl_games b order by b.bdate !';<br>
    return replace(p_sql,'$',':');<br>
    end;
    <br><br>
    Message was edited by:
    [email protected]

  • ALV performance with large number of columns

    Dear friends,
    I have created an ALV grid which has approximately 225 fields in it using Classes an not REUSE fms..
    After the ALV grid is first displayed if the user scrolls down to the next page it takes significant time to display the data in the next page.. The documentation says that the ALV grid only caches the data upon display (After first display of a page and before the ALV grid data is refreshed it works fine).  
    Is there any mechanism of caching the entire ALV grid data before/after the method set_table for_first_display is called??
    Helpful answers will be appropriately rewarded..
    Cheers
    Nitesh

    We're actually doing some TableView performance work right now, I wonder if you could file an issue with a simple reproducible test case? I haven't seen the same data you have here in our profiles (nearly all time is spent on reapplying CSS) so I would be interested in your exact test to be able to profile it and see what is going on.
    Thanks
    Richard

  • Displaying tables with dynamic number of columns

    Hello,
    I'm pretty new to JSF. Currently I'm working on a project where I have to select a table from a list, and then make it browsable/editable. The problem I have is that the different tables also have a different number of columns.
    I have no problem displaying different tables if the number of coulumns stays the same (using h:datatable) but when it's dynamic, I don't know how I can have my JSP to adjust to support the varying number of columns.
    Has anyone got an example of dynamic datatable or maybe someone can point me in the right direction.
    Brimborian

    Hi daniel,
    1. There is an INDEPENDENT FORM
      whose inputs are FIELD LIST
      and from those, it consructs dynamic table.
    2. Here is the program.
    the dynamic table name will be
    <DYNTABLE>.
    3. U can use this program (FORM in this program)
    to generate any kind of internal table
    by specifying some inputs (ie. field list)
    4.
    REPORT abc.
    COMPULSORY
    FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
    FIELD-SYMBOLS: <dynline> TYPE ANY.
    DATA: lt TYPE lvc_t_fcat.
    DATA: ls TYPE lvc_s_fcat.
    FIELD-SYMBOLS: <fld> TYPE ANY.
    DATA : fldname(50) TYPE c.
    PARAMETERS : infty(4) TYPE c OBLIGATORY.
    DATA : iname LIKE dd02l-tabname.
    START-OF-SELECTION.
    GET INFO
    CONCATENATE 'P' infty INTO iname.
    DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
    EXPORTING
    tabname = iname
    TABLES
    ddfields = ddfields.
    CONSTRUCT FIELD LIST
    LOOP AT ddfields.
    ls-fieldname = ddfields-fieldname.
    APPEND ls TO lt.
    ENDLOOP.
    PERFORM
    PERFORM mydyntable USING lt.
    BREAK-POINT.
    INDEPENDENT FORM
    FORM mydyntable USING lt TYPE lvc_t_fcat .
    Create Dyn Table From FC
    FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
    FIELD-SYMBOLS: <fs_1>.
    FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
    DATA: lt_data TYPE REF TO data.
    ASSIGN lt_data TO <fs_data>.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = lt
    IMPORTING
    ep_table = <fs_data>
    EXCEPTIONS
    generate_subpool_dir_full = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    ENDIF.
    Assign Dyn Table To Field Sumbol
    ASSIGN <fs_data>->* TO <fs_1>.
    ASSIGN <fs_1> TO <fs_2>.
    ASSIGN <fs_1> TO <dyntable>.
    ENDFORM. "MYDYNTABLE
    regards,
    amit m.

  • Create a Procedural ALV Report with editable fields and save the changes

    Hi,
    I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
    BCALV_TEST_GRID_EDIT_01
    BCALV_TEST_GRID_EDIT_02
    BCALV_TEST_GRID_EDIT_04_FORMS
    BCALV_TEST_GRID_EDITABLE
    BCALV_EDIT_01
    BCALV_EDIT_02
    BCALV_EDIT_03
    BCALV_EDIT_04
    BCALV_EDIT_05
    BCALV_EDIT_06
    BCALV_EDIT_07
    BCALV_EDIT_08
    BCALV_FULLSCREEN_GRID_EDIT
    But all these are using OO Concepts.
    Please help.
    Regards,
    Smruthi

    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) TYPE c,     "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE slis_layout_alv,
          gd_repid     LIKE sy-repid.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
    fieldcatalog-edit             = 'X'
      fieldcatalog-col_pos     = 5.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      APPEND fieldcatalog TO fieldcatalog.
      CLEAR  fieldcatalog.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
      gd_layout-info_fieldname =      'LINE_COLOR'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          Display report using ALV grid
    FORM display_alv_report.
      gd_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = gd_repid
                i_callback_pf_status_set = 'STATUS'
                i_callback_top_of_page   = 'TOP-OF-PAGE'
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
               is_variant              = z_template
           TABLES
                t_outtab                = it_ekko
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      DATA: ld_color(1) TYPE c.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekko.
      LOOP AT it_ekko INTO wa_ekko.
        ld_color = ld_color + 1.
        IF ld_color = 8.
          ld_color = 1.
        ENDIF.
        CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
        MODIFY it_ekko FROM wa_ekko.
      ENDLOOP.
    ENDFORM.                    " DATA_RETRIEVAL
          FORM top-of-page                                              *
    FORM top-of-page.
      WRITE:/ 'This is First Line of the Page'.
    ENDFORM.
          FORM status                                                   *
    FORM status USING rt_extab TYPE slis_t_extab.  .
      SET PF-STATUS 'ALV'.
    ENDFORM.
          FORM USER_COMMAND                                          *
    -->  RF_UCOMM                                                      *
    -->  RS                                                            *
    FORM user_command USING rf_ucomm LIKE sy-ucomm
                             rs TYPE slis_selfield.            
      DATA ref1 TYPE REF TO cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = ref1.
      CALL METHOD ref1->check_changed_data.
      CASE rf_ucomm.
    when 'SAVE'.
    get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
    endcase.
    endform.
    ENDFORM.
    here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
    create a custom PF status and create push buttons and assign your ok codes in your PF status.
    if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
    Hope this will help you.
    Regards,
    phani.

  • Print or download ALV report with sort options

    Dear friends,
    How i can download into excel or print ALV report with sort options, like customer name column with similar values should not repeat in the print out or download file.
    Regards,
    Praveen Lobo

    Hi Praveen,
    Use this code, its working:-
    *FOR SORTING DATA
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *          SORT W.R.T. CUSTOMER NAME
      wa_sort-spos = 1.
      wa_sort-fieldname = 'NAME1'. "field customer name
      wa_sort-tabname = 'IT_KNA1'. "internal table with records
      wa_sort-up = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    "this will sort the ALV o/p for customer with same name
    "now the name will not be repeated
    "records with same name will be grouped
    *          DISPLAY RECORDS IN ALV GRID
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program                = sy-repid "report id
        it_fieldcat                       = it_field "field catalog
        it_sort                           = it_sort "sort info
      TABLES
        t_outtab                          = it_kna1 "internal table
      EXCEPTIONS
        program_error                     = 1
        OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir
    Edited by: Tarun Gambhir on Dec 31, 2008 1:13 PM

  • ALV Reporting with drill down capabillities

    I'm creating a abap custom report using the ALV.  I want to drill down to CJ03 which is projects.  I know how to do it in regular custom reporting, but I don't seem to be able to get it to work using the ALV.  Can anyone help?
    Thanks.
    Linda

    Hi Linda,
    Take a look at this sample program. The logic to handle any interaction with the user is in my "PORCESS_USER_COMMANDS" routine.
    This is defined in the "I_CALLBACK_USER_COMMAND" parameter in the ALV FM.
    Hope this helps.
    Cheers,
    Pat.
    [code]
    Modification History
    Date      | Author    | Chg Req #     | Description
    15.08.2001| Pat Yee   | $TMP          | Program Creation
    This program is an example of how the ALV Display works.
    It will display Customer Data.
    This report will also show how to display an ALV report with different
    colored lines and icons
    REPORT zpat.
    Include Programs
    INCLUDE <icon>.
    Database Tables
    TABLES: kna1.                  "Customer Master
    Types
    TYPE-POOLS: kkblo.
    Structures
    Structure to hold the Color Information
    DATA: BEGIN OF st_color,
            color(3) TYPE c,
          END OF st_color.
    Structure to hold the Icon Information
    DATA: BEGIN OF st_icon,
            icon(4) TYPE c,
          END OF st_icon.
    ALV Field Catalog Structure
    DATA: st_fieldcat   TYPE slis_fieldcat_alv.
    ALV Layout Structure
    DATA: st_layout     TYPE slis_layout_alv.
    Internal Tables
    Output Table
    DATA: BEGIN OF tbl_kna1 OCCURS 0.
            INCLUDE STRUCTURE st_icon.   "Icon Structure
            INCLUDE STRUCTURE kna1.      "Customer Master Structure
            INCLUDE STRUCTURE st_color.  "Color Structure
    DATA: END OF tbl_kna1.
    ALV Field Catalog Table
    DATA: tbl_fieldcat  TYPE slis_t_fieldcat_alv.
    Variables
    DATA: fieldname(30) TYPE c,
          g_repid       LIKE sy-repid.
    Start of Selection
    START-OF-SELECTION.
      g_repid = sy-repid.
      PERFORM get_data.
    End of Selection
    END-OF-SELECTION.
      PERFORM do_fancy_stuff.
      PERFORM get_layout.
      PERFORM get_fieldcat.
      PERFORM create_report.
    *&      Form  CREATE_REPORT
          Learn to read the subroutine name!
    FORM create_report.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_interface_check       = ' '
                i_callback_program      = g_repid
                i_callback_user_command = 'PROCESS_USER_COMMANDS'
                it_fieldcat             = tbl_fieldcat
                i_default               = 'X'
                i_save                  = ' '
                is_layout               = st_layout
           TABLES
                t_outtab                = tbl_kna1
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                               " CREATE_REPORT
    *&      Form  GET_FIELDCAT
          Build the Field Catalog
    FORM get_fieldcat.
    Here the field catalog is created. To display more fields simply
    'uncomment' the additional lines and add the field name. Also note
    that the field catalog is much more powerful than this. You can
    intensify fields, change the colour, assign reference fields, etc.
    Look at type slis_fieldcat_alv for more options.
      PERFORM write_fieldcat USING 'ICON'  'TBL_KNA1' '    ' 'X' 1 '2' 'X'
      PERFORM write_fieldcat USING 'KUNNR' 'TBL_KNA1' 'KNA1' 'X' 2 ' ' ' '
      PERFORM write_fieldcat USING 'NAME1' 'TBL_KNA1' 'KNA1' ' ' 3 '10' ' '
                                   'X'.
      PERFORM write_fieldcat USING 'STRAS' 'TBL_KNA1' 'KNA1' ' ' 4 ' ' ' '
      PERFORM write_fieldcat USING 'TELF1' 'TBL_KNA1' 'KNA1' ' ' 5 ' ' ' '
      PERFORM write_fieldcat USING 'ORT01' 'TBL_KNA1' 'KNA1' ' ' 6 ' ' ' '
      PERFORM write_fieldcat USING 'PSTLZ' 'TBL_KNA1' 'KNA1' ' ' 7 ' ' ' '
      PERFORM write_fieldcat USING 'SORTL' 'TBL_KNA1' 'KNA1' ' ' 8 ' ' ' '
      PERFORM write_fieldcat USING 'ERNAM' 'TBL_KNA1' 'KNA1' ' ' 9 ' ' ' '
      PERFORM write_fieldcat USING 'SPRAS' 'TBL_KNA1' 'KNA1' ' ' 10 ' ' ' '
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 10 ' '.
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 11 ' '.
    perform write_fieldcat using '     ' 'TBL_KNA1' 'KNA1' ' ' 12 ' '.
    ENDFORM.                               " GET_FIELDCAT
    *&      Form  WRITE_FIELDCAT
          Write the Field Catalog data to the Field Catalog Table
         -->name   Field name
         -->tab    Table name
         -->st     Structure Name
         -->key    Is this field a Key?
         -->pos    Position Number
         -->length Field Length
         -->icon   Display as Icon
         -->hot    Hotspot
    FORM write_fieldcat USING name tab st key pos length icon hot.
      st_fieldcat-fieldname   = name.
      st_fieldcat-tabname     = tab.
      st_fieldcat-ref_tabname = st.
      st_fieldcat-key         = key.
      st_fieldcat-col_pos     = pos.
      st_fieldcat-outputlen   = length.
      st_fieldcat-icon        = icon.
      st_fieldcat-hotspot     = hot.
      APPEND st_fieldcat TO tbl_fieldcat.
      CLEAR st_fieldcat.
    ENDFORM.                               " WRITE_FIELDCAT
    *&      Form  PROCESS_USER_COMMANDS
          Interactive Reporting Commands
    FORM process_user_commands USING syst-ucomm LIKE syst-ucomm
                                     selfield TYPE slis_selfield.
    This subroutine is called when there is user interaction in the output
    In this case if the user double clicks the Customer Number then the
    program will call transaction XD03 and display the Customer Master
    Data
      CASE syst-ucomm.
        WHEN '&IC1'.
    get cursor field fieldname.
          READ TABLE tbl_kna1 INDEX selfield-tabindex.
          SET PARAMETER ID 'KUN' FIELD tbl_kna1-kunnr.
          CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                               " PROCESS_USER_COMMANDS
    *&      Form  GET_LAYOUT
      set the layout of the ALV.
      add color to the row?
    FORM get_layout.
      st_layout-info_fieldname    = 'COLOR'.
      st_layout-colwidth_optimize = 'X'.
      st_layout-get_selinfos      = 'X'.
    ENDFORM.                    " GET_LAYOUT
    *&      Form  get_data
          Get some data to play with
    FORM get_data.
      SELECT * FROM kna1 INTO CORRESPONDING FIELDS OF TABLE tbl_kna1
             UP TO 30 ROWS.
    ENDFORM.                    " get_data
    *&      Form  do_fancy_stuff
          Do some fancy pants stuff for example changing the color of
          lines and adding icons
    FORM do_fancy_stuff.
    Here we will demonstrate changing the color of ALV Record lines as
    well as displaying Icons
      LOOP AT tbl_kna1.
    All records where NAME1 begins with 'M', will be displayed in Bluish
    Green
        IF tbl_kna1-name1(1) EQ 'M'.
          tbl_kna1-color = 'C41'.  "Bluish Green
          MODIFY tbl_kna1 TRANSPORTING color.
        ENDIF.
    All records with no TELF1 will be displayed in White and have a
    Warning Icon
        IF tbl_kna1-telf1 IS INITIAL.
          tbl_kna1-color = 'C00'.  "White
          tbl_kna1-icon  = '@AH@'. "Warning Icon
          MODIFY tbl_kna1 TRANSPORTING icon color.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " do_fancy_stuff[/code]

  • Reports with more than 100 columns

    I am using Apex 3.2. I am using a classic report with more than 100 columns. So to use the custom heading in the report, I exported the page,did modification in exported sql file and imported back.
    But when I am passing the parameters from a input screen for the first time either it is showing the all data avilable in the database or with only header. If I do the refresh in input screen and try it then it is working as intended. I am updating at the below loaction of the page.Let me know if I have to update anything more in the sql file.
    declare
    s varchar2(32767) := null;
    begin
    s := null;
    wwv_flow_api.create_report_columns (
    p_id=> 200100535534034253 + wwv_flow_api.g_id_offset,
    p_region_id=> 2003453533453 + wwv_flow_api.g_id_offset,
    p_flow_id=> wwv_flow.g_flow_id,
    p_query_column_id=> 157,
    p_form_element_id=> null,
    p_column_alias=> 'XYZ',
    p_column_display_sequence=> 157,
    p_column_heading=> 'XYZ 123',
    p_column_alignment=>'LEFT',
    p_disable_sort_column=>'Y',
    p_sum_column=> 'N',
    p_hidden_column=> 'N',
    p_display_as=>'WITHOUT_MODIFICATION',
    p_pk_col_source=> s,
    p_column_comment=>'');
    end;
    /

    Hi,
    Its just a general thought and I realize you know your application and user community better I do, but do you think your users are going to be very happy when they are presented with a report with more than a hundred columns? Have you considered maybe presenting the data in some sort of rolled up form from which the user can then drill down to the data they are particularly interested in. Also, I'm sure your LAN administrator would be happy not to see 100+ column by x number row reports being regularly shipped across the network.
    Also, 100+ column reports suggests tables with 100+ columns which are probably not designed in a very relationally compliant way. I find that good DB design usually results in applications that have to make less compromises, such as hacking export files in order to fool the API into making ridiculous, unsupported and unsupportable compromises.
    Just a thought..................
    Regards
    Andre

Maybe you are looking for

  • How do I sync 3 email accounts with iPhone

    I have 3 email accounts all currently appearing on iMac (using entourage). I tried mobileme and couldn't seem to get all 3 to work. Had a chat with apple support and they say I can't use mobileme for more than 1 email address. What is the best was to

  • App Manager gives Download Error msg

    Hello, Just signed up for the cloud service.  i installed the Application Manager.  as soon as it opens, it gives a "download error.  Please contact customer support" message.  there is no other infomation on the screen and the app window is blank. I

  • Setting up a webservice url for consumption in browser

    Hi, I am new at webservices and all this fancy stuff... I managed to set up a webservice wrapper in NW Developer Studio for my stateless session bean endpoint creating an order in our 3rd party erp system. So far so good, I ceated a client proxy and

  • Old 2005 Video iPod - How do I take music off and add to my iTunes music library?  And battery life issues...

    I bought my husband a Video iPod clear back in 2005.  I bought the 30GB serial No 4V544C1WTXK Model number A1136.  Yes, very, very old.  However, it is an Apple product and therefore should be good forever right?    We actually rarely used it then an

  • Looking for a Edge/JS/DPS tutor

    Hi I'm working on a project using Adobe DPS. Id like to incorporate some of the more complex Edge effects (like controlling the timeline via a scrollable frame with DPS for playback on iOS). Everything Ive seen, and tried, works fine on a browser but