Regarding ALV GRID

Hi all,
i am having one issue regarding ALV GRID.
my issue is after executin  report O/P in grid format is ok,
but the same format i want to display when u click print preview or when u execute it in back ground,
it is displaying as same as ALV LIST,

hi use the coding like this,
here i am calling hirarchial from list check this....
*& Report  ZZZ00
REPORT  ZPR_02.
TYPE-POOLS: SLIS.
TABLES:pa0002,pa0008.
data:begin of it_pa0002 occurs 0,
     checkbox,
     pernr like pa0002-pernr,
     begda like pa0002-begda,
     endda like pa0002-endda,
     vorna like pa0002-vorna,
     nachn like pa0002-nachn,
     end of it_pa0002.
data:begin of it_pa00021 occurs 0,
     pernr like pa0002-pernr,
     begda like pa0002-begda,
     endda like pa0002-endda,
     vorna like pa0002-vorna,
     nachn like pa0002-nachn,
     expand TYPE xfeld value 'X',
     end of it_pa00021.
data:begin of it_pa0008 occurs 0,
     pernr like pa0008-pernr,
     begda like pa0008-begda,
     endda like pa0008-endda,
     ANSAL like pa0008-ANSAL,
     LGA01 like pa0008-LGA01,
     BET01 LIKE PA0008-BET01,
     end of it_pa0008.
DATA: IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
      IT_FIELD_CAT1 TYPE SLIS_T_FIELDCAT_ALV,
      IT_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
      WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
      WA_FIELD_CAT1 TYPE SLIS_FIELDCAT_ALV,
      IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
      IT_EVENTS TYPE SLIS_T_EVENT,
      WA_EVENTS TYPE SLIS_ALV_EVENT,
      IT_HEADER TYPE SLIS_T_LISTHEADER,
      WA_HEADER TYPE SLIS_LISTHEADER,
      wa_keyinfo TYPE slis_keyinfo_alv.
CONSTANTS:c VALUE 'X'.
SELECT-OPTIONS: S_pernr FOR pa0002-pernr.
START-OF-SELECTION.
  SET PF-STATUS 'DATA' .
  PERFORM GET_DATA.
  PERFORM BUILD_FIELD_CAT.
  PERFORM GET_EVENTS.
  PERFORM DISPLAY_DATA.
*&      Form  get_data
      text
FORM GET_DATA .
  SELECT pernr
         begda
         endda
         vorna
         nachn
         FROM pa0002
         INTO CORRESPONDING FIELDS OF TABLE IT_pa0002
         WHERE pernr IN S_pernr.
ENDFORM.                    " get_data
*&      Form  build_field_cat
      text
FORM BUILD_FIELD_CAT .
    wa_field_cat-tabname = 'PA0002'.
  WA_FIELD_CAT-FIELDNAME = 'CHECKBOX'.
  wa_field_cat-ref_tabname = 'IT_PA0002'.
  WA_FIELD_CAT-REPTEXT_DDIC = 'Check Box'.
  APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
  CLEAR WA_FIELD_CAT.
    wa_field_cat-tabname = 'PA0002'.
  WA_FIELD_CAT-FIELDNAME = 'PERNR'.
    wa_field_cat-ref_tabname = 'IT_PA0002'.
  WA_FIELD_CAT-REPTEXT_DDIC = 'Personnel no'.
  APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
  CLEAR WA_FIELD_CAT.
    wa_field_cat-tabname = 'PA0002'.
  WA_FIELD_CAT-FIELDNAME = 'BEGDA'.
  wa_field_cat-ref_tabname = 'IT_PA0002'.
  WA_FIELD_CAT-REPTEXT_DDIC = 'Start date'.
  APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
  CLEAR WA_FIELD_CAT.
    wa_field_cat-tabname = 'PA0002'.
  WA_FIELD_CAT-FIELDNAME = 'ENDDA'.
  wa_field_cat-ref_tabname = 'IT_PA0002'.
  WA_FIELD_CAT-REPTEXT_DDIC = 'End date'.
  APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
  CLEAR WA_FIELD_CAT.
    wa_field_cat-tabname = 'PA0002'.
  WA_FIELD_CAT-FIELDNAME = 'VORNA'.
  wa_field_cat-ref_tabname = 'IT_PA0002'.
  WA_FIELD_CAT-REPTEXT_DDIC = 'First name'.
  APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
  CLEAR WA_FIELD_CAT.
    wa_field_cat-tabname = 'PA0002'.
  WA_FIELD_CAT-FIELDNAME = 'NACHN'.
    wa_field_cat-ref_tabname = 'IT_PA0002'.
  WA_FIELD_CAT-REPTEXT_DDIC = 'Last name'.
  APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
  CLEAR WA_FIELD_CAT.
    wa_field_cat1-tabname = 'PA0002'.
  WA_FIELD_CAT1-FIELDNAME = 'PERNR'.
    wa_field_cat1-ref_tabname = 'IT_PA00021'.
  WA_FIELD_CAT1-REPTEXT_DDIC = 'Personnel no'.
  APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
  CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0002'.
  WA_FIELD_CAT1-FIELDNAME = 'BEGDA'.
    wa_field_cat1-ref_tabname = 'IT_PA00021'.
  WA_FIELD_CAT1-REPTEXT_DDIC = 'Start date'.
  APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
  CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0002'.
  WA_FIELD_CAT1-FIELDNAME = 'ENDDA'.
    wa_field_cat1-ref_tabname = 'IT_PA00021'.
  WA_FIELD_CAT1-REPTEXT_DDIC = 'End date'.
  APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
  CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0002'.
  WA_FIELD_CAT1-FIELDNAME = 'VORNA'.
    wa_field_cat1-ref_tabname = 'IT_PA00021'.
  WA_FIELD_CAT1-REPTEXT_DDIC = 'First name'.
  APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
  CLEAR WA_FIELD_CAT.
    wa_field_cat1-tabname = 'PA0002'.
  WA_FIELD_CAT1-FIELDNAME = 'NACHN'.
    wa_field_cat1-ref_tabname = 'IT_PA00021'.
  WA_FIELD_CAT1-REPTEXT_DDIC = 'Last name'.
  APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
  CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0008'.
    wa_field_cat1-fieldname = 'PERNR'.
      wa_field_cat-ref_tabname = 'IT_PA0008'.
    wa_field_cat1-REPTEXT_DDIC = 'personnelno'.
    APPEND wa_field_cat1 TO it_field_cat1.
   CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0008'.
    wa_field_cat1-fieldname = 'BEGDA'.
      wa_field_cat-ref_tabname = 'IT_PA0008'.
    wa_field_cat1-REPTEXT_DDIC = 'begindate'.
    APPEND wa_field_cat1 TO it_field_cat1.
    CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0008'.
    wa_field_cat1-fieldname = 'ENDDA'.
      wa_field_cat-ref_tabname = 'IT_PA0008'.
    wa_field_cat1-REPTEXT_DDIC = 'enddate'.
    APPEND wa_field_cat1 TO it_field_cat1.
    CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0008'.
    wa_field_cat1-fieldname = 'ANSAL'.
      wa_field_cat-ref_tabname = 'IT_PA0008'.
    wa_field_cat1-REPTEXT_DDIC = 'annualsalary'.
    APPEND wa_field_cat1 TO it_field_cat1.
    CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0008'.
    wa_field_cat1-fieldname = 'LGA01'.
      wa_field_cat-ref_tabname = 'IT_PA0008'.
    wa_field_cat1-REPTEXT_DDIC = 'wagetype'.
    APPEND wa_field_cat1 TO it_field_cat1.
    CLEAR WA_FIELD_CAT1.
    wa_field_cat1-tabname = 'PA0008'.
    wa_field_cat1-fieldname = 'BET01'.
      wa_field_cat-ref_tabname = 'IT_PA0008'.
    wa_field_cat1-REPTEXT_DDIC = 'Amount'.
    APPEND wa_field_cat1 TO it_field_cat1.
    CLEAR WA_FIELD_CAT1.
ENDFORM.                    " build_field_cat
*&      Form  display_data
      text
FORM DISPLAY_DATA .
it_layout-box_fieldname = 'CHECKBOX'.
it_layout-EDIT = 'X'.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM             = SY-REPID
      I_CALLBACK_PF_STATUS_SET       = 'PF_STATUS'
      I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
      IT_FIELDCAT                    = IT_FIELD_CAT
      IS_LAYOUT                      = IT_LAYOUT
      IT_EVENTS                      = IT_EVENTS
    TABLES
      T_OUTTAB           = IT_pa0002.
ENDFORM.                    " display_data
*&      Form  get_events
      text
FORM GET_EVENTS .
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
   IMPORTING
     ET_EVENTS             = IT_EVENTS .
  READ TABLE IT_EVENTS INTO WA_EVENTS
                       WITH KEY NAME = SLIS_EV_TOP_OF_PAGE.
  IF SY-SUBRC = 0.
    WA_EVENTS-FORM = 'TOP_OF_PAGE'.
    MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
  ENDIF.
ENDFORM.                    " get_events
*&      Form  top_of_page
      text
FORM TOP_OF_PAGE.
  WA_HEADER-TYP = 'H'.
  WA_HEADER-INFO = 'EMPLOYEE DATA'.
  APPEND WA_HEADER TO IT_HEADER.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY       = IT_HEADER
ENDFORM. "top_of_page
*&      Form  GUI_SET
FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .
  SET PF-STATUS 'DATA' .
ENDFORM.                    "GUI_SET
*&      Form  USER_COMMAND
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                        R_SELFIELD TYPE SLIS_SELFIELD.
DATA:V_PERNR LIKE PA0002-PERNR.
  CASE R_UCOMM.
    WHEN 'DET'.
DATA: V_FLAG.
  clear : v_flag.
LOOP AT IT_PA0002.
     if it_PA0002-checkbox =  'X'.
               v_flag = 'X'.
          v_pernr = IT_PA0002-PERNR.
SELECT  PERNR
        BEGDA
        ENDDA
        VORNA
        NACHN
        FROM PA0002
        INTO CORRESPONDING FIELDS OF TABLE IT_PA00021
        WHERE PERNR = V_PERNR.
SORT IT_PA00021 BY PERNR.
DELETE ADJACENT DUPLICATES FROM IT_PA00021 COMPARING PERNR.
READ TABLE IT_PA00021 INDEX 1.
SELECT PERNR
       BEGDA
       ENDDA
       ANSAL
       LGA01
       BET01
       FROM PA0008
       INTO TABLE IT_PA0008
       FOR ALL ENTRIES IN IT_PA00021
       WHERE PERNR = IT_PA00021-PERNR.
          if not it_PA0008[] Is initial.
          SORT IT_PA0008 BY PERNR.
         delete adjacent duplicates from  it_PA0008 comparing pernr.
          READ TABLE IT_PA0008 INDEX 1.
          endif.
        endif.
     enddo.
  it_layout1-group_change_edit = c.
  it_layout1-colwidth_optimize = c.
  it_layout1-zebra             = c.
  it_layout1-detail_popup      = c.
  it_layout1-get_selinfos      = c.
  it_layout-expand_fieldname  = 'EXPAND'.
  wa_keyinfo-header01 = 'PERNR'.
  wa_keyinfo-item01 = 'PERNR'.
IF NOT V_FLAG IS INITIAL.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
  EXPORTING
   I_CALLBACK_PROGRAM             = SY-REPID
    IS_LAYOUT                      = IT_LAYOUT1
   IT_FIELDCAT                    =  IT_FIELD_CAT1
    I_TABNAME_HEADER               = 'PA0002'
    I_TABNAME_ITEM                 = 'PA0008'
    IS_KEYINFO                     = wa_keyinfo
    TABLES
    T_OUTTAB_HEADER                = IT_PA00021
    T_OUTTAB_ITEM                  = IT_PA0008.
ENDIF.
CLEAR: IT_PA00021,IT_PA0002,IT_PA0008.
ENDLOOP.
WHEN 'BACK'.
EXIT.
ENDCASE.
ENDFORM.                    "USER_COMMAND
reward points if useful,
venkat.

Similar Messages

  • Regarding Alv Grid Totals_text is not Printing

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

    Hi,
    Please refer to the sample code :
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    Thanks,
    Sriram Ponna.

  • Displaying text from domain in ALV Grid OO

    Hi all,
    i have a problem regarding ALV grid OO.
    I try to displaying domain text instead of domain value in the grid.
    The domain value range are:
    1     text 1
    5     text 5
    6     text 6
    I created a drop down list and it works fine, but the eintries in the grid displaying only the value instead of text.
    General I like to work the value's but in the grid schoul be only the texts.
    Have anybody any idea?
    Thanks,
    a
    If it is not enogh clear , please ask me.

    hi,
    look this.
    U should be able to get text of domain  from table DD07V.
    SELECT DOMNAME VALPOS DOMVALUE_L DOMVALUE_H
    into idomval
    from dd07v
    where domname = Domain Name
    and ddlanguage = sy-langu.
    <i><b>opr u can use the below FM</b></i>
    DATA : BEGIN OF int_orient OCCURS 10,
               domvalue_l LIKE dd07v-domvalue_l,
               ddtext LIKE dd07v-ddtext,
               END OF int_orient.
    DATA: ZPETS_PORTORIEN type dd07l-domname,
            int_values_table  TYPE dd07v OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'GET_DOMAIN_VALUES'
        EXPORTING
          domname         = 'ZPETS_PORTORIEN'
          text            = 'X'
        TABLES
          values_tab      = int_values_table
        EXCEPTIONS
          no_values_found = 1
          OTHERS          = 2.
      LOOP AT int_values_table.
         int_orient-domvalue_l = int_values_table-domvalue_l.
        int_orient-ddtext = int_values_table-ddtext .
        append int_orient.
      ENDLOOP.
    read table int_orient. with key domvalue_l transporting  ddtext .
    rgds
    Anver
    <b>if hlped pls mark points</b>

  • ALV Grid merge cells horizontally for specific record

    Hi Experts,
    We have a requirement regarding ALV Grid developement.
    In ALV Grid, we will have multiple records as normal output.
    Output will be as below.
    In that, we need Summery Text should be in from Field 2 * to*  Field 6 as a single Cell and below that all output
    will be normal each cell wise.
    That Summery will come for each new Field1.
    OUTPUT
    Field1  Field2  Field3    Field4  Field5  Field6  Field7   Field8   Field9
    001  | . ....      ..        ..  Summery  ........... |  10   |  20      |  30
    001  |  10   |    20  |     30  |   40   |    50  |   60 |    70  |   80     |
    001  |  10   |    20  |     30  |   40   |    50  |   60 |    70  |   80     |
    001  |  10   |    20  |     30  |   40   |    50  |   60 |    70  |   80     |
    001  |  10   |    20  |     30  |   40   |    50  |   60 |    70  |   80     |
    Thanks & regards
    Manglesh

    Hi Manglesh,
    sorry ALV is not as flexible as Excel may be.
    You can only define a header in that way but it would be above the column headings.
    The ALV table display allows only to change the width of the whole column.
    Regards,
    Clemens

  • Double Click on ALV Grid

    Hi,
    I have this doubt regarding ALV grid display.
    I am displaying a list using REUSE_ALV_GRID_DISPLAY.
    I need to go to a transaction when i double click on a particular line on the output list based on the content of the 1st cell of that line. (ie if i have 4 columns and 5 records and click on the 3rd column of 2nd record then i need to know the value of the 1st field of the 2nd record)
    I am using a call back user command subroutine to capture the index and the field which has been clicked upon. This index is giving perfect result by which I am reading the output table and doing the later operations.
    But what if i sort the list in ALV by any column? Then the index that I will get on double clicking will correspond to the index on the screen but not to the index on my internal output table. In that case I will get a wrong value of the 1st field.
    I do not want to use OO alv. Is there a way to handle this situation?
    Regards,
    Shinjan

    Hello Shinjan,
    When i display an output table say t_out on ALV GRID, the records in the table shown on the grid is identical to what i have in t_out. Hence the tabindex will correspond to that very record in t_out.
    But when i sort the table on the grid, the order of the rows changes... so for example a row which had index 2 will now have an index 6 (say). So on clicking this record, the tabindex will be 6 where as the same record exist in 2nd position in t_out. How to handle this?
    {quote]
    Did you try this scenario? Your output table t_out also gets refarranged after SORT. Good thing is you DONOT have to code anything for this )
    As per your example the table t_out will be rearranged so that the initial 2nd record will be at 6th posn.
    FORM f_user_command  USING   fp_v_ucomm   TYPE syucomm
                                 fp_selfield  TYPE slis_selfield."#EC CALLED
      CONSTANTS:
              l_c_ic1           TYPE char4 VALUE '&IC1',
              l_c_vl            TYPE char2 VALUE 'VL',
              l_c_vl03n         TYPE char5 VALUE 'VL03N'.
      CASE fp_v_ucomm.
    * Ok code for double code
        WHEN l_c_ic1.
          IF fp_selfield-tabindex NE space.
            READ TABLE it_final INTO wa_final           "it_final gets rearranged as per the SORT condition
                                   INDEX fp_selfield-tabindex. "tabindex keeps the correct index after SORT
            SET PARAMETER ID l_c_vl FIELD wa_final-vbeln.
            CALL TRANSACTION l_c_vl03n AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "f_user_command
    Please check & let us know.
    BR,
    Suhas
    Edited by: Suhas Saha on Jan 2, 2009 11:48 AM
    Edited by: Suhas Saha on Jan 2, 2009 11:53 AM

  • Printing Page numbers in ALV grid with oops

    Hi ,
    I have a ALV grid display with OOPS , there are also fields in top of page and end of page that go along with the print. I want to print the page numbers also . If I give a variable and increment it along with every call to top of page , then if a second print is issued, the variable can not be cleared out. Is there any other way.
    Thank you .

    Regarding  ALV Grid  Control using OOPs concepts
    Please give me reward point if it is useful.
    Thanks
    Murali Poli

  • Regarding PF Status In ALV Grid Dispaly

    Hi..
    Can you please tell me how to set PF status in ALV Grid Display.
    Regards
    Sandeep.

    hi,
    if u use REUSE_ALV_LIST_DISPLAY copy the standard GUI-Status named STANDARD from function group SALV in your program
    if u use REUSE_ALV_GRID_DISPLAY_LVC or REUSE_ALV_GRID_DISPLAY copy the standard GUI-Status named STANDARD_FULLSCREEN from function group SLVC_FULLSCREEN in your program
    after  that you cas set the pf-status in this way:
    >CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'                   
    > EXPORTING                                               
    >    i_callback_program                = sy-cprog         
    >    i_callback_pf_status_set          = 'STATUS'
    >    i_callback_user_command           = 'USERCOMMAND'    
    >   is_layout                           = st_layout         
    >   it_fieldcat                          = st_fieldcat      
    >  TABLES                                      
    >    t_outtab                          = outtab 
    or
    >CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'              
    > EXPORTING                                              
    >    i_callback_program                = sy-cprog         
    >    i_callback_pf_status_set          = 'STATUS'  
    >    i_callback_user_command           = 'USERCOMMAND'   
    >    is_layout_lvc                     = wa_slis_layout  
    >    it_fieldcat_lvc                   = tb_slis_fieldcat
    >  TABLES                                                
    >    t_outtab                          = tb_app          
    where USERCOMMAND and STATUS are 2 forms in your program.
    >FORM status USING pfstat TYPE slis_t_extab.
    > SET PF-STATUS 'STANDARD' EXCLUDING pfstat.
    >ENDFORM.
    >
    > ...
    >
    >FORM usercommand USING okcode LIKE sy-ucomm
    >                       wa_selfield TYPE slis_selfield.
    >  CASE okcode.
    >      .... 
    >  ENDCASE
    >ENDFORM.
    Bye.
    Marco

  • 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

  • REGARDING READING THE SCREEN CONTENTS IN ALV GRID

    HI ALL,
    i have to transfer contents from one grid display to another grid.
    internal table has :
    internal- table name: itab
    chkbx
    v_lights
    matnr
    maktx
    dline(longtext of the material)
    alv grid is having following contents:
    1. chkbx which will get the user command.
    2. v_lights to display the different colors of light according to the contents of the longtext which i am fetching using the read_text function.
    3. matnr
    4. maktx
    5. longtext of the material.
    after the display of the first grid display.
    if user changes contents of the check box .. i have to read the screen and  and modify my internal table(itab) so that i can fetch data from the internal table to another internal table which i can use for the next screen.
    can anyone of you tell me how can i do this.
    and some help contents so that i can understand the whole concept.
    regards
    vamsi

    Hi vamsi,
      Do this way:
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
        I_CALLBACK_PROGRAM                = W_REPID
        I_CALLBACK_PF_STATUS_SET          = 'PF_STATUS'
        I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
    FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
                            P_SELFLD TYPE SLIS_SELFIELD.
    case p_ucomm.
    when '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.
    Now your internal table will have the latest values.
    loop at itab where check = 'X'. "Assuming the first fieldname for the check box is 'CHECK'.
    move-corresponding itab to itab2.
    append itab2.
    clear itab2.
    endcase.
    Build anothe r field catalog
    Display another grid.
    ENDFORM.
    Regards,
    Ravi

  • Regard check box concept in alv grid display

    HI Friends,
            i am displaying the sales order details with check box. so my first field is checkbox. When user click on check box then he press the details icon.
            my question i need a logic for calling the tcode based on the vbeln when it is cheked.
            thanks in advance.
    Regards,
    Purna.

    hi,
    go through this program
    program bcalv_edit_05.
    Purpose:
    ~~~~~~~~
    This example shows how to use checkboxes within an ALV Grid Control.
    You learn:
    o how to define a column for editable checkboxes for an attribute
       of your list (see also remark below)
    o how to evaluate the checked checkboxes
    o how to switch between editable and non-editable checkboxes
    Important Remark
    ~~~~~~~~~~~~~~~~
    The checkbox functionality has been replaced by selection buttons
    in front of each row (field SEL_MODE of the layout structure
    set to 'A' or 'D'; when using the editable ALV Grid Control,
    these selection buttons are always visible).
    Class methods like GET_SELECTED_ROWS work only for this new
    functionality and not for checkboxes.
    Thus checkboxes should not be used for line selection but for
    a column as an additional or for an already existing attribute
    (like field SMOKER in SBOOK).
    To check program behavior
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    Try out the functions displayed in the application toolbar:
    o The first sets all checked lines to initial values.
      (see form reset_selected_entries)
    o The seconds marks all checkboxes that are input enabled
    o The third unmarks all checkboxes that are input enabled
    o To try the forth, you have to select a line first using
      the selection buttons on the left.
      The function deactivates/activates a checkbox.
    Checkboxes may be locked/unlocked using a double click on the
    checkbox cell.
    Essential steps (search for '§')
    ~~~~~~~~~~~~~~~
    This example focusses on two aspects of checkboxes in an
    editable ALV Grid Control:
    A How to integrate, set, reset and evaluate checkboxes
    B What you must do to lock particular checkboxes against input
    A) Integrate, set, reset and evaluate checkboxes
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    A1.Extend your output table by a checkbox field.
    A2.Add an entry for the checkbox in the fieldcatalog
    A3.Optionally, check checkboxes initially after selecting data.
    A4.Before you (a)set, (b)reset, (c)(de)activate or
       (d)evaluate checkboxes, you must check the input cells.
    B) Lock particular checkboxes against input
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    B1.Extend your output table by a field to dis- or enable
        cells for input.
    B2.After selecting data,
        assign a style for each row of your checkbox column.
    B3.Use the layout structure to aquaint additional field to ALV.
    B4.Switch the style to dis- or enable a cell for input
    class lcl_event_receiver definition deferred.  "for event handling
    data: ok_code like sy-ucomm,
          save_ok like sy-ucomm,
          g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
          g_grid  type ref to cl_gui_alv_grid,
          g_custom_container type ref to cl_gui_custom_container,
          g_event_receiver type ref to lcl_event_receiver,
          gt_fieldcat type lvc_t_fcat,
          gs_layout type lvc_s_layo,
          g_max type i value 100.
    *§A1.Extend your output table by a checkbox field.
        If you do not want to lock sole checkboxes against input
        you do not need field 'celltab'.
    types: begin of gs_outtab.
    types: checkbox type c.                "field for checkbox
    §B1.Extend your output table by a field to dis- or enable
        cells for input.
    types: celltab type lvc_t_styl.        "field to switch editability
            include structure sflight.
    types: end of gs_outtab.
    data: gt_outtab type gs_outtab occurs 0 with header line.
    LOCAL CLASSES
    This local class only handles event DOUBLE_CLICK.
    Wenn the user double clicks on a checkbox cell the status of
    this cell is switched from editable to not editable and vice versa.
    class lcl_event_receiver definition.
    public section.
    methods: catch_doubleclick
             for event double_click of cl_gui_alv_grid
             importing
                e_column
                es_row_no
                sender.
    endclass.
    class lcl_event_receiver implementation.
    method catch_doubleclick.
      data: ls_outtab type gs_outtab,
            ls_celltab type lvc_s_styl.
    Function:
    Switch between 'editable' and 'not editable' checkbox.
    If the user clicked on another column there is
    nothing to do.
      if e_column-fieldname ne 'CHECKBOX'.
        exit.
      endif.
      read table gt_outtab into ls_outtab index es_row_no-row_id.
    The loop is only needed if there are other columns that
    use checkboxes. At this point the loop could be
    replaced by a READ of the first line of CELLTAB.
          loop at ls_outtab-celltab into ls_celltab.
            if ls_celltab-fieldname eq 'CHECKBOX'.
    §B4.Switch the style to dis- or enable a cell for input
             if ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
              ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
             else.
              ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
             endif.
             modify ls_outtab-celltab from ls_celltab.
            endif.
          endloop.
          modify gt_outtab from ls_outtab index es_row_no-row_id.
        call method sender->refresh_table_display.
    endmethod.
    endclass.
          MAIN                                                          *
    end-of-selection.
      call screen 100.
          MODULE PBO OUTPUT                                             *
    module pbo output.
      set pf-status 'MAIN100'.
      set titlebar 'MAIN100'.
      if g_custom_container is initial.
        perform create_and_init_alv.
      endif.
    endmodule.
          MODULE PAI INPUT                                              *
    module pai input.
      save_ok = ok_code.
      clear ok_code.
      case save_ok.
        when 'EXIT'.
          perform exit_program.
        when 'SELECT'.
          perform select_all_entries changing gt_outtab[].
        when 'DESELECT'.
          perform deselect_all_entries changing gt_outtab[].
        when 'RESET'.
          perform reset_selected_entries changing gt_outtab[].
        when 'SWITCH'.
          perform switch_activation changing gt_outtab[].
      endcase.
    endmodule.
          FORM EXIT_PROGRAM                                             *
    form exit_program.
      leave program.
    endform.
    *&      Form  BUILD_FIELDCAT
          text
         <--P_GT_FIELDCAT  text
    form build_fieldcat changing pt_fieldcat type lvc_t_fcat.
      data ls_fcat type lvc_s_fcat.
      call function 'LVC_FIELDCATALOG_MERGE'
           exporting
                i_structure_name = 'SFLIGHT'
           changing
                ct_fieldcat      = pt_fieldcat.
    *§A2.Add an entry for the checkbox in the fieldcatalog
      clear ls_fcat.
      ls_fcat-fieldname = 'CHECKBOX'.
    Essential: declare field as checkbox and
               mark it as editable field:
      ls_fcat-checkbox = 'X'.
      ls_fcat-edit = 'X'.
    do not forget to provide texts for this extra field
      ls_fcat-coltext = text-f01.
      ls_fcat-tooltip = text-f02.
      ls_fcat-seltext = text-f03.
    optional: set column width
      ls_fcat-outputlen = 10.
      append ls_fcat to pt_fieldcat.
    endform.
    *&      Form  CREATE_AND_INIT_ALV
          text
         <--P_GT_OUTTAB  text
         <--P_GT_FIELDCAT  text
         <--P_GS_LAYOUT  text
    form create_and_init_alv.
      data: lt_exclude type ui_functions.
      create object g_custom_container
             exporting container_name = g_container.
      create object g_grid
             exporting i_parent = g_custom_container.
      perform build_fieldcat changing gt_fieldcat.
    Exclude all edit functions in this example since we do not need them:
      perform exclude_tb_functions changing lt_exclude.
      perform build_data.
    *§ B3.Use the layout structure to aquaint additional field to ALV.
      gs_layout-stylefname = 'CELLTAB'.
      call method g_grid->set_table_for_first_display
           exporting is_layout             = gs_layout
                     it_toolbar_excluding  = lt_exclude
           changing  it_fieldcatalog       = gt_fieldcat
                     it_outtab             = gt_outtab[].
      create object g_event_receiver.
      set handler g_event_receiver->catch_doubleclick for g_grid.
    Set editable cells to ready for input initially
      call method g_grid->set_ready_for_input
       exporting
        i_ready_for_input = 1.
    endform.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
          text
         <--P_LT_EXCLUDE  text
    form exclude_tb_functions changing pt_exclude type ui_functions.
      data ls_exclude type ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
      append ls_exclude to pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
      append ls_exclude to pt_exclude.
    endform.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_data
          text
    -->  p1        text
    <--  p2        text
    form build_data.
      data: lt_sflight type table of sflight,
            ls_sflight type sflight,
            ls_celltab type lvc_s_styl,
            lt_celltab type lvc_t_styl,
            l_index type i.
      select * from sflight into table lt_sflight up to g_max rows.
      if sy-subrc ne 0.
    generate own entries if db-table is empty so that this example
    still works
        perform generate_entries changing lt_sflight.
      endif.
    *§A3.Optionally, check checkboxes initially after selecting data.
    (Omitted in this example)
      loop at lt_sflight into ls_sflight.
        move-corresponding ls_sflight to gt_outtab.
      if gt_outtab-connid eq '400'.
        gt_outtab-checkbox = 'X'.
      endif.
        append gt_outtab.
      endloop.
    §B2.After selecting data,
       assign a style for each row of your checkbox column.
    Initially, set all checkbox cells editable.
      ls_celltab-fieldname = 'CHECKBOX'.
      ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
      loop at gt_outtab.
        l_index = sy-tabix.
        refresh lt_celltab.
        ls_celltab-fieldname = 'CHECKBOX'.
        ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
        insert ls_celltab into table lt_celltab.
        insert lines of lt_celltab into table gt_outtab-celltab.
        modify gt_outtab index l_index.
      endloop.
    endform.                               " build_data
    *&      Form  generate_entries
          text
         <--P_LT_SLFIGHT  text
    form generate_entries changing pt_slfight type standard table.
    This form is only needed for the case that there is no
    data in database table SFLIGHT.
      data: ls_sflight type sflight,
            l_month(2) type c,
            l_day(2) type c,
            l_date(8) type c.
      ls_sflight-carrid = 'LH'.
      ls_sflight-connid = '0400'.
      ls_sflight-currency = 'DEM'.
      ls_sflight-planetype = '747-400'.
      ls_sflight-seatsmax = 660.
      do 110 times.
        ls_sflight-price = sy-index * 100.
        ls_sflight-seatsocc = 660 - sy-index * 6.
        ls_sflight-paymentsum = ls_sflight-seatsocc * ls_sflight-price.
        l_month = sy-index / 10 + 1.
        do 2 times.
          l_day = l_month + sy-index * 2.
          l_date+0(4) = '2000'.
          l_date4(2) = l_month0(2).
          l_date6(2) = l_day0(2).
          ls_sflight-fldate = l_date.
          append ls_sflight to pt_slfight.
        enddo.
      enddo.
    endform.                               " generate_entries
    *&      Form  select_all_entries
          text
         <--P_GT_OUTTAB  text
    form select_all_entries changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c,
            l_locked type c.
    *§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
          you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        loop at pt_outtab into ls_outtab.
          perform check_lock using    ls_outtab
                             changing l_locked.
          if l_locked is initial
             and not ls_outtab-checkbox eq '-'.
            ls_outtab-checkbox = 'X'.
          endif.
          modify pt_outtab from ls_outtab.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.                               " select_all_entries
    *&      Form  deselect_all_entries
          text
         <--P_GT_OUTTAB[]  text
    form deselect_all_entries changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c,
            l_locked type c.
    *§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
          you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        loop at pt_outtab into ls_outtab.
          perform check_lock using    ls_outtab
                           changing l_locked.
          if l_locked is initial
             and not ls_outtab-checkbox eq '-'.
            ls_outtab-checkbox = ' '.
          endif.
          modify pt_outtab from ls_outtab.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.                               " deselect_all_entries
    *&      Form  reset_selected_entries
          text
         <--P_GT_OUTTAB[]  text
    form reset_selected_entries changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c.
    *§A4b. Before you set, (b)reset or evaluate checkboxes,
         you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        loop at pt_outtab into ls_outtab.
          if     not ls_outtab-checkbox is initial
             and not ls_outtab-checkbox eq '-'.
            clear ls_outtab.
            modify pt_outtab from ls_outtab.
          endif.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.                               " reset_selected_entries
    form switch_activation changing pt_outtab type standard table.
      data: ls_outtab type gs_outtab.
      data: l_valid type c,
            lt_row_no type lvc_t_roid with header line.
    *§A4c. Before you set, reset, (c)(de)activate
         or evaluate checkboxes, you must check the input cells.
    If all entries are ok, ALV transferes new values to the output
    table which you then can modify.
      call method g_grid->check_changed_data
                  importing
                     e_valid = l_valid.
      if l_valid eq 'X'.
        call method g_grid->get_selected_rows
          importing
             et_row_no     = lt_row_no[].
        loop at lt_row_no.
           read table pt_outtab into ls_outtab index lt_row_no-row_id.
           if ls_outtab-checkbox ne '-'.
             ls_outtab-checkbox = '-'.
           else.
             ls_outtab-checkbox = ' '.
           endif.
           modify pt_outtab from ls_outtab index lt_row_no-row_id.
        endloop.
        call method g_grid->refresh_table_display.
      endif.
    endform.                               " switch_activation
    *&      Form  check_lock
          text
         -->P_LS_OUTTAB  text
         <--P_L_LOCKED  text
    form check_lock using    ps_outtab type gs_outtab
                    changing p_locked.
      data ls_celltab type lvc_s_styl.
      loop at ps_outtab-celltab into ls_celltab.
        if ls_celltab-fieldname = 'CHECKBOX'.
          if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
            p_locked = 'X'.
          else.
            p_locked = space.
          endif.
        endif.
      endloop.
    endform.                               " check_lock
    Regards,
    Sindhu

  • Regarding column editing in alv grid

    hi experts,
    i m using alv grid display for my report layout what i want that after the output dispaly when the user will select my customized button "change the amount column" then after pressing this my amount column will become editable and user can put there new aount for this i have used this codes but it is not working plz help me to sort out this,
    for u here is my code.
    FORM DISPLAY_LIST .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = sy-cprog
          is_layout                = i_layout
          it_fieldcat              = i_fieldtab
          i_grid_title             = 'Production Incentive Details'
          I_CALLBACK_PF_STATUS_SET = 'SET_PFSTATUS'
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          it_events                = global_events
        TABLES
          t_outtab                 = itab_final
        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_LIST
    *&      Form  SET_PFSTATUS
          text
         -->RT_EXTAB   text
    FORM SET_PFSTATUS USING rt_extab TYPE slis_t_extab..
      SET PF-STATUS 'ZPINCENTIVE' .
    EXCLUDING rt_extab..
    ENDFORM.                    " CREATE_PFSTATUS
    *&      Form  user_command
          text
         -->R_UCOMM      text
         -->RS_SELFIELD  text
    form user_command using r_ucomm like sy-ucomm
                                         rs_selfield type slis_selfield.
      case r_ucomm.
    *BREAK-POINT.
        when  '&CHANGED'.        "for change the amount button.
          read table i_fieldtab into s_fieldtab with key FIELDNAME = 'AMOUNT'.
          if sy-subrc = 0.
            move:sy-tabix to index,
                 'X' to s_fieldtab-edit.
            modify:i_fieldtab index index from s_fieldtab.
            clear:s_fieldtab.
          endif.

    solved by own

  • Regarding user interface in subtotal line of ALV grid, ensure points

    Hi,
    I have 3 fields,
    A= vendor , B = freight , C = Cost PMT
    When the vendor get changed, My Grid is showing subtotal of B i.e freight.
    Now my requirement is, in the same subtotal line, I want average of C (Cost PMT) field.
    So how we can interact with the subtotal line of the ALV grid.
    Pleas reply!!!!   & have ur points.
    cheers

    Read the documentation of FM ICON_CREATE, the purpose of the Function module is entirely different from what you are using it for.
    To print Icons in ALV (Using FMs ) all you need to do is to send the Icon name in the field.
    Also parameters TEXT and INFO of FM ICON_CREATE seem to be flags, that are appended to the icon name so that when you set it on the screen the appropriate info or Text is shown.

  • REGARDING horizontal scroller in alv grid o/p

    hi,
       i have developed a report in alv grid its wrking fine..
      i want one thing >>>>in the o/p screen the plantid  is the first column, the second column is the plant name what i want is that, horizontal  scroller will work from plant name not from plantid for this what parameters sud i pass in the fieldcat for plantid.plz help me.

    Hi,
    U have to put for that particular plant id
    wfieldcat-key = 'X'.
    Thanks,
    Sankar M

  • Regarding output using alv grid display

    Hi experts,
        i have a program
    FS_TAB1-A = P_T1.
    IF P_T1 = 0.
      TEMP1 = 1.
      DO TEMP1 TIMES.
        FS_TAB1-A = P_T1 * DUMMY1.
        APPEND FS_TAB1 TO T_TAB1.
        DUMMY1 = DUMMY1  + 1.
      ENDDO.
    now i have to diplay the p_t1*dummy1 using alv grid display like it goes into thew  loop for ten times then i have to show it 10 times like
    10 1  102 103 104 111 112  like that can u help me

    hi,
        you have to get the result of the multiplication at each row and then concatenate the result and the factor to show the final result in multiples value and multiplication factor...

  • Regarding subtotals and new page in ALV Grid

    Hi All,
    I have 5 employees in my internal table and each employee having five records.
    Now iam displaying total employees in ALV grid and calculating their totals at the end of the hole records.
    But i need to display the sub totals for each employee and i need new page for each employee.
    means  1) New page for each employye
                2) sub totals for each employee
                3) grand total for all employees
    How can i proceed for this requirement in ALV grid?

    For subtotals first you need to set the do_sum = 'X' in the fieldcatalog for the columns you want totals.
    fieldcat-fieldname = 'ABC'.
    fieldcat-do_sum = 'X'.
    Append fieldcat to it_fieldcat,
    for subtotals you need to populate the SORT table.
    sort-fieldname = 'EMPLOYEE'.
    sort-up = 'X'.
    sort-group = '*'.  "<----- this is for new page
    "you can view new page in preview / print /
    "if you are using the list function
    sort-subtot = 'X'.
    append sort to it_sort.
    pass this it_sort to it_sort of the alv function.

Maybe you are looking for