Assigning Column Headers Dynamically in ALV output

Hello Experts,
I have to create dynamic column headers based on the user input on the selection-screen. Basically users enter the period and the ALV output has to create the column headers dynamically for that along with some standard columns.
For eg, The selection screen is like this:
From:  'Q4' '2009'
To      'Q2'  '2011'.
Then I have to create 12 columns for the months and rest for the Quarters.
Then the output will be like this:
Material, Description,10/09, 11/09, 12/09, 01/10, 02/10, 03/10, 04/10, 05/10, 06/10, 07/10, 08/10, 09/10, Q4/10, Q1/11, Q2/11
I have built the logic to determine the number of colums for the periods based on input.
By reading other posts, I have learnt that I have to use call method cl_alv_table_create=>create_dynamic_table to get the functionality.
I have also looked at program BCALV_TABLE_CREATE for some help. It only has column headers in increasing order. But I am not able to understand How to pass the Column Header Label (for eg 10/09 or Q1/10) to the fieldcat dynamically.
Is there any blog/sample prog close to my req? Can anybody please please help me. I grealy appreciate it.
Thanks.

Hi Lope,
You need to filll column heading based on dynamic internal table column names.
In your final internal table, you will have some column names like '1009, 1109, 1209' .
While filling fieldcatalog you need to put your logic for column heading text.
If column name is 1009, concatenate '10 '  '/'   '09', or calculate the quarter 10 falls into ,and display Q4/09.
Regards,
Nisha Vengal.

Similar Messages

  • Need to display COlumn headers dynamically in ALG Grid

    Hello,
    I need to display column headers dynamically in alv grid Display with its corresponding value.
    Column headers should be picked from a field in Final Internal table and its corresponding field will also need to pick from the same table.
    T_final... Suppose Field STCTS - (To pick coulmn headers)
                                      CCNGN - (To pick appropriate value for that column)
    Can anybody explain me how i can pass these values to ALV Grid using
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
      EXPORTING
        IT_FIELDCATALOG           = Y_I_FCAT
      IMPORTING
        EP_TABLE                  = DY_TABLE.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Any suggestions will be appreciated....
    Regards,
    Kittu

    Hi,
    Go thru this link, and the code of Mr.Dev Parbutteea
    Re: Probelm with Using Field Symbol in FM
    thanks
    Mahesh

  • Two headers in an ALV Output

    Hi,
    Searched but could find anything.
    Would anybody know how i could code 2 headers in an ALV output.
    Tnks.
    eg..
    Month1      Month2
    Value1 Value2  Value1 Value2
    5           6           7          8

    Hi,
    Check this thread
    Re: multiple headers in alv output
    aRs

  • Create grouped column headers dynamically

    Hi all,
    I want to create grouped column headers dynamically.
    DATA lr_table_column TYPE REF TO cl_wd_table_column.
    DATA lr_column_group TYPE REF TO cl_wd_table_column_group.
    DATA lr_caption TYPE REF TO cl_wd_caption.
    lr_table_column = cl_wd_table_column=>new_table_column( ).
    lr_table_column->set_table_cell_editor( lr_input ).
    lr_caption = cl_wd_caption=>new_caption( ).
    lr_caption->set_text( 'Min' ).
    lr_column_group = cl_wd_table_column_group=>NEW_TABLE_COLUMN_GROUP( ).
    lr_column_group->set_header( EXPORTING the_header = lr_caption ).
    CALL METHOD lr_column_group->add_column
            EXPORTING
              index      = 1
              the_column = lr_table_column.
           lr_table->ADD_GROUPED_COLUMN( EXPORTING the_grouped_column = lr_column_group ).
    But I don't understand how I can get the grouping of the columns.
    The following structure should be realized:
    FR  | Headline 1  |  Headline 2  |
    SR  | Min |  Max   |  Min |  Max   |
    FR = first row
    SR = second row
    regards
    Edited by: Wolfgang Bauer on May 19, 2010 7:52 AM

    LOOP AT it_comp_header INTO wa_comp_header.
    Minimum
          counter = counter + 1.
          CONDENSE counter.
          CONCATENATE 'INPUT_' counter INTO id.
         c_count = sy-index.
          c_count = counter.
          CONDENSE c_count.
          CONCATENATE 'IT_BIN_COMP.MIN' c_count INTO binding.
          cl_wd_input_field=>new_input_field(
            EXPORTING
               bind_value             = binding
               id                     = id
            RECEIVING
              control                = lr_input ).
          lr_column_group = cl_wd_table_column_group=>new_table_column_group( ).
          lr_table_column = cl_wd_table_column=>new_table_column( ).
          lr_table_column->set_table_cell_editor( lr_input ).
          lr_caption = cl_wd_caption=>new_caption( ).
          lr_caption->set_text( 'Min' ).
          lr_table_column->set_header( lr_caption ).
          lr_column_group->add_column( lr_table_column ).
          lr_table_column = cl_wd_table_column=>new_table_column( ).
          lr_table_column->set_table_cell_editor( lr_input ).
          lr_caption = cl_wd_caption=>new_caption( ).
          lr_caption->set_text( 'Max' ).
          lr_table_column->set_header( lr_caption ).
          lr_column_group->add_column( lr_table_column ).
          lr_table_column = cl_wd_table_column=>new_table_column( ).
          lr_table_column->set_table_cell_editor( lr_input ).
          lr_caption = cl_wd_caption=>new_caption( ).
          lr_caption->set_text( 'Sorting Bin' ).
          lr_table_column->set_header( lr_caption ).
          lr_column_group->add_column( lr_table_column ).
          lr_caption = cl_wd_caption=>new_caption( ).
          text = wa_comp_header-chip.
          lr_caption->set_text( text ).
          lr_column_group->set_header( lr_caption ).
          lr_table->add_grouped_column( lr_column_group ).
        ENDLOOP.
    Sub product
        lr_column_group = cl_wd_table_column_group=>new_table_column_group( ).
        lr_table_column = cl_wd_table_column=>new_table_column( ).
        lr_table_column->set_table_cell_editor( lr_input ).
        lr_caption = cl_wd_caption=>new_caption( ).
        lr_caption->set_text( 'Sub Product' ).
        lr_table_column->set_header( lr_caption ).
        lr_column_group->add_column( lr_table_column ).
        lr_table->add_grouped_column( lr_column_group ).
    Remarks
        lr_column_group = cl_wd_table_column_group=>new_table_column_group( ).
        lr_table_column = cl_wd_table_column=>new_table_column( ).
        lr_table_column->set_table_cell_editor( lr_input ).
        lr_caption = cl_wd_caption=>new_caption( ).
        lr_caption->set_text( 'Remarks' ).
        lr_table_column->set_header( lr_caption ).
        lr_column_group->add_column( lr_table_column ).
        lr_table->add_grouped_column( lr_column_group ).

  • Getting column headers dynamically from input parameters in alv.

    Hi all,
    I am new to abap, can any one help me in getting column header dynamically through parameters in alv ?
    Eg:-
    i Have parametars for days field ,
    user inputs days as 10 20 30 40.
    Now I want to display in alv column headers as:-
    1st column-  'FROM 0 TO 10'
    2nd column- 'FROM 10 TO 20 '
    3rd column- 'FROM 20 TO 30'
    4th column- 'FROM 30 TO 40'
    5th column- 'FROM 40 TO 50'
    6th column- 'FROM 50 TO 60'
    thanks in advance........

    Check this code snippet:
    Step 1: Create a dynamic table based on the input in the selection screen.
    TYPE-POOLS: abap.
    DATA:
      lr_structdescr    TYPE REF TO cl_abap_structdescr,
      lr_tabledescr     TYPE REF TO cl_abap_tabledescr,
      lr_datadescr      TYPE REF TO cl_abap_datadescr,
      lt_components     TYPE abap_component_tab,
      ls_component      TYPE abap_componentdescr,
      lr_wa             TYPE REF TO data,
      lr_tab            TYPE REF TO data.
    DATA: lv_index TYPE sy-index.
    DATA: lv_index_num(5) TYPE n.
    DATA: lv_index_char(5) TYPE c,
          lv_iter TYPE i,
          lv_low TYPE numc2 VALUE 0,
          lv_high TYPE numc2 VALUE 10.
    DATA: lr_alv TYPE REF TO cl_salv_table.
    FIELD-SYMBOLS: <fs_field> TYPE ANY.
    FIELD-SYMBOLS: <fs_wa> TYPE ANY.
    FIELD-SYMBOLS: <fs_tab> TYPE table.
    PARAMETERS p_numcol(2) TYPE n DEFAULT 50.
    START-OF-SELECTION.
      lv_iter = p_numcol DIV 10.
      DO lv_iter TIMES.
        IF sy-index > 1.
          lv_low = lv_low + 10.
          lv_high = lv_high + 10.
        ENDIF.
        lv_index_num = sy-index.
        lv_index_char = lv_index_num.
        CONCATENATE 'FROM' lv_low 'TO' lv_high INTO ls_component-name
        SEPARATED BY '_'.
        ls_component-type =
        cl_abap_elemdescr=>get_p( p_length = 10 p_decimals = 2 ).
        INSERT ls_component INTO TABLE lt_components.
      ENDDO.
    * get structure descriptor -> lr_STRUCTDESCR
      lr_structdescr
      = cl_abap_structdescr=>create( p_components = lt_components
                                     p_strict = space ).
    * create work area of structure lr_STRUCTDESCR -> lr_WA
      CREATE DATA lr_wa TYPE HANDLE lr_structdescr.
      ASSIGN lr_wa->* TO <fs_wa>.
      lr_datadescr = lr_structdescr.
      lr_tabledescr
      = cl_abap_tabledescr=>create( lr_datadescr ).
    * Create dynamic internal table
      CREATE DATA lr_tab TYPE HANDLE lr_tabledescr.
      ASSIGN lr_tab->* TO <fs_tab>.
    * Populate the internal table
      DO 10 TIMES.
        DO.
          lv_index = sy-index.
          ASSIGN COMPONENT  lv_index  OF STRUCTURE <fs_wa> TO <fs_field>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_field> = sy-index.
        ENDDO.
        APPEND <fs_wa> TO <fs_tab>.
      ENDDO.

  • Change column headers dynamically in OBIEE

    hey guys.
    We are working on a BI module for Finance. The data mart captures data for Actuals/Forecasts and Budgets for entire year by months (for example Jan2008 will have Actual/Forecast value and Budget value & similarly for other months of the year) .
    Now while displaying on the dashboard reports the column header for the current month should read as Actual and for coming months it should read as Forecast.
    Any suggestions as to where we can implement this business rule so as to make the column header dynamic.
    Thanks
    OBIEE_user

    Seems like you don't know Venkat yet...
    http://oraclebizint.wordpress.com/2008/01/25/oracle-bi-ee-101332-dynamic-column-headers-using-presentation-variables-sets-and-conditional-formatting/

  • How to group the column headers using WDA ALV ?

    Hello All.
    How can I group the column headers as shown in the picture(chart), using  WDA  ALV.
    Thanks for any help !
    A
    B
    A1
    A2
    A3
    A4
    B1
    B2
    B3
    B4
    B11
    B12
    B13
    B21
    B22
    B23
    B31
    B32
    B33
    B41
    B42
    B43
    消息编辑者为:Cloud Li

    Hi ,
    This functionality was not exposed/supported in WDP ALV,however the same can be achieved in normal table(table UI element)
    The reason this isn't exposed directly in the ALV is because it is used internally when you do a grouped sort.  The ALV automatically buids group headers to explain the grouped sort/sum.
    Depending upon your requirements if you must have the group header and aren't using much else in the ALV, you might be better off using the plain old table. Below is a link to how to do group headers in the table UI element.
    Table
    Hope this helps you.
    Thanks
    KH

  • How Do I cahnge lables(column headers) dynamically?

    Hi,
    Dynamically, how do I change column headers based on some other value is the report?
    Thanks

    If the value you want as the column header is in the XML use the element.
    If you want different column headers based on a particular element in the XML then use conditional logic (if or when) wrapped around the column headers to do the selection at run time. See the user guide for examples of conditional processing in the template.
    cheers,
    Dave

  • Change column headers in ALV report

    Hi experts,
    I have created a new simple ALV report (it uses only internal tables, no structures). I would like to change the names of column headers in the ALV report. Is this possible? How can I do it?
    Thanks in advanced.

    Thanks for your reply,
    I am trying to use the code mentioned in the link but I think that something
    is missing, probably a CASE statement before WHEN in the LOOP.
    Can you help me? What do I have to put before WHEN statement?
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = <program name>
          i_structure_name       = <DDIC structure>
          i_bypassing_buffer     = 'X'
        CHANGING
          ct_fieldcat            = gi_fieldcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.                           "#EC *
      LOOP AT gi_fieldcat INTO wa_fieldcat.
          WHEN 'XXXX'.
            wa_fieldcat-seltext_s    = 'Fac'.
            wa_fieldcat-seltext_m    = 'Factory'.
            wa_fieldcat-seltext_l    = 'Factory'.
            wa_fieldcat-reptext_ddic = 'Factory'.
        MODIFY gi_fieldcat FROM wa_fieldcat.
      ENDLOOP.

  • How to make a particular row and column field editable in ALV

    Hi Experts,
    I have a requirement to make a particular row and column field editable in ALV output. Like i need to make 2nd row - 4th column editable of ALV output.
    Kindly help me out to solve this.
    Any help would be appreciated.
    Thanks,
    Ashutosh

    Hi Ashutosh,
    please check below, explained by some experts.
    In the below link  editing two columns MOD_RANK and TECH_RANK.
    These two columns will be in edit mode once after selecting the required record
    Editing single cell in a row of ALV table
    And also look for more info
    http://scn.sap.com/thread/884976

  • Dynamic value assignment to a particular column in a vertical ALV

    Hi Friends,
    In the present program ALV has 44 fields and output row is only one(with some field editable).
    My requirement is to change present output to vertical ALV and editable field should be available
    as editable.
    Now I have changed this to transposed ALV manually(not dynamically) with required fields editable.
    Now there is 44 rows and two column "FIELD and "VALUE'.Some values in the second column is editable.
    Previously output was like this:
    field1   field2  field3 ...
    val1     val2    val3   ...
    Now output is like:
    FIELD   VALUE
    field1  value1(type INT)
    field2  value2(type char5) Editable(need F4 help)
    field3  value3(type date)
    My present structure declaration is:
    types: begin of ty_itab,
            field type char 50,
            value type char70,
            celltab type lvc_t_styl,(for editing some values in VALUE column).
           end of ty_itab.
    data: itab type standard table of ty_itab.
    Now the second column i have declared as CHAR70 which contains only char
    values because to put all differt types of values to one single column named
    'VALUE'.
    But as field1 field2 field3... had differnt type of value like integer char date...I need to validate some values
    (specially those which are editable) before saving to custom DB table.
    So I need dynamic value assignment to VALUE column when preparing internal table for display.
    What I want to say is that VALUE column should be able to contain different type of values like INT, DATE, CHAR...etc
    Is the requirement is feasible?
    If yes then How should I declare the structure and populate different type of values within single column 'VALUE'.
    Also is it possible to have F4 helps in the second column (VALUE)???

    Hi Manab,
    I did something comparable: We have a very complex transaction with several subscreens with multiple fields to be filled with complex logic to create a very special contract. The requirement was to create a method to create a copy of this contract being able to apply some changes.
    I created a wizard (transaction SBPT_WIZARD_BUILDER - Wizard-Builder) to accomplish that. I grouped all the fields to just 3 logical groups and thius created 3 stesp where the user gets an ALV as you describe, but we have the rows like FIELD  with the new value editable. Additionally I have hidden fields with table name and field name so that I can determine the characteristics (datatype) at run time.
    The value fields are just strings (every ALV field is a text field on the surface).
    For editable fields, you have an event DATA_CHANGED. I used this method as a handler for the event:
    (I will leave out the wizard part here - maybe a good idea for a blog to explain that)
    METHOD handle_data_changed.
        CALL FUNCTION 'RS_CONV_EX_2_IN'
          EXPORTING
             input_external                     = <mod>-value
             table_field                        = ls_tabfield
    I also created handlers for F1 and F4
    Handler for CL_GUI_ALV_GRID->ONF1
    METHOD handle_f1.
        CALL FUNCTION 'HELP_OBJECT_SHOW_FOR_FIELD'
          EXPORTING
            called_for_tab   = lv_tabname
            called_for_field = lv_fieldname
          EXCEPTIONS
            object_not_found = 1
            sapscript_error  = 2
            OTHERS           = 3.
    Handler for CL_GUI_ALV_GRID->HANDLE_F4
    METHOD handle_f4.
      CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
        EXPORTING
          tabname    = lv_tabname
          fieldname  = lv_fieldname
        TABLES
          return_tab = lt_return_tab
        EXCEPTIONS
          OTHERS     = 5.
        er_event_data->m_event_handled = abap_true.
    * if er_event_data->m_event_handled is not set to abap_true, system will handle it.
    * In this context the message 'Keine Eingabehilfe verfügbar' will be displayed
    ENDMETHOD.
    This is just an excerpt from my project. It shows that you can do more in ALV as you knew.
    I tried to post a little more but the formatting break down, possibly a result of the character limit
    Regards,
    Clemens

  • Rows as columns and dynamic alv display

    Hi everyone,
    I need to build a intenal table dynamically as well as dispaly few rows as columns in alv output.
    I have seen posts where internal table has been created dynamicaaly as well seen the posts where rows of the table are displayed as columns but, can we achieve both the functionalities at same time.
    I have table as:
    SO     PO     Date    MAT    QTY  
    1        A       X    Y1      10 
                           K1      15
                           M2      11
    2       B       X1     Y2       5
                           M1      12
    3       C       1x     Z1      15
                           K1       6
                           L1      10
    Now the ouput has to be :
    SO     PO   Date     MAT-Y1    MAT-K1    MAT-Y2   MAT-L1     Mat-Z1    MAT-M1   MAT-M2
    1        A     X      10          15                                               11            
    2        B     X1                         5                             12                
    3        C     1X                  6                10          15                                       
    I will not be knowing the number of materials untill runtime(dynamic) and as well the rows has to be displayed as columns. Is it possible to do that.
    Regards
    Edited by: Madhu Posanipalli on Jun 6, 2011 4:51 PM

    Hi,
    Check below code. It will work definitly.
    *& Report  YTEST_PROG_RP
    REPORT  YTEST_PROG_RP.
    type-POOLs slis.
    TYPES: BEGIN OF ty_tab,
        so TYPE i,
        po TYPE c,
        date(2) TYPE c,
        mat(2) TYPE c,
        qty TYPE i,
    END OF ty_tab.
    DATA: itab TYPE STANDARD TABLE OF ty_tab INITIAL SIZE 0,
          jtab TYPE STANDARD TABLE OF ty_tab INITIAL SIZE 0,
          ktab TYPE STANDARD TABLE OF ty_tab INITIAL SIZE 0,
          wa_tab TYPE ty_tab, wa_j TYPE ty_tab, wa_k TYPE ty_tab.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
                   <fs_dyntable>,
                   <fs_fldval> type any.
    *ALV data declarations
    data: fieldcatalog type LVC_T_FCAT, " with header line, "slis_t_fieldcat_alv with header line,
          fieldcatalog1 TYPE LVC_s_FCAT,
          fieldcatalog2 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,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    DATA t_newtable TYPE REF TO data.
    DATA t_newline  TYPE REF TO data.
    DATA wa_flname TYPE string.
    *Start-of-selection.
    START-OF-SELECTION.
      perform data_retrieval.
      perform build_fieldcatalog.
      perform dynamic_table.
      perform build_layout.
      perform build_events.
      perform build_print_params.
      perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
      DATA: lv_field1 TYPE string, lv_cnt LIKE sy-tabix VALUE 3, itab_lines TYPE i.
      DATA: fieldname(20) TYPE c.
      DATA: fieldvalue(10) TYPE c.
      DATA: index(3) TYPE c.
      DATA: wa_cat LIKE LINE OF fieldcatalog2,
      wa_colno(2) TYPE n,
      wa_flname(5) TYPE c. .
      fieldcatalog1-fieldname   = 'SO'.
    fieldcatalog1-seltext   = 'SO'.
      fieldcatalog1-col_pos     = 1.
      fieldcatalog1-outputlen   = 2.
    fieldcatalog-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog1 to fieldcatalog.
      clear  fieldcatalog1.
      fieldcatalog1-fieldname   = 'PO'.
    fieldcatalog1-seltext   = 'PO'.
      fieldcatalog1-col_pos     = 2.
      fieldcatalog1-outputlen   = 2.
      append fieldcatalog1 to fieldcatalog.
      clear  fieldcatalog1.
      fieldcatalog1-fieldname   = 'DATE'.
    fieldcatalog1-seltext   = 'Date'.
      fieldcatalog1-col_pos     = 3.
      fieldcatalog1-outputlen   = 2.
      append fieldcatalog1 to fieldcatalog.
      clear  fieldcatalog1.
      LOOP AT itab INTO wa_tab.
        lv_cnt = lv_cnt + 1.
        CONCATENATE 'MAT-' wa_tab-mat into lv_field1.
        TRANSLATE lv_field1 TO UPPER CASE.
        fieldcatalog1-fieldname   = lv_field1.
       fieldcatalog1-seltext   = lv_field1.
        fieldcatalog1-col_pos     = lv_cnt.
        fieldcatalog1-outputlen   = 6.
        append fieldcatalog1 to fieldcatalog.
        clear fieldcatalog1.
        CLEAR: lv_field1, wa_tab.
      ENDLOOP.
      CLEAR lv_cnt.
    Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = fieldcatalog
        IMPORTING
          ep_table        = t_newtable.
      ASSIGN t_newtable->* TO <t_dyntable>.
      CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
      ASSIGN t_newline->* TO <fs_dyntable>.
    DESCRIBE TABLE fieldcatalog LINES itab_lines.
      loop at fieldcatalog INTO fieldcatalog1.
        CLEAR wa_cat.
        wa_cat-fieldname = fieldcatalog1-fieldname.
        wa_cat-seltext_s = fieldcatalog1-fieldname.
        wa_cat-outputlen = fieldcatalog1-outputlen.
        APPEND wa_cat TO fieldcatalog2.
        CLEAR fieldcatalog1.
      ENDLOOP.
    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-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    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_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
               is_layout               = gd_layout
                it_fieldcat             = fieldcatalog2[]
               it_special_groups       = gd_tabgroup
               it_events               = gt_events
               is_print                = gd_prntparams
               i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = <t_dyntable>
           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.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
      DATA: lv_index LIKE sy-tabix.
      wa_tab-so = 1.
      wa_tab-po = 'A'.
      wa_tab-date = 'X'.
      wa_tab-mat = 'Y1'.
      wa_tab-qty = 10.
      append wa_tab to itab.
      clear wa_tab.
      wa_tab-mat = 'K1'.
      wa_tab-qty = 15.
      append wa_tab to itab.
      CLEAR wa_tab.
      wa_tab-mat = 'M2'.
      wa_tab-qty = 11.
      append wa_tab to itab.
      CLEAR wa_tab.
      wa_tab-so = 2.
      wa_tab-po = 'B'.
      wa_tab-date = 'X1'.
      wa_tab-mat = 'Y2'.
      wa_tab-qty = 5.
      append wa_tab to itab.
      CLEAR wa_tab.
      wa_tab-mat = 'M1'.
      wa_tab-qty = 12.
      append wa_tab to itab.
      CLEAR wa_tab.
      wa_tab-so = 3.
      wa_tab-po = 'C'.
      wa_tab-date = '1x1'.
      wa_tab-mat = 'Z1'.
      wa_tab-qty = 15.
      append wa_tab to itab.
      CLEAR wa_tab.
    wa_tab-mat = 'K1'.
    wa_tab-qty = 6.
    append wa_tab to itab.
    CLEAR wa_tab.
      wa_tab-mat = 'L1'.
      wa_tab-qty = 10.
      append wa_tab to itab.
      CLEAR wa_tab.
      LOOP AT itab INTO wa_tab.
        if wa_tab-so is NOT INITIAL AND wa_tab-po is NOT INITIAL AND wa_tab-date is NOT INITIAL.
          wa_j-so = wa_tab-so.
          wa_j-po = wa_tab-po.
          wa_j-date = wa_tab-date.
          lv_index = wa_tab-so.
        else.
          READ TABLE itab INTO wa_j WITH KEY so = lv_index.
        ENDIF.
        wa_j-mat = wa_tab-mat.
        wa_j-qty = wa_tab-qty.
        APPEND wa_j to jtab.
        CLEAR: wa_tab, wa_j.
      ENDLOOP.
    endform.                    " DATA_RETRIEVAL
    Form  TOP-OF-PAGE                                                 *
    ALV Report Header                                                 *
    Form top-of-page.
    **ALV Header declarations
    *data: t_header type slis_t_listheader,
         wa_header type slis_listheader,
         t_line like wa_header-info,
         ld_lines type i,
         ld_linesc(10) type c.
    Title
    wa_header-typ  = 'H'.
    wa_header-info = 'EKKO Table Report'.
    append wa_header to t_header.
    clear wa_header.
    Date
    wa_header-typ  = 'S'.
    wa_header-key = 'Date: '.
    CONCATENATE  sy-datum+6(2) '.'
                  sy-datum+4(2) '.'
                  sy-datum(4) INTO wa_header-info.   "todays date
    append wa_header to t_header.
    clear: wa_header.
    Total No. of Records Selected
    describe table it_ekko lines ld_lines.
    ld_linesc = ld_lines.
    concatenate 'Total No. of Records Selected: ' ld_linesc
                       into t_line separated by space.
    wa_header-typ  = 'A'.
    wa_header-info = t_line.
    append wa_header to t_header.
    clear: wa_header, t_line.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
          exporting
               it_list_commentary = t_header.
               i_logo             = 'Z_LOGO'.
    endform.                    "top-of-page
          FORM USER_COMMAND                                          *
          --> R_UCOMM                                                *
          --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    Check function code
    CASE r_ucomm.
       WHEN '&IC1'.
      Check field clicked on within ALVgrid report
       IF rs_selfield-fieldname = 'EBELN'.
        Read data table, using index of row user clicked on
         READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
        Set parameter ID for transaction screen field
         SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
        Sxecute transaction ME23N, and skip initial data entry screen
         CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
       ENDIF.
    ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  BUILD_EVENTS
          Build events table
    form build_events.
    data: ls_event type slis_alv_event.
    call function 'REUSE_ALV_EVENTS_GET'
          exporting
               i_list_type = 0
          importing
               et_events   = gt_events[].
    read table gt_events with key name =  slis_ev_end_of_page
                              into ls_event.
    if sy-subrc = 0.
       move 'END_OF_PAGE' to ls_event-form.
       append ls_event to gt_events.
    endif.
       read table gt_events with key name =  slis_ev_end_of_list
                              into ls_event.
    if sy-subrc = 0.
       move 'END_OF_LIST' to ls_event-form.
       append ls_event to gt_events.
    endif.
    endform.                    " BUILD_EVENTS
    *&      Form  BUILD_PRINT_PARAMS
          Setup print parameters
    form build_print_params.
    gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
    gd_prntparams-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
    *&      Form  END_OF_PAGE
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.                    "END_OF_PAGE
    *&      Form  END_OF_LIST
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.                    "END_OF_LIST
    *&      Form  dynamic_table
          text
    -->  p1        text
    <--  p2        text
    FORM dynamic_table .
      DATA: lv_s1 TYPE string, lv_s2 TYPE string.
      DATA lv_mat TYPE string.
      DATA: fieldvalue(10) TYPE c.
      ktab[] = jtab[].
      delete ADJACENT DUPLICATES FROM ktab COMPARING so.
      loop at ktab INTO wa_tab.
    Field1
        wa_flname = 'SO'.
        fieldvalue = wa_tab-so.
        CONDENSE    fieldvalue NO-GAPS.
        ASSIGN COMPONENT  wa_flname
            OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
        <fs_fldval> =  fieldvalue.
        CLEAR fieldvalue.
    Field2
        wa_flname = 'PO'.
        fieldvalue = wa_tab-po.
        CONDENSE    fieldvalue NO-GAPS.
        ASSIGN COMPONENT  wa_flname
            OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
        <fs_fldval> =  fieldvalue.
        CLEAR fieldvalue.
    Field3
        wa_flname = 'DATE'.
        fieldvalue = wa_tab-date.
        CONDENSE    fieldvalue NO-GAPS.
        ASSIGN COMPONENT  wa_flname
            OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
        <fs_fldval> =  fieldvalue.
        CLEAR fieldvalue.
        loop at jtab INTO wa_j WHERE so = wa_tab-so.
          CONCATENATE 'MAT-' wa_j-mat INTO lv_mat.
          wa_flname = lv_mat.
          fieldvalue = wa_j-qty.
          CONDENSE    fieldvalue NO-GAPS.
          ASSIGN COMPONENT  wa_flname
              OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
          <fs_fldval> =  fieldvalue.
          CLEAR: wa_j, fieldvalue.
        ENDLOOP.
        APPEND <fs_dyntable> TO <t_dyntable>.
        CLEAR wa_tab.
        FREE <fs_dyntable>.
      ENDLOOP.
    ENDFORM.                    " dynamic_table
    Ram.

  • Strange behaviour in alv output display for a date column!

    hi friends,
    my alv output list display contains a column for budat (posting date), if this field has no value, then it displays a blank cell (space) in the output in my user login...but when the same report is run in another user login, even though the value of the column is null, it displays 00000000 (8 zeroes) rather than displaying a blank cell...i have set the field catalog property NO_ZERO = 'X'; is this property has anything to do with authorization to achieve its funcionality? am not sure...this is strange, as it is the same report, same field catalog that is being used..need some inputs on this
    thanks in advance
    Sathish

    There are 2 solutions for an adhoc solution you can change the field to a char10 field, this will solve your immediate problem of the 0 display. For a permanent solution you can check the user profile setting for the date for you as well as the concerned user. 
    Hope That Helps
    Anirban M.

  • FSG report output does not show column headers (XML Publisher)

    Hi everyone
    Iam required to create a template for an FSG report with 20 columns. Used copy of FSG:Fixed number of columns Template(FSGTEMP) to create the template because i need to do some conditional formatting(need to show negative values in red color).
    here is the problem:
    when i use the template and run the program the output i can see the row data but not the column headers..column headings are blank!
    regarding the conditional formatting, can anybody tell me how to give the condition
    iam able to give the condition for oracle reports but not for FSG reports as i dont see the column name in the 'data field' in conditional format
    Regards
    sam

    Open the report in Edit Mode Click on the reports and in the properties section Uncheck the
    Enable Document Cache Property and your issue should be resolved.

  • Runtime Error while summing a column in ALV output

    Dear All,
    I have developed an ALV Report and the report is giving output without any flaws.
    I have defined proper field catalog and displaying the results using REUSE_ALV_GRID function module.
    Now the report is generating Runtime Error while the user selects a column and click the SUM icon.
    The fields like Qty, or amounts are also theowing runtime error while summing up their column in the ALV output.
    What might be the reason and how to resolve this issu?
    Regards
    Pavan

    Hi ,
    I don't know how you have write  down the code but follow the below coding example:
    FOR TOTAL:
    there is a property of fieldcatalog, that is do_sum.
    USE COED LIKE:
    PERFORM fieldcat USING:
    '1' 'MATNR' 'I_MARD' 'MATERIAL NO' 'MARD' 'MATNR ' ' ',
    '2' 'NETWR' 'I_MARD' 'PLANT' 'MARD' 'WERKS' ' ',
    FORM fieldcat USING value(p_0029)
    value(p_0030)
    value(p_0031)
    value(p_0032)
    wa_fieldcat-col_pos = p_0029.
    wa_fieldcat-fieldname = p_0030.
    wa_fieldcat-tabname = p_0031.
    wa_fieldcat-reptext = p_0032.
    wa_fieldcat-do_sum = 'X'.
    APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM. " FIELDCAT
    in final output you will get the total of currency field.
    FOR SUB TOTAL:
    decleare: i_sort type standard table of slis_sortinfo_alv,
              wa_sort type slis_t_sortinfo_alv.
    wa_sort-spos = '1'.
    wa_sort-fieldname = 'field1'.
    wa_sort-subtot = 'X'.
    append wa_tab to i_sort.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    it_fieldcat = it_fieldcat
    it_sort = i_sort
    Hope this can solve your pbs.
    If you need more inputs let me know.
    Regards,
    Tutun

Maybe you are looking for

  • Update data from a view

    Hi, trying to update data from a view with: - Company (table) - Products (table) In a form, the user wants to update e.g: both products.product_name and Company.company_name. Is there a way to update a view records built on 2 tables ? Any idea will b

  • Migrating open transactions to a new CoA

    Hi I have a new CoA migration.But can by any chance the complete AR transactions be migrated. Putting it briefly,can i migrate closed and open transactions as well as applied and unapplied receipts of the previous CoA Regards Sthita Edited by: user60

  • Premiere CC 2014.1 + SAN: Can't import folders

    We used to edit off an of-the-shelf NAS and just recently upgraded to a Facilis TerraBlock SAN. Now whenever we try to import folders, Premiere won't import anything. The import dialogue shows up briefly, but the progress bar just skips to the end an

  • Import format and scripts

    Hi, I have been testing an import script in a location but it kept showing me an import error message. Now I had only slightly modified a script from another location which i wrote a couple weeks ago so I was pretty sure I was working in the right di

  • Asset under construction with MM

    I try to enter a service sheet by ts ML81N. The purchase order is for limits with Account Assignment Category 'A' -asset- and Item Category is 'Service'. The asset class is 'asset under construction' (line item settlement). The problem is when I go t