Update all alv (grid) displayed records to internal table

Hi all,
i want to update the records into the internal table which are changed by the user in the edit field.
after he select save button.
i  have to save the ALV grid displayed records in the internal table.
hw can i do this ?

ALV with EDIT and SAVE functionality
Code: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

Similar Messages

  • How to get  selected records from an ALV  Grid in some other internal table

    I am using a standard SAP program (RFKKMA02) in a Z program. Now i want to select some rows in ALV and after doing some modification, i want to store those records in some other internal table. I am not using OO concept.
    Thanks in advance.

    u create first internal table of structur of fields that u want to copy and then move taht values to internal table

  • Text after end of each type in ALV GRID DISPLAY

    Hi Experts,
    My Requirement is that after end of every order type I need to give the text to display how many records are there under that order type in ALV GRID DISPLAY.
    Sample internal table is shown below
    Ordertyp       date
    PM1            25/05/2010
    PM1            25/05/2010
    PM2            25/05/2010
    PM2            25/05/2010
    PM2            25/05/2010
    PM2           25/05/2010
    Out put should be as shown below
    PM1       25/05/2010
    PM1       25/05/2010
    Total PM1 order types are 2
    PM2     25/05/2010
    PM2     25/05/2010
    PM2    25/05/2010
    PM2    25/05/2010
    Total PM2 Order types are 4
    Total all order types are 6.
    Please note here I am not doing any subtotal, just I want to display how many records are there under that particular order
    Thanks
    Babumiya Mohammad

    Hi,
    whatever it may be you can very well use the given logic to build.
    Let say you are making the final table for display. While final table display make the process and append the data in final table itself and pass it to ALV.
    LOOP AT ITAB.
    ITAB1-FLD1 = ITAB-FLD1
    ITAB1-FLD2 = ITAB-FLD2
    APPEND ITAB1.
    *For making the count
    L_Cnt = L_cnt + 1.
    At end of OrdTYP
    L_ord_text = L_cnt.
    MOVE L_ORD_TEXT  to L_SUB_TEXT.
    L_TEXT1 = '' TOTAL"
    L_TEXT2 =  "Order types are"
    concatenate L_TEXT    ITAB-ORDTYP   L_TEXT2       L_ord_text      into            l_TOT1.
    ITAB1- FLD2 = L_TOT1.
    APPEDN ITAB1.
    clear : L_cnt, L_ord_text .
    ENDLOOP.
    L_TOT_TEXT = L_TOT_TEXT + L_SUB_TEXT  ( Here you will get total order type count)
    Do the conactenate
    L_TEXT3 = " Total all order types are"
    concatenate L_TEXT3    L_TOT_TEXT  INTo L_TOT2.
    ITAB1-FLD2 =  L_TOT2.
    APPEND IATB1.
    Here you will total text. Like above you can build the logic. It will work fine.
    You should not clear the L_SUB_TEXT.

  • 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.

  • Not able to download all the rows to excel sheet from alv grid display

    Hi experts,
    I am not able to download all the rows which are displayed in alv grid display for some material numbers.
    for some materials i am able to download, i used two ways to download 1) from icon(local file) on grid 2) menu list->export.
    i checked in debugging till selecting the spread sheet pop up window, i am able to see all the data in internal table.
    Can you suggest me what will be the problem....
    thanks in advance,

    hi sandeep,
    sorry for didnt specify clearly.
    note: EX: "asaasdada  in this sentence i said  " this symbol is special character not the text.
    building final internal table code
    CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
        EXPORTING
          capid                 = p_capid
          datuv                 = sy-datum
          ehndl                 = '1'
          mktls                 = 'X'
          mehrs                 = 'X'
          mmory                 = '1'
          mtnrv                 = p_matnr
          stlal                 = '1'
          stpst                 = 0
          svwvo                 = 'X'
          werks                 = p_werks
          vrsvo                 = 'X'
        TABLES
          stb                   = i_stb
        EXCEPTIONS
          alt_not_found         = 1
          call_invalid          = 2
          material_not_found    = 3
          missing_authorization = 4
          no_bom_found          = 5
          no_plant_data         = 6
          no_suitable_bom_found = 7
          conversion_error      = 8
          OTHERS                = 9.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      i_stb1[] = i_stb[].
      IF NOT i_stb1[] IS INITIAL.
        SORT i_stb1 BY idnrk.
        DELETE ADJACENT DUPLICATES FROM i_stb1 COMPARING idnrk.
        SELECT bmatn ematn FROM ampl INTO TABLE i_ampl
          FOR ALL ENTRIES IN i_stb1
          WHERE bmatn = i_stb1-idnrk AND
                datuv LE sy-datum AND                          
                datub GE sy-datum.                              
        SELECT
        matnr
        bwkey
        verpr
        stprs
        bwprh
        FROM mbew
        INTO TABLE i_mbew
        FOR ALL ENTRIES IN i_stb1
        WHERE
            matnr EQ i_stb1-idnrk AND
            bwkey EQ i_stb1-werks.
        IF NOT i_stb1[] IS INITIAL.
          SELECT matnr werks beskz
                 dzeit webaz plifz                              
                 ekgrp                                         
          INTO TABLE i_marc
          FROM marc
          FOR ALL ENTRIES IN i_stb1
          WHERE matnr = i_stb1-idnrk
          AND werks = i_stb1-werks.
          SORT i_marc BY matnr werks.
        ENDIF.
        CLEAR i_ekpo.
        CLEAR i_vend.
        IF NOT i_stb1[] IS INITIAL.
          SELECT ebeln ebelp matnr werks loekz aedat
                 netpr peinh                                   
          INTO TABLE i_ekpo
          FROM ekpo
                FOR ALL ENTRIES IN i_stb1
                WHERE matnr = i_stb1-idnrk
                AND werks = i_stb1-werks.
          SORT i_ekpo BY matnr ASCENDING
                         aedat DESCENDING
                         ebeln DESCENDING
                         ebelp DESCENDING.
          IF NOT i_ekpo IS INITIAL.
            SELECT k~ebeln k~lifnr l~name1
            INTO TABLE i_vend
            FROM ekko AS k INNER JOIN lfa1 AS l
            ON k~lifnr EQ l~lifnr
            FOR ALL ENTRIES IN i_ekpo
            WHERE ebeln = i_ekpo-ebeln.
            SORT i_vend BY ebeln.
          ENDIF.
        ENDIF.
      ENDIF.
      i_ampl1[] = i_ampl[].
      IF NOT i_ampl1[] IS INITIAL.
        SORT i_ampl1 BY ematn.
        DELETE ADJACENT DUPLICATES FROM i_ampl1 COMPARING ematn.
        SELECT matnr mfrpn mfrnr FROM mara INTO TABLE i_mara
          FOR ALL ENTRIES IN i_ampl1
           WHERE matnr = i_ampl1-ematn.
      ENDIF.
      SORT i_ampl BY bmatn.
      IF NOT i_stb[] IS INITIAL.
        SELECT stlty stlnr stlkn stpoz idnrk potx1 potx2
        INTO TABLE i_stpo
        FROM stpo
        FOR ALL ENTRIES IN i_stb
        WHERE stlty = i_stb-stlty
          AND stlnr = i_stb-stlnr
          AND stlkn = i_stb-stlkn
          AND stpoz = i_stb-stpoz
          AND idnrk = i_stb-idnrk.
        SORT i_stpo BY stlty stlnr stlkn stpoz idnrk.
      ENDIF.
      LOOP AT i_stb INTO wa_stb.
        READ TABLE i_marc INTO wa_marc
        WITH KEY     matnr = wa_stb-idnrk
                     werks = wa_stb-werks
                     BINARY SEARCH.
        IF sy-subrc = 0.
          wa_outtab-beskz = wa_marc-beskz.
          wa_outtab-dzeit = wa_marc-dzeit.                      
          wa_outtab-webaz = wa_marc-webaz.                     
          wa_outtab-plifz = wa_marc-plifz.                     
          wa_outtab-ekgrp = wa_marc-ekgrp.                     
        ENDIF.
        READ TABLE i_ekpo INTO wa_ekpo
            WITH KEY matnr = wa_stb-idnrk.
        IF sy-subrc = 0.
          wa_outtab-netpr = wa_ekpo-netpr.                     
          wa_outtab-peinh = wa_ekpo-peinh.                     
          READ TABLE i_vend INTO wa_vend
          WITH KEY ebeln = wa_ekpo-ebeln
                   BINARY SEARCH.
          IF sy-subrc = 0.
            wa_outtab-lifnr = wa_vend-lifnr.
            wa_outtab-name_sup = wa_vend-name1.
          ENDIF.
        ENDIF.
        READ TABLE i_stpo INTO wa_stpo
        WITH KEY stlty = wa_stb-stlty
                 stlnr = wa_stb-stlnr
                 stlkn = wa_stb-stlkn
                 stpoz = wa_stb-stpoz
                 idnrk = wa_stb-idnrk
                 BINARY SEARCH.
        IF sy-subrc = 0.
          wa_outtab-potx1 = wa_stpo-potx1.
          wa_outtab-potx2 = wa_stpo-potx2.
        ENDIF.
        READ TABLE i_mbew INTO wa_mbew
        WITH KEY
        matnr = wa_stb-idnrk
        bwkey = wa_stb-werks.
        IF sy-subrc IS INITIAL.
          MOVE:
          wa_mbew-verpr TO wa_outtab-verpr,
          wa_mbew-stprs TO wa_outtab-stprs,
          wa_mbew-bwprh TO wa_outtab-bwprh.
        ENDIF.
        wa_outtab-matnr = p_matnr.
        wa_outtab-posnr = wa_stb-posnr.
        wa_outtab-stufe = wa_stb-stufe.
        wa_outtab-idnrk = wa_stb-idnrk.
        wa_outtab-ojtxb = wa_stb-ojtxp.
        wa_outtab-menge = wa_stb-menge.
        wa_outtab-meins = wa_stb-meins.
        MOVE: wa_stb-zzitem_draw_no TO wa_outtab-zzitem_draw_no.
        IF wa_stb-upskz = 'X'.
          SELECT * FROM stpu INTO TABLE i_stpu
                   WHERE  stlty = wa_stb-stlty AND
                          stlnr = wa_stb-stlnr AND
                          stlkn = wa_stb-stlkn AND
                          stpoz = wa_stb-stpoz.
        ENDIF.
        LOOP AT i_stpu INTO wa_stpu.
          wa_outtab-upmng = wa_stpu-upmng.
          wa_outtab-ebort = wa_stpu-ebort.
          wa_outtab-uposz = wa_stpu-uposz.
          CONCATENATE v_ebort wa_stpu-ebort      INTO v_ebort
          SEPARATED BY space.
        ENDLOOP.
        MOVE strlen( v_ebort ) TO v_len.
        MOVE: 0 TO x,
          128 TO y.
        DATA : lt_tab TYPE TABLE OF swastrtab.
        DATA : ls_tab LIKE LINE OF lt_tab.
        DATA : lv_ebort TYPE string.
        CLEAR lv_ebort. CLEAR lt_tab.
        MOVE v_ebort TO lv_ebort.
        CALL FUNCTION 'SWA_STRING_SPLIT'
          EXPORTING
            input_string                 = lv_ebort
            max_component_length         = 128
          TABLES
            string_components            = lt_tab
          EXCEPTIONS
            max_component_length_invalid = 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.
        IF lt_tab[] IS NOT INITIAL.
          LOOP AT lt_tab INTO ls_tab.
            CLEAR lv_ebort.
            MOVE: ls_tab-str TO lv_ebort.
            CONDENSE lv_ebort.
            MOVE lv_ebort TO wa_outtab-ebort.
            APPEND wa_outtab TO i_outtab.
            CLEAR:
            wa_outtab-matnr,
            wa_outtab-posnr,
            wa_outtab-zzitem_draw_no,
            wa_outtab-ojtxb,
            wa_outtab-menge,
            wa_outtab-meins,
            wa_outtab-uposz,
            wa_outtab-upmng,
            wa_outtab-verpr,
            wa_outtab-stprs,
            wa_outtab-bwprh,
            wa_outtab-lifnr,
            wa_outtab-name_sup,
            wa_outtab-potx1,
            wa_outtab-potx2,
            wa_outtab-netpr,
            wa_outtab-peinh.
    *        wa_outtab-idnrk.
          ENDLOOP.
        ELSE.
          APPEND wa_outtab TO i_outtab.
        ENDIF.
        CLEAR v_ebort.
        CLEAR: wa_stpu.
        REFRESH: i_stpu.
        LOOP AT i_ampl INTO wa_ampl WHERE bmatn = wa_stb-idnrk.
        READ TABLE i_mara INTO wa_mara WITH TABLE KEY matnr = wa_ampl-ematn.
          IF sy-subrc = 0.
            LOOP AT i_outtab INTO wa_outtab
            WHERE
            idnrk = wa_stb-idnrk AND
            flag NE 'X'.
              wa_outtab-mfrpn = wa_mara-mfrpn.
              wa_outtab-mfrnr = wa_mara-mfrnr.
              SELECT SINGLE name1 FROM lfa1 INTO wa_outtab-name1 WHERE lifnr = wa_mara-mfrnr.
              MOVE 'X' TO wa_outtab-flag.
              MODIFY i_outtab FROM wa_outtab
              TRANSPORTING mfrpn mfrnr name1 flag.
              EXIT.
            ENDLOOP.
            IF sy-subrc <> 0.
              CLEAR:
              wa_outtab-matnr,
              wa_outtab-posnr,
              wa_outtab-zzitem_draw_no,
              wa_outtab-ojtxb,
              wa_outtab-ebort,
    *          wa_outtab-idnrk,
              wa_outtab-menge,
              wa_outtab-meins,
              wa_outtab-uposz,
              wa_outtab-upmng,
              wa_outtab-verpr,
              wa_outtab-stprs,
              wa_outtab-bwprh,
              wa_outtab-lifnr,                                 
              wa_outtab-name_sup,                              
              wa_outtab-potx1,                                 
              wa_outtab-potx2,                                 
              wa_outtab-netpr,                                 
              wa_outtab-peinh.                                 
              wa_outtab-mfrpn = wa_mara-mfrpn.
              wa_outtab-mfrnr = wa_mara-mfrnr.
              SELECT SINGLE name1 FROM lfa1 INTO wa_outtab-name1 WHERE lifnr = wa_mara-mfrnr.
              APPEND wa_outtab TO i_outtab.
            ENDIF.
          ENDIF.
          REFRESH i_stpu.
          CLEAR i_stpu.
        ENDLOOP.    CLEAR: wa_matnr1, wa_mfrnr, wa_outtab.
      ENDLOOP.
    Edited by: srinivasareddy j on Mar 9, 2011 7:16 AM
    Edited by: srinivasareddy j on Mar 9, 2011 7:20 AM

  • To update an alv grid..

    Hello everyone,
    I have a requirement.
      update button in selection-screen.
    I have an alv grid display and I have to maintain last 2 fields in editable mode in the output and the user will enter the values after executing the report in the output screen and will save it.
    and when he will select  display radiobutton in the selection-screen ,,
    the entries which he entered above has to display ,,( all the entries should display in the output ).
    is it possible ? if yes, then let me know the procedure.
    will be rewarded..

    Hi,
           yes it is possible 
    all u need to do is call a new alv with same funtion modules and pass the updated internal table to these function modules
    i have the same req for 'SAVE' button in menu , u just change it by your radio button in the sample code below
    type-pools : slis.
    types : begin of t_mat,
            matnr type matnr,
            werks type werks_d,
            lgort type lgort_d,
            labst type labst,
            meins type meins,
            maktx type maktx,
            name1 type name1,
            lgobe type lgobe,
            msehl type msehl,
            v_lights type c,
            v_row type c length 4,     "FOR ROW COLOR
            v_col type slis_t_specialcol_alv,
            end of t_mat,
            begin of t_makt,
            matnr type matnr,
            maktx type maktx,
            end of t_makt,
            begin of t_marc,
            matnr type matnr,
            werks type werks_d,
            end of t_marc,
            begin of t_mard,
            matnr type matnr,
            werks type werks_d,
            lgort type lgort_d,
            labst type labst,
            end of t_mard,
            begin of t_t001l,
            werks type werks_d,
            lgort type lgort_d,
            lgobe type lgobe,
            end of t_t001l,
            begin of t_t001w,
            werks type werks_d,
            name1 type name1,
            end of t_t001w.
    types : begin of wa_mat,
            werks type werks,
            end of wa_mat.
    data : flag type i value 0.
    ******VARIABLE DECLARATION********
    data:v_prog_name type sy-repid,      "VARIABLE FOR PROG NAME
         v_grid_title type lvc_title. "VARIABLE FOR GRID TITLE
    *****INTERNAL TABLE DECLARATION***
    data:  it_mat type standard table of t_mat,
           it_marc type standard table of t_marc,
           it_mard type standard table of t_mard,
           it_t001l type standard table of t_t001l,
           it_t001w type standard table of t_t001w,
           it_makt type standard table of t_makt,
           it_fieldcat  type slis_t_fieldcat_alv,
           it_sortinfo   type slis_t_sortinfo_alv,
           it_eventcat   type slis_t_event,
           it_listheader type slis_t_listheader,
           t_color type slis_specialcol_alv.
    data : it_werks type standard table of wa_mat.
    *****WORK AREA DECLARATION*********
    data:  wa_mat type t_mat,
           wa_mard type t_mard,
           wa_t001l type t_t001l,
           wa_t001w type t_t001w,
           wa_makt type t_makt,
           wa_layout type slis_layout_alv.
    data : wa_werks type wa_mat.
    data : wa_variant1          like disvariant,
           wa_variant2          like disvariant.
               Selection-Screen                        *
    selection-screen begin of block plant with frame title text-001.
    select-options:  s_plant for wa_mat-werks,
                     s_stor for wa_mat-lgort.
    parameters     : p_var like disvariant-variant.
    selection-screen end of block plant.
    selection-screen begin of block output with frame title text-002.
    parameter:  p_rb_01 radiobutton group rd1 default 'X',  " list
                p_rb_02 radiobutton group rd1.              " grid
    selection-screen end of block output.
                   Initialization                      *
    perform zf_initialization.
                 At Selection Screen                   *
    at selection-screen on value-request for p_var.
      wa_variant1-report = sy-repid.
      call function 'REUSE_ALV_VARIANT_F4'
        exporting
          is_variant                = wa_variant1
      I_TABNAME_HEADER          =
      I_TABNAME_ITEM            =
      IT_DEFAULT_FIELDCAT       =
         i_save                    = 'A'
       i_display_via_grid        = 'X'
    importing
        e_exit                    = v_exit
         es_variant                = wa_variant2
       exceptions
         not_found                 = 1
         program_error             = 2
         others                    = 3
      if sy-subrc = 0.
        p_var = wa_variant2-variant.
      else.
        clear wa_variant2.
      endif.
    at selection-screen.
      perform zf_validate_sel_screen.
                Start of Selection                     *
    start-of-selection.
      perform zf_get_data.
              End of Selection                         *
    end-of-selection.
      perform zf_display_data.
    *&      Form  zf_initialization
      This will intialize all the variables, work area & subroutines
    -->  p1        text
    <--  p2        text
    form zf_initialization .
      clear :   wa_mat,
                wa_mard,
                wa_t001l,
                wa_t001w,
                wa_makt,
                wa_layout.
      refresh : it_mat,
                it_marc,
                it_mard,
                it_t001l,
                it_t001w,
                it_makt,
                it_fieldcat,
                it_sortinfo,
                it_eventcat,
                it_listheader.
      v_prog_name = sy-repid.
      wa_variant2-report = sy-repid.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
        exporting
          i_save        = 'A'
        changing
          cs_variant    = wa_variant2
        exceptions
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          others        = 4.
      if sy-subrc = 0.
        p_var = wa_variant2-variant.
      else.
        p_var = '/DEFAULT'.
      endif.
    endform.                    " zf_initialization
    *&      Form  zf_validate_sel_screen
      This is to validate the inputs on the selction screen
    -->  p1        text
    <--  p2        text
    form zf_validate_sel_screen .
      if not p_var is initial.
        wa_variant1-report = sy-repid.
        wa_variant1-variant = p_var.
        call function 'REUSE_ALV_VARIANT_EXISTENCE'
          exporting
            i_save        = 'A'
          changing
            cs_variant    = wa_variant1
          exceptions
            wrong_input   = 1
            not_found     = 2
            program_error = 3
            others        = 4.
        if sy-subrc = 0.
          clear wa_variant2.
          move p_var to wa_variant2-variant.
          move sy-repid to wa_variant2-report.
        else.
          message e006. "No such variant exists
        endif.
      else.
        clear wa_variant1.
      endif.
      select werks from marc into wa_mat-werks where werks in s_plant.
        exit.
      endselect.
      if sy-subrc <> 0.
        message e002.
        clear wa_mat.
      endif.
      select lgort from mard into wa_mat-lgort where lgort in s_stor.
        exit.
      endselect.
      if sy-subrc <> 0.
        message e003.
        clear wa_mat.
      endif.
    endform.                    " zf_validate_sel_screen
    *&      Form  zf_get_data
      This will fetch data from the database tables & finally merge them
         into a single internal table, to pass it to alv
    -->  p1        text
    <--  p2        text
    form zf_get_data .
      select matnr werks into table it_marc from marc where werks in s_plant
      if sy-subrc = 0.
        sort it_marc by matnr werks.
      endif.
      if it_marc[] is not initial.
        select matnr maktx into table it_makt from makt
                          for all entries in it_marc
                          where matnr = it_marc-matnr
                            and spras = sy-langu.
        if sy-subrc = 0.
          sort it_makt by matnr.
        endif.
        select matnr werks lgort labst into table it_mard from mard
                                       for all entries in it_marc
                                       where matnr = it_marc-matnr
                                             and werks = it_marc-werks
                                             and lgort in s_stor.
        if sy-subrc = 0.
          sort it_mard by matnr werks lgort.
        endif.
        select werks name1 into table it_t001w from t001w
                           for all entries in it_marc
                           where werks = it_marc-werks.
        if sy-subrc = 0.
          sort it_t001w by werks.
        endif.
      endif.
      if it_mard[] is not initial.
        select werks lgort lgobe into table it_t001l from t001l
                                 for all entries in it_mard
                                 where werks = it_mard-werks
                                   and lgort = it_mard-lgort.
        if sy-subrc = 0.
          sort it_t001l by werks lgort.
        endif.
      endif.
      clear : wa_mat,
              wa_mard,
              wa_t001l,
              wa_t001w,
              wa_makt.
      loop at it_mard into wa_mard.
        wa_mat-matnr = wa_mard-matnr.
        wa_mat-werks = wa_mard-werks.
        wa_mat-lgort = wa_mard-lgort.
        wa_mat-labst = wa_mard-labst.
        read table it_makt into wa_makt with key matnr = wa_mard-matnr
    binary search.
        if sy-subrc = 0.
          wa_mat-maktx = wa_makt-maktx.
        endif.
        read table it_t001l into wa_t001l with key werks = wa_mard-werks
    lgort = wa_mard-lgort binary search.
        if sy-subrc = 0.
          wa_mat-lgobe = wa_t001l-lgobe.
        endif.
        read table it_t001w into wa_t001w with key werks = wa_mard-werks
    binary search.
        if sy-subrc = 0.
          wa_mat-name1 = wa_t001w-name1.
        endif.
        append wa_mat to it_mat.
      endloop.
      sort it_mat by matnr werks lgort.
      loop at it_mat into wa_mat.
        clear t_color.
        if wa_mat-labst < 100.
          wa_mat-v_lights = '1'.
          t_color-fieldname = 'LABST'.
          t_color-color-col = 6.
          append t_color to wa_mat-v_col.
          wa_mat-v_row = 'C610'.
          modify it_mat from wa_mat.
        elseif wa_mat-labst < 1000.
          wa_mat-v_lights = '2'.
          t_color-fieldname = 'LABST'.
          t_color-color-col = 3.
          append t_color to wa_mat-v_col.
          wa_mat-v_row = 'C510'.
          modify it_mat from wa_mat.
        else.
          wa_mat-v_lights = '3'.
          t_color-fieldname = 'LABST'.
          t_color-color-col = 5.
          append t_color to wa_mat-v_col.
          wa_mat-v_row = 'C210'.
          modify it_mat from wa_mat.
        endif.
        clear wa_mat.
      endloop.
    endform.                    " zf_get_data
    *&      Form  zf_display_data
    -->  p1        text
    <--  p2        text
    form zf_display_data .
    *If Internal Table Is Populated Then Only Display Alv Report.
      if not it_mat[] is initial.
    &---Prepare fieldcatalog .
        perform zf_build_fieldcat using it_fieldcat.
    &---Build event catalog.
        perform zf_eventcat using it_eventcat.
    &---Build Listheader for TOP OF PAGE EVENT.
        perform zf_build_listheader using it_listheader.
    &---Build layout.
        perform zf_layout.
    &---Build sorting.
        perform zf_sorting using it_sortinfo.
    &---Initializating Grid Title
        perform zf_build_grid_title.
    IF GRID RADIO button (ALV GRID) IS selected .
        if p_rb_02 is not initial.
    DISPLAY ALV GRID.
          perform zf_display_alv_grid.
        else.
    DISPLAY ALV LIST.
          perform zf_display_alv_list.
        endif.
      else.
    *&---If Table is not Populated ie Records Does not exist
        message s001.
      endif.
    endform.                    " zf_display_data
    *&      Form  ZF_BUILD_FIELDCAT
          text
         -->P_IT_FIELDCAT  text
    form zf_build_fieldcat  using    p_it_fieldcat type slis_t_fieldcat_alv.
    *Declaring Local Variable
      data: l_fieldcat type slis_fieldcat_alv.
      clear l_fieldcat.
    for First field
      l_fieldcat-col_pos     = '1'.          "POSITION OF THE COLUMN.
      l_fieldcat-fieldname   = 'WERKS'.      "FIELD FOR WHICH CATALOG
      l_fieldcat-tabname     = 'IT_MAT'.     "NAME OF INTERNAL TABLE
      l_fieldcat-ref_tabname = 'MARC'.       "FOR F1 & F4 HELP AS REFERNCED
      l_fieldcat-key         = 'X'.          "MAKING FIELD AS KEY FIELD
      l_fieldcat-outputlen   =  4.           "SET THE OUTPUT LENGTH.
      l_fieldcat-seltext_l   = text-003.  "Long text for header.
      l_fieldcat-seltext_m   = text-003.    "Medium text for header.
      l_fieldcat-seltext_s   = text-003.           "Short text for header.
      append l_fieldcat to p_it_fieldcat.
      clear l_fieldcat.
    for Second field
      l_fieldcat-col_pos     = '2'.          "POSITION OF THE COLUMN.
      l_fieldcat-fieldname   = 'LGORT'.      "FIELD FOR WHICH CATALOG
      l_fieldcat-tabname     = 'IT_MAT'.     "NAME OF INTERNAL TABLE
      l_fieldcat-ref_tabname = 'MARD'.       "FOR F1 & F4 HELP AS REFERNCED
      l_fieldcat-key         = 'X'.          "MAKING FIELD AS KEY FIELD
      l_fieldcat-outputlen   =  4.           "SET THE OUTPUT LENGTH.
      l_fieldcat-seltext_l   = text-004.  "Long text for header.
      l_fieldcat-seltext_m   = text-005.    "Medium text for header.
      l_fieldcat-seltext_s   = text-006.           "Short text for header.
      append l_fieldcat to p_it_fieldcat.
      clear l_fieldcat.
    for third field
      l_fieldcat-col_pos     = '3'.          "POSITION OF THE COLUMN.
      l_fieldcat-fieldname   = 'MATNR'.      "FIELD FOR WHICH CATALOG
      l_fieldcat-tabname     = 'IT_MAT'.     "NAME OF INTERNAL TABLE
      l_fieldcat-ref_tabname = 'MARA'.       "FOR F1 & F4 HELP AS REFERNCED
    l_fieldcat-key         = 'X'.          "MAKING FIELD AS KEY FIELD
      l_fieldcat-outputlen   =  18.           "SET THE OUTPUT LENGTH.
      l_fieldcat-seltext_l   = text-007.  "Long text for header.
      l_fieldcat-seltext_m   = text-008.    "Medium text for header.
      l_fieldcat-seltext_s   = text-009.           "Short text for header.
      append l_fieldcat to p_it_fieldcat.
      clear l_fieldcat.
    for fourth field
      l_fieldcat-col_pos     = '4'.          "POSITION OF THE COLUMN.
      l_fieldcat-fieldname   = 'LABST'.      "FIELD FOR WHICH CATALOG
      l_fieldcat-tabname     = 'IT_MAT'.     "NAME OF INTERNAL TABLE
      l_fieldcat-ref_tabname = 'MARD'.       "FOR F1 & F4 HELP AS REFERNCED
      l_fieldcat-outputlen   =  16.           "SET THE OUTPUT LENGTH.
      l_fieldcat-seltext_l   = text-010.  "Long text for header.
      l_fieldcat-seltext_m   = text-011.    "Medium text for header.
      l_fieldcat-seltext_s   = text-012.           "Short text for header.
      l_fieldcat-do_sum = 'X'.
      l_fieldcat-input       = 'X'.          "Making the field editable
      l_fieldcat-edit        = 'X'.
      append l_fieldcat to p_it_fieldcat.
      clear l_fieldcat.
    endform.                    " ZF_BUILD_FIELDCAT
    *&      Form  zf_eventcat
          text
         -->P_IT_EVENTCAT  text
    form zf_eventcat  using    p_it_eventcat type slis_t_event.
      data l_eventcat type slis_alv_event.
      clear l_eventcat.
    *Get all the events.
      call function 'REUSE_ALV_EVENTS_GET'
        exporting
          i_list_type     = 0
        importing
          et_events       = p_it_eventcat
        exceptions
          list_type_wrong = 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.
    TOP-OF-PAGE FORM
      clear l_eventcat.
      read table p_it_eventcat into l_eventcat with key
                              name = slis_ev_top_of_page.
      if sy-subrc = 0.
        move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                             transporting form.
      endif.
    PF_STATUS_SET FORM
      clear l_eventcat.
      read table p_it_eventcat into l_eventcat with key
                              name = slis_ev_pf_status_set.
      if sy-subrc = 0.
        move 'ZF_PF_STATUS_SET' to l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                          transporting form.
      endif.
    USER_COMMAND FORM
      clear l_eventcat.
      read table p_it_eventcat into  l_eventcat with key
                               name = slis_ev_user_command.
      if sy-subrc = 0.
        move 'ZF_USER_COMMAND' to  l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                          transporting form.
      endif.
    endform.                    " zf_eventcat
    *&      Form  ZF_BUILD_LISTHEADER
          text
         -->P_IT_LISTHEADER  text
    form zf_build_listheader  using  p_it_listheader type slis_t_listheader.
      data: l_listheader type slis_listheader.
      refresh p_it_listheader.
      clear l_listheader.
      l_listheader-typ = 'H'.   "Header
    l_listheader-key = 'FCIL,INDIA'. "Ignored for "Header" Type
      l_listheader-info = text-013.
      append l_listheader to p_it_listheader.
      clear l_listheader.
      data : lv_date(10) type c .
      write sy-datum to lv_date .
      l_listheader-typ = 'S'.
      l_listheader-key = 'DATE'.
      l_listheader-info = lv_date.
      append l_listheader to p_it_listheader.
      clear l_listheader.
      l_listheader-typ = 'A'.
    l_listheader-key = 'COMMENT'.    " key is ignored
      l_listheader-info = text-014.
      append l_listheader to p_it_listheader.
      clear l_listheader.
      l_listheader-typ = 'S'.
      l_listheader-key = text-016.
    l_listheader-info = 'Input Plant'.
      append l_listheader to p_it_listheader.
      clear l_listheader.
      l_listheader-typ = 'S'.
      l_listheader-key = text-017.
    l_listheader-info = 'Plant'.
      append l_listheader to p_it_listheader.
      select werks from marc into  table it_werks where werks in s_plant.
      sort it_werks by werks.
      delete adjacent duplicates from it_werks comparing werks.
      loop at it_werks into wa_werks.
        clear l_listheader.
        l_listheader-typ = 'S'.
       l_listheader-key = 'X'.
        l_listheader-info = wa_werks-werks.
        append l_listheader to p_it_listheader.
      endloop.
    endform.                    " ZF_BUILD_LISTHEADER
    *&      Form  ZF_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    form zf_layout .
      clear wa_layout.
      wa_layout-zebra = 'X'.
      wa_layout-lights_fieldname = 'V_LIGHTS'.
      wa_layout-lights_tabname   = 'IT_MAT'.
      wa_layout-info_fieldname = 'V_ROW'. " infofield for listoutput
      wa_layout-coltab_fieldname = 'V_COL'. " colors
    endform.                    " ZF_LAYOUT
    *&      Form  ZF_SORTING
          text
         -->P_IT_SORTINFO  text
    form zf_sorting  using    p_it_sortinfo type slis_t_sortinfo_alv.
      data l_sortinfo type slis_sortinfo_alv.
      clear l_sortinfo.
      l_sortinfo-spos = '1'.
      l_sortinfo-fieldname = 'WERKS'.
      l_sortinfo-tabname = 'IT_MAT'.
      l_sortinfo-up = 'X'.
      l_sortinfo-group = 'UL'.              "UNDERLINE AFTER EVERY GROUP
      l_sortinfo-subtot = 'X'.
      append l_sortinfo to p_it_sortinfo.
    endform.                    " ZF_SORTING
    *&      Form  ZF_BUILD_GRID_TITLE
          text
    -->  p1        text
    <--  p2        text
    form zf_build_grid_title .
      v_grid_title = text-015.
    endform.                    " ZF_BUILD_GRID_TITLE
    *&      Form  ZF_DISPLAY_ALV_GRID
          text
    -->  p1        text
    <--  p2        text
    form zf_display_alv_grid .
      call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = v_prog_name
       i_callback_pf_status_set          = 'ZF_PF_STATUS_SET'
       i_callback_user_command           = 'ZF_USER_COMMAND'
       i_callback_top_of_page            = 'ZF_TOP_OF_PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
         i_grid_title                      = v_grid_title
      I_GRID_SETTINGS                   =
         is_layout                         = wa_layout
         it_fieldcat                       = it_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sortinfo
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
       i_save                            = 'A'
       is_variant                        = wa_variant2
       it_events                         = it_eventcat
      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_mat
    exceptions
       program_error                     = 1
       others                            = 2
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " ZF_DISPLAY_ALV_GRID
    *&      Form  zf_display_alv_list
          text
    -->  p1        text
    <--  p2        text
    form zf_display_alv_list .
      call function 'REUSE_ALV_LIST_DISPLAY'
       exporting
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
         i_callback_program             = v_prog_name
       i_callback_pf_status_set       = 'ZF_PF_STATUS_SET'
       i_callback_user_command        = 'ZF_USER_COMMAND'
      I_STRUCTURE_NAME               =
         is_layout                      = wa_layout
         it_fieldcat                    = it_fieldcat
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
       it_sort                        = it_sortinfo
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = 'A'
      IS_VARIANT                     = WA_VARIANT2
       it_events                      = it_eventcat
      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_mat
       exceptions
         program_error                  = 1
         others                         = 2
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " zf_display_alv_list
    *&      Form  zf_top_of_page
          text
    -->  p1        text
    <--  p2        text
    form zf_top_of_page .
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary       = it_listheader
         i_logo                   = 'ENJOYSAP_LOGO'
      I_END_OF_LIST_GRID       =
    endform.                    " zf_top_of_page
    *&      Form  zf_pf_status_set
          text
    -->  p1        text
    <--  p2        text
    form zf_pf_status_set using rt_extab type slis_t_extab.
      set pf-status  'ALV_MENU_MAT' excluding  'BACK'.
      case sy-ucomm.
        when 'SAVE'.
    IF flag <> 0.
          set pf-status  'ALV_MENU_MAT' .
    ENDIF.
      endcase.
    endform.                    " zf_pf_status_set
    *&      Form  zf_user_command
          text
    -->  p1        text
    <--  p2        text
    form zf_user_command using r_ucomm like sy-ucomm
                            rs_selfield type slis_selfield.
    sy-ucomm = r_ucomm.
      case r_ucomm.
        when 'SAVE'.
          flag = flag + 1.
          read table it_mat index rs_selfield-tabindex into wa_mat.
          wa_mat-labst = rs_selfield-value.
          if rs_selfield-value < 100.
            wa_mat-v_lights = '1'.
            t_color-fieldname = 'LABST'.
            t_color-color-col = 6.
            wa_mat-v_row = 'C610'.
            clear wa_mat-v_col.
            append t_color to wa_mat-v_col.
          elseif rs_selfield-value < 1000.
            wa_mat-v_lights = '2'.
            t_color-fieldname = 'LABST'.
            t_color-color-col = 3.
            wa_mat-v_row = 'C510'.
            clear wa_mat-v_col.
            append t_color to wa_mat-v_col.
          else.
            wa_mat-v_lights = '3'.
            t_color-fieldname = 'LABST'.
            t_color-color-col = 5.
            wa_mat-v_row = 'C210'.
            clear wa_mat-v_col.
            append t_color to wa_mat-v_col.
          endif.
          modify it_mat from wa_mat index rs_selfield-tabindex.
    IF GRID RADIO button (ALV GRID) IS selected .
          if p_rb_02 is not initial.
           SET PF-STATUS  'ALV_MENU_MAT'.
    DISPLAY ALV GRID.
            perform zf_display_alv_grid.
          else.
           SET PF-STATUS  'ALV_MENU_MAT'.
    DISPLAY ALV LIST.
            perform zf_display_alv_list.
          endif.
          set screen 0.
        when 'BACK'.
          leave screen.
        when others.
          message i004.
      endcase.
       WHEN 'BACK'.
    CASE sy-ucomm.
       WHEN 'BACK'.
         LEAVE SCREEN.
    ENDCASE.
    endform.                    " zf_user_command
    reward points if helpful

  • Push button in ALV Grid Display

    Hi all,
    I have a requirement wherin i need to place a button in the ALV Grid Display which should update all the records whatever are displayed in the specified infotype. This is to be done in a report.
    Can anybody give me any pointers or sample code for the above query.
    Regards,
    Amrita

    Simply add a button on your GUI status. Then when pushed, code your logic for update IT0008.
    AT USER-COMMAND event block will be triggered when you press your button.
    AT USER-COMMAND.
      if sy-ucomm = 'PUSHBUTTON'.    "here comes function code of your pushbutton
         "update your diplayed records
      endif.

  • How to devide the top of page in alv grid display

    hi all
    in the alv grid display am getting the page number and total number of pages in the left hand side
    but what i need is i need in the right hand side
    how to get that

    Hi,
    PLease refer to the code below:
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform build_events.
    perform build_print_params.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
                it_events               = gt_events
                is_print                = gd_prntparams
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    * Form  TOP-OF-PAGE                                                 *
    * ALV Report Header                                                 *
    Form top-of-page.
    *ALV Header declarations
    data: t_header type slis_t_listheader,
          wa_header type slis_listheader,
          t_line like wa_header-info,
          ld_lines type i,
          ld_linesc(10) type c.
    * Title
      wa_header-typ  = 'H'.
      wa_header-info = 'EKKO Table Report'.
      append wa_header to t_header.
      clear wa_header.
    * Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      CONCATENATE  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) INTO wa_header-info.   "todays date
      append wa_header to t_header.
      clear: wa_header.
    * Total No. of Records Selected
      describe table it_ekko lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'Total No. of Records Selected: ' ld_linesc
                        into t_line separated by space.
      wa_header-typ  = 'A'.
      wa_header-info = t_line.
      append wa_header to t_header.
      clear: wa_header, t_line.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                it_list_commentary = t_header.
    *            i_logo             = 'Z_LOGO'.
    endform.
    *       FORM USER_COMMAND                                          *
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
    *   Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'EBELN'.
    *     Read data table, using index of row user clicked on
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    *     Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
    ENDFORM.
    *&      Form  BUILD_EVENTS
    *       Build events table
    form build_events.
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = gt_events[].
      read table gt_events with key name =  slis_ev_end_of_page
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_PAGE' to ls_event-form.
        append ls_event to gt_events.
      endif.
        read table gt_events with key name =  slis_ev_end_of_list
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_LIST' to ls_event-form.
        append ls_event to gt_events.
      endif.
    endform.                    " BUILD_EVENTS
    *&      Form  BUILD_PRINT_PARAMS
    *       Setup print parameters
    form build_print_params.
      gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
      gd_prntparams-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
    *&      Form  END_OF_PAGE
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *&      Form  END_OF_LIST
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    Thanks,
    Sriram Ponna.

  • Field Catolgue in alv grid display

    Hi Abapers,
    I need to display the percentage rows with decimals and other rows without decimal . Is their any option in field catalog to do like this. Or tell me any other alternative to achieve this.
    sno  total     col1      col2      col3
    1      220       100        20       100
    2      320      120         50        150
    tot    540       220        70         250
    per               40.74     1.87  and so on
    or ,
    I have two different internal tables how can i put it in one field catalog to pass it to alv grid display.
    Regards,
    Priya

    Don't   do  total  by your  self  in the Pogram.
    in the   Fieldcatalog  there is an Attribute which will do total  &  Average .
    Enable it so that  from one  internal  table   data   it self it will do  good.
    example program
    Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
    display it using the basic ALV grid functionality(including column total). The example details the main
    sections of coding required to implement the ALV grid functionality:
                             Data declaration
                             Data retrieval
                             Build fieldcatalog
                             Build layout setup
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15. 
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    gowri
    Message was edited by:
            Gowri Krishna

  • 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

  • How to capture the checkbox status in ALV Grid display

    I need some immediate help regarding Grid ALV.
    My Requirement: I need to display an ALV grid report along with checkboxes. Further, I need to provide an option wherein the user can checkboxes and select the records that I need to process further (by clicking the process button on the ALV Report).
    My Query: The problem here is that I am not able to capture the status of the checkboxes. This means that I am not able to capture which of the records have been selected by checking their resp checkboxes.
    Solutions that I have tried: I have tried capturing the same at user command by checking the value in slis_selfield. But all the records show the value as 1 for the checkbox field.
    Kinldy suggest how to go about it.
    I am not using Object Oriented ALV. Please suggest something to be used in ALV Grid display in 4.6C version.
    Regards,
    Namrata

    Here is a Sample code , it might help you
    TABLES : sflight.
    TYPE-POOLS: slis.
    DATA : w_repid LIKE sy-repid.
    w_repid = sy-repid.
    DATA: BEGIN OF it_sflight OCCURS 0,
      checkbox(1),
      carrid LIKE sflight-carrid,
    END OF it_sflight.
    *layout
    DATA: wa_layout TYPE slis_layout_alv.
    *field catalog
    DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
              wa_fieldcatalog TYPE slis_fieldcat_alv.
    START-OF-SELECTION.
      SELECT carrid FROM sflight
         INTO CORRESPONDING FIELDS OF TABLE it_sflight.
    END-OF-SELECTION.
      CLEAR it_fieldcatalog.
      REFRESH it_fieldcatalog.
      wa_fieldcatalog-fieldname = 'CHECKBOX'.
      wa_fieldcatalog-outputlen = '3'.
      wa_fieldcatalog-col_pos = '1'.
      wa_fieldcatalog-seltext_m = 'Chk'.
      wa_fieldcatalog-checkbox = 'X'.
      wa_fieldcatalog-edit = 'X'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'CARRID'.
      wa_fieldcatalog-outputlen = '10'.
      wa_fieldcatalog-col_pos = '2'.
      wa_fieldcatalog-seltext_m = 'Carrid'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = w_repid
          is_layout = wa_layout
          i_callback_user_command = 'USER_COMMAND'
          it_fieldcat = it_fieldcatalog
        TABLES
          t_outtab = it_sflight
        EXCEPTIONS
          program_error = 1
          OTHERS = 2.
    *& Form USER_COMMAND
    FORM user_command USING p_ucomm TYPE sy-ucomm
      p_selfld TYPE slis_selfield.
      CASE p_ucomm.
       WHEN '&DATA_SAVE'.
          DATA ref1 TYPE REF TO cl_gui_alv_grid.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
             IMPORTING
               e_grid = ref1.
          CALL METHOD ref1->check_changed_data.
          LOOP AT it_sflight WHERE checkbox = 'X'.
             DELETE it_sflight INDEX sy-tabix.
          ENDLOOP.
          p_selfld-refresh = 'X'.
      ENDCASE.
    ENDFORM. "user_command

  • ALV GRID DISPLAY

    Hi,
    I'm modifying a program with ALV Grid Display.There are lot of Classes and Methods which i don't understand.
    In my program, the Program is executes and displays an Output. Now in the O/P , when I dbl click a field of a row a POP up is displayed with the existing value.now i can edit this value or Update with a new value.After closing the POP up the edited valueor the new value is displayed in the field. The program works good upto here.Now if my O/P has 20 Pages and if i edit a field in the 18 page, then after closing the popup the cursor ( or display ) is displayed in the 1 page( the 1 page of the O/P is displayed). Now, again, if i want to edit a field in the 18 page i have to scroll to the 18 page. Is there any way to hold the display at the 18 page after closing the POPUP.
    I arrived at using CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id
    EXPORTING
    IS_ROW_ID = <structure of type LVC_S_ROW >
    IS_COLUMN_ID = <structure of type LVC_S_COL >
    IS_ROW_NO = <structure of type LVC_S_ROID >.
    can some one help me how to pass values to is_row_id and all the parameters.
    Is there any other way?Thanks in advance.
    Thanks,
    Bhaskar.

    Dear Bhaskar,
    To acheieve this follow the below steps:
    1.  On double click first get the scroll information using the method GET_SCROLL_INFO_VIA_ID of class CL_GUI_ALV_GRID.
    CALL METHOD go_alv_grid->get_scroll_info_via_id
    IMPORTING
    es_row_no   = gv_s_roid
    es_row_info  = gv_s_row
    es_col_info  = gv_s_col.
    2.  Again at the end of your double click event call the method SET_SCROLL_INFO_VIA_ID to set the scroll.
    CALL METHOD go_alv_grid->set_scroll_info_via_id
    EXPORTING
    is_row_info = gv_s_row
    is_col_info = gv_s_col
    is_row_no  = gv_s_roid.
    Regards
    Kesava

  • Alv grid display regarding

    hi all,
    i have an issue in which i fetch data from mkpf and mseg tables into my final internal table everytin is fine and i want to display the data in alv and download it to excel sheet so the problem is while im running the prog im gettin an error in reuse_alv_list_display the code is as follows:
    it_final_tab is my final internal table
    wt_fieldcat is for building field catalog
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM     = wlv_repid
       IS_LAYOUT                         = wls_layout
       IT_FIELDCAT                       = wt_fieldcat[]
       I_DEFAULT                         = 'X'
       I_SAVE                               = 'X'
       IT_EVENTS                         = wlt_events[]
    TABLES
        T_OUTTAB                          = it_final_tab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    the error is "field string is not yet set". its eatin  my brain so can any one plz help me out. Point are rewarded for correct solution
    thanks in advance
    anupama.

    Hi Anupama,
    Fieldcatalog information through your internal table wt_fieldcat[]
    is not being passed properly. That is causing the problem.
    Can I have ur fullcode so that we can check it out. Otherwise refer sample code on ALV grid.
    REPORT  zvenkat_alv_grid.
    TABLES:t001.
    "Types
    TYPES:
          BEGIN OF t_1001,
            bukrs TYPE t001-bukrs,
            butxt TYPE t001-butxt,
            ort01 TYPE t001-ort01,
            land1 TYPE t001-land1,
          END OF t_1001.
    "Work area
    DATA:
          w_t001 TYPE t_1001.
    "Internal table
    DATA:
          i_t001 TYPE STANDARD TABLE OF t_1001.
    " ALV Declarations
    * Types Pools
    TYPE-POOLS:
       slis.
    * Types
    TYPES:
       t_fieldcat         TYPE slis_fieldcat_alv,
       t_events           TYPE slis_alv_event,
       t_layout           TYPE slis_layout_alv.
    * Workareas
    DATA:
       w_fieldcat         TYPE t_fieldcat,
       w_events           TYPE t_events,
       w_layout           TYPE t_layout.
    * Internal Tables
    DATA:
       i_fieldcat         TYPE STANDARD TABLE OF t_fieldcat,
       i_events           TYPE STANDARD TABLE OF t_events.
    *&    start of selection
    START-OF-SELECTION.
      PERFORM get_data.
    *&    end-of-selection.
    END-OF-SELECTION.
      PERFORM build_fieldcatlog.
      PERFORM build_events.
      PERFORM build_layout.
      PERFORM list_display.
    *&      Form  get_data
    FORM get_data .
      SELECT bukrs
             butxt
             ort01
             land1
        FROM t001
        INTO TABLE i_t001
        UP TO 30 ROWS.
    ENDFORM.                    " get_data
    *&      Form  build_fieldcatlog
    FORM build_fieldcatlog .
      CLEAR:w_fieldcat,i_fieldcat[].
      PERFORM build_fcatalog USING:
               'BUKRS' 'I_T001' 'BUKRS',
               'BUTXT' 'I_T001' 'BUTXT',
               'ORT01' 'I_T001' 'ORT01',
               'LAND1' 'I_T001' 'LAND1'.
    ENDFORM.                    "BUILD_FIELDCATLOG
    *&      Form  BUILD_FCATALOG
    FORM build_fcatalog USING l_field l_tab l_text.
      w_fieldcat-fieldname      = l_field.
      w_fieldcat-tabname        = l_tab.
      w_fieldcat-seltext_m      = l_text.
      APPEND w_fieldcat TO i_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " build_fieldcatlog
    *&      Form  build_events
    *       text
    FORM build_events.
      CLEAR :
            w_events, i_events[].
      w_events-name = 'TOP_OF_PAGE'."Event Name
      w_events-form = 'TOP_OF_PAGE'."Callback event subroutine
      APPEND w_events TO i_events.
      CLEAR  w_events.
    ENDFORM.                    "build_events
    *&      Form  build_layout
    FORM build_layout .
      w_layout-colwidth_optimize = 'X'.
      w_layout-zebra             = 'X'.
    ENDFORM.                    " build_layout
    *&      Form  list_display
    FORM list_display .
      DATA:
            l_program TYPE sy-repid.
      l_program = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = l_program
          is_layout          = w_layout
          it_fieldcat        = i_fieldcat
          it_events          = i_events
        TABLES
          t_outtab           = i_t001
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " list_display
    *&      Form  top_of_page
    FORM top_of_page.
      DATA :
       li_header TYPE slis_t_listheader,
       w_header  LIKE LINE OF li_header.
      DATA:
            l_date TYPE char10.
      WRITE sy-datum TO l_date.
      w_header-typ  = 'H'.
      CONCATENATE sy-repid ':' 'From Date' l_date INTO w_header-info SEPARATED BY space.
      APPEND w_header TO li_header.
      CLEAR w_header.
      w_header-typ  = 'S'.
      w_header-info = sy-title.
      APPEND w_header TO li_header.
      CLEAR w_header.
      w_header-typ  = 'A'.
      w_header-info = sy-uname.
      APPEND w_header TO li_header.
      CLEAR w_header.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = li_header.
    ENDFORM.                    "top_of_page
    I hope that it helps you.
    Regards,
    Venkat.O

  • New Page in ALV GRID display.

    HI Experts,
    I have a requirement of displaying top of page and corresponding detailed records for specific combination of top of page(say plant,material,batch etc). Again for the next combination I need repeated header and detail list.
    I guess I have to use NEW PAGE to get this.
    However, I am using the REUSE ALV GRID DISPLAY for which the sort table does not display as required.
    Could you please help me  on this?
    In addition could you please suggest how to use NEW page in report without using OOPS concept.
    Please reply.
    Thanks,
    Suchi.

    Hi,
    1.Put a pushbutton  on the ALV o/p say 'Next'.
    2. Now in the user comand routine you have to change the  table contents u supply to reuse_alv_commentary write, also fill the o/p internal table with data corresponding to ur specific combination and supply to reuse_alv_grid_display.
    3.In the user comand routine u have  slis_selfield.
    4.It contains a component refresh, mark it as 'X'.( slis_selfield-refresh = 'X'.)
    5.No need of new page or calling reus_alv_grid_display number of times.
    Regards,
    Phani.

  • How to change the selected row color in an alv grid display ?

    Hello ,
    I WANT TO CHANGE THE COLOR OF THE SELECTED RECORDS  IN AN ALV GRID DISPLAY ?
    ITS URGENT..
    WILL BE REWARDED...

    hai   Ssnagh Samala 
    EXicut This report >
    Hope It Will  Meet U r Requirement.
    If Found Helpfull Reward.
    REPORT zcuitest_alv_07.
    Use of colours in ALV grid (cell, line and column) *
    Table
    TABLES : mara.
    Type
    TYPES : BEGIN OF ty_mara,
    matnr LIKE mara-matnr,
    matkl LIKE mara-matkl,
    counter(4) TYPE n,
    free_text(15) TYPE c,
    color_line(4) TYPE c, " Line color
    color_cell TYPE lvc_t_scol, " Cell color
    END OF ty_mara.
    Structures
    DATA : wa_mara TYPE ty_mara,
    wa_fieldcat TYPE lvc_s_fcat,
    is_layout TYPE lvc_s_layo,
    wa_color TYPE lvc_s_scol.
    Internal table
    DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
    it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
    it_color TYPE TABLE OF lvc_s_scol.
    Variables
    DATA : okcode LIKE sy-ucomm,
    w_alv_grid TYPE REF TO cl_gui_alv_grid,
    w_docking_container TYPE REF TO cl_gui_docking_container.
    PARAMETERS : p_column AS CHECKBOX,
    p_line AS CHECKBOX,
    p_cell AS CHECKBOX.
    START-OF-SELECTION.
    PERFORM get_data.
    END-OF-SELECTION.
    PERFORM fill_catalog.
    PERFORM fill_layout.
    CALL SCREEN 2000.
    *& Module status_2000 OUTPUT
    text
    MODULE status_2000 OUTPUT.
    SET PF-STATUS '2000'.
    ENDMODULE. " status_2000 OUTPUT
    *& Module user_command_2000 INPUT
    text
    MODULE user_command_2000 INPUT.
    DATA : w_okcode LIKE sy-ucomm.
    MOVE okcode TO w_okcode.
    CLEAR okcode.
    CASE w_okcode.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " user_command_2000 INPUT
    *& Module alv_grid OUTPUT
    text
    MODULE alv_grid OUTPUT.
    IF w_docking_container IS INITIAL.
    PERFORM create_objects.
    PERFORM display_alv_grid.
    ENDIF.
    ENDMODULE. " alv_grid OUTPUT
    *& Form create_objects
    text
    --> p1 text
    <-- p2 text
    FORM create_objects.
    Ratio must be included in http://5..95
    CREATE OBJECT w_docking_container
    EXPORTING
    ratio = 95
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6.
    CREATE OBJECT w_alv_grid
    EXPORTING
    i_parent = w_docking_container.
    ENDFORM. " create_objects
    *& Form display_alv_grid
    text
    --> p1 text
    <-- p2 text
    FORM display_alv_grid.
    CALL METHOD w_alv_grid->set_table_for_first_display
    EXPORTING
    is_layout = is_layout
    CHANGING
    it_outtab = it_mara
    it_fieldcatalog = it_fieldcat
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    ENDFORM. " display_alv_grid
    *& Form get_data
    text
    --> p1 text
    <-- p2 text
    FORM get_data.
    SELECT * FROM mara UP TO 5 ROWS.
    CLEAR : wa_mara-color_line, wa_mara-color_cell.
    MOVE-CORRESPONDING mara TO wa_mara.
    ADD 1 TO wa_mara-counter.
    MOVE 'Blabla' TO wa_mara-free_text.
    IF wa_mara-counter = '0002'
    AND p_line = 'X'.
    Color line
    MOVE 'C410' TO wa_mara-color_line.
    ELSEIF wa_mara-counter = '0004'
    AND p_cell = 'X'.
    Color cell
    MOVE 'FREE_TEXT' TO wa_color-fname.
    MOVE '5' TO wa_color-color-col.
    MOVE '1' TO wa_color-color-int.
    MOVE '1' TO wa_color-color-inv.
    APPEND wa_color TO it_color.
    wa_mara-color_cell] = it_color[.
    ENDIF.
    APPEND wa_mara TO it_mara.
    ENDSELECT.
    ENDFORM. " get_data
    *& Form fill_catalog
    text
    --> p1 text
    <-- p2 text
    FORM fill_catalog.
    Colour code : *
    Colour is a 4-char field where : *
    - 1st char = C (color property) *
    - 2nd char = color code (from 0 to 7) *
    0 = background color *
    1 = blue *
    2 = gray *
    3 = yellow *
    4 = blue/gray *
    5 = green *
    6 = red *
    7 = orange *
    - 3rd char = intensified (0=off, 1=on) *
    - 4th char = inverse display (0=off, 1=on) *
    Colour overwriting priority : *
    1. Line *
    2. Cell *
    3. Column *
    DATA : w_position TYPE i VALUE '1'.
    CLEAR wa_fieldcat.
    MOVE w_position TO wa_fieldcat-col_pos.
    MOVE 'MATNR' TO wa_fieldcat-fieldname.
    MOVE 'MARA' TO wa_fieldcat-ref_table.
    MOVE 'MATNR' TO wa_fieldcat-ref_field.
    APPEND wa_fieldcat TO it_fieldcat.
    ADD 1 TO w_position.
    CLEAR wa_fieldcat.
    MOVE w_position TO wa_fieldcat-col_pos.
    MOVE 'MATKL' TO wa_fieldcat-fieldname.
    MOVE 'MARA' TO wa_fieldcat-ref_table.
    MOVE 'MATKL' TO wa_fieldcat-ref_field.
    Color column
    IF p_column = 'X'.
    MOVE 'C610' TO wa_fieldcat-emphasize.
    ENDIF.
    APPEND wa_fieldcat TO it_fieldcat.
    ADD 1 TO w_position.
    CLEAR wa_fieldcat.
    MOVE w_position TO wa_fieldcat-col_pos.
    MOVE 'COUNTER' TO wa_fieldcat-fieldname.
    MOVE 'N' TO wa_fieldcat-inttype.
    MOVE '4' TO wa_fieldcat-intlen.
    MOVE 'Counter' TO wa_fieldcat-coltext.
    APPEND wa_fieldcat TO it_fieldcat.
    ADD 1 TO w_position.
    CLEAR wa_fieldcat.
    MOVE w_position TO wa_fieldcat-col_pos.
    MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname.
    MOVE 'C' TO wa_fieldcat-inttype.
    MOVE '20' TO wa_fieldcat-intlen.
    MOVE 'Text' TO wa_fieldcat-coltext.
    APPEND wa_fieldcat TO it_fieldcat.
    ENDFORM. " fill_catalog
    *& Form fill_layout
    text
    --> p1 text
    <-- p2 text
    FORM fill_layout.
    Field that identify color line in internal table
    MOVE 'COLOR_LINE' TO is_layout-info_fname.
    Field that identify cell color in inetrnal table
    MOVE 'COLOR_CELL' TO is_layout-ctab_fname.
    ENDFORM. " fill_layout
    Regards.
    Eshwar.

Maybe you are looking for

  • Using more than one motu 828

    does anyone use more than one motu 828 for 16 x DA outputs with logic pro - if so how?

  • Unable to customize notificati​ons & wallpaper.

    On My BB Z10, after going to System Settings and selecting Notifications, I am unable to customize notifications for contacts & applications. Also I'm not able to change wallpaper. On clicking the select wallpaper option (under Display Settings) , th

  • NAFTA Revoke functionality

    Hi There, I have one doubt in NAFTA revoke functionality. Scenario 1: Material was positive in the LTVD we issued; now the status is changed to negative. The original LTVD has to be cancelled. It is done via revoke functionality. This is working fine

  • Problem to startup from my disk installation

    Hello... Now I use Panther and i want to install Tiger... But a stupid problem at first step: I can start from CD Installation!!! I put my disc of Tiger in my computer (G4 733 mgz) then I put on «C key» and restart... The result is always the same :

  • IPod + iTunes Section in Apple WebSite

    This section of the Apple WebSite isn't shown properly under windows internet explorer 7 when the language is set to spanish. Please website developers take a look to it. Ther's another issue even bigger when QuickTime Plugin for windows internet exp