Dynamic columns for ALV/classical

Hi friends,
I came across an issue where I need to create an output list based on the selection screen.
Example: In selection screen if user enters plant 1000 2000 3000 4000 .
I want the output table having columns 1000 2000 3000 4000 .
Please help me out how to accomplish this task.  Is  this functionality is possible with ALV..?
A sample code for this will really help me a lot .. or send me your valuable suggestions..
Thanks
Prasead K

Search sdn for [cl_alv_table_create=>create_dynamic_table|https://www.sdn.sap.com/irj/scn/advancedsearch?query=cl_alv_table_create%3d%3ecreate_dynamic_table&cat=sdn_all], there are already many threads and samples. Basically, you dynamically fill an ALV fieldcatalog, then use the method to create a dynamic internal table from this catalog, fill the internal table and display it.
Regards

Similar Messages

  • Dynamic columns in ALV report

    halo fellow SAPiens,
    i need to show dynamic columns for a particular material........the scenario is as follows....
    1) there r 7 fixed columns describing the material...
    2)when the material returns back to the plant for some reason , i need to insert a column which shows the date and reason(char) of return.
    3)again after dispatching the material for some reason it comes back again a new column shld be displayed showin the date and reason(char).
    4)if the material doesnt come back...the report shows only 7 columns.
    any solution?

    try <a href="http://www.alvrobot.com.ar/home.php">here</a>  ......its a useful tool for dealing with ALV
    <b>reward points if useful</b>

  • Define Dynamic column for integrated inbox

    hi ,
    can any one explain me what is the puprose of this setting.
    SPRO>SRM>Cross application basic settings>sap business workflow>define Dynamic columns for integarted inbox.
    what we maintain here and how it is helpful
    regards
    subhash

    Hi Subhash,
    Please check if the following link helps you:
    How to add an extra dynamic columns in workflow inbox?
    Regards,
    Saumya

  • Dynamic column in ALV Report

    Hi,
    We need to display amount fields in the ALV and that fields should be able to display both 3 decimals or 2 decimals at the same time.When we refer this as a character field it is not allowed for totals/subtotals .
    if we refer it as 3 decimals ,it is adding zero for 2 decimal  values.
    if we refer it as 2 decimals ,it is adding rounding off  for 2 decimal  values.
    How can we dynamically refer this field in order to handle both these cases at the same time?
    We tried with reference of CURR ,but no use.
    Any pointers in this regard are highly appreciated.
    Regards,

    Hi Kranti,
    if you want to display amount then you should use amount fields. Then you need another column for the currency displayed. In the field catalog, you reference the amount field to the currensy field using fieldcat component CFIELDNAME.
    Then all values are displayed with the number of decimals defined for the respective currency.
    Additionally, you will get separate subtotal lines for each currency.
    --  asked several times, answered several times --
    What serach term did you use?
    Kind regards,
    Clemens

  • To increase dynamically columns in ALV report

    hi everyone,
    Could any one give me a sample code ,to increase columns in ALV report output dynamically as record increase, i need to increase columns so that i can keep all the years data of a particular project in one row

    Please refer to the code piece
    *& Report  ZTEST_DYNAMIC_ALV
    REPORT  ztest_dynamic_alv.
    DATA: gt_fcat TYPE lvc_t_fcat,
          gw_grid TYPE REF TO cl_gui_alv_grid.
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-s01.
    PARAMETERS: p_number TYPE i.
    SELECTION-SCREEN : END OF BLOCK b1.
    ** Start of Selection
    START-OF-SELECTION.
    *1) Create Base Catalog
      PERFORM sub_create_base_catalog.
    *2) Add additional fields
      PERFORM sub_fill_addtional.
    *3) Display output data.
      PERFORM sub_display_output.
    *&      Form  SUB_CREATE_BASE_CATALOG
    *       Create Base catalog for display
    FORM sub_create_base_catalog .
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'ZSTRCT'
        CHANGING
          ct_fieldcat            = gt_fcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
    ENDFORM.                    " SUB_CREATE_BASE_CATALOG
    *&      Form  SUB_FILL_ADDTIONAL
    *       text
    FORM sub_fill_addtional .
      DATA: lw_fcat  TYPE lvc_s_fcat,
            lw_from  TYPE i,
            lw_data  TYPE REF TO data,
            lw_fname TYPE stfna,
            lw_index(2) TYPE n.
      FIELD-SYMBOLS: <l_output> TYPE table.
      DESCRIBE TABLE gt_fcat LINES lw_from.
      DO p_number TIMES.
        lw_from = lw_from + 1.
        lw_index = sy-index.
        CONCATENATE 'DYNA' lw_index INTO lw_fname SEPARATED BY '-'.
        lw_fcat-col_pos = lw_from.
        lw_fcat-fieldname = lw_fname.
        lw_fcat-tabname = '1'.
       lw_fcat-scrtext_l = lw_fcat-scrtext_m = lw_fcat-scrtext_s = lw_fname.
        APPEND lw_fcat TO gt_fcat.
        CLEAR lw_fcat.
      ENDDO.
    ** Convert gt_fcat to internal table.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = gt_fcat
        IMPORTING
          ep_table                  = lw_data
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc = 0.
    ** Create the internal table form field catalog.
        ASSIGN lw_data->* TO <l_output>.
    ** display the ALV data.
        CREATE OBJECT gw_grid
          EXPORTING
            i_parent          = cl_gui_container=>screen0
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc = 0.
          CALL METHOD gw_grid->set_table_for_first_display
            CHANGING
              it_outtab                     = <l_output>
              it_fieldcatalog               = gt_fcat
            EXCEPTIONS
              invalid_parameter_combination = 1
              program_error                 = 2
              too_many_lines                = 3
              OTHERS                        = 4.
          IF sy-subrc = 0.
            MESSAGE s000(zrak) WITH p_number 'DISPLAYED DYNAMICALLY'.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    " SUB_FILL_ADDTIONAL
    *&      Form  SUB_DISPLAY_OUTPUT
    *       text
    FORM sub_display_output .
      CALL SCREEN '9001'.
    ENDFORM.                    " SUB_DISPLAY_OUTPUT
    *&      Module  STATUS_9001  OUTPUT
    *       text
    MODULE status_9001 OUTPUT.
      SET PF-STATUS ' '.
      SET TITLEBAR 'MAIN00'.
    ENDMODULE.                 " STATUS_9001  OUTPUT
    *&      Module  USER_COMMAND_9001  INPUT
    *       text
    MODULE user_command_9001 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK' OR
             'CANC' OR
             '%EX'.
          SET SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9001  INPUT

  • Generating dynamic columns for a report

    Hi all,
          Can anybody pls. tell me how to output dynamic columns in a report. my req. is that i've to generate so many columns as there are no. of unique(a particular field value) rows in my internal table. for e.g say suppose i've 5 rows in my internal table which has 2 fields, one short text & it's corresponding value. so now my report output shud have 5 columns with the short text as the column heading & the their corresponding values below each column heading. i heard it can be done thru field-symbols. can anyone pls. guide me.

    Hi Sushma,
    This piece of code might be useful.
    The following sections will help you to understand the steps required to define a Dynamic ALV.
    Following symbol signifies:
    Þ                    Important
    Main Steps Required
    The following are the main steps that are to be performed for defining a dynamic Alv
    1.       Defining a field catalog
    2.       Defining the dynamic table
    3.       Filling data into the table
    4.       Displaying ALV list
    Defining a field catalog
    The purpose of defining a field catalog first in case of Dynamic ALV is somewhat different than in case of normal ALV. In case of Dynamic ALV the field catalog is used to define the final internal table that will hold the data, and would be used to display the final output.
    Þ It is very important to remember that the field catalog table be refreshed first, else it might give an error.
    For example:
    DATA: T_FIELDCAT TYPE LVC_T_FCAT,
    L_FIELDCAT TYPE LVC_S_FCAT.
       Refresh T_FIELDCAT.
      CLEAR L_FIELDCAT.
      L_FIELDCAT-FIELDNAME = 'LIFNR'.
      L_FIELDCAT-INTTYPE = ''.
      L_FIELDCAT-OUTPUTLEN  = 10.
      L_FIELDCAT-COLTEXT  = TEXT-002.
      APPEND L_FIELDCAT TO T_FIELDCAT.
    Defining the dynamic table.
    This table will hold the final data that needs to be displayed. To declare the table the following things need to be done.
    Declare a field symbol
    Displaying Alv List
    This is done in the same way as we do for normal Alv. Call function “REUSE_ALV_GRID_DISPLAY” and pass the field catalog table in the export parameters and the dynamic table in Tables.
    Reward Points if it is helpful.
    Reagrds,
    Kiran I

  • Dynamic columns in ALV

    Dear Experts,
    I want to display dynamc columns in ALV, how it possible.
    venkey

    create dynamic internal table from field catalog i m sending u some sample code hope it will help u.
    FORM create_dynamic_itab.
    Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fieldcat[]
        IMPORTING
          ep_table        = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    Create dynamic work area and assign to FS
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    ENDFORM.

  • Show dynamic columns in ALV table

    I have a question that i need to create report in ALV
    like this ...
    i need to select doc date e.g. from 03.11.2007 to 05.02.2008
    and the report is expected to show like this
    SO#   |  cust |  sales gp | 2007-11 order amt | 2007-12 order amt | 2008-01 order amt | 2008-02 order amt
    ____ |_____|________|________________|________________|________________|_________________
              |         |               |                            |                            |                            | 
    something like that ....
    the no. of period column which is depend on the range of selected doc date....
    so how to do that ?!?!?

    hi sky ,
      use dynamic table as:-
      Declaration for Dynamic Table:-
    FIELD-SYMBOLS: <dyn_table>  TYPE STANDARD TABLE,
                   <dyn_table1> TYPE STANDARD TABLE,
                   <dyn_wa1>,
                   <dyn_wa>.
    FIELD-SYMBOLS: <l_fs_dyn> TYPE ANY,
                   <l_fs_bom> TYPE ANY.
    *---Dynamic Internal Table
    DATA: dy_table            TYPE REF TO data,
          dy_table1           TYPE REF TO data,
          dy_line             TYPE REF TO data.
    Creation of Dynamic Internal Table:-
      CALL METHOD cl_alv_table_create=>create_dynamic_table
           EXPORTING
             it_fieldcatalog = fcat  (for which internal table needs to be built)
           IMPORTING
             ep_table = dy_table
           EXCEPTIONS
             generate_subpool_dir_full = 1
             OTHERS = 2
      IF sy-subrc <> 0.
      ENDIF.
    Population of Dynamic Internal Table:-
    CLEAR: l_tabix,
           w_tabix.
      ASSIGN dy_table->* TO <dyn_table>.
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
      ASSIGN dy_table->* TO <dyn_table1>.
      CREATE DATA dy_line LIKE LINE OF <dyn_table1>.
      ASSIGN dy_line->* TO <dyn_wa1>.
       LOOP AT it_parent.
        l_tabix = sy-tabix.
        LOOP AT fcat INTO ls_fcat TO 23."WHERE col_pos <= '19'.
            ASSIGN COMPONENT ls_fcat-fieldname
                OF STRUCTURE <dyn_wa> TO <l_fs_dyn>.
            ASSIGN COMPONENT ls_fcat-fieldname
                OF STRUCTURE it_parent TO <l_fs_bom>.
            <l_fs_dyn> = <l_fs_bom>.
          ENDIF.
        ENDLOOP
    Thanks & Regards,
    Ruchi Tiwari

  • Display dynamic columns in ALV

    Hi All,
    I have a requirement in which I have develop a report displaying material master basic data and classification data. The basic data I am getting from MARA and MAKT tables. And for classification data I am getting the class maintained from each material from tables INOB,KSSK and from KLAH, then I am getting the characteristics and its values by calling BAPI u2018BAPI_OBJCL_GETDETAILu2019 for each material .
    Now I have to prepare ALV  having column name for basic data (would be static) and characteristic name (would be dynamic, and I have to display characteristics values under it, for each material ).
    For example: if  material u2018CHWOJA4u2019 has 2 characteristics as u2018country (value u2018Franceu2019)u2019 and  u2018creation season(value u2018Decu2019)u2019  and second material u2018E50480u2019 has  3 characteristics as u2018Abacus (value u2018yesu2019)u2019 ,u2018country (value u2018Indiau2019)u2019 and  u2018 season(value Jank)u2019 , the  ALV output would be :
    Material Number;     Material description; Base Unit of Measure;Material Group; Abacus; Country;season          
    CHWOJA4; JACKET;PC;Z05; ; France;Dec          
    E50480;BRAZIL REAL;PC;Z06; yes; India;Jan               
    In short, my last column of the ALV would be the characteristic name and the content would be the char. value.
    Can you please suggest some ways to achieve this? A quick reply would be highly appreciated!
    Thanks,
    Vanitha

    Idea here is to have many fields for characterstic values in your output internal table.
    For eg.
    types : Begin of ty_mara,
               matnr type matnr_d,
               mtext type mktxt,
               char1 type string,
               char2 type string,
               char20 type string.
    Check for all the materials which has the maximum characterstic values. So, say for a material, there are 12 characterstics values and that is the maximum compared to anyother materials. Then in the field catalog hide the columns related to charactertics CHAR13 onwards till CHAR20.
    Note : I have assumed char20 as the max., which you can alter based on your scenario.
    Regards
    Ranganath

  • Dynamic Columns in ALV GRID

    Hi Folks,
    can any body please give some input on the follwoing.
    i want to display material created by and material
    created on for each material based on material selection
    from selction screen dynamically.
    like s_mat = 1, 2,3.
    o/p must be
    mat1 |creted by | creted on| mat2 |creted by | creted on|mat3 |creted by | creted on|
    like if iam inputting 3 materials i need 3*3 = 9 columns in my alv grid o/p.
    I have alreaady searched SDN  I am not gettting any thing related to my requirement, please post some sample caode as I am new ot OOABAP.
    Thanks,
    Shwetha.
    Moderator message : Not enough re-search before posting, specification dumping not allowed.  Thread locked.
    Edited by: Vinod Kumar on Nov 24, 2011 1:31 PM

    method handle_data_changed.
         data: ls_good type lvc_s_modi,
               li_diff type i,
               value type p DECIMALS 3,
               old_value type p DECIMALS 3,
               lw_outtab1 type gt_tab.
    clear value.
           loop at er_data_changed->mt_good_cells into ls_good.
           value = ls_good-value.
           old_value = ls_good-value.
            if value lt 0 or value gt 1.
               MESSAGE 'Value is out of range' TYPE 'I'.
              Read table gt_outtab1 into lw_outtab1 index ls_good-row_id .
               perform show_alv.
               clear ls_good.
            ENDIF.
          ENDCASE.
           ENDLOOP.
    I again created the table.. actually data is not changed in the internal table but still it shows the changed value in the alv grid. even in build the table again and call the refersh alv grid method..

  • Dsiplay Dynamic Column in ALV Grid

    Hellow everyone,
    i am using alv grid to display the stock in detail , I need date and stock qnty with labour hour dynamic , my requriend output is:
                                LVside                                 HV side                      Coreside
    StockNumber             Qnty        Date                         Qnty    Date              Qnty      Date
    10000014               14.1          10/11/2011                12.2  11/11/2011
    Plz tell me how can iget this , The LVside and HVside is constant and Qnty date label also constant only date and Qnty will change.
    Thanks

    Hi venkatesh   even my requirment is same,
    yes you are correct venkatesh actually i have static column but as you see i am getting the data as per follow
    in LVside total Qnty is 14.2 on Date 10.11.2011 of stockNum 100008 , so my requried out put is something like below
    StockNum                        LVside .... ..........................HVside
                              Qnty   | Date                              Qnty   | Date
    1000008                   14.2    10.11.2011                          5.2    11.11.2011
    My current Out put is :
    StockNum                10.11.2011 .................11.11.2011
    1000008                   14.2                            5.2   
    my refer code is :
    DATA: BEGIN OF i_alv OCCURS 0,
          ARBID TYPE AFRU-ARBID,
          BUDAT TYPE AFRU-BUDAT,
          WERKS TYPE AFRU-WERKS,
          LMNGA TYPE AFRU-LMNGA,
          AUFNR TYPE AFRU-AUFNR,
          KDAUF TYPE AUFK-KDAUF,
          KDPOS TYPE AUFK-KDPOS,
          VBELN TYPE VBAK-VBELN,
          KUNNR TYPE VBAK-KUNNR,
          NAME1 TYPE KNA1-NAME1,
          MATNR TYPE VBAP-MATNR,
          KDKG1 TYPE VBKD-KDKG1,
      end of i_alv.
    TYPES: BEGIN OF ty_data,
             BUDAT TYPE AFRU-BUDAT,
             ARBID TYPE AFRU-ARBID,
             aufnr TYPE AFRU-AUFNR,
             kdauf TYPE AUFK-KDAUF,
             name1 TYPE KNA1-NAME1,
             matnr TYPE VBAP-MATNR,
             kdkg1 TYPE VBKD-KDKG1,
            lmnga TYPE AFRU-LMNGA,
           END OF ty_data,
           tt_data TYPE STANDARD TABLE OF ty_data,
           BEGIN OF ty_dyn1,                                    "#EC NEEDED
    *         ARBID TYPE AFRU-ARBID,
    *         aufnr TYPE AFRU-AUFNR,
             kdauf TYPE AUFK-KDAUF,
             name1 TYPE KNA1-NAME1,
             matnr TYPE VBAP-MATNR,
             kdkg1 TYPE VBKD-KDKG1,
             kdkg2 TYPE VBKD-KDKG2,
             lmnga TYPE AFRU-LMNGA,
           END OF ty_dyn1,
           BEGIN OF ty_dyn2,                                    "#EC NEEDED
             date  TYPE AFRU-LMNGA,
           END OF ty_dyn2,
           BEGIN OF ty_cols,
             date TYPE BUDAT,
           END OF ty_cols,
           tt_cols TYPE SORTED TABLE OF ty_cols WITH UNIQUE KEY date.
    DATA: gt_data TYPE tt_data,
          gt_data2 type tt_data,
          gt_cols TYPE tt_cols,
          gs_col  TYPE ty_cols.
    thanks

  • Dynamic mapping for alv

    Hi All,
    I need to display three tables  using alv.
    i have used one alv component  in my application.
    In my context  i have three nodes ( for three tables )
    when i am trying to map  one node of my component control to  'DATA' of alv component
    its working fine. i am getting the data of one table .
    Now , my problem is for the remainig two tables . how these two nodes are mapped for the same alv 'DATA' attribute of alv component.
    Whether i need to create  two more  alv components or Is there any possible to dynamic mapping ?
    Thanks and Regards,
    sravan.

    Hi Sravan,
    Now , my problem is for the remainig two tables . how these two nodes are mapped for the same alv 'DATA' attribute of alv component
    You cann't map the multiple context nodes to the DATA node of interface controller.You have to declare 3 component usages.
    or
    you want to set the map the dynamically then use this code.
    data:l_ref_interfacecontroller type ref to iwci_salv_wd_table.
    l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
    l_ref_interfacecontroller->set_data( lo_node ).

  • Dynamic column in alv

    Hi Experts,
    In the selection screen i have 2 radiobuttons.I have 6 fields in my internal table , 5 of which have to be displayed for both the radiobutton options. When i click on the first radiobutton then i should be able to
    see all the 6 fields, but when i click on the 2nd radiobutton, only first 5 columns should be displayed.
    i.e. the 6 column should be displayed only for the 1st radiobutton option
    How do i do this

    Hi Priti,
    this may help..
    data: t_fcat type slis_t_fieldcat_alv with header line.
    prepare fieldcatalog for all 6 fields ,
    for 6th col chk parameter radio-button2
    if p_rad2= 'X'.
    t_fcat-no_out = 'X'.
    modify t_fcat transporting no_out where fieldname = 'COL6'.
    endif.
    Regards,
    Mdi.Deeba

  • Hide columns for ALV list output in SAP Query SQ01/SQ02

    Hi All,
    I have a requirement to hide the columns which are empty in sap query SQ01 alv list output.
    Please let me know this functionality available in Query (SQ01) like normal reports
    Regards,
    Venkat

    Hi,
    We just can't make changes in this case as this are all system generated programs.
    WE have to write our own reports to make things flexible to match our requirements.
    Things you are asking is not possible.
    Regards,
    Suvendu

  • Dynamic program for alv

    Hi
    i want a simple dynamic alv code .

    Hi Fozia,
    the program SALV_DEMO_TABLE_REAL_SIMPLE is very simple.
    Regards Rudi

Maybe you are looking for

  • Clicking 'more' at the bottom of the page doesn't work

    Howdy. When i scroll down to the bottom of the first page in of any category in this community, if i click on 'more' it doesn't show more discussions. i'm using a macbook pro with snow leopard. any ideas?

  • New keypress bug in N95 after v12 update + other b...

    Update v12 has rendered the whole phone practically useless. It misses keypresses - that is what is well known in this firmware, BUT the major pain in the **bleep** is that the end-call button doubles as a 9 on keypad and vice versa. I cannot press n

  • Is 1.3 Bios really better than 1.52B?? Neo2 Board and Some Observations!

    Hi All... I read this post on the forums and it got me thinking and i did some fiddling and made some observations.. This is whith regard to the 1.3Bios being better than the 1.52B Bios.. because it would let you run in turbo mode... Ok i've spent th

  • ASM files not in database

    Hi all, we have oracle 11.2.0 2 node cluster database. there are 20 database files for that database. but when i checked in that location appears 23 datafiles. looks like 3 datafiles are not related to the database. result is like below. i think firs

  • Failed to launch

    hi all, I hope someone can help, I'm sure i must be doing something really thick! I cant get the XE download to work. During install it says my 8080 port is busy and recommends 8081, ok... next error message, unable to register Oraoledblo.dll using r