Symbols in ALV grid

Hi Friends,
      I want to show two different type of symbol in ALV grid report based on the line item status  ,How to do this one,can anybody help me  .
With Thanx
Elango

Hi,
use can use traffic lights to differntiate the line items. Here i sthe code for using traffic lights:
report  zkeerthi_alv2                           .
tables: vbak.
type-pools : slis.
data: begin of it_vbak occurs 0,
      icon type icon-id,
      vbeln like vbak-vbeln,
      audat like vbak-audat,
      vbtyp like vbak-vbtyp,
      auart like vbak-auart,
      augru like vbak-augru,
      netwr like vbak-netwr,
      waerk like vbak-waerk,
      end of it_vbak.
data: g_repid like sy-repid,
      wa_sort type slis_sortinfo_alv,
      it_sort type slis_t_sortinfo_alv,
      wa_layout type slis_layout_alv,
      it_fieldtab type slis_t_fieldcat_alv,
      wa_fieldcat type slis_fieldcat_alv.
selection-screen begin of block b1 with frame.
select-options:s_vbeln for vbak-vbeln,
               s_vbtyp for vbak-vbtyp default 'C'.
selection-screen end of block b1 .
selection-screen begin of block b2 with frame.
parameters: list radiobutton group rad1,
            grid radiobutton group rad1.
selection-screen end of block b2.
initialization.
  g_repid = sy-repid.
start-of-selection.
  select vbeln
         audat
         vbtyp
         auart
         augru
         netwr
         waerk into corresponding fields of table it_vbak
         from vbak where audat > '01/01/2004' and
         netwr > 0 and
         vbeln in s_vbeln and
         vbtyp in s_vbtyp.
  loop at it_vbak.
    if it_vbak-netwr < 10000.
      it_vbak-icon = '@08@'.
    elseif it_vbak-netwr > 10000 and it_vbak-netwr < 100000.
      it_vbak-icon = '@09@'.
    elseif it_vbak-netwr > 100000.
      it_vbak-icon = '@0A@'.
    endif.
    modify it_vbak index sy-tabix.
  endloop.
end-of-selection.
  perform sort_list.
  perform modify_fieldcat.
  perform layout_list.
*&      Form  sort_list
      text
-->  p1        text
<--  p2        text
form sort_list .
  clear wa_sort.
  wa_sort-fieldname = 'AUART'.
  wa_sort-spos = '1'.
  wa_sort-up = 'X'.
  append wa_sort to it_sort.
  clear wa_sort.
  wa_sort-fieldname = 'VBTYP'.
  wa_sort-spos = '2'.
  wa_sort-up = 'X'.
  append wa_sort to it_sort.
  clear wa_sort.
  wa_sort-fieldname = 'WAERK'.
  wa_sort-spos = '3'.
  wa_sort-up = 'X'.
  wa_sort-subtot = 'X'.
  append wa_sort to it_sort.
endform.                    " sort_list
*&      Form  layout_list
      text
-->  p1        text
<--  p2        text
form layout_list .
  clear wa_layout.
  if list = 'X'.
    wa_layout-zebra = 'X'.
    wa_layout-window_titlebar = 'LIST DISPLAY'.
    wa_layout-subtotals_text = 'SUBTOTAL'.
    wa_layout-totals_text = 'TOTAL'.
    call function 'REUSE_ALV_LIST_DISPLAY'
     exporting
  I_INTERFACE_CHECK              = ' '
  I_BYPASSING_BUFFER             =
  I_BUFFER_ACTIVE                = ' '
       i_callback_program             = g_repid
  I_CALLBACK_PF_STATUS_SET       = ' '
  I_CALLBACK_USER_COMMAND        = ' '
  I_STRUCTURE_NAME               =
       is_layout                      = wa_layout
       it_fieldcat                    = it_fieldtab[]
  IT_EXCLUDING                   =
  IT_SPECIAL_GROUPS              =
       it_sort                        = it_sort[]
  IT_FILTER                      =
  IS_SEL_HIDE                    =
  I_DEFAULT                      = 'X'
  I_SAVE                         = ' '
  IS_VARIANT                     =
  IT_EVENTS                      =
  IT_EVENT_EXIT                  =
  IS_PRINT                       =
  IS_REPREP_ID                   =
  I_SCREEN_START_COLUMN          = 0
  I_SCREEN_START_LINE            = 0
  I_SCREEN_END_COLUMN            = 0
  I_SCREEN_END_LINE              = 0
IMPORTING
  E_EXIT_CAUSED_BY_CALLER        =
  ES_EXIT_CAUSED_BY_USER         =
      tables
        t_outtab                       = it_vbak
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.
  elseif grid = 'X'.
    wa_layout-zebra = 'X'.
    wa_layout-window_titlebar = 'GRID DISPLAY'.
    wa_layout-subtotals_text = 'SUBTOTAL'.
    wa_layout-totals_text = 'TOTAL'.
    call function 'REUSE_ALV_GRID_DISPLAY'
     exporting
  I_INTERFACE_CHECK                 = ' '
  I_BYPASSING_BUFFER                = ' '
  I_BUFFER_ACTIVE                   = ' '
       i_callback_program                =  g_repid
  I_CALLBACK_PF_STATUS_SET          = ' '
  I_CALLBACK_USER_COMMAND           = ' '
  I_CALLBACK_TOP_OF_PAGE            = ' '
  I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
  I_CALLBACK_HTML_END_OF_LIST       = ' '
  I_STRUCTURE_NAME                  =
  I_BACKGROUND_ID                   = ' '
  I_GRID_TITLE                      =
  I_GRID_SETTINGS                   =
       is_layout                         = wa_layout
       it_fieldcat                       = it_fieldtab
  IT_EXCLUDING                      =
  IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
  IT_FILTER                         =
  IS_SEL_HIDE                       =
  I_DEFAULT                         = 'X'
  I_SAVE                            = ' '
  IS_VARIANT                        =
  IT_EVENTS                         =
  IT_EVENT_EXIT                     =
  IS_PRINT                          =
  IS_REPREP_ID                      =
  I_SCREEN_START_COLUMN             = 0
  I_SCREEN_START_LINE               = 0
  I_SCREEN_END_COLUMN               = 0
  I_SCREEN_END_LINE                 = 0
  IT_ALV_GRAPHICS                   =
  IT_HYPERLINK                      =
  IT_ADD_FIELDCAT                   =
  IT_EXCEPT_QINFO                   =
  I_HTML_HEIGHT_TOP                 =
  I_HTML_HEIGHT_END                 =
IMPORTING
  E_EXIT_CAUSED_BY_CALLER           =
  ES_EXIT_CAUSED_BY_USER            =
      tables
        t_outtab                          = it_vbak
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.
  endif.
endform.                    " layout_list
*&      Form  modify_fieldcat
      text
-->  p1        text
<--  p2        text
form modify_fieldcat .
  clear wa_fieldcat.
  wa_fieldcat-tabname   = 'IT_VBAK'.
  wa_fieldcat-fieldname = 'ICON'.
  wa_fieldcat-seltext_l  = 'LIGHTS'.
  wa_fieldcat-icon = 'X'.
WA_FIELDCAT-ddictxt = 'l'.
  wa_fieldcat-col_pos = 1.
  wa_fieldcat-outputlen = 10.
  append wa_fieldcat to it_fieldtab.
  clear wa_fieldcat .
  wa_fieldcat-tabname   = 'IT_VBAK'.
  wa_fieldcat-fieldname = 'VBELN'.
  wa_fieldcat-seltext_l  = 'SALES DOCUMENT'.
WA_FIELDCAT-ddictxt = 'l'.
  wa_fieldcat-col_pos = 2.
  wa_fieldcat-outputlen = 10.
  append wa_fieldcat to it_fieldtab.
  clear wa_fieldcat .
when 'maktx'.
  wa_fieldcat-tabname   = 'IT_VBAK'.
  wa_fieldcat-fieldname = 'AUDAT'.
  wa_fieldcat-seltext_l  = 'DATE'.
WA_FIELDCAT-ddictxt = 'l'.
  wa_fieldcat-col_pos = 3.
  wa_fieldcat-outputlen = 15.
  append wa_fieldcat to it_fieldtab.
  clear wa_fieldcat .
  wa_fieldcat-tabname   = 'IT_VBAK'.
  wa_fieldcat-fieldname = 'VBTYP'.
  wa_fieldcat-seltext_l  = 'SALES CATEGORY'.
  wa_fieldcat-col_pos = 4.
  wa_fieldcat-outputlen = 10.
  append wa_fieldcat to it_fieldtab.
  clear wa_fieldcat .
  wa_fieldcat-tabname   = 'IT_VBAK'.
  wa_fieldcat-fieldname = 'AUART'.
  wa_fieldcat-seltext_l  = 'SALES DOCUMENT TYPE'.
  wa_fieldcat-col_pos = 5.
  wa_fieldcat-outputlen = 10.
  append wa_fieldcat to it_fieldtab.
  clear wa_fieldcat .
  wa_fieldcat-tabname   = 'IT_VBAK'.
  wa_fieldcat-fieldname = 'AUGRU'.
  wa_fieldcat-seltext_l  = 'ORDER REASON'.
WA_FIELDCAT-ddictxt = 'l'.
  wa_fieldcat-col_pos = 6.
  wa_fieldcat-outputlen = 10.
  append wa_fieldcat to it_fieldtab.
  clear wa_fieldcat .
  wa_fieldcat-tabname   = 'IT_VBAK'.
  wa_fieldcat-fieldname = 'NETWR'.
  wa_fieldcat-seltext_l  = 'QUANTITY'.
  wa_fieldcat-do_sum = 'X'.
WA_FIELDCAT-ddictxt = 'l'.
  wa_fieldcat-col_pos = 7.
  wa_fieldcat-outputlen = 25.
  append wa_fieldcat to it_fieldtab.
  clear wa_fieldcat .
  wa_fieldcat-tabname   = 'IT_VBAK'.
  wa_fieldcat-fieldname = 'WAERK'.
  wa_fieldcat-seltext_l  = 'CURRENCY'.
WA_FIELDCAT-ddictxt = 'l'.
  wa_fieldcat-col_pos = 8.
  wa_fieldcat-outputlen = 10.
  append wa_fieldcat to it_fieldtab.
  clear wa_fieldcat .
endform.                    " modify_fieldcat
regards,
keerthi.

Similar Messages

  • Displaying the field symbol result in ALV GRID

    hi.
        I have a requirement to display the field symbol in ALV GRID. I am getting a error 'FIELD SYMBOL NOT YET BEEN ASSIGNED'  when i am calling the 'REUSE ALV GRID DISPLAY'. Can any one help me out..

    I have a requirement that i have to display all the GL indicators as a field.
    For that i have created a dynamic internal table so that based upon the GL indicators available in the database table i can create a dynamic internal table with GL indicators as the fieldnames.
    Now i want to populate the corresponding amount with respect to the GL indicators in the dynamic internal table.
    For ex.
    I have a database table as follows:
    Vendor Id GL indicators Amount
    1000 A 2000
    1000 S 3000
    I have to created a field symbol as follows
    Vendor Id A S
    1000 2000 3000.
    Now my requirement is that i want this values to be displayed in ALV GRID.
    At the point of calling REUSE ALV GRID DISPLAY  i am getting the error field symbol is not yet been assigned..

  • Field symbol has not yet been defined-ALV Grid Display in Report

    Hi all,
              Iam calling a Function module for ALV grid display in Report programming. Its throwing the Error message Field Symbol has not yet defined. Can any one suggest what i have to do regarding it?

    Hi,
    <li> This is problem with fieldcatalog.
    <li> Check field names or table name in small letters in quotes while building fieldcatalog internal table
    <li> Check the fieldcatalog internal table , whether it has same fields as in data table which is shown using GRID_DISPLAY function module.
    Thanks
    Venkat.O

  • Regarding Alv Grid Totals_text is not Printing

    Hi All,
    I am presently working in Alv Grid dispaly.
    I need to dispaly Totals_Text = 'Totals'. But this text is not displaying in my output dispaly.i am copying my code here.
    Code:
    REPORT  ZFTRSERV NO STANDARD PAGE HEADING
                     MESSAGE-ID YV
                     LINE-SIZE 255.
    TABLES: BSIS,           "Accounting: Secondary Index for G/L Accounts
            BSAS,           "Accounting: Secondary Index for G/L Accounts (Cleared Items)
            BSID,           "Accounting: Secondary Index for Customers
            BKPF,           "Accounting Document Header
            ITCPP.          "SAPscript output parameters
    TYPE-POOLS: SLIS.       "ALV Declarations
    $$********************************************************************
    $$    GLOBAL TYPES
    $$    NAMING CONVENTION: "Y_NAME"
    $$********************************************************************
    *eject
    $$********************************************************************
    $$    GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
    $$    NAMING CONVENTION: "I_NAME"
    $$********************************************************************
    $$********************************************************************
    $$    GLOBAL INTERNAL TABLES (CUSTOM STRUCTURE)
    $$    NAMING CONVENTION: "T_NAME"
    $$********************************************************************
    *eject
    $$********************************************************************
    $$    GLOBAL FIELD-SYMBOLS
    $$    NAMING CONVENTION: "<FS_NAME>"
    $$********************************************************************
    FIELD-SYMBOLS: <FS_BSIS>  TYPE Y_BSIS.
    $$********************************************************************
    $$    MACROS DECLARATION
    $$    NAMING CONVENTION: M_NAME
    $$********************************************************************
    $$********************************************************************
    $$    PARAMETERS & SELECT-OPTIONS
    $$    NAMING CONVENTION: "P_NAME" & "S_NAME"
    $$********************************************************************
    SELECTION-SCREEN BEGIN OF BLOCK SS01 WITH FRAME TITLE TEXT-B01.
    GENERAL SELECTIONS
    SELECT-OPTIONS:   S_BUKRS FOR BSIS-BUKRS OBLIGATORY,
                      S_HKONT FOR BSIS-HKONT OBLIGATORY,
                      S_BLART FOR BSIS-BLART,
                      S_BELNR FOR BSIS-BELNR.
    SELECTION-SCREEN END OF BLOCK SS01.
    SELECTION-SCREEN BEGIN OF BLOCK SS02 WITH FRAME TITLE TEXT-B02.
      OPEN ITEMS:
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS P_OPIT LIKE ITEMSET-XOPSEL RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 3(20) TEXT-003 FOR FIELD P_OPIT.
    SELECTION-SCREEN END OF LINE.
    PARAMETERS P_STIDA LIKE RFPDO-ALLGSTID DEFAULT SY-DATLO.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN: COMMENT (12) BLANK1,
                      COMMENT (20) TEXT-006 FOR FIELD P_OSST.
    PARAMETERS:  P_OSST  AS CHECKBOX DEFAULT SPACE.
    SELECTION-SCREEN: COMMENT (12) BLANK2,
                      COMMENT (20) TEXT-007 FOR FIELD P_OUTD.
    PARAMETERS:P_OUTD LIKE ITCPP-TDDEST.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK SS03.
    *eject
    $$********************************************************************
    $$    INITIALIZATION
    $$********************************************************************
    INITIALIZATION.
      CLEAR: E_BSID,
             E_BSIS,
             E_BSAS,
             E_BKPF,
             E_TOTAL,
             E_SUMSHET_OPEN,
             E_SUMSHET_CLEAR,
             E_SUMSHET_TOTAL,
             E_CATLOG,
             E_ALV_LAYOUT.
      FREE:  T_BSID,
             T_BSIS,
             T_BSAS,
             T_BKPF,
             T_TOTAL,
             T_SUMSHET_OPEN,
             T_SUMSHET_CLEAR,
             T_SUMSHET_TOTAL.
    *eject
    $$********************************************************************
    $$    AT SELECTION-SCREEN
    $$********************************************************************
    AT SELECTION-SCREEN .
    *eject
    $$********************************************************************
    $$    START-OF-SELECTION
    $$********************************************************************
    START-OF-SELECTION.
    To Get data from tables
      PERFORM F_OUT_DATA_RETRIEVEL.
    *eject
    $$********************************************************************
    $$    END-OF-SELECTION
    $$********************************************************************
    END-OF-SELECTION.
    To Display ALV Grid Layout
      PERFORM F_ALV_DATA_RETRIVAL.
    *eject
    *&      Form  f_out_data_retrievel
        data retrival for Open,Clear and All items
    FORM F_OUT_DATA_RETRIEVEL.
      IF P_OPIT EQ C_X.
    *‘open items’ is selected data will be retrieved from BSIS table.
        PERFORM F_OPEN_ITEMS.
    TO GET DATA FOR SUMMARY SHEET OPEN ITEMS.
        PERFORM F_GET_OPEN_SUMSHET.
      ENDIF.
    ENDFORM.                    " f_out_data_retrievel
    *&      Form  F_OPEN_ITEMS
       getting data for Open items from BSIS Table
    FORM F_OPEN_ITEMS .
      SELECT BUKRS
             HKONT
             AUGDT
             AUGBL
             ZUONR
             GJAHR
             BELNR
             BUZEI
             BUDAT
             BLDAT
             BLART
             BSCHL
             MWSKZ
             DMBTR
             SGTXT
        FROM BSIS
        INTO  CORRESPONDING FIELDS OF TABLE T_BSIS
       WHERE BUKRS IN S_BUKRS
         AND HKONT IN S_HKONT
         AND BLART IN S_BLART
         AND BELNR IN S_BELNR
         AND AUGDT NE P_STIDA .
      IF SY-SUBRC NE C_0.
        MESSAGE S999 WITH text-030.
      ENDIF.
      PERFORM F_GET_DATA_BSIS.
    ENDFORM.                    " F_OPEN_ITEMS
    To get the Entry date and Reference Key2
      PERFORM F_GET_DATA_BSIS.
    *&      Form  F_GET_DATA_BSAS
          GETTING DATA FROM BSAS TABLE
    FORM F_GET_DATA_BSAS .
      DATA: W_TABIX TYPE SY-TABIX.
      UNASSIGN <FS_BSAS>.
    GETTING DATA FROM BKPF AND BSID TABLES
      LOOP AT T_BSAS ASSIGNING <FS_BSAS>.
        CLEAR: E_BKPF,
               E_BSID,
               W_TABIX.
        MOVE SY-TABIX TO W_TABIX.
        SELECT SINGLE BUKRS
                      BELNR
                      GJAHR
                      CPUDT
                      BUDAT
          FROM BKPF
          INTO CORRESPONDING FIELDS OF E_BKPF
         WHERE BUKRS EQ E_BSAS-BUKRS
           AND BLART EQ E_BSAS-BLART
           AND BELNR EQ E_BSAS-BELNR
           AND BUDAT EQ E_BSAS-BUDAT.
        IF SY-SUBRC EQ C_0.
          MOVE E_BKPF-CPUDT TO <FS_BSAS>-CPUDT.
          MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
                 TRANSPORTING CPUDT.
        ENDIF.
        SELECT SINGLE BUKRS
                      KUNNR
                      UMSKS
                      UMSKZ
                      AUGDT
                      AUGBL
                      ZUONR
                      GJAHR
                      BELNR
                      BUZEI
                      XREF2
          FROM  BSID
          INTO CORRESPONDING FIELDS OF E_BSID
         WHERE BUKRS EQ E_BSAS-BUKRS
           AND BELNR EQ E_BSAS-BELNR
           AND BLART EQ E_BSAS-BLART
           AND BUDAT EQ E_BSAS-BUDAT.
        IF SY-SUBRC EQ C_0.
          MOVE E_BSID-XREF2 TO <FS_BSAS>-XREF2.
          FREE T_BSID.
          MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
                 TRANSPORTING XREF2.
        ENDIF.
        <FS_BSAS>-IDATE = SY-DATUM.
        <FS_BSAS>-IEDAT = <FS_BSAS>-CPUDT - <FS_BSAS>-ZUONR.
        <FS_BSAS>-PTIME = SY-DATUM - <FS_BSAS>-CPUDT.
        MODIFY T_BSAS INDEX W_TABIX FROM <FS_BSAS>
               TRANSPORTING IEDAT
                            PTIME
                            IDATE.
      ENDLOOP.
      SORT T_BSAS BY HKONT XREF2 CPUDT.
    ENDFORM.                    " F_GET_DATA_BSAS
    *&      Form  F_GET_DATA_BSIS
        GETTING DATA FROM BSIS TABLE
    FORM F_GET_DATA_BSIS .
      DATA: W_TABIX  TYPE SY-TABIX,
            W_SGTXT  LIKE BSIS-SGTXT,
            W_SGTXT1 LIKE BSIS-SGTXT,
            W_SORTL LIKE KNA1-SORTL.
      CLEAR: E_BKPF,
             E_BSID,
             W_TABIX,
             W_SGTXT,
             W_SGTXT1,
             W_SORTL.
    GETTING DATA FROM BKPF AND BSID TABLES
      LOOP AT T_BSIS INTO E_BSIS.
        MOVE SY-TABIX TO W_TABIX.
        SELECT SINGLE BUKRS
                      BELNR
                      GJAHR
                      CPUDT
                      BUDAT
          FROM BKPF
          INTO CORRESPONDING FIELDS OF E_BKPF
         WHERE BUKRS EQ E_BSIS-BUKRS
           AND BLART EQ E_BSIS-BLART
           AND BELNR EQ E_BSIS-BELNR
           AND BUDAT EQ E_BSIS-BUDAT.
        IF SY-SUBRC EQ C_0.
          MOVE E_BKPF-CPUDT TO E_BSIS-CPUDT.
          FREE T_BKPF.
          MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
                 TRANSPORTING CPUDT.
        ENDIF.
        SELECT SINGLE BUKRS
                      KUNNR
                      UMSKS
                      UMSKZ
                      AUGDT
                      AUGBL
                      ZUONR
                      GJAHR
                      BELNR
                      BUZEI
                      XREF2
          FROM BSID
          INTO CORRESPONDING FIELDS OF E_BSID
         WHERE BUKRS EQ E_BSIS-BUKRS
           AND BLART EQ E_BSIS-BLART
           AND BELNR EQ E_BSIS-BELNR
           AND BUDAT EQ E_BSIS-BUDAT.
        IF sy-subrc EQ C_0.
         DUMMY CHECK
        ENDIF.
        SELECT SINGLE  KUNNR
          FROM BSID
          INTO CORRESPONDING FIELDS OF E_BSID
         WHERE BUKRS EQ E_BSIS-BUKRS
           AND BLART EQ E_BSIS-BLART
           AND BELNR EQ E_BSIS-BELNR
           AND BUDAT EQ E_BSIS-BUDAT.
        IF sy-subrc EQ C_0.
         DUMMY CHECK
        ENDIF.
        SELECT SINGLE SORTL
          FROM KNA1
          INTO W_SORTL
         WHERE KUNNR EQ E_BSID-KUNNR.
        IF SY-SUBRC EQ C_0.
          MOVE W_SORTL TO E_BSIS-XREF2.
          MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
                 TRANSPORTING XREF2.
        ENDIF.
        W_SGTXT = E_BSIS-SGTXT.
        SPLIT W_SGTXT AT C_SLASH INTO W_SGTXT W_SGTXT1.
        MOVE: W_SGTXT TO E_BSIS-SGTXT,
              SY-DATUM TO E_BSIS-IDATE.
        DATA : W_ZOUNR LIKE BSAS-ZUONR,
               W_DATE TYPE D,
               W_Z(10) TYPE C.
        CLEAR:  W_ZOUNR,
                W_DATE,
                W_Z.
        MOVE E_BSIS-ZUONR TO W_ZOUNR.
        MOVE : W_ZOUNR4(4) TO W_Z0(4),
               W_ZOUNR2(2) TO W_Z4(2),
               W_ZOUNR0(2) TO W_Z6(2).
        MOVE W_Z TO W_DATE.
        E_BSIS-IEDAT = E_BSIS-CPUDT - W_DATE.
        CONCATENATE W_ZOUNR+0(2)  C_DOT
                    W_ZOUNR+2(2)  C_DOT
                    W_ZOUNR+4(4)  INTO E_BSIS-ZUONR.
        E_BSIS-PTIME = SY-DATUM - E_BSIS-CPUDT.
        MODIFY T_BSIS INDEX W_TABIX FROM E_BSIS
               TRANSPORTING IEDAT
                            PTIME
                            IDATE
                            SGTXT
                            ZUONR.                              "30TH
      ENDLOOP.
      SORT T_BSIS BY HKONT XREF2 CPUDT.
    ENDFORM.                    " F_GET_DATA_BSIS
    *&      Form  f_build_fld_catlog1
          BUILDING FIELD CATALOG FOR OPEN ITEMS DATA
    FORM F_FLD_CATLOG_OPEN_ITEMS.
      ORM f_fld_catlog_open_items.
      REFRESH i_catlog1.
      CLEAR w_col_pos.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING C_HKONT
                                          C_BSIS
                                          w_col_pos
                                          text-010
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING C_XREF2
                                          C_BSIS
                                          w_col_pos
                                          text-011
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING C_BELNR
                                          C_BSIS
                                          w_col_pos
                                          text-012
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING C_BLART
                                          C_BSIS
                                          w_col_pos
                                          text-013
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING c_BLDAT
                                          C_BSIS
                                          W_col_pos
                                          text-014
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING c_BUDAT
                                          C_BSIS
                                          w_col_pos
                                          text-015
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING c_CPUDT
                                          C_BSIS
                                          w_col_pos
                                          text-016
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING c_ZUONR
                                          C_BSIS
                                          w_col_pos
                                          text-017
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING c_BSCHL
                                          C_BSIS
                                          w_col_pos
                                          text-018
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING C_DMBTR
                                          C_BSIS
                                          w_col_pos
                                          text-019
                                          C_X           "dispaly Sum Total
                                          '40'.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING c_MWSKZ
                                          C_BSIS
                                          w_col_pos
                                          text-020
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING c_SGTXT
                                          C_BSIS
                                          w_col_pos
                                          text-021
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING c_IEDAT
                                          C_BSIS
                                          w_col_pos
                                          text-022
                                          SPACE
                                          SPACE.
      w_col_pos = w_col_pos + c_1.
      PERFORM f_first_field_catalog USING C_PTIME
                                          C_BSIS
                                          w_col_pos
                                          text-023
                                          SPACE
                                          SPACE.
      CLEAR: W_COL_POS,
             I_ALV_EVENTS.
    ENDFORM.                    " f_fld_catlog_open_items
    *&      Form  f_first_report_dispaly
         ROUTINE FOR OPEN ITEMS  GRID LAYOUT DISPLAY
    FORM F_DISPALY_OPEN_ITEMS.
      CLEAR W_REPNAME.
      W_REPNAME = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = W_REPNAME
       I_CALLBACK_PF_STATUS_SET          = C_FSTAT
       I_CALLBACK_USER_COMMAND           = C_FUCOM
         I_CALLBACK_TOP_OF_PAGE            = C_FTOPI
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      = ' '
      I_GRID_SETTINGS                   =
         IS_LAYOUT                         = E_ALV_LAYOUT
         IT_FIELDCAT                       = I_CATLOG1[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
         I_DEFAULT                         = C_A
      I_SAVE                            = ' '
      IS_VARIANT                        =
         IT_EVENTS                         = I_ALV_EVENTS
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = T_BSIS
       EXCEPTIONS
         PROGRAM_ERROR                     = 1
         OTHERS                            = 2  .
      IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " f_dispaly_open_items
    *&      Form  f_first_field_catalog
          BUILDING FIELD CATALOG FOR SECONDERY LIST
         -->us_fieldname  field name
         -->us_ref field  ref field
         -->us_ref tab    ref table
         -->us_text       text
         -->us_sum        sum
    FORM F_FIRST_FIELD_CATALOG  USING    US_FIELDNAME TYPE ANY
                                         US_REF_TAB   TYPE ANY
                                         US_COL_POS   TYPE ANY
                                         US_COLTEXT   TYPE ANY
                                         US_DO_SUM    TYPE ANY
                                         us_out       type any.
      CLEAR E_CATLOG.
      MOVE : US_FIELDNAME TO E_CATLOG-FIELDNAME,
             US_REF_TAB   TO E_CATLOG-TABNAME,
             US_COL_POS   TO E_CATLOG-COL_POS,
             US_COLTEXT   TO E_CATLOG-SELTEXT_L,
             US_DO_SUM    TO E_CATLOG-DO_SUM,
             US_out       to E_CATLOG-outputlen.
      APPEND E_CATLOG TO I_CATLOG1.
      CLEAR E_CATLOG.
      APPEND E_CATLOG TO I_CATLOG1.
      CLEAR E_CATLOG.
    ENDFORM.                    " f_first_field_catalog
    *&      Form  F_ALV_DATA_RETRIVAL
          ALV DATA VALIDATION
    FORM F_ALV_DATA_RETRIVAL .
      IF  P_OPIT EQ C_X
      AND P_OSST EQ C_SPACE .
    building field catlog for ‘open items’  list
        PERFORM f_fld_catlog_open_items.
    first list display ‘open items’ list
        PERFORM f_dispaly_open_items.
    Building Alv Layout
        PERFORM f_alv_layout_open_items.
      ENDIF.
    Code to display only summary sheet P_OSST check box
      IF  P_OPIT EQ C_X
      AND P_OSST EQ C_X.
    building field catlog for ‘open items’ Summary sheet
        PERFORM F_FLD_CATLOG_SUMSHET_OPEN.
    first list display ‘open items’ Summary sheet
        PERFORM F_DISPALY_SUMSHEET_OPEN.
      ENDIF.
    ENDFORM.                    " F_ALV_DATA_RETRIVAL
    *&      Form  F_GET_OPEN_SUMSHET
         GET SUMMARY SHEET OPEN ITEM DATA
    FORM F_GET_OPEN_SUMSHET .
      SORT T_BSIS BY SGTXT.
      UNASSIGN <FS_BSIS>.
      LOOP AT T_BSIS ASSIGNING <FS_BSIS>.
        MOVE SY-TABIX TO W_TABIX.
        IF W_TABIX EQ C_1.
          MOVE : <FS_BSIS>-SGTXT TO W_SGTXT,
                 <FS_BSIS>-PTIME TO W_PTIME,
                 <FS_BSIS>-DMBTR TO W_DMBTR,
                 <FS_BSIS>-IEDAT TO W_IEDAT.
          W_COUNT = W_COUNT + C_1.
          CONTINUE.
        ELSE.
          IF <FS_BSIS>-SGTXT EQ W_SGTXT.
            W_PTIME = W_PTIME + <FS_BSIS>-PTIME.
            W_DMBTR = W_DMBTR + <FS_BSIS>-DMBTR.
            W_COUNT = W_COUNT + C_1.
            W_IEDAT = W_IEDAT + <FS_BSIS>-IEDAT.
            CONTINUE .
          ELSE.
            W_ATIME = W_PTIME / W_COUNT.
            W_IEDAT = W_IEDAT / W_COUNT.
            MOVE : W_SGTXT TO E_SUMSHET_OPEN-SGTXT,
                   W_COUNT TO E_SUMSHET_OPEN-COUNT,
                   W_ATIME TO E_SUMSHET_OPEN-ATIME,
                   W_DMBTR TO E_SUMSHET_OPEN-DMBTR,
                   W_IEDAT TO E_SUMSHET_OPEN-IEDAT.
            APPEND E_SUMSHET_OPEN TO T_SUMSHET_OPEN.
            CLEAR: W_SGTXT,
                   W_PTIME,
                   W_DMBTR,
                   W_COUNT,
                   W_IEDAT.
            MOVE :  <FS_BSIS>-SGTXT TO W_SGTXT,
                    <FS_BSIS>-PTIME TO W_PTIME,
                    <FS_BSIS>-DMBTR TO W_DMBTR,
                    <FS_BSIS>-IEDAT TO W_IEDAT.
            W_COUNT = W_COUNT + C_1.
            CONTINUE.
          ENDIF.
        ENDIF.
      ENDLOOP.
      W_ATIME = W_PTIME / W_COUNT.
      W_IEDAT = W_IEDAT / W_COUNT.
      MOVE : W_SGTXT TO E_SUMSHET_OPEN-SGTXT,
             W_COUNT TO E_SUMSHET_OPEN-COUNT,
             W_ATIME TO E_SUMSHET_OPEN-ATIME,
             W_DMBTR TO E_SUMSHET_OPEN-DMBTR,
             W_IEDAT TO E_SUMSHET_OPEN-IEDAT.
      APPEND E_SUMSHET_OPEN TO T_SUMSHET_OPEN.
      CLEAR  E_SUMSHET_OPEN.
    ENDFORM.                    " F_GET_OPEN_SUMSHET
    *&      Form  F_TOP_OF_PAGE
          ITEMS TOP OF PAGE DATA
    FORM F_TOP_OF_PAGE .
      DATA: T_HEADER  TYPE SLIS_T_LISTHEADER,
            W_HEADER TYPE SLIS_LISTHEADER,
            T_LINE    LIKE W_HEADER-INFO.
      CLEAR W_HEADER.
    *TITLE
      MOVE C_H TO W_HEADER-TYP.
      MOVE C_TEXT TO W_HEADER-INFO.
      APPEND W_HEADER TO T_HEADER.
      CLEAR W_HEADER.
      MOVE C_S TO W_HEADER-TYP.
      MOVE C_TEXT2 TO W_HEADER-KEY.
      CONCATENATE  SY-DATUM+6(2) C_SLASH
                   SY-DATUM+4(2) C_SLASH
                   SY-DATUM(4) INTO W_HEADER-INFO.
      APPEND W_HEADER TO T_HEADER.
      CLEAR: W_HEADER.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = T_HEADER.
    ENDFORM.                    " F_TOP_OF_PAGE
    FORM F_DISPALY_SUMSHEET_OPEN .
      CLEAR w_repname.
      w_repname = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = w_repname
       I_CALLBACK_PF_STATUS_SET          = C_FSTAT
      I_CALLBACK_USER_COMMAND           = ' '
       I_CALLBACK_TOP_OF_PAGE            =  C_FTOPS
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      = ' '
      I_GRID_SETTINGS                   =
         IS_LAYOUT                         = e_alv_layout
         IT_FIELDCAT                       = i_catlog1[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
         I_DEFAULT                         = C_A
      I_SAVE                            = ' '
      IS_VARIANT                        =
         IT_EVENTS                         = i_alv_events
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = T_SUMSHET_OPEN
       EXCEPTIONS
         PROGRAM_ERROR                     = 1
         OTHERS                            = 2
      IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      FREE T_SUMSHET_OPEN.
    ENDFORM.                    " F_DISPALY_SUMSHEET_OPEN
    *&      Form  F_TOP_OF_PAGE_SUMSHET
          TOP OF PAGE FOR SUMMARY SHEET
    FORM F_TOP_OF_PAGE_SUMSHET .
      DATA: T_HEADER  TYPE SLIS_T_LISTHEADER,
            W_HEADER TYPE SLIS_LISTHEADER,
            T_LINE    LIKE W_HEADER-INFO.
      CLEAR: W_HEADER,
             T_HEADER,
             T_LINE.
    *TITLE
      MOVE C_H TO W_HEADER-TYP.
      MOVE C_TEXT1 TO W_HEADER-INFO.
      APPEND W_HEADER TO T_HEADER.
      CLEAR W_HEADER.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = T_HEADER.
    ENDFORM.                    " F_TOP_OF_PAGE_SUMSHET
    *&      Form  F_PF_STATUS
          GET PF STATUS
    FORM F_PF_STATUS USING US_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS C_STAT EXCLUDING US_EXTAB.
    ENDFORM.                    "F_PF_STATUS
    *&      Form  F_USER_COMMAND
          GET USER COMMAND
    *FORM F_USER_COMMAND USING W_UCOMM LIKE SY-UCOMM
                             US_SELFIELD  TYPE SLIS_SELFIELD.
    FORM F_USER_COMMAND USING US_UCOMM LIKE SY-UCOMM
                                      US_SELFIELD  TYPE SLIS_SELFIELD.
      CONSTANTS:C_NEXT(6)  TYPE C  VALUE '&NEXT'.
      if sy-subrc eq c_0.
        MOVE C_TEXT3 TO US_SELFIELD-TABNAME.
      endif.
      IF   P_OPIT  EQ C_X
      AND  US_UCOMM EQ C_NEXT .
        PERFORM F_FLD_CATLOG_SUMSHET_OPEN.
        PERFORM F_DISPALY_SUMSHEET_OPEN.
      ELSEIF  P_CLIT EQ C_X
      AND     US_UCOMM EQ C_NEXT.
        PERFORM F_FLD_CATLOG_SUMSHET_CLEAR.
        PERFORM F_DISPALY_SUMSHET_CLEAR.
      ELSEIF  P_ALIT EQ C_X
      AND     US_UCOMM EQ C_NEXT.
        PERFORM F_FLD_CATLOG_SUMSHET_TOTAL.
        PERFORM F_DISPALY_SUMSHET_TOTAL.
      ENDIF.
    ENDFORM.                    "F_USER_COMMAND
    *&      Form  f_alv_layout_open_items
          text
    ----

    Hi,
    Please refer to the sample code :
    *&      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
    Thanks,
    Sriram Ponna.

  • Total Field in ALV Grid

    Can i change the values in total column in ALV Grid program. I had made one report with 3 hirerchy level and for first hirerchy i need different total values just for one column as total values are misleading the users. is it possible to change the value total field in ALV?

    hi
    make the fields for which u r displaying total as editable.
    so when ever u make changes in the column,
    see the sample code, i have done a similar program
    FORM DATA_CHANGED_MATRIX USING P_ER_DATA_CHANGED TYPE REF TO
    CL_ALV_CHANGED_DATA_PROTOCOL P_ONF4 type C E_UCOMM TYPE SY-UCOMM.
      DATA: VALUE LIKE YRECORDINGD_QDMS-SCORE.
      CLEAR VALUE.
      data: begin of wa_tot,
      TOTAL_SCORE like yrecordingd_qdms-score,
      end of wa_tot.
      DATA: BEGIN OF WA_DATA,
      SRNO type i,
      LOCATION LIKE YCONCERNS_QDMS-LOCATION,
      LOC_DESC LIKE YLOCATION_QDMST-LOC_DESC,
      TOTAL_SCORE LIKE YRECORDINGD_QDMS-SCORE,
      END OF WA_DATA.
      FIELD-SYMBOLS: <LS_VALUE1> TYPE ANY,
      <LS_VALUE2> TYPE ANY.
      DATA: L_VALUE TYPE LVC_VALUE,
      ls_mod_cell type lvc_s_modi.
      SORT P_ER_DATA_CHANGED->MT_MOD_CELLS BY ROW_ID.
      LOOP AT P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
        CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = LS_MOD_CELL-row_id
            I_FIELDNAME = LS_MOD_CELL-fieldname
          IMPORTING
            E_VALUE     = L_VALUE.
        VALUE = L_VALUE.
        IF VALUE < 100.
          READ TABLE <TEMP_TAB> INTO <TEMP_WA> INDEX LS_MOD_CELL-ROW_ID.
          MOVE-CORRESPONDING <TEMP_WA> TO WA_TOT.
          WA_TOT-TOTAL_SCORE = WA_TOT-TOTAL_SCORE + VALUE.
          MOVE-CORRESPONDING WA_TOT TO <TEMP_WA>.
          MODIFY <TEMP_TAB> FROM <TEMP_WA> INDEX LS_MOD_CELL-ROW_ID.
          CALL METHOD GO_GRID->REFRESH_TABLE_DISPLAY.
        ELSE.
              CLEAR WA_DATA.
        ENDIF.
        CLEAR:WA_TOT,VALUE.
      ENDLOOP.
    ENDFORM.

  • Update values in AlV grid display after entering value

    Hi,
         I have an issue in ALV grid display.
        Let me explain.
        i have 8 fields to display in which one is editiable.
       Fields are: date
                       material,
                       material Description,
                       Opening Stock,
                       Closing stock-  (  this field is editiable)
                       Closing stock,
                       Received Stock,
                       Actual production.
    Actual production = Closing stock + removal stock
                                 - receipt stock - opening stock.
    when i change the value of closing stock and press enter, actual production should get update, the new values should display.
    Thany you in advance.

    Hi,
    Please refer the code below:
    REPORT z_demo_alv_jg.*******************************************************************
    * TYPE-POOLS                                                      *
    TYPE-POOLS: slis. *******************************************************************
    * INTERNAL TABLES/WORK AREAS/VARIABLES     *
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
          w_field TYPE slis_fieldcat_alv,
          p_table LIKE dd02l-tabname,
          dy_table TYPE REF TO data,
          dy_tab TYPE REF TO data,
          dy_line TYPE REF TO data.*******************************************************************
    * FIELD-SYMBOLS                                                   *
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa> TYPE ANY,
                   <dyn_field> TYPE ANY,
                   <dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
    * SELECTION SCREEN                                                *
    PARAMETERS: tabname(30) TYPE c,
                lines(5)  TYPE n.*******************************************************************
    * START-OF-SELECTION                                              *
    START-OF-SELECTION.* Storing table name
      p_table = tabname.* Create internal table dynamically with the stucture of table name
    * entered in the selection screen
      CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_table->* TO <dyn_table>.
      IF sy-subrc <> 0.
        MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.    LEAVE TO LIST-PROCESSING.
      ENDIF.
    * Create workarea for the table
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
      CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_tab->* TO <dyn_tab_temp>.  SORT i_fieldcat BY col_pos.* Select data from table
      SELECT * FROM (p_table)
      INTO TABLE <dyn_table>
      UP TO lines ROWS.  REFRESH <dyn_tab_temp>.* Display report
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_structure_name         = p_table
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
        TABLES
          t_outtab                 = <dyn_table>
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.  IF sy-subrc <> 0.  ENDIF.*&-----------------------------------------------------------------*
    *&      Form  SET_PF_STATUS
    *       Setting custom PF-Status
    *      -->RT_EXTAB   Excluding table
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.  SET PF-STATUS 'Z_STANDARD'.ENDFORM.                    "SET_PF_STATUS*&----------------------------------------------------------------*
    *&      Form  user_command
    *       Handling custom function codes
    *      -->R_UCOMM      Function code value
    *      -->RS_SELFIELD  Info. of cursor position in ALV
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                               rs_selfield TYPE slis_selfield.* Local data declaration
      DATA: li_tab TYPE REF TO data,
            l_line TYPE REF TO data.* Local field-symbols
      FIELD-SYMBOLS:<l_tab> TYPE table,
                    <l_wa>  TYPE ANY.* Create table
      CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN li_tab->* TO <l_tab>.* Create workarea
      CREATE DATA l_line LIKE LINE OF <l_tab>.
      ASSIGN l_line->* TO <l_wa>.  CASE r_ucomm.*   When a record is selected
        WHEN '&IC1'.*     Read the selected record
          READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
          rs_selfield-tabindex.      IF sy-subrc = 0.*       Store the record in an internal table
            APPEND <dyn_wa> TO <l_tab>.*       Fetch the field catalog info
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
              EXPORTING
                i_program_name         = 'Z_DEMO_PDF_JG'
                i_structure_name       = p_table
              CHANGING
                ct_fieldcat            = i_fieldcat
              EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
            IF sy-subrc = 0.*         Make all the fields input enabled except key fields
              w_field-input = 'X'.          MODIFY i_fieldcat FROM w_field TRANSPORTING input
              WHERE key IS INITIAL.        ENDIF.*       Display the record for editing purpose
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
              EXPORTING
                i_callback_program    = sy-repid
                i_structure_name      = p_table
                it_fieldcat           = i_fieldcat
                i_screen_start_column = 10
                i_screen_start_line   = 15
                i_screen_end_column   = 200
                i_screen_end_line     = 20
              TABLES
                t_outtab              = <l_tab>
              EXCEPTIONS
                program_error         = 1
                OTHERS                = 2.        IF sy-subrc = 0.*         Read the modified data
              READ TABLE <l_tab> INDEX 1 INTO <l_wa>.*         If the record is changed then track its index no.
    *         and populate it in an internal table for future
    *         action
              IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
                <dyn_wa> = <l_wa>.
                i_index = rs_selfield-tabindex.
                APPEND i_index.
              ENDIF.
            ENDIF.      ENDIF.*   When save button is pressed
        WHEN 'SAVE'.*     Sort the index table
          SORT i_index.*     Delete all duplicate records
          DELETE ADJACENT DUPLICATES FROM i_index.      LOOP AT i_index.*       Find out the changes in the internal table
    *       and populate these changes in another internal table
            READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
            IF sy-subrc = 0.
              APPEND <dyn_wa> TO <dyn_tab_temp>.
            ENDIF.      ENDLOOP.*     Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = p_table
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.      IF sy-subrc = 0.*       Modify the database table with these changes
            MODIFY (p_table) FROM TABLE <dyn_tab_temp>.        REFRESH <dyn_tab_temp>.*       Unlock the table
            CALL FUNCTION 'DEQUEUE_E_TABLE'
              EXPORTING
                mode_rstable = 'E'
                tabname      = p_table.      ENDIF.
      ENDCASE.  rs_selfield-refresh = 'X'.ENDFORM.                    "user_command
    Thanks,
    Sriram Ponna.

  • How to make a entire column editable in an ALV grid

    Hi all,
             I am trying to make a column editable in an ALV grid. For that I wrote the following code. In the below code I have set the 'edit' field of ls_fcat to 'X'. But Iam getting Runtime error. Can anyone help in resolving this problem or suggest any method to make a column editable in an ALV grid.
    form prepare_fc  changing go_fieldcat type lvc_t_fcat.
    data: ls_fcat type lvc_s_fcat.
    refresh: go_fieldcat.
    clear: ls_fcat.
    ls_fcat-reptext   = ' Safety Stock Figures'.
      ls_fcat-coltext    = 'Safety Stock Figures'.
      ls_fcat-fieldname  = 'EISBE'.
    ls_fcat-ref_table  = 'IMAT'.
      ls_fcat-edit = 'X'.
    modify go_fieldcat from ls_fcat.
      APPEND LS_FCAT TO GO_FIELDCAT.
    endform.
    Thanks & Regards,
    Vishnu Priya.

    ls_fcat-edit = 'X'.
    is correct only.
    have a look into this code
    struct_grid_lset  TYPE lvc_s_layo,
    i_grid_fcat    TYPE lvc_t_fcat
    DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'MONTH'.
      ls_fcat-ref_table = 'TYPE'.
      ls_fcat-ref_field = 'C'.
    <b>  ls_fcat-edit      = 'X'.</b>
      ls_fcat-coltext   = text-030."Month
      ls_fcat-seltext   = text-030.
      APPEND ls_fcat TO p_i_grid_fcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'YEAR'.
      ls_fcat-ref_table = 'TYPE'.
      ls_fcat-ref_field = 'C'.
      ls_fcat-coltext   = text-031."Year
      ls_fcat-seltext   = text-031.
      APPEND ls_fcat TO p_i_grid_fcat.
    CALL METHOD o_grid->set_table_for_first_display
          EXPORTING
            i_bypassing_buffer    =  space
            is_variant            =  ws_f_grid_disvar
            i_save                =  ws_c_grid_save
            is_layout             =  struct_grid_lset
          CHANGING
            it_outtab             =  i_grid_outs[]
            <b>it_fieldcatalog       =  i_grid_fcat[]</b>
            it_sort               =  i_sort_fcat.      " Period
    Also Check this code.Another way using field symbols.
    i_fieldcat    TYPE lvc_t_fcat,
           w_layout TYPE lvc_s_layo ,
           w_variant TYPE disvariant.
    FIELD-SYMBOLS : <lfs_fieldcat> TYPE lvc_s_fcat.
    *Default display
      LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.
        CASE <lfs_fieldcat>-fieldname.
          WHEN 'GL_ACCT'.
            <lfs_fieldcat>-coltext = text-050.
            <lfs_fieldcat>-no_out = ' '.
            <lfs_fieldcat>-scrtext_l = text-050.
           <b> <lfs_fieldcat>-edit    = 'X'.</b>
    WHEN OTHERS.
        ENDCASE.
      ENDLOOP.
    Hope this helps.

  • For all users having probs with OO ALV Grid

    I wanted to put this in the WIKI but it keeps bombing out when I try and save so I've put this here -- Maybe a MOD can move it for me.
    This generic class should give you far more insite into using an EDITABLE ALV table than the standard documentation.
    If you follow the steps you should be able to code very quickly a decent useable ALV OO program which can retrieve and manipulate data very easily.  The events are (hopefully) well documented as are all the steps.
    Once you understand the basics you can add more functionality like colouring Cells, adding hyperlinks etc etc.
    I've always found that stupid SEAT / AIRLINE application SAP uses for its examples far too overblown and in reality who would ever use a SAP system for Airline reservations anyway.
    The class here describes a much simpler application which CLEARLY (I hope) explains how the whole thing works.
    Jimbo's generic class for using the OO ALV GRID Class CL_GUI_ALV_GRID
    from an application program to display and manipulate ANY table
    with minimal coding needed in the Calling application program.
    Handles the following EVENTS
    1) TOOLBAR BUTTONS
    (you can add more to the toolbar method
      if you need even more functionality).
    2) DOUBLE CLICK
    3) ENTER KEY PRESSED
    4) DATA CHANGED
    5) DATA CHANGED FINISHED
    Methods available
    PUBLIC METHODS  ( Can be called directly from the application program).
    1) display_grid  displays grid with toolbar
       Table and FCAT are built dynamically - user only needs to
       define the table structure (can be DDIC or User fields)
    2) change_title  - changes title at the top of the Grid
    3) refresh_grid   - refreshes grid after table updated etc.
    4) build_dynamic_structures - this method creates a dynamic table and a dynamic FCAT
       using the structure defined in the calling application program
    PRIVATE METHODS (Internal Methods used within the class)
    1) verwerk - returns to FORM VERWERK in calling application program
       (Via Toolbar). The application program can then do any special processing
       at this point e.g update SAP tables etc.
    2) download_to_excel (via Toolbar). This creates an EXCEL spreadsheet
       directly which can be downloaded / saved to a file if required,
    3) return_structure - internal method returns the structure
       of the table defined in the calling application program. This is needed in order
       to build the dynamic table and Field Catalog.
    4) create_dynamic_table  - creates a dynamic table from the structure defined in
       the calling application program
    5) create_dynamic_fcat  - creates the dynamic field catalog from the structure
       defined in the application program.
    6) dubbleklik entered when user double clicks a cell
    activated by EVENT DOUBLE_CLICK.
    returns to FORM DUBBELKLIK  in the
    calling application program
       COOKBOOK STEP BY STEP instructions on how to use this class
       in your application program.
       In the application program :
    1) define a blank screen 100  - SE51 with a custom container
       on it called CCONTAINER1.
       you need the following logic in the screen
       The PAI is only used if you have defined a STATUS with SE41 and you exit the
       application program via the standard SAP buttons on the
       top of the Screen (NOT the GRID toolbar).
         PROCESS BEFORE OUTPUT.
          MODULE STATUS_0100.
         PROCESS AFTER INPUT.
         MODULE USER_COMMAND_0100.
    2) (optional) define a STATUS with a titlebar - SE41
       you only need this if you want the standard EXIT and menu buttons on the
       top line of the screen
    3) If you want to have your OWN colum names on the grid
       add the following macro to the start of your program
         DEFINE col_name.
         read  table it_fldcat into  wa_it_fldcat index &1.
         wa_it_fldcat-coltext = &2.
         modify it_fldcat from wa_it_fldcat index &1.
         END-OF-DEFINITION.
    4) Define the following Field symbols
       <fs1>           TYPE  ANY,
       <fs2>           TYPE  STANDARD TABLE,
       <fs3>           TYPE ANY,
       <field_catalog> TYPE STANDARD TABLE,
       <dyn_table>    TYPE  STANDARD TABLE,
       <orig_table>   TYPE  STANDARD TABLE,
       <dyn_field>,
       <dyn_wa>.
    5) After the field-symbols add the code in this class
        as an INCLUDE
        e.g INCLUDE ZZJIMBOXX_INCL.
    6) define your Internal table as follows
        TYPES:  BEGIN OF s_elements,
                  Your structure
                your structure etc.
                END OF  s_elements.
    For example
    INCLUDE  <icon>.
    TABLES: VAPMA.
    *TYPES:  BEGIN OF s_elements,
    vbeln   TYPE vapma-vbeln,
    posnr   TYPE vapma-posnr,
    matnr   TYPE vapma-matnr,
    kunnr   TYPE vapma-kunnr,
    werks   TYPE vapma-werks,
    vkorg   TYPE vapma-vkorg,
    vkbur   TYPE vapma-vkbur,
    status  TYPE c,
    *END OF  s_elements.
    7) Define the following data  IN YOUR APPLICATION PROGRAM
       (note here only data is described
       that relates to using THIS CLASS. Data purely used internally
       in the application program is NOT shown here).
    DATA: z_object          TYPE REF TO zcl_dog,  "Instantiate our class
          grid_container1    TYPE REF TO cl_gui_custom_container,
          t_elements         TYPE TABLE OF s_elements, "refers to our ITAB
          wa_elements        TYPE s_elements,
          wa_dyn_table_line  TYPE REF TO DATA,
          it_fldcat          TYPE lvc_t_fcat,
          i_gridtitle        TYPE lvc_title,
          wa_it_fldcat       TYPE lvc_s_fcat,
          new_table          TYPE REF TO DATA,
          dy_table           TYPE REF TO data,
          dy_line            TYPE REF TO data,
          row_id             TYPE sy-index.
    8) insert the following code at the start of the application program.
    *START-OF-SELECTION.
    *CALL SCREEN 100.
    *END-OF-SELECTION.
    *MODULE status_0100 OUTPUT.
    *ASSIGN  wa_elements TO <fs1>.
    *CREATE OBJECT z_object EXPORTING z_object = z_object. "Instantiate the class
    *CALL METHOD z_object->build_dynamic_structures
           CHANGING it_fldcat = it_fldcat.
    9) if you inserted the macro in step 3) then
       define your own column names as follws
      col_name 1 'Name1'.
      col_name 2 'Name2'.
      etc. The number is the colum number you want and the name is
      the name you want to assign to the column.
    for example using the table shown above
      col_name 1 'Order Nr'.
      col_name 2 'Item'.
      col_name 3 'Material'.
      col_name 4 'Customer'.
      col_name 5 'Plant'.
      col_name 6 'Sales Org'.
      col_name 7 'Sales Office'.
      col_name 8 'Status'.
    10)  perform a routine that fills your dynamic table and
         display the GRID. If you created a status with SE41 you can set
         a title etc. Further processing is dependent on the users action
         after the GRID is displayed for example if a Cell is double clicked,
         dat is entered, a toolbar button is pressed or a SAP ICON on top of the screen is pressed.
    PERFORM populate_dynamic_itab.
    CALL METHOD z_object->display_grid
          CHANGING it_fldcat = it_fldcat.
    SET PF-STATUS '0001'.
    SET TITLEBAR '000'.
    ENDMODULE.
    11) If you added a STATUS via SE41 you can exit the program via the
    standard SAP buttons at the top of the screen
    otherwise exit via the exit button on the toolbar.
    You only need this piece of code if you defined a STATUS in the application program
    MODULE user_command_0100 INPUT.
    CASE sy-ucomm.
       WHEN 'BACK'.
         LEAVE PROGRAM.
       WHEN 'EXIT'.
         LEAVE PROGRAM.
       WHEN 'RETURN'.
         LEAVE PROGRAM.
       WHEN OTHERS.
    ENDCASE.
    12)  to populate the dynamic table you only need to code something like this
    remember the class has already created and structured the field-symbol <dyn_table>
    so you don't have to do anything other than just select the fields you want
    filled and from what data source(es).
    *FORM populate_dynamic_itab.
    *SELECT vbeln posnr matnr kunnr werks vkorg vkbur
          UP TO 200 rows
          FROM vapma
          INTO  CORRESPONDING FIELDS OF TABLE <dyn_table>.
    if you want to keep the original table before making any changes etc code
    the following
    create 2nd Dyn table to hold original data. We can use
    the same field catalog as for the original table
    as we are just creating an identical copy here.
    *CALL METHOD cl_alv_table_create=>create_dynamic_table
       EXPORTING
            it_fieldcatalog = it_fldcat
         IMPORTING
            ep_table = dy_table.
      ASSIGN dy_table->* TO <orig_table>.
    CREATE DATA dy_line LIKE LINE OF <orig_table>.
    ASSIGN dy_line->* TO <dyn_wa>.
    <orig_table> = <dyn_table>.
    ENDFORM.
    13) you need these 2 processing routines in your application program.
    FORM VERWERK.  "Entered from VERW on toolbar
    *break-point 1.
    Orig table is in dynamic table <orig_table>
    ALV GRID changed table is in <dyn_table>.
    *Loop at <orig_table>  into <dyn_wa>.
      Do what you want here
    end
    endloop.
    ENDFORM.
    *form dubbleklik using     "Entered when a cell is double clicked
           e_row   type LVC_S_ROW
           e_column type LVC_S_col
           es_row_no type lvc_s_roid.
           break-point 1.
    Get Row id into a variable for this program.
           row_id =  e_row.
            SET TITLEBAR '001'.      "If you defined a status in SE41
           i_gridtitle = 'Grid Title Changed'.
           CALL METHOD  z_object->change_title
             EXPORTING i_gridtitle = i_gridtitle.
           PERFORM refresh.
    endform.
    The REFRESH routine is optional but after a double click I assume
    you want to do some processing
    and re-display the data
    so as a sample code something like
    *FORM refresh.
    data: ord_nr  TYPE vapma-vbeln.  "Your data
    *READ TABLE  <dyn_table> index row_id into wa_elements.
       ord_nr = wa_elements-vbeln.
    You've now got the Row double clicked so pick out the data element(s)
    you wnat to process and do your processing
    *set parameter id 'AUN'  field ord_nr.
    *CALL TRANSACTION  'VA02' AND SKIP FIRST SCREEN.
    You can update the dynamic table for example
    *wa_elements-status = 'C'.
    *modify <dyn_table> from wa_elements index row_id.
    now redisplay the updated grid.
    *CALL METHOD z_object->refresh_grid.
    *ENDFORM.
    *************Class ZCL_DOG*************
    CLASS zcl_dog DEFINITION.
    PUBLIC SECTION.
    METHODS:
      constructor
         IMPORTING
                      z_object TYPE REF TO zcl_dog,
       display_grid
         CHANGING
                      it_fldcat TYPE lvc_t_fcat,
           build_dynamic_structures
         CHANGING        it_fldcat TYPE lvc_t_fcat,
        change_title
         IMPORTING
                i_gridtitle  TYPE lvc_title,
         refresh_grid.
      PRIVATE SECTION.
       METHODS:
        on_user_command FOR EVENT before_user_command OF cl_gui_alv_grid
          IMPORTING       e_ucomm
                          sender,
        on_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING      e_object
                         e_interactive,
         on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row
                    e_column
                    es_row_no,
        handle_data_changed
                 FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING er_data_changed,
        handle_data_changed_finished
                 FOR EVENT data_changed_finished OF cl_gui_alv_grid
                 IMPORTING e_modified
                           et_good_cells,
        verwerk
                IMPORTING program TYPE sy-repid,
        download_to_excel,
        dubbleklik
                IMPORTING
                     e_row  type  LVC_S_ROW
                     e_column   TYPE LVC_S_COL
                     es_row_no  type lvc_s_ROID
                     program type sy-repid,
         return_structure,
         create_dynamic_fcat
          EXPORTING       it_fldcat TYPE lvc_t_fcat,
          create_dynamic_table
          IMPORTING       it_fldcat TYPE lvc_t_fcat
          EXPORTING       dy_table  TYPE REF TO DATA.
    DATA:
        lr_rtti_struc    TYPE REF TO cl_abap_structdescr,        "RTTI
        zog              LIKE LINE OF lr_rtti_struc->components, "RTTI
        wa_it_fldcat     TYPE lvc_s_fcat,
        it_fldcat        TYPE lvc_t_fcat,
        dy_table         TYPE REF TO data,
        dy_line          TYPE REF TO data,
        struct_grid_lset TYPE lvc_s_layo,
        e_row            TYPE LVC_S_ROW,
        e_column         TYPE lvc_s_col,
        es_rowid         TYPE lvc_s_roid,
        grid_container1  TYPE REF TO cl_gui_custom_container,
        grid1            TYPE REF TO cl_gui_alv_grid,
        ls_layout        TYPE kkblo_layout,
        lt_fieldcat_wa   TYPE kkblo_fieldcat,
        l_mode           TYPE raw4,
        celltab          TYPE LVC_T_STYL,
        wa_celltab       TYPE lvc_s_styl,
        lt_fieldcat      TYPE kkblo_t_fieldcat,
       l_tabname         TYPE slis_tabname.
    TYPES:
       struc            LIKE  zog.
    DATA:
        zogt           TYPE TABLE OF struc.
       ENDCLASS.
    CLASS zcl_dog IMPLEMENTATION.
    METHOD constructor.
       CREATE OBJECT grid_container1
           EXPORTING
                   container_name = 'CCONTAINER1'.
        CREATE OBJECT  grid1
            EXPORTING
                  i_parent = grid_container1.
        SET HANDLER z_object->on_user_command for grid1.
        SET HANDLER z_object->on_toolbar for grid1.
        SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
        SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
        CALL METHOD grid1->register_edit_event
            EXPORTING
                    i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    ENDMETHOD.
    METHOD refresh_grid.
      CALL METHOD cl_gui_cfw=>flush.
      CALL METHOD grid1->refresh_table_display.
    ENDMETHOD.
    METHOD on_dubbelklik.
    CALL METHOD me->dubbleklik
             EXPORTING
                     e_row  = e_row
                     e_column =  e_column
                     es_row_no = es_row_no
                     program  = sy-repid.
    break-point 1.
    ENDMETHOD.
    METHOD  handle_data_changed.
    Insert user code here if required
    this method is entered if user ENTERS DATA.
    ENDMETHOD.
    METHOD handle_data_changed_finished.
    Insert user code here if required
    Method entered here after data entry has finished.
    ENDMETHOD.
    METHOD return_structure.
      lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <fs1> ).
      zogt[]  = lr_rtti_struc->components.
      ASSIGN zogt[] TO <fs2>.
      ENDMETHOD.
    METHOD create_dynamic_fcat.
        LOOP AT <fs2>  INTO zog.
          CLEAR wa_it_fldcat.
          wa_it_fldcat-fieldname = zog-name .
          wa_it_fldcat-datatype = zog-type_kind.
          wa_it_fldcat-inttype = zog-type_kind.
          wa_it_fldcat-intlen = zog-length.
          wa_it_fldcat-decimals = zog-decimals.
          wa_it_fldcat-coltext = zog-name.
          wa_it_fldcat-lowercase = 'X'.
          APPEND wa_it_fldcat TO it_fldcat .
          ASSIGN it_fldcat[] TO <field_catalog>.
          ENDLOOP.
           ASSIGN  it_fldcat[] TO <field_catalog>.
        ENDMETHOD.
    METHOD  download_to_excel.
    break-point 5.
    CALL FUNCTION  'LVC_TRANSFER_TO_KKBLO'
        EXPORTING
          it_fieldcat_lvc   = <field_catalog>
         is_layout_lvc     = m_cl_variant->ms_layout
           is_tech_complete  = ' '
        IMPORTING
          es_layout_kkblo   = ls_layout
          et_fieldcat_kkblo = lt_fieldcat.
    LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
       CLEAR lt_fieldcat_wa-tech_complete.
        IF lt_fieldcat_wa-tabname IS initial.
           lt_fieldcat_wa-tabname = '1'.
           MODIFY lt_fieldcat FROM lt_fieldcat_wa.
        ENDIF.
        l_tabname = lt_fieldcat_wa-tabname.
    ENDLOOP.
    CALL FUNCTION 'ALV_XXL_CALL'
        EXPORTING
          i_tabname           = l_tabname
          is_layout           = ls_layout
          it_fieldcat         = lt_fieldcat
          i_title             = sy-title
        TABLES
          it_outtab           = <dyn_table>
        EXCEPTIONS
          fatal_error         = 1
          no_display_possible = 2
          others              = 3.
      IF  sy-subrc <> 0.
         message id sy-msgid type 'S' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    ENDMETHOD.
    METHOD create_dynamic_table.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
             it_fieldcatalog = it_fldcat
          IMPORTING
             ep_table = dy_table.
    ENDMETHOD.
    METHOD build_dynamic_structures.
    CALL METHOD me->return_structure.
    CALL METHOD me->create_dynamic_fcat
       IMPORTING
         it_fldcat = it_fldcat.
    CALL METHOD me->create_dynamic_table
        EXPORTING
          it_fldcat = it_fldcat
        IMPORTING
          dy_table        = dy_table.
         ASSIGN dy_table->* TO <dyn_table>.
    CREATE DATA dy_line LIKE LINE OF <dyn_table>.
    ASSIGN dy_line->* TO <dyn_wa>.
    ENDMETHOD.
    METHOD display_grid.
      struct_grid_lset-edit = 'X'. "To enable editing in ALV
      struct_grid_lset-grid_title = 'Bulkwijzigingen inkoopprijzen'.
      struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
      struct_grid_lset-stylefname = 'CELLTAB'.
      CALL METHOD grid1->set_ready_for_input
          EXPORTING
               i_ready_for_input = '1'.
      CALL METHOD grid1->set_table_for_first_display
          EXPORTING
               is_layout       = struct_grid_lset
        CHANGING
               it_outtab       = <dyn_table>
               it_fieldcatalog = it_fldcat.
    ENDMETHOD.
    METHOD change_title.
      CALL METHOD grid1->set_gridtitle
       EXPORTING
       i_gridtitle =  i_gridtitle.
      ENDMETHOD.
    METHOD on_user_command.
      CASE e_ucomm.
          WHEN 'EXIT'.
            LEAVE PROGRAM.
         WHEN 'EXCEL'.
         CALL METHOD me->download_to_excel.
          WHEN 'SAVE'.
          WHEN 'VERW'.
          CALL METHOD me->verwerk
               EXPORTING
                  PROGRAM = SY-REPID.
      ENDCASE.
    ENDMETHOD.                    "on_user_command
    METHOD on_toolbar.
    User can add extra functionality by adding extra
    buttons if required. Functionality can also be simplified by removing buttons.
    DATA: ls_toolbar TYPE stb_button.
         CLEAR ls_toolbar.
         MOVE 0 TO ls_toolbar-butn_type.
         MOVE 'EXIT' TO ls_toolbar-function.
         MOVE SPACE TO ls_toolbar-disabled.
         MOVE icon_system_end TO ls_toolbar-icon.
         MOVE 'Click2Exit' TO ls_toolbar-quickinfo.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'SAVE' TO ls_toolbar-function.
         MOVE SPACE TO ls_toolbar-disabled.
         MOVE  icon_system_save TO ls_toolbar-icon.
         MOVE 'Save data' TO ls_toolbar-quickinfo.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'EDIT' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE  icon_toggle_display_change TO ls_toolbar-icon.
         MOVE 'Edit data' TO ls_toolbar-quickinfo.
         MOVE  'EDIT' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
         CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'VERW' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE   icon_businav_process to ls_toolbar-icon.
         MOVE 'Verw.' TO ls_toolbar-quickinfo.
         MOVE  'VERW' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
          CLEAR ls_toolbar.
         MOVE  0 TO ls_toolbar-butn_type.
         MOVE 'EXCEL' TO ls_toolbar-function.
         MOVE  SPACE TO ls_toolbar-disabled.
         MOVE  icon_xxl TO ls_toolbar-icon.
         MOVE 'Excel' TO ls_toolbar-quickinfo.
         MOVE  'EXCEL' TO ls_toolbar-text.
         APPEND ls_toolbar TO e_object->mt_toolbar.
       ENDMETHOD.
       METHOD verwerk.
          PERFORM verwerk IN PROGRAM (program).
          LEAVE PROGRAM.
      ENDMETHOD.
      METHOD dubbleklik.
      PERFORM dubbleklik IN PROGRAM (program)
        USING
            e_row
            e_column
            es_row_no.
      ENDMETHOD.
    ENDCLASS.
    Cheers
    Jimbo

    Hi Dinu,
    Before analysing ALV, please cross check the behaviour of the calling program.
    Is the control really going to the application server when you do all the above process?
    If so, when user makes some changes are they saved in the data base / affected the internal table which you are using for ALV?
    Regards
    Surya.

  • How to download only some fields(dynamically) from alv grid layouts

    I have ALV grid list.
    I have layouts for selecting sets of fields dynamically.
    If I select a particular layout, I want to download only those fields into an Excel sheet.
    If I select another layout, I want to download only fields of that layout , into an Excel sheet.
    Can u plz write examples.
    Narendra

    Hello ,
    Here it is.
      FIELD-SYMBOLS <FS> TYPE ANY.
      DATA: GR_ATTACHMENT TYPE Z48S3_ATTACHMENT,
            GT_ATTACHMENT TYPE Z48S3_ATTACHMENT_TAB,
            L_F_TITLE     TYPE SO_OBJ_DES,
            L_R_FIELDCAT  LIKE LINE OF GT_FIELDCAT,
            L_F_FIELD     LIKE L_R_FIELDCAT-FIELDNAME,
            L_F_EMAILID   TYPE Z48S3_RECEIVER,
            L_F_FIRST     TYPE C.
      IF SY-SYSID EQ G_C_DEV_SYSTEM OR
         SY-SYSID EQ G_C_QUA_SYSTEM.
        CONCATENATE SY-SYSID '/' SY-MANDT ':' INTO L_F_TITLE.
        CONDENSE L_F_TITLE.
        CONCATENATE L_F_TITLE SY-TITLE INTO L_F_TITLE SEPARATED BY SPACE.
      ELSE.
        L_F_TITLE = SY-TITLE.
      ENDIF.
      G_R_VARIANT-REPORT = SY-REPID.
      G_R_VARIANT-VARIANT = P_VARIAN.
      CALL FUNCTION 'REUSE_ALV_VARIANT_SELECT'
           EXPORTING
                I_DIALOG            = 'N'
                I_USER_SPECIFIC     = 'A'
                I_DEFAULT           = 'X'
                IT_DEFAULT_FIELDCAT = G_T_FIELDCAT
                I_LAYOUT            = GR_LAYOUT
           IMPORTING
                ET_FIELDCAT         = G_T_FIELDCAT
                ES_LAYOUT           = GR_LAYOUT
           CHANGING
                CS_VARIANT          = G_R_VARIANT
           EXCEPTIONS
                ERROR_MESSAGE       = 4
                OTHERS              = 4.
      SORT G_T_FIELDCAT BY COL_POS.
      PERFORM CREATE_EXCEL_ATTM_HEADING_ROW TABLES GT_ATTACHMENT
                                                   G_T_FIELDCAT.
      LOOP AT G_T_ALVLIST.
        L_F_FIRST = 'X'.
        LOOP AT G_T_FIELDCAT INTO L_R_FIELDCAT WHERE NO_OUT IS INITIAL.
          CLEAR GR_ATTACHMENT-XNEWLINE.
          IF NOT L_F_FIRST IS INITIAL.
            GR_ATTACHMENT-XNEWLINE = 'X'.
            CLEAR L_F_FIRST.
          ENDIF.
          CLEAR L_F_FIELD.
          CONCATENATE 'G_T_ALVLIST-' L_R_FIELDCAT-FIELDNAME
                 INTO L_F_FIELD.
          CONDENSE L_F_FIELD.
          ASSIGN (L_F_FIELD) TO <FS>.
          WRITE <FS> TO GR_ATTACHMENT-FIELDVALUE.
          UNASSIGN <FS>.
          APPEND GR_ATTACHMENT TO GT_ATTACHMENT.
        ENDLOOP.
      ENDLOOP.
    Regards,
    Vasanth

  • Need to display two ALV GRIDs in a single screen

    Hi,
    I have a question, i'm using version 4.6. I want to display 2 ALVs in a single screen or by calling.
    Step 1 : The internal table (which holds the data for the ALVs has to be populated before calling ALV1 or ALV2) 
    Step 2 : Display In a single report
    ALV1 report (Editable ,Has to be a GRID)
    ALV2 report (Non Editable, Has to be a GRID)
                             (or)
    Step 1 : The internal table (which holds the data for the ALVs has to be populated before calling ALV1 or ALV2)
    Step 2 :
    ALV1 report (Editable ,Has to be a GRID, with a custom button to call ALV2 hiding the ALV1 ie not visible to user)
    ALV2 report (Non Editable ,Has to be a GRID, with a custom button to call ALV1 hiding the ALV2 ie not visible to user)
    Please help me <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

    Hi
    ABAP List Viewer
    Simple ALV report
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
    2. How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    Check the program in the following link:
    http://sap-img.com/abap/display-secondary-list-using-alv-grid.htm
    3. How do I add subtotals (I have problem to add them)...
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm
    4. How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    5. How to print page number / total number of pages X/XX in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
    http://www.sapfans.com/forums/viewtopic.php?t=64320
    http://www.sapfans.com/forums/viewtopic.php?t=44477
    7. How can I set the cell color in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    8. How do I print a logo/graphics in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=81149
    http://www.sapfans.com/forums/viewtopic.php?t=35498
    http://www.sapfans.com/forums/viewtopic.php?t=5013
    9. How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    10. How can I use ALV for reports that are going to be run in background?
    http://www.sapfans.com/forums/viewtopic.php?t=83243
    http://www.sapfans.com/forums/viewtopic.php?t=19224
    11. How can I display an icon in ALV? (Common requirement is traffic light icon).
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    12. How can I display a checkbox in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    13. Top-of-page in ALV
    selection-screen and top-of-page in ALV
    14.  ALV Group Heading
    http://www.sap-img.com/fu037.htm
    How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    15. ALV output to PDF conversion
    It has an example code for PDF Conversion.
    http://www.erpgenie.com/abap/code/abap51.htm
    converting the output of alv in pdf
    Go thru these programs they may help u to try on some hands on
    ALV Demo program
    BCALV_DEMO_HTML
    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
    BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
    BCALV_GRID_DEMO Simple ALV Control Call Demo Program
    BCALV_TREE_DEMO Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO
    BC_ALV_DEMO_HTML_D0100
    The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
    This helps us to implement all the features mentioned very effectively.
    Using ALV, We can have three types of reports:
    1. Simple Report
    2. Block Report
    3. Hierarchical Sequential Report
    There are some function modules which will enable to produce the above reports without much effort.
    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
    1. SIMPLE REPORT.
    The important function modules are
    a. Reuse_alv_list_display
    b. Reuse_alv_fieldcatalog_merge
    c. Reuse_alv_events_get
    d. Reuse_alv_commentary_write
    e. Reuse_alv_grid_display
    A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
    The important parameters are :
    I. Export :
    i. I_callback_program : report id
    ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
    iii. I_callback_user_command : routine where the function codes are handled
    iv. I_structure name : name of the dictionary table
    v. Is_layout : structure to set the layout of the report
    vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
    vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
    II. Tables :
    i. t_outtab : internal table with the data to be output
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table
    iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
    declared in the type pool SLIS.
    C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
    Parameters :
    I. Import :
    Et_Events : The event table is returned with all possible CALLBACK events
    for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
    II. Export :
    I_List_type :
    0 = simple list REUSE_ALV_LIST_DISPLAY
    1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
    3 = hierarchical-sequential block list
    REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
    Parameters :
    I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
    This internal table has three fields :
    Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action
    Key : only when typ is ‘S’.
    Info : the text to be printed
    E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
    Parameters : same as reuse_alv_list_display
    This is an example for simple list.
    2. BLOCK REPORT
    This is used to have multiple lists continuously.
    The important functions used in this report are:
    A. REUSE_ALV_BLOCK_LIST_INIT
    B. REUSE_ALV_BLOCK_LIST_APPEND
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    A. REUSE_ALV_BLOCK_LIST_INIT
    Parameters:
    I. I_CALLBACK_PROGRAM
    II. I_CALLBACK_PF_STATUS_SET
    III. I_CALLBACK_USER_COMMAND
    This function module is used to set the default gui status etc.
    B. REUSE_ALV_BLOCK_LIST_APPEND
    Parameters :
    Export :
    I. is_layout : layout settings for block
    II. it_fieldcat : field catalog
    III. i_tabname : internal table name with output data
    IV. it_events : internal table with all possible events
    Tables :
    i. t_outtab : internal table with output data.
    This function module adds the data to the block.
    Repeat this function for all the different blocks to be displayed one after the other.
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    This function module is used for hierarchical sequential blocks.
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    Parameters : All the parameters are optional.
    This function module display the list with data appended by the above function.
    Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
    3. Hierarchical reports :
    Hierarchical sequential list output.
    The function module is
    A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
    Parameters:
    I. Export:
    i. I_CALLBACK_PROGRAM
    ii. I_CALLBACK_PF_STATUS_SET
    iii. I_CALLBACK_USER_COMMAND
    iv. IS_LAYOUT
    v. IT_FIELDCAT
    vi. IT_EVENTS
    vii. i_tabname_header : Name of the internal table in the program containing the
    output data of the highest hierarchy level.
    viii. i_tabname_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    ix. is_keyinfo : This structure contains the header and item table field
    names which link the two tables (shared key).
    II. Tables
    i. t_outtab_header : Header table with data to be output
    ii. t_outtab_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.
    Important Attributes :
    A. col_pos : position of the column
    B. fieldname : internal fieldname
    C. tabname : internal table name
    D. ref_fieldname : fieldname (dictionary)
    E. ref_tabname : table (dictionary)
    F. key(1) : column with key-color
    G. icon(1) : icon
    H. symbol(1) : symbol
    I. checkbox(1) : checkbox
    J. just(1) : (R)ight (L)eft (C)ent.
    K. do_sum(1) : sum up
    L. no_out(1) : (O)blig.(X)no out
    M. outputlen : output length
    N. seltext_l : long key word
    O. seltext_m : middle key word
    P. seltext_s : short key word
    Q. reptext_ddic : heading (ddic)
    R. ddictxt(1) : (S)hort (M)iddle (L)ong
    S. datatype : datatype
    T. hotspot(1) : hotspot
    Regards
    Anji

  • Hiding a column in ALV GRID function module if it doesnt have data

    Hi ,
    I am using alv grid function module, in output i dont want to display the fields which dont have data

    we dont know which column has no data..... we have to do it dynamically
    This code does that dynamically, Here the field2 & Fiels4 are not displayed.
    TYPE-POOLS:slis,abap.
    TYPES:BEGIN OF ty_stru,
          field1 TYPE c,field2 TYPE c,field3 TYPE c,field4 TYPE c,
          END OF ty_stru.
    DATA:itab TYPE TABLE OF ty_stru,
         wa_stru TYPE ty_stru,
         lv_repid TYPE sy-repid,
         wa_fieldcat TYPE slis_fieldcat_alv,
         it_fieldcat TYPE TABLE OF slis_fieldcat_alv,
         it_details TYPE abap_compdescr_tab,
         wa_components TYPE abap_compdescr,
         lf_ref_descr TYPE REF TO cl_abap_structdescr,
         lv_field TYPE abap_compname.
    FIELD-SYMBOLS:<fs> TYPE ANY,
                  <fs1> TYPE ANY.
    lf_ref_descr ?= cl_abap_typedescr=>describe_by_data( wa_stru ).
    it_details[] = lf_ref_descr->components[].
    wa_stru-field1 = 'A'.wa_stru-field3 = 'C'.APPEND wa_stru TO itab.
    wa_stru-field1 = 'X'.wa_stru-field3 = 'Y'.APPEND wa_stru TO itab.
    IF NOT itab[] IS INITIAL.
      LOOP AT it_details INTO wa_components.
        ASSIGN wa_components-name TO <fs>.
        CHECK sy-subrc = 0.
        SORT itab BY (<fs>) DESCENDING.
        CONCATENATE 'WA_STRU' '-' <fs> INTO lv_field .
        ASSIGN (lv_field) TO <fs1>.
        CHECK sy-subrc = 0.
        READ TABLE itab INTO wa_stru INDEX 1 TRANSPORTING (<fs>).
        IF sy-subrc = 0 AND ( NOT <fs1> IS INITIAL ).
          wa_fieldcat-fieldname = wa_components-name.
          wa_fieldcat-seltext_m = wa_components-name.
          APPEND wa_fieldcat TO it_fieldcat.
          CLEAR wa_fieldcat.
        ENDIF.
      ENDLOOP.
      lv_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program = lv_repid
                it_fieldcat        = it_fieldcat[]
           TABLES
                t_outtab           = itab[].
    ENDIF.

  • How to identify the modified rows in ALV grid in OO

    Hello All,
    I have strange problem and i don't know how to solve it?
    I have ALV grid and in that ALV grid i have two buttons 'CONT' and 'ALLOC', when the user press 'ALLOC' button i will give a popup to make the user to enter some value.
    After entering the value i will do some calicualtions and i will distribute the amount in the fields of ALV grid and i should update the ALVGRID.
    Normally we can use CALL METHOD ME->REFRESH_TABLE_DISPLAY.( I have already checked by using this method and it worked fine)
    Here is the way my program look like
    ALVTREE1
    ALVTREE2
                 |----
    ALVGRID
    The problem is when i press the other button CONT i am unable to know what values exist in ALVGRID.
    How can i find these distributed amount in ALV?
    I hope i am clear while explaining problem.
    Here is  the required code:
      method handle_user_command.
        data: lt_fields       type table of sval,
              ls_field        type sval,
              ls_fieldcatalog type lvc_s_fcat,
              ls_merkpl       type zvhf_merkpl,
              lv_month(2)     type n ,
              lv_year(4)      type n ,
              lv_spmon        type zvhf_allocation-spmon,
              lv_value        type p.
        field-symbols: <fs> type any,
                       <ls_merkpl> type zvhf_merkpl.
        case  e_ucomm.
          when 'CNT'.
            call method gcl_gui_alv_grid->check_changed_data.
            call method dailogbox_container->set_visible
              exporting
                visible = space.
            call method gcl_gui_alv_tree2->frontend_update.
            call method gcl_gui_alv_tree2->update_calculations.
            clear: gt_merkpl.
          when 'ALCT'.
    Popup to get the values enterd by the user
            ls_field-tabname   = 'DD02V'.
            ls_field-fieldname = 'DDTEXT'.
            append ls_field to lt_fields.
            call function 'POPUP_GET_VALUES'
              exporting
                popup_title     = 'Enter value'
                start_column    = '1'
                start_row       = '1'
              tables
                fields          = lt_fields
              exceptions
                error_in_fields = 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.
            elseif sy-subrc = 0.
              read table lt_fields into ls_field index 1.
              if sy-subrc = 0.
                gv_value = ls_field-value.
    Read the table zvhf_allocation with nodekey  in order to get percentages
                select * from zvhf_allocation into table gt_allocation
                                   where dvkbur = gs_node_info-nodename.
    Read gt_merkpl in order to get existing line in ALV grid
                loop at  gt_merkpl into ls_merkpl.
    *Read FCAT inorder to find the field and move proprtinate value
                  loop at gt_fieldcatlog3 into ls_fieldcatalog.
    *Split is required to match ZVHF_ALLOCATION-SPMON  with screen text and to proprtinate the value
                    split ls_fieldcatalog-scrtext_l at '.' into
                          lv_month lv_year.
                    concatenate lv_year lv_month into lv_spmon.
    Check whether an entry exist or not in ZVHF_allocation
                    read table gt_allocation into gs_allocation
                                              with key spmon = lv_spmon binary search.
    *If an entry exist proprtinate the value as enterd in table
                    if sy-subrc = 0.
                      lv_value  = gv_value * gs_allocation-prozent.
                      lv_value = lv_value / 100.
                      perform assign_value using     ls_fieldcatalog-fieldname lv_value
                                           changing  ls_merkpl.
                      modify gt_merkpl from ls_merkpl.
                    endif.
                  endloop.
                 CALL METHOD gcl_gui_alv_grid->frontend_update.
                  call method gcl_gui_alv_grid->refresh_table_display
                    exceptions
                      finished = 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.
                endloop.
              endif.
            endif.
        endcase.
      endmethod.                    "handle_user_command
    If you have any further questions please let me know.
    Regards,
    Lisa

    Hello Vijay,
    Thanks for you reply,
    The event data_changed is not working because i called method refresh_table_display. So the event changed will not be raised after i press button CONT
    If i didn't call this method then i can see the value enterd by the user in ALV grid.
    So, do you have an more ideas.
    Regards,
    Lisa

  • Dynamic creation of variables and alv grid output/internal table

    Dear Experts
    I am stuck in an inventory ageing report which is to be done year wise. the scenario is as follow.
    selection screen i enter the year 2011 or 2010 or 2009.
    the output should show me 2011-2007 or 2010-2007 or 2009-2007. the alv grid should always start from 2007 and end at the year that is entered in the selection screen.
    Now how can i create a dynamic variables to store the values of the corresponding yr and also how can i create a dynamic internal table to store these values.
    Thanks & Regards
    Zamir Parkar

    Hi Zamir,
    if you are new to ABAP you may leave old and buggy techniques behind.
    If you want to create the table dynamically, please do not use l_alv_table_create=>create_dynamic_table because it is limited and always triggers a possibly unwanted database commit.
    You better use RTTS dynamic runtime type services, i.e. check the example for [Creating Flat and Complex Internal Tables Dynamically using RTTI|http://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI].
    As done here, leave all outdated ALV technologies behind and start with CL_SALV_TABLE. It is following the object-oriented approach and does not need a field catalog.
    You will get used to field-symbols that can be compared to the data referenced by a pointer. For dynamic fields, you may build the field names dynamically, i.e.
    DATA:
          lo_structdescr         TYPE REF TO cl_abap_structdescr,
          lo_typedescr           TYPE REF TO cl_abap_typedescr,
          lo_tabledescr          TYPE REF TO cl_abap_tabledescr,
          lr_data                TYPE REF TO data,
          lt_comp_all            TYPE cl_abap_structdescr=>component_table,
          lv_index               TYPE numc2.
        FIELD-SYMBOLS:
          <any>                  TYPE ANY,
          <component>            TYPE LINE OF abap_component_tab,
           <table>                TYPE table.
        DO nnn TIMES.
          lv_index = sy-index.
          lo_typedescr   =  cl_abap_typedescr=>describe_by_name( <name of data element> ).
          APPEND INITIAL LINE TO lt_comp_all ASSIGNING <component>.
          <component>-type ?= lo_typedescr.
          CONCATENATE 'YEARVAL' lc_underscore lv_index INTO <component>-name.
          <component>-as_include  = abap_true.
          CONCATENATE lc_underscore lv_index INTO <component>-suffix.
        ENDDO.
    * create description object for structured type
        lo_structdescr = cl_abap_structdescr=>create( lt_comp_all ).
    *  create table description object for this
        lo_tabledescr = cl_abap_tabledescr=>create(
                        p_line_type  = lo_structdescr
                        p_table_kind = cl_abap_tabledescr=>tablekind_std
                        p_unique     = abap_false ).
    * create data object
        CREATE DATA lr_data TYPE HANDLE lo_tabledescr.
    ASSIGN lr_data->* to <table>.
    This is a fragment. Please adapt to your needs.
    Regards,
    Clemens

  • Custom total/subtotal formula in an ALV Grid and printing.

    I have an ALV grid using OOPs method (Class cl_gui_alv_grid). The table that I am displaying is a dynamic table.
    call method o_grid->set_table_for_first_display
        exporting
          is_variant      = gx_variant
          i_save          = 'A'
          is_layout       = gs_layout
        changing
          it_fieldcatalog = it_fldcat
          it_outtab       = <gt_tabletotal>.
    On one of the columns in the ALV grid, instead of the regular summation, I had to do weighted averages (not avg).
    I built a logic to manipulate this total field for that column using field symbols.
    CALL METHOD o_grid->get_subtotals
        IMPORTING ep_collect00 = total
                  ep_collect01 = subto.
    ASSIGN total->* TO <ftotal>.
    ASSIGN subto->* TO <fsubto>.
    CALL METHOD o_grid->refresh_table_display
       EXPORTING I_SOFT_REFRESH = '1' .
    I manipulated <ftotal>-mycustomformulafield field there using some logic.
    In my field catalog i have the above field with wa_it_fldcat-do_sum = 'X ' .
    Now, II am able to see my custom formula on the screen. But when I print the grid using the print button or when I export to an excel sheet(I use export to local file and then select excel there) , my custom formula that i calculated above is reset to 0.000 .
    (Also when I email the grid, my custom formula is wiped). How can I avoid this ? Any useful suggestion is well appreciated.

    Hi, Shareen,
    We have the same problema here.
    Could you solve it?
    Thanks in advance

  • How to print $ symbol in ALV outout

    using ALV grid with function modules how to print $ symbol in output.
    like $ 11.85  in ALV grid
    please help me

    take a character type field in itab.
    loop at itab.
    concatenate '$' itab-amt into itab-chamt.
    modify itab.
    endloop.
    now in fieldcat just pass that itab-chamt field in place of itab-amt.
    regards
    shiba dutta

Maybe you are looking for

  • To see values of same column in a single row

    Hi, I have a requirement. I've to show all the column values in a row (as a comma separated) through a single query (No custom functions can't be used). For example EMP table has these records (no fix no. of records). empno ename 123 BILL 234 SCOTT 2

  • Return file data

    ok, I want to create a sub-routine in a spearate class that when I call it opens up a file and returns the file data result in a string. so: string = file.GetFile("filename.txt"); And that gives me the data contained in a file in one string varaible.

  • Recovering music library after restoring iPod Touch

    My uncle bought a used iPod Touch, which came with a bunch of music on it.  At some point, it froze on him, and he restarted it, and then restored it.  At that point, he lost all that music.  He is hoping to get it back.  I told him that the music is

  • Can anyone help me in DefaultTreeModel insertNodeInto(.. meth.

    hi, I am adding items or nodes to my DefaultTreeModel. And I have a probelm I am trying to build a tree structure by clicking on an item and adding it under the previous one. That is if I add one item and then add another item then the first item is

  • Left pane (with TOC, Search, ect) is collapsed in .CHM

    This works fine when I am viewing the .chm just after creating it in RH. But when I copy to a different location (like a desktop), or open from within the software app, the contents pane is not visible unless you drag the divider to expand it. Does a