ALV Operations on columns

Hi,
I want to perform some arithmetic operations on my columns for eg. i want add the contents of column1 and column2 and store the result in column3. i've made these three columns editable. Can anyone help me in this regard.

Hi Sai,
   For this you need to code for Cell Variant in ALV. Here is the Sample program SALV_WD_TEST_TABLE_CV which has implemented the Cell variant. Just check that you can easily get an idea about it.
Please see Package SALV_WD_DEMO.In that Package you will find many demo examples where ALV tables examples are given . It will help you.
Hope this will help!!!!
Cheers,
Darshna.

Similar Messages

  • In Alv table, a column is editable mode, but want few cells in read only

    Hi All,
    I have a ALV table which column A and B.
    Both are in editable mode. I want to make fews in column B, to be read only.
    How to make it. Please help me.
    Thanks
    Vimalraj

    hi,
    refer this program,
    *& Report  ZALV_COLOR_DISPLAY_EDIT
    REPORT  zalv_color_display_edit.
    TYPE-POOLS: slis.
    TABLES : zcust_master2.
    INTERNAL TABLE DECLARATION
    TYPES : BEGIN OF wi_zcust_master2,
            zcustid LIKE zcust_master2-zcustid,
            zcustname LIKE zcust_master2-zcustname,
            zaddr LIKE zcust_master2-zaddr,
            zcity LIKE zcust_master2-zcity,
            zstate LIKE zcust_master2-zstate,
            zcountry LIKE zcust_master2-zcountry,
            zphone LIKE zcust_master2-zphone,
            zemail LIKE zcust_master2-zemail,
            zfax LIKE zcust_master2-zfax,
            zstat LIKE zcust_master2-zstat,
            field_style  TYPE lvc_t_styl,
    END OF wi_zcust_master2.
    DATA: it_wi_zcust_master2 TYPE STANDARD TABLE OF wi_zcust_master2
                                                     INITIAL SIZE 0,
          wa_zcust_master2 TYPE wi_zcust_master2.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    DATA: it_fieldcat TYPE lvc_t_fcat,     "slis_t_fieldcat_alv WITH HEADER
    line,
          wa_fieldcat TYPE lvc_s_fcat,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE lvc_s_layo,     "slis_layout_alv,
          gd_repid     LIKE sy-repid.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM set_specific_field_attributes.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      wa_fieldcat-fieldname   = 'ZCUSTID'.
      wa_fieldcat-scrtext_m   = 'CUSTOMER ID'.
      wa_fieldcat-col_pos     = 0.
      wa_fieldcat-outputlen   = 10.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCUSTNAME'.
      wa_fieldcat-scrtext_m   = 'CUSTOMER NAME'.
      wa_fieldcat-col_pos     = 1.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZADDR'.
      wa_fieldcat-scrtext_m   = 'ADDRESS'.
      wa_fieldcat-col_pos     = 2.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCITY'.
      wa_fieldcat-scrtext_m   = 'CITY'.
      wa_fieldcat-col_pos     = 3.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZSTATE'.
      wa_fieldcat-scrtext_m   = 'STATE'.
      wa_fieldcat-col_pos     = 4.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCOUNTRY'.
      wa_fieldcat-scrtext_m   = 'COUNTRY'.
      wa_fieldcat-col_pos     = 5.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZPHONE'.
      wa_fieldcat-scrtext_m   = 'PHONE NUMBER'.
      wa_fieldcat-col_pos     = 6.
    wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZEMAIL'.
      wa_fieldcat-scrtext_m   = 'EMAIL'.
      wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      wa_fieldcat-col_pos     = 7.
      wa_fieldcat-outputlen   = 15.
      wa_fieldcat-datatype     = 'CURR'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZFAX'.
      wa_fieldcat-scrtext_m   = 'FAX'.
      wa_fieldcat-col_pos     = 8.
      wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZSTAT'.
      wa_fieldcat-scrtext_m   = 'STATUS'.
      wa_fieldcat-col_pos     = 9.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    FORM build_layout.
    Set layout field for field attributes(i.e. input/output)
      gd_layout-stylefname = 'FIELD_STYLE'.
      gd_layout-zebra             = 'X'.
    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'
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_callback_program = gd_repid
          is_layout_lvc      = gd_layout
          it_fieldcat_lvc    = it_fieldcat
          i_save             = 'X'
        TABLES
          t_outtab           = it_wi_zcust_master2
        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
          text
    -->  p1        text
    <--  p2        text
    FORM data_retrieval .
      DATA: ld_color(1) TYPE c.
      SELECT zcustid zcustname zaddr zcity zstate zcountry zphone zemail
    zfax zstat UP TO 10 ROWS FROM zcust_master2 INTO CORRESPONDING FIELDS OF
    TABLE it_wi_zcust_master2.
    ENDFORM.                    "data_retrieval
    *&      Form  set_specific_field_attributes
          populate FIELD_STYLE table with specific field attributes
    FORM set_specific_field_attributes .
      DATA ls_stylerow TYPE lvc_s_styl .
      DATA lt_styletab TYPE lvc_t_styl .
    Populate style variable (FIELD_STYLE) with style properties
    The following code sets it to be disabled(display only) if 'ZFAX'
    is NOT INITIAL.
      LOOP AT it_wi_zcust_master2 INTO  wa_zcust_master2.
        IF  wa_zcust_master2-zfax IS NOT INITIAL.
          ls_stylerow-fieldname = 'ZFAX' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
                                          "set field to disabled
          APPEND ls_stylerow  TO  wa_zcust_master2-field_style.
          MODIFY it_wi_zcust_master2  FROM  wa_zcust_master2.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "set_specific_field_attributes
    Regards,
    K.Tharani.

  • In ALV  maintain  one column as color Green

    Hi ,
    In ALV  maintain  one column as color Green
    Thanks,
    Asha

    There are options in ALV grid to color whole row or cell, you want column (bad luck) so you will have to color cells.
    1-Add a field of type LVC_T_SCOL to the internal table.
    2-Fill the internal table with your application data.
    3-Loop once again at the table, add one record into the LVC_T_SCOL field, with the fieldname of the column and the color you want, update every record.
    4-In the layout of the grid, give the extra field name to subfield CTAB_FNAME.
    - Réf: Coloring Cells in ALV Grid Control (BC-SRV-ALV)
    - Sample: Program to color columns , rows and cells of an alv grid(oops)
    Regards,
    Raymond

  • How Format Text in ALV Colum when Column set as TEXTVIEW

    I am displaying ALV with Multiple Column's , One of the Column is TEXTVIEW .
    When ALV is Displayed TEXT Column Comes as Continues TEXT  and is Not Formatted .
    Now when i want to edit this text i am Calling another View which contains UI element Formated textview  . This Formated textview  will display correct Formatted Text . but when i save it and Come back to ALV again i do see continues text .
    I use the cl_salv_wd_uie_text_view to set the ALV Column as text view.
    Is there any way where in i can display the Formatted text in ALV Column ?
    Thanks in Advance
    Badarinarayan patil

    Hi ,
    You cannot use the Formatted TextView as a celleditor in table or ALV , its not provided by SAP .
    Regards
    Yash

  • Hierarchical ALV - enabling row/column input

    Hello,
    I'm going to incoporate the hierarchical ALV in a report.  Let's say I have 5 item rows for a header row, is it possible to make individiual rows input enabled?  Meaning, of the 5 item rows, I wish to make two of them editable, but not the other three. 
    I've done the standard ALV and made columns input enabled when building the fieldcat, but this applied to all rows, which I don't want in my scenario.
    Any help would be appreciated.
    Thanks

    Hello,
    Input enable is a parameter of fieldcat but you have to specify the internal table that you used in header row or item row.
    You create a data ZHEAD and ZITEM that you transfer in fieldcat data "table"
    Don't forget the clear when youo fill this internal table
    Regards
    sebastien

  • On ALV report in1 column I want to put Icon on every row of that column.

    On ALV report there is 1 column I want to put Icon on every row of that column.That ALV program uses object oriented concept all class and methods.
      I want to use that icon on that row. That icon name is ‘ICON_OKAY’
    In my program when I assign values to internal table at that time I am assigning that ‘ICON_OKAY’ value to that row as follow.
    Itab-
    Itab-icon = ICON_OKAY.
    Append itab.

    please follow below procedure to display icon in ALV
    1) In corresponding fieldcatelog entry do
    fieldcatalog-icon = 'X'
    2) While filling the internal table fill the corresponding key value of icon , for example ICON_OKAY value is '@0V@' so statement would be
    Itab-icon = '@0V@'
    to get list of corresponding key for icon open include <ICON> in se38

  • Multiple Hotspots in a ALV Grid single column

    Hi Experts,
    My ALV Grid report output looks like below....
    If you observe below output, column 3 has multiple documents each one separated by ' ; '. Now, I would like to assign hotspot on each documents like DOC1, DOC2, DOC3, etc.
    Heading#:          COL1 | COL2 | COL3 |
    Records1:              1      |  xxxxx  | _DOC1_ ; DOC2 ; *DOC3*
    Records2:              2      |  xxxxx  | _DOC1_ ; DOC5 ;
    I know, we can assign hotspot for entire column. but my requirement is multiple hot spots in a single column.
    Please help me on this?
    Thanks in Advance
    Raghu

    As I mentioned earlier,
    My ALV Grid report output looks like below....
    Heading#: FIELD1 | FIELD2 | FIELD3 |
    Records1: 1 | xxxxx | DOC1 ; DOC2 ; DOC3
    Records2: 2 | xxxxx | DOC1 ; DOC5 ;
    If you observe above output, field 3 has multiple documents each one separated by ' ; '.
    When I click on DOC1, it supposed to display related picture on the POP-Up Screen. Similarly when I click on DOC2, it supposed to display that document picture on POP-up screen.
    Before going to do this, first I need to assign hotspots on each documents like DOC1, DOC2, DOC3, etc.
    Please help me.

  • ALV Operations In Webdynpro for ABAP

    Hello Experts,
                          I have a requirement in ALV table in which I want To make one column as link. On clicking of that link a textedit UI element should be created on the same page on top of ALV Table. Please Suggest me how to display textedit on the same page above the ALV table and also how to create link of the column.
    Thanks,
    Pratibha

    Hi,
    To create all the cells of a column as a link follow this thread:
    Re: Creating hyperlink in column based on data, in ALV Web Dynpro ABAP
    You have to set the cell editor as linktoaction. The corresponding click you can capture in event ON_CLICK ( define your own event handler for this ALV event ).
    You can create a textedit box whose visiblity is bound to a context attribut of type wdy_boolean, on the event handler of click you can just change this attribute property and set it to true and bind it back.
    Regards
    Manas Dua

  • ALV GRID Display Column Width problem when filtering

    Hello All,
       When i displaying ALV Grid Display ,i selected one column and set filter for that.
    the problem is column width at display is 12 charecters but in filter it is allowing only 10 charecters to enter which is wrong. i am unable to set filter.please give solution.
    Thanks
    Sandeep.G

    hello i am calling perform, ineed to set OUTPUTLEN according to field length how can i do that.
    FORM fill_fieldcat  USING  p_field TYPE slis_fieldcat_alv-fieldname
                               p_text  TYPE slis_fieldcat_alv-seltext_l
                               p_flag TYPE c.
      wa_fieldcat-fieldname    = p_field.
      wa_fieldcat-seltext_l    = p_text.
      wa_fieldcat-no_out  = p_flag.
       wa_fieldcat-outputlen = 20.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.

  • Excel Download of ALV with one column containing leading zeros

    Hello Experts,
    I have the requirement in which the first column is of type company code (T001-BUKRS). So if the company code is '0061', then on the ALV display its displayed as '0061', but when it is downloaded to Excel sheet, it shows '61' in place of '0061'.
    Is there any way we can display in the downloaded Excel as 0061?
    Any pointers could help.
    Regards,
    Mansi.

    Hi Mansi,
    I think its because of excel property.You can format cell of excel to category 'special'.
    regards
    vivek

  • ALV display custom columns

    Hello experts,
    I am currently working on the report to display ACQUISITION PRICE and RENEWAL PRICE of some equipments. The renewal price will be calculated according to CPI, the CPI value should be entered by user. Based on this CPI the report should display renewal price of the equipments in Specific Column. I don't understand how to get Custom Column and how to display values in it. The formula for the renewal price will be
                                  New Price = Acquisition Price + (Acquisition Price * (CPI/100))
    I have defined the column with Data Type I. But i dont know weather it is correct or not. If anybody have any idea regarding this issue please share it with me.
    Thanks,
    Avadhut

    I have created own report its TYPE 1. I have used ALV in it. I am able to display all the other values but RENEWAL PRICE. There is CHECKBOX on selection screen, when selected report should display renewal prices automatically according to CPI. But i dont understand how to display it in custom column. The code is as below.
    *& Report  ZIE_EQUIP_RENEWAL_COST
    REPORT  zie_equip_renewal_cost.
    types: begin of g_outtab,
             EQUNR TYPE EQUNR,
             EQKTX TYPE KTX01,
             ANSDT TYPE ANSDT,
             ANSWT TYPE ANSWT,
             INVNR TYPE INVNR,
           end of g_outtab.
    TABLES: v_equi,                     "Equipments
            equi,                       "Equipment Master
            eqkt.                       "Equipment Text
    TYPE-pools: slis.
    DATA:
           alv_container   TYPE REF TO cl_gui_custom_container,
           alv_grid        TYPE REF TO cl_gui_alv_grid,
    *       event_receiver  TYPE REF TO lcl_event_receiver,
           str_outtab      TYPE g_outtab,
           gr_table   type ref to cl_salv_table.
    DATA: it_data TYPE TABLE OF v_equi,
          it_equi TYPE STANDARD TABLE OF equi,
          it_eqkt TYPE STANDARD TABLE OF eqkt,
          str_data TYPE v_equi.
    DATA: ok_code LIKE sy-ucomm,
          save_ok LIKE ok_code.
    **              Selection Screen                                      **
    SELECTION-SCREEN BEGIN OF BLOCK rammi WITH FRAME TITLE text-010.
    SELECT-OPTIONS:
      s_equnr  FOR equi-equnr,                                   "Equipment Number
      s_eqtyp  FOR equi-eqtyp,                                   "Equipment Type
      s_invnr  FOR equi-invnr,                                   "Inventory Number
      s_ansdt  FOR equi-ansdt,                                   "Acquisition date
      s_answt  FOR equi-answt.                                   "Acquisition Value
    *PARAMETERS: p_waers TYPE v_equi-waers DEFAULT 'ISK',         "Currency Key
    PARAMETERS: p_cpi   TYPE i,
                p_test AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK rammi.
    **              Start of Selection                                    **
    START-OF-SELECTION.
      CLEAR: it_data, it_equi, it_eqkt.
      PERFORM read_data.
      CALL SCREEN 100.
    *&      Form  read_data
    FORM read_data.
      SELECT a~equnr b~eqktx a~ansdt a~answt
        FROM equi AS a
        INNER JOIN eqkt AS b ON a~mandt = b~mandt
        AND a~equnr = b~equnr
    *    AND spras = sy-langu
      INTO CORRESPONDING FIELDS OF TABLE it_data
        WHERE a~equnr   IN s_equnr
          AND a~eqtyp   IN s_eqtyp
          AND a~ansdt   IN s_ansdt
          AND a~answt   IN s_answt.
    ENDFORM.                    " read_data
    INCLUDE zie_equip_renewal_cost_stato01.
    INCLUDE ZIE_EQUIP_RENEWAL_COST_USERI01.
    *&      Form  set_columns_technical
    *       text
    form set_columns_technical using ir_columns type ref to cl_salv_columns.
        data: lr_column1 type ref to cl_salv_column_table,
              lr_column type ref to cl_salv_column.
      try.
          lr_column1 ?= ir_columns->get_column( 'EQUI-EQUNR' ).
          lr_column1->set_F4( if_salv_c_bool_sap=>FALSE ).
        catch cx_salv_not_found.                            "#EC NO_HANDLER
      endtry.
      try.
          lr_column = ir_columns->get_column( 'EQKT-eqktx' ).
          lr_column->set_technical( if_salv_c_bool_sap=>true ).
        catch cx_salv_not_found.                            "#EC NO_HANDLER
      endtry.
      try.
          lr_column = ir_columns->get_column( 'EQUI-ansdt' ).
          lr_column->set_technical( if_salv_c_bool_sap=>true ).
        catch cx_salv_not_found.                            "#EC NO_HANDLER
      endtry.
      try.
          lr_column = ir_columns->get_column( 'EQUI-answt' ).
          lr_column->set_technical( if_salv_c_bool_sap=>true ).
        catch cx_salv_not_found.                            "#EC NO_HANDLER
      endtry.
    endform.                    " set_columns_technical(

  • How to merge the contents of two rows in ALV for particular column data

    Hi Experts,
    I have a requirement to merge various rows in a ALV Grid with same data for particular columns.
    Kindly Suggest,
    Thanks and Best Regards,
    Sahil

    Hi,
    Just fill the and pass the SORT table for what ever fields you want this functionality.
      DATA: lwa_sort  TYPE lvc_s_sort.
      CLEAR lwa_sort.
      MOVE: 'VBELN' TO lwa_sort-fieldname,
                   'X' TO lwa_sort-up,
    APPEND lwa_sort TO i_sort.
    Now pass this SORT table to ALV FM.
    Thanks,
    Vinod.

  • ALV Display dynamic column with multiline header

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

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

  • ALV with dynamic columns and description labels in header titles

    Hi everybody,
    I have to implement an ALV whose columns are not defined until runtime. Is it possible to do that in some simple way? Is it necessary to use objects to define this kind of ALV's?
    And another one query, is it possible to add description labels to column headers so that when the user points with the cursor in them he/she gets a little explanation about the detail of the column (for example, description name of the product hierarchy when pointing to the column named with one of the existing hierarchies, i.e 010102102)
    Thanks in advance,

    for your first question check this
    Just check this sample from one of the SAP site
    ABAP Code Sample for Dynamic Table for ALV with Cell Coloring
    Applies To:
    ABAP / ALV Grid
    Article Summary
    ABAP Code Sample that uses dynamic programming techniques to build a dynamic internal table for display in an ALV Grid with Cell Coloring.
    Code Sample
    REPORT zcdf_dynamic_table.
    * Dynamic ALV Grid with Cell Coloring.
    * Build a field catalog dynamically and provide the ability to color
    * the cells.
    * To test, copy this code to any program name and create screen 100
    * as described in the comments. After the screen is displayed, hit
    * enter to exit the screen.
    * Tested in 4.6C and 6.20
    * Charles Folwell - [email protected] - Feb 2, 2005
    DATA:
    r_dyn_table TYPE REF TO data,
    r_wa_dyn_table TYPE REF TO data,
    r_dock_ctnr TYPE REF TO cl_gui_docking_container,
    r_alv_grid TYPE REF TO cl_gui_alv_grid,
    t_fieldcat1 TYPE lvc_t_fcat, "with cell color
    t_fieldcat2 TYPE lvc_t_fcat, "without cell color
    wa_fieldcat LIKE LINE OF t_fieldcat1,
    wa_cellcolors TYPE LINE OF lvc_t_scol,
    wa_is_layout TYPE lvc_s_layo.
    FIELD-SYMBOLS:
    <t_dyn_table> TYPE STANDARD TABLE,
    <wa_dyn_table> TYPE ANY,
    <t_cellcolors> TYPE lvc_t_scol,
    <w_field> TYPE ANY.
    START-OF-SELECTION.
    * Build field catalog based on your criteria.
    wa_fieldcat-fieldname = 'FIELD1'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 1'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    wa_fieldcat-fieldname = 'FIELD2'.
    wa_fieldcat-inttype = 'C'.
    wa_fieldcat-outputlen = '10'.
    wa_fieldcat-coltext = 'My Field 2'.
    wa_fieldcat-seltext = wa_fieldcat-coltext.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Before adding cell color table, save fieldcatalog to pass
    * to ALV call. The ALV call needs a fieldcatalog without
    * the internal table for cell coloring.
    t_fieldcat2[] = t_fieldcat1[].
    * Add cell color table.
    * CALENDAR_TYPE is a structure in the dictionary with a
    * field called COLTAB of type LVC_T_SCOL. You can use
    * any structure and field that has the type LVC_T_SCOL.
    wa_fieldcat-fieldname = 'T_CELLCOLORS'.
    wa_fieldcat-ref_field = 'COLTAB'.
    wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
    APPEND wa_fieldcat TO t_fieldcat1.
    * Create dynamic table including the internal table
    * for cell coloring.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fieldcat1
    IMPORTING
    ep_table = r_dyn_table
    EXCEPTIONS
    generate_subpool_dir_full = 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.
    * Get access to new table using field symbol.
    ASSIGN r_dyn_table->* TO <t_dyn_table>.
    * Create work area for new table.
    CREATE DATA r_wa_dyn_table LIKE LINE OF <t_dyn_table>.
    * Get access to new work area using field symbol.
    ASSIGN r_wa_dyn_table->* TO <wa_dyn_table>.
    * Get data into table from somewhere. Field names are
    * known at this point because field catalog is already
    * built. Read field names from the field catalog or use
    * COMPONENT <number> in a DO loop to access the fields. A
    * simpler hard coded approach is used here.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'ABC'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'XYZ'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'TUV'.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    <w_field> = 'DEF'.
    APPEND <wa_dyn_table> TO <t_dyn_table>.
    * Color cells based on your criteria. In this example, a test on
    * FIELD2 is used to decide on color.
    LOOP AT <t_dyn_table> INTO <wa_dyn_table>.
    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_dyn_table> TO <w_field>.
    * Get access to internal table used to color cells.
    ASSIGN COMPONENT 'T_CELLCOLORS'
    OF STRUCTURE <wa_dyn_table> TO <t_cellcolors>.
    CLEAR wa_cellcolors.
    wa_cellcolors-fname = 'FIELD2'.
    IF <w_field> = 'DEF'.
    wa_cellcolors-color-col = '7'.
    ELSE.
    wa_cellcolors-color-col = '5'.
    ENDIF.
    APPEND wa_cellcolors TO <t_cellcolors>.
    MODIFY <t_dyn_table> FROM <wa_dyn_table>.
    ENDLOOP.
    * Display screen. Define screen 100 as empty, with next screen
    * set to 0 and flow logic of:
    * PROCESS BEFORE OUTPUT.
    * MODULE initialization.
    * PROCESS AFTER INPUT.
    CALL SCREEN 100.
    * MODULE initialization OUTPUT
    MODULE initialization OUTPUT.
    * Set up for ALV display.
    IF r_dock_ctnr IS INITIAL.
    CREATE OBJECT r_dock_ctnr
    EXPORTING
    side = cl_gui_docking_container=>dock_at_left
    ratio = '90'.
    CREATE OBJECT r_alv_grid
    EXPORTING i_parent = r_dock_ctnr.
    * Set ALV controls for cell coloring table.
    wa_is_layout-ctab_fname = 'T_CELLCOLORS'.
    * Display.
    CALL METHOD r_alv_grid->set_table_for_first_display
    EXPORTING
    is_layout = wa_is_layout
    CHANGING
    it_outtab = <t_dyn_table>
    it_fieldcatalog = t_fieldcat2.
    ELSE. "grid already prepared
    * Refresh display.
    CALL METHOD r_alv_grid->refresh_table_display
    EXPORTING
    i_soft_refresh = ' '
    EXCEPTIONS
    finished = 1
    OTHERS = 2.
    ENDIF.
    ENDMODULE. " initialization OUTPUT

  • ALV Report - displaying column name in two fields.

    Dear All,
                 I am working on ALV report , report is ready but now i have to format it according to client requirment, in which have to show column name in two row like.
    supppose there is field by name
    "Date of receipt of processed Goods"
    can i display it like
    "Date of receipt of
    processed Goods "
    Assured points for suitable answer.
    Looking foward to your response.
    Best Regards,
    Gulrez Alam

    Hi Ellery,
    As Philipp said, there is no need for populating the field using PL/SQL. You would just need to go to the Paper Layout in the Reports Editor, click on "Text" in the Drawing toolbar, drag it to the appropriate place in your layout to create the field, and write what you want in that field. Below that, you can create the field(s) which will display the actual totals. I'm assuming that creating the totals field is not a problem.
    Navneet.

Maybe you are looking for