ALV using clases and  methods

Hi all
how can i use alv 's for reading data from table mara and dispyaing 10 records on out put screen as a grid  using classes or methods
thanks in advance

Hi,
look into the sample code:
                       TYPE-POOLS                                    *
TYPE-POOLS: slis.
                     TRANSPARENT TABLES                              *
TABLES: rbkp,rbco,sscrfields,t009b.
      CLASS cl_event_receiver DEFINITION
CLASS cl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS: handle_double_click
             FOR EVENT double_click OF cl_gui_alv_grid
             IMPORTING e_row e_column,
             handle_top_of_page
             FOR EVENT print_top_of_page OF cl_gui_alv_grid.
  PRIVATE SECTION.
ENDCLASS.
      CLASS CL_EVENT_RECEIVER IMPLEMENTATION
CLASS cl_event_receiver IMPLEMENTATION.
*--Method double click
  METHOD :handle_double_click.
    PERFORM drill_down USING e_column-fieldname
                             e_row-index .
  ENDMETHOD.
*--Method top of page
  METHOD handle_top_of_page.
    PERFORM event_top_of_page.
  ENDMETHOD.                 "top_of_page
ENDCLASS.
DATA: event_receiver TYPE REF TO cl_event_receiver.
                      Global Variables                               *
DATA:
  v_xblnr     LIKE rbkp-xblnr,         " Refernce Doc No
  v_lifnr     LIKE lfa1-lifnr,         " Vendor
  v_bukrs     LIKE t001-bukrs,         " Company Code
  v_zzmprd    LIKE mara-matnr,         " MPM
  v_monat     LIKE t009b-poper.        " Fiscal Period
                     GLOBAL TYPES                                    *
*-Structure for Invoice details
TYPES:BEGIN OF y_invoice,
        belnr LIKE rbkp-belnr,                    " Invoice Doc No
        gjahr LIKE rbkp-gjahr,                    " Fiscal Year
        blart LIKE rbkp-blart,                    " Document type
        bldat LIKE rbkp-bldat,                    " Document date
        budat LIKE rbkp-budat,                    " Posting date
        xblnr LIKE rbkp-xblnr,                    " Refernce Doc no
        bukrs LIKE rbkp-bukrs,                    " Company Code
        lifnr LIKE rbkp-lifnr,                    " Vendor
        waers LIKE rbkp-waers,                    " Local Currency
        bktxt LIKE rbkp-bktxt,                    " Doc header text
        zlspr LIKE rbkp-zlspr,                    " payment block
        buzei LIKE rseg-buzei,                    " Invoice Item No
        ebeln LIKE rseg-ebeln,                    " PO
        ebelp LIKE rseg-ebelp,                    " PO line item
        matnr LIKE rseg-matnr,                    " SAP Material
        bwtar LIKE rseg-bwtar,                    " Valuation type
        wrbtr LIKE rseg-wrbtr,                    " Inv Value
        menge LIKE rseg-menge,                    " Inv Qty
      END OF y_invoice,
*-Structure for Material details
      BEGIN OF y_material,
        matnr LIKE mara-matnr,                   " Material No
        normt LIKE mara-normt,                   " Article Number
        ismconttype LIKE mara-ismconttype,       " Window
        ismdesign LIKE mara-ismdesign,           " No of disc in MPM
        werks LIKE marc-werks,                   " Plant
        mfrgr LIKE marc-mfrgr,                   " Product Line
      END OF y_material,
Structure for Costtype data
     BEGIN OF y_costtype,
       bukrs    LIKE zsn0325_costtype-bukrs,      " Company Code
       land1    LIKE zsn0325_costtype-land1,      " Country key
       window   LIKE zsn0325_costtype-window,     " Window
       ewlnr    LIKE zsn0325_costtype-ewlnr,      " Cost type
       distmeth LIKE zsn0325_costtype-distmeth,   " Distribution type
       zvalfrom LIKE zsn0325_costtype-zvalfrom,   " Posting date from
       zvalto   LIKE zsn0325_costtype-zvalto,     " Posting Date TO
       disc1pr  LIKE zsn0325_costtype-disc1pr,    " Disc price
       disc2pr  LIKE zsn0325_costtype-disc2pr,    " Disc price
     END OF y_costtype,
Structure for Distmeth data
    BEGIN OF y_distmeth,
       distmeth  LIKE zsn0325_distmeth-distmeth,  " Distribution Methods
       distext  LIKE zsn0325_distmeth-distext,    " Description
    END OF y_distmeth,
*-structure for rbco
      BEGIN OF y_rbco,
        belnr LIKE rbco-belnr,                    " Account Doc#
        gjahr LIKE rbco-gjahr,                    " Fiscal year
        buzei LIKE rbco-buzei,                    " Doc item in inv doc
        cobl_nr LIKE rbco-cobl_nr,                " 4 Character
                                                   " Seq No for Coding
        wrbtr LIKE rbco-wrbtr,                    " Amt in doc currency
        saknr LIKE rbco-saknr,                    " G/L Account Number
        sgtxt LIKE rbco-sgtxt,                    " Item text
        zzcou LIKE rbco-zzcou,                    " Country
        zzmprd LIKE rbco-zzmprd,                  " MPM Product
        menge LIKE rbco-menge,                    " Quantity
        bukrs LIKE rbco-bukrs,                    " Company Code
        xnegp LIKE rbco-xnegp,                    " Variance Flag
        matnr LIKE mara-matnr,                    " MPM Product
        land1 LIKE zsop_fame-sop_cnt,           " SOP country code
      END OF y_rbco,
*-structure for rbco_tmp
      BEGIN OF y_rbco_tmp,
       bukrs LIKE rbco-bukrs,                     " Company Code
       sgtxt LIKE rbco-sgtxt,                     " Item text
       ewlnr    LIKE zsn0325_costtype-ewlnr,      " Cost type
       distmeth LIKE zsn0325_costtype-distmeth,   " Distribution type
       land1    LIKE zsop_fame-sop_cnt,           " SOP country code
      END OF y_rbco_tmp,
*-Structure for setleaf
     BEGIN OF y_setleaf,
     setname      LIKE  setleaf-setname,
       valsign    LIKE  setleaf-valsign,
       valoption  LIKE  setleaf-valoption,
       valfrom    LIKE  setleaf-valfrom,
       valto      LIKE  setleaf-valto,
     END OF y_setleaf,
*-Structure for Output data
     BEGIN OF y_output,
       bukrs      LIKE rbkp-bukrs,                " Company Code
       gjahr      LIKE rbkp-gjahr,                " Fiscal year
       lifnr      LIKE rbkp-lifnr,                " Vendor
       zlspr      LIKE rbkp-zlspr,                " Payment block
       xblnr      LIKE rbkp-xblnr,                " Refernece Doc no
       bldat      LIKE rbkp-bldat,                " Document date
       budat      LIKE rbkp-budat,                " Posting date
       belnr      LIKE rbkp-belnr,                " Invoice Doc No
       bktxt      LIKE rbkp-bktxt,                " Invoice Type
       normt      LIKE mara-normt,                " Article Number
       ismconttype LIKE mara-ismconttype,         " Window
       zzcou      LIKE rbco-zzcou,                " Country
       zzmprd     LIKE rbco-zzmprd,               " MPM Product
       xnegp      LIKE rbco-xnegp,                " Cost type variance
       cobl_nr    LIKE rbco-cobl_nr,              " 4 Character
                                                   " Seq No for Coding
       invfqty    LIKE rbco-menge,                " Inventory Fee Qty
       discqty    LIKE rbco-menge,                " Dist Cost Qty
       disrqty    LIKE rbco-menge,                " Dist Return Qty
       sseqty     LIKE rbco-menge,                " Special Services Qty
       sgtxt      LIKE rbco-sgtxt,                " Item Text
       ismdesign  LIKE mara-ismdesign,            " No of disc on MPM
       mfrgr      LIKE marc-mfrgr,                " Product Line
       ddeal(3),                                  " Distribution DEAL
       distmeth   LIKE zsn0325_costtype-distmeth, " Distribution type
       distext    LIKE zsn0325_distmeth-distext,  " Description
       ndisc(2)   TYPE c,                         " NO of disc on INV
       rifval     LIKE rbco-wrbtr,                " Inv fee value
       stdrif     LIKE zsn0325_costtype-disc1pr,  " STD Inv fee
       rfvar      LIKE zsn0325_costtype-disc1pr,  " Inv Fee Variance
       dicval     LIKE rbco-wrbtr,                " Dist cost Value
       stddico    LIKE zsn0325_costtype-disc1pr,  " STD Dis cost
       dicvar     LIKE zsn0325_costtype-disc1pr,  " Dist Cost Variance
       disrev     LIKE rbco-wrbtr,                " Dist Return Value
       stdirco    LIKE zsn0325_costtype-disc1pr,  " STD Dis Return cost
       drevar     LIKE zsn0325_costtype-disc1pr,  " Dist Ret Variance
       adj_qty_ct LIKE rbco-menge,                " Adjustments Qty
       adj_pr_ct  LIKE rbco-wrbtr,                " Adjustments Value
       ssval      LIKE rbco-wrbtr,                " Special Value
       color_cell TYPE lvc_t_scol,                " Cell Color
       END OF y_output,
*-Structure for Temporary Output data
     BEGIN OF y_output_tmp,
       bukrs      LIKE rbkp-bukrs,                " Company Code
       gjahr      LIKE rbkp-gjahr,                " Fiscal year
       lifnr      LIKE rbkp-lifnr,                " Vendor
       zlspr      LIKE rbkp-zlspr,                " Payment block
       xblnr      LIKE rbkp-xblnr,                " Refernece Doc no
       bldat(10)    TYPE  c,                      " Document Date
       budat(10)    TYPE  c,                      " Posting date
       belnr      LIKE rbkp-belnr,                " Invoice Doc No
       bktxt      LIKE rbkp-bktxt,                " Invoice Type
       normt(18)    TYPE  c,                      " Article Number
       ismconttype LIKE mara-ismconttype,         " Window
       zzcou      LIKE rbco-zzcou,                " Country
       zzmprd     LIKE rbco-zzmprd,               " MPM Product
       xnegp      LIKE rbco-xnegp,                " Cost type variance
       cobl_nr    LIKE rbco-cobl_nr,              " 4 Character
                                                   " Seq No for Coding
       invfqty    LIKE rbco-menge,                " Inventory Fee Qty
       discqty    LIKE rbco-menge,                " Dist Cost Qty
       disrqty    LIKE rbco-menge,                " Dist Return Qty
       sseqty     LIKE rbco-menge,                " Special Services Qty
       sgtxt      LIKE rbco-sgtxt,                " Item Text
       ismdesign(2) TYPE c,                       " No of disc on MPM
       mfrgr      LIKE marc-mfrgr,                " Product Line
       ddeal(3),                                  " Distribution DEAL
       distmeth   LIKE zsn0325_costtype-distmeth, " Distribution type
       distext    LIKE zsn0325_distmeth-distext,  " Description
       ndisc(2)   TYPE c,                         " NO of disc on INV
       rifval     LIKE rbco-wrbtr,                " Inv fee value
       stdrif     LIKE zsn0325_costtype-disc1pr,  " STD Inv fee
       rfvar      LIKE zsn0325_costtype-disc1pr,  " Inv Fee Variance
       dicval     LIKE rbco-wrbtr,                " Dist cost Value
       stddico    LIKE zsn0325_costtype-disc1pr,  " STD Dis cost
       dicvar     LIKE zsn0325_costtype-disc1pr,  " Dist Cost Variance
       disrev     LIKE rbco-wrbtr,                " Dist Return Value
       stdirco    LIKE zsn0325_costtype-disc1pr,  " STD Dis Return cost
       drevar     LIKE zsn0325_costtype-disc1pr,  " Dist Ret Variance
       adj_qty_ct LIKE rbco-menge,                " Adjustments Qty
       adj_pr_ct  LIKE rbco-wrbtr,                " Adjustments Value
       ssval      LIKE rbco-wrbtr,                " Special Value
       color_cell TYPE lvc_t_scol,                " Cell Color
      END OF y_output_tmp.
               GLOBAL DATA -INTERNAL TABLES                          *
DATA: i_invoice      TYPE STANDARD TABLE OF y_invoice,
      i_output       TYPE STANDARD TABLE OF y_output,
      i_output_tmp   TYPE STANDARD TABLE OF y_output_tmp,
      i_rbco         TYPE STANDARD TABLE OF y_rbco,
      i_rbco_tmp     TYPE STANDARD TABLE OF y_rbco_tmp,
      i_setleaf      TYPE STANDARD TABLE OF y_setleaf,
      i_material     TYPE STANDARD TABLE OF y_material,
      i_costtype     TYPE STANDARD TABLE OF y_costtype,
      i_distmeth     TYPE STANDARD TABLE OF y_distmeth,
      i_toolbar_excluding TYPE ui_functions,
      i_fieldcatalog TYPE lvc_t_fcat.
                        WORK AREAS                                   *
DATA: w_invoice       TYPE  y_invoice,
      w_material      TYPE  y_material,
      w_output        TYPE  y_output,
      w_output_tmp    TYPE  y_output_tmp,
      w_costtype      TYPE  y_costtype,
      w_distmeth      TYPE  y_distmeth,
      w_rbco          TYPE  y_rbco,
      w_rbco_tmp      TYPE  y_rbco_tmp,
      w_setleaf       TYPE  y_setleaf,
      w_toolbar_excluding TYPE ui_func,
      w_fieldcatalog  TYPE  lvc_s_fcat.
*--Ranges
RANGES: r_setinv FOR setleaf-valfrom,
        r_matnr FOR mara-matnr.
         DATA DECLARATION FOR ALV                                    *
*--Data declaration for ALV Grid
DATA :w_alvgrid    TYPE REF TO cl_gui_alv_grid,
      w_ccontainer TYPE REF TO cl_gui_custom_container,
      w_okcode     LIKE sy-ucomm.
*--Color cell
DATA: i_color    TYPE lvc_t_scol,
      w_color    TYPE lvc_s_scol.
*--- Layout structure
DATA w_layout TYPE lvc_s_layo .
                 SELECTION SCREEN                                    *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-055.
SELECT-OPTIONS:
  s_bukrs FOR rbkp-bukrs,                           " Company Code
  s_lifnr FOR rbkp-lifnr,                           " Vendor
  s_xblnr FOR rbkp-xblnr,                           " Reference Doc No
  s_gjahr FOR rbkp-gjahr OBLIGATORY,                " Fiscal Year
  s_monat FOR t009b-poper,                          " Period
  s_budat FOR rbkp-budat,                           " Posting date
  s_bldat FOR rbkp-bldat,                           " Document date
  s_zzmprd FOR rbco-zzmprd.                         " MPM
SELECTION-SCREEN END OF BLOCK blk1.
                AT SELECTION SCREEN                                  *
Validating Company Code
AT SELECTION-SCREEN ON s_bukrs.
  IF NOT s_bukrs[] IS INITIAL.
    SELECT bukrs                        " Company Code
           UP TO 1 ROWS
           INTO v_bukrs
           FROM t001
           WHERE bukrs IN s_bukrs.
    ENDSELECT.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'Invalid Company Code'(e06).
    ENDIF.
  ENDIF.
Validating ODS Invoice Document No.
AT SELECTION-SCREEN ON s_xblnr.
  IF NOT s_xblnr[] IS INITIAL.
    SELECT xblnr                        " Reference Document number
           UP TO 1 ROWS
           INTO v_xblnr
           FROM rbkp
           WHERE xblnr IN s_xblnr.
    ENDSELECT.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'Invalid ODS Invoice No.'(e05).
    ENDIF.
  ENDIF.
Validating Vendor Number
AT SELECTION-SCREEN ON s_lifnr.
  IF NOT s_lifnr[] IS INITIAL.
    SELECT lifnr                        " Vendor Number
           UP TO 1 ROWS
           INTO v_lifnr
           FROM lfa1
           WHERE lifnr IN s_lifnr.
    ENDSELECT.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'Invalid Vendor Number'(e04).
    ENDIF.
  ENDIF.
Validating MPM
AT SELECTION-SCREEN ON s_zzmprd.
  REFRESH r_matnr.
  LOOP AT s_zzmprd.
    MOVE-CORRESPONDING s_zzmprd TO r_matnr.
    IF NOT s_zzmprd IS INITIAL.
      CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
           EXPORTING
                input        = s_zzmprd-low
           IMPORTING
                output       = r_matnr-low
           EXCEPTIONS
                length_error = 1
                OTHERS       = 2.
      CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
           EXPORTING
                input        = s_zzmprd-high
           IMPORTING
                output       = r_matnr-high
           EXCEPTIONS
                length_error = 1
                OTHERS       = 2.
      APPEND r_matnr.
    ENDIF.
  ENDLOOP.
  SELECT matnr                          " MPM
         UP TO 1 ROWS
         INTO v_zzmprd
         FROM mara
         WHERE matnr IN r_matnr.
  ENDSELECT.
  IF sy-subrc NE 0.
    MESSAGE e000 WITH 'Invalid MPM'(e09).
  ENDIF.
Validating Fiscal Period
  IF NOT s_monat[] IS INITIAL.
    SELECT poper                        " Fiscal Period
           UP TO 1 ROWS
           INTO v_monat
           FROM t009b
           WHERE periv = 'K4'
             AND poper IN s_monat
             AND bdatj IN s_gjahr.
    ENDSELECT.
    IF sy-subrc NE 0.
      MESSAGE e000 WITH 'Invalid Fiscal Period'(e02).
    ENDIF.
  ENDIF.
*For Company Code & Vendor
AT SELECTION-SCREEN.
  MOVE sy-ucomm TO sscrfields-ucomm.
  IF sy-ucomm EQ 'ONLI'
  AND s_bukrs[] IS INITIAL
  AND s_lifnr[] IS INITIAL.
    MESSAGE i000 WITH
       'Either Company code or Vendor must be selected'(e03).
    STOP.
  ENDIF.
  IF ( NOT s_budat[] IS INITIAL OR NOT s_bldat IS INITIAL )
      AND NOT s_monat[] IS INITIAL.
    MESSAGE i000 WITH
'Select either Period or Posting date,Document date'(e01).
    STOP.
  ENDIF.
                 START OF SELECTION                                  *
START-OF-SELECTION.
*-Retrieve Invoice Details from RBKP & RSEG
  PERFORM get_invoice.
  IF NOT i_invoice[] IS INITIAL.
*-Retrieve Invoice Details from RBCO
    PERFORM get_rbco.
  ENDIF.
  IF NOT i_rbco[] IS INITIAL.
*-Retrieve Material Document details from MARA & MARC
    PERFORM get_material.
  ENDIF.
  IF NOT i_invoice[] IS INITIAL.
*-Retrieve costtype details from zsn0325_costtype & zsn0325_distmeth
    PERFORM get_costtype.
    PERFORM get_distmeth.
  ENDIF.
*-Populate internal table  for output
  PERFORM populate_output.
                 END OF SELECTION                                    *
END-OF-SELECTION.
*-TO Display Output
  IF NOT i_invoice[] IS INITIAL
    AND  NOT i_output[]  IS INITIAL.
    PERFORM display_report.
    CALL SCREEN 100.
  ENDIF.
*&      Form  get_Invoice
Retrieve Invoice Details from RBKP & RSEG
FORM get_invoice.
  DATA : lv_monat LIKE bkpf-monat.
*-Get  Value form set zsn_doc_types_inv
  SELECT setname
         valsign
         valoption
         valfrom
         valto
         FROM setleaf
         INTO TABLE i_setleaf
         WHERE setclass = '0000'
         AND setname =  'ZSN_DOC_TYPES_INV'.
  IF sy-subrc = 0.
    LOOP AT i_setleaf INTO w_setleaf.
      r_setinv-sign = w_setleaf-valsign.
      r_setinv-option = w_setleaf-valoption.
      r_setinv-low = w_setleaf-valfrom.
      r_setinv-high = w_setleaf-valto.
      APPEND r_setinv.
    ENDLOOP.
  ENDIF.
Get Invoice Doc details
  SELECT a~belnr                       " Document number of an invoice
         a~gjahr                       " Fiscal Year
         a~blart                       " Document type
         a~bldat                       " Document Date in Document
         a~budat                       " Posting Date in the Document
         a~xblnr                       " Reference Document Number
         a~bukrs                       " Company Code
         a~lifnr                       " Different invoicing party
         a~waers                       " Currency Key
         a~bktxt                       " Document header text
         a~zlspr                       " Payment Block Key
         b~buzei                       " Document item in invoice
         b~ebeln                       " Purchasing Document Number
         b~ebelp                       " Item Number of PO Document
         b~matnr                       " Material Number
         b~bwtar                       " Valuation type
         b~wrbtr                       " Amount in document currency
         b~menge                       " Quantity
         INTO TABLE i_invoice
         FROM rbkp AS a
         LEFT OUTER JOIN rseg AS b
         ON abelnr EQ bbelnr
         WHERE a~bukrs IN s_bukrs
         AND a~gjahr IN s_gjahr
         AND a~bldat IN s_bldat
         AND a~blart IN r_setinv
         AND a~budat IN s_budat
         AND a~xblnr IN s_xblnr
         AND a~lifnr IN s_lifnr.
  IF sy-subrc NE 0.
    MESSAGE i000 WITH 'No Invoice exists for this selection'(e07)
                   'criteria'(e08).
    STOP.
  ELSE.
    SORT i_invoice BY belnr gjahr.
    LOOP AT i_invoice INTO w_invoice.
      CALL FUNCTION 'FI_PERIOD_DETERMINE'
        EXPORTING
          i_budat             = w_invoice-budat
         i_bukrs              = w_invoice-bukrs
         i_periv              = 'K4'
         i_gjahr              = w_invoice-gjahr
      I_MONAT              = 00
      X_XMO16              = ' '
       IMPORTING
      E_GJAHR              =
         e_monat              = lv_monat
      E_POPER              =
       EXCEPTIONS
         fiscal_year          = 1
         period               = 2
         period_version       = 3
         posting_period       = 4
         special_period       = 5
         version              = 6
         posting_date         = 7
         OTHERS               = 8.
      IF sy-subrc <> 0.
        DELETE i_invoice.
      ELSE.
        IF lv_monat IN s_monat.
        ELSE.
          DELETE i_invoice.
        ENDIF.
      ENDIF.
    ENDLOOP.
    IF i_invoice[] IS INITIAL.
      MESSAGE i000 WITH 'No Invoice exists for this selection'(e07)
                     'criteria'(e08).
      STOP.
    ENDIF.
  ENDIF.
ENDFORM.                    " get_Invoice
*&      Form  get_rbco
Retrieve Invoice Details from RBCO
FORM get_rbco.
  SELECT belnr
         gjahr
         buzei
         cobl_nr
         wrbtr
         saknr
         sgtxt
         zzcou
         zzmprd
         menge
         bukrs
         xnegp
         FROM rbco
         INTO TABLE i_rbco
         FOR ALL ENTRIES IN i_invoice
         WHERE belnr = i_invoice-belnr
           AND gjahr = i_invoice-gjahr
           AND wrbtr <> 0
           AND zzmprd IN s_zzmprd.
  IF sy-subrc NE 0.
    MESSAGE i000 WITH 'No Distribution Data Exists'(e10).
    STOP.
  ELSE.
    SORT i_rbco BY belnr gjahr.
  ENDIF.
ENDFORM.                    " get_rbco
*&      Form  get_material
Retrieve Material Document details from MARA & MARC
FORM get_material.
  LOOP AT i_rbco INTO w_rbco.
    SELECT SINGLE sop_cnt
                  INTO w_rbco_tmp-land1
                  FROM zsop_fame
                  WHERE fame_cnt = w_rbco-zzcou.
    IF sy-subrc = 0.
      w_rbco_tmp-bukrs = w_rbco-bukrs.
      w_rbco_tmp-ewlnr = w_rbco-sgtxt+7(2).
      w_rbco_tmp-distmeth = w_rbco-sgtxt+0(3).
    ENDIF.
    w_rbco-land1 = w_rbco_tmp-land1.
    APPEND w_rbco_tmp TO i_rbco_tmp.
    CLEAR w_rbco_tmp.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
         EXPORTING
              input        = w_rbco-zzmprd
         IMPORTING
              output       = w_rbco-matnr
         EXCEPTIONS
              length_error = 1
              OTHERS       = 2.
    MODIFY i_rbco FROM w_rbco.
    CLEAR w_rbco.
  ENDLOOP.
  SELECT     a~matnr                             " Material Number
             a~normt                             " Article Number
             a~ismconttype                       " Window
             a~ismdesign                         " No of discs in MPM
             b~werks                             " Plant
             b~mfrgr                             " Product Line
             INTO TABLE i_material
             FROM mara AS a
             INNER JOIN
             marc AS b
             ON amatnr = bmatnr
             FOR ALL ENTRIES IN i_rbco
             WHERE a~matnr = i_rbco-matnr.
  IF sy-subrc = 0.
    SORT i_material BY matnr.
  ENDIF.
ENDFORM.                    " get_material
*&      Form  get_costtype
Retrieve costtype details from zsn0325_costtype
FORM get_costtype.
  SELECT bukrs                                " Company code
         land1                                " Country key
         window                               " Window
         ewlnr                                " Cost type
         distmeth                             " Distribution type
         zvalfrom                             " Invoice date
         zvalto                               " Invoice date
         disc1pr                              " Disc Price
         disc2pr                              " Additional DiscPrice
          FROM zsn0325_costtype
         INTO TABLE i_costtype
         FOR ALL ENTRIES IN i_rbco_tmp
         WHERE bukrs = i_rbco_tmp-bukrs
           AND ewlnr = i_rbco_tmp-ewlnr
           AND distmeth = i_rbco_tmp-distmeth
           AND land1 = i_rbco_tmp-land1.
  IF sy-subrc = 0.
    SORT i_costtype BY bukrs land1 window ewlnr distmeth.
  ENDIF.
ENDFORM.                    " get_costtype
*&      Form  get_distmeth
Retrieve costtype details from zsn0325_distmeth
FORM get_distmeth.
  SELECT distmeth
         distext
         FROM zsn0325_distmeth
         INTO TABLE i_distmeth
         FOR ALL ENTRIES IN i_costtype
         WHERE distmeth = i_costtype-distmeth.
  IF sy-subrc = 0.
    SORT i_distmeth BY distmeth.
  ENDIF.
ENDFORM.                    " get_distmeth
*&      Form  display_report
TO Display Output
FORM display_report.
  IF NOT i_output[] IS INITIAL.
    SORT i_output BY xblnr.
    PERFORM build_fieldcat.
  ENDIF.
ENDFORM.                    " display_report
*&      Form  build_fieldcat
Build Field Catalog
FORM build_fieldcat.
  PERFORM fill_fieldcat USING 'BUKRS'         'I_OUTPUT'
                                              'Company Code'(001) 12.
  PERFORM fill_fieldcat USING 'LIFNR'         'I_OUTPUT'
                                              'Vendor'(002) 6.
  PERFORM fill_fieldcat USING 'ZLSPR'         'I_OUTPUT'
                                              'Payment Block'(003) 13.
  PERFORM fill_fieldcat USING 'XBLNR'         'I_OUTPUT'
                                           'Vendor Invoice No'(004) 17.
  PERFORM fill_fieldcat USING 'BLDAT'         'I_OUTPUT'
                                              'Invoice Date'(005) 12.
  PERFORM fill_fieldcat USING 'BUDAT'         'I_OUTPUT'
                                              'Posting Date'(006) 12.
  PERFORM fill_fieldcat USING 'BKTXT'         'I_OUTPUT'
                                              'Invoice Type'(007) 12.
  PERFORM fill_fieldcat USING 'BELNR'         'I_OUTPUT'
                                              'R/3 Invoice No'(008) 14.
  PERFORM fill_fieldcat USING 'COBL_NR'       'I_OUTPUT'
                                              'Line Item'(009) 9.
  PERFORM fill_fieldcat USING 'NORMT'         'I_OUTPUT'
                                              'Article No'(010) 10.
  PERFORM fill_fieldcat USING 'ZZMPRD'        'I_OUTPUT'
                                              'MPM Product'(034) 11.
  PERFORM fill_fieldcat USING 'ISMCONTTYPE'   'I_OUTPUT'
                                              'Window'(011) 6.
  PERFORM fill_fieldcat USING 'NDISC'         'I_OUTPUT'
                                       'No of Discs on invoice'(012) 22.
  PERFORM fill_fieldcat USING 'ISMDESIGN'     'I_OUTPUT'
                                           'No of discs on MPM'(013) 10.
  PERFORM fill_fieldcat USING 'DISTMETH'      'I_OUTPUT'
                                           'Distribution type'(014) 17.
  PERFORM fill_fieldcat USING 'DISTEXT'       'I_OUTPUT'
                                              'Description'(015) 11.
  PERFORM fill_fieldcat USING 'DDEAL'         'I_OUTPUT'
                                           'Distribution Deal'(016) 17.
  PERFORM fill_fieldcat USING 'MFRGR'         'I_OUTPUT'
                                           'MPM Product Line'(017) 16.
  PERFORM fill_fieldcat USING 'ZZCOU'         'I_OUTPUT'
                                              'Country'(018) 7.
  PERFORM fill_fieldcat USING 'XNEGP'         'I_OUTPUT'
                                              'Qty Var flag'(019) 12.
  PERFORM fill_fieldcat USING 'INVFQTY'       'I_OUTPUT'
                                              'Inv fee Qty'(020) 11.
  PERFORM fill_fieldcat USING 'RIFVAL'        'I_OUTPUT'
                                              'Inv fee Value'(021) 13.
  PERFORM fill_fieldcat USING 'STDRIF'        'I_OUTPUT'
                                              'Std Inv fee'(022) 11.
  PERFORM fill_fieldcat USING 'RFVAR'         'I_OUTPUT'
                                              'Inv fee Var'(023) 11.
  PERFORM fill_fieldcat USING 'DISCQTY'       'I_OUTPUT'
                                              'Dis cost Qty'(024) 11.
  PERFORM fill_fieldcat USING 'DICVAL'        'I_OUTPUT'
                                              'Dist Cost Value'(025) 15.
  PERFORM fill_fieldcat USING 'STDDICO'       'I_OUTPUT'
                                              'Std Dist Cost'(026) 11.
  PERFORM fill_fieldcat USING 'DICVAR'        'I_OUTPUT'
                                              'Dist Cost Var'(027) 13.
  PERFORM fill_fieldcat USING 'DISRQTY'       'I_OUTPUT'
                                              'Dis Ret Qty'(028) 11.
  PERFORM fill_fieldcat USING 'DISREV'        'I_OUTPUT'
                                              'Dis Ret Value'(029) 11.
  PERFORM fill_fieldcat USING 'STDIRCO'       'I_OUTPUT'
                                           'Std Dis Ret cost'(030) 11.
  PERFORM fill_fieldcat USING 'DREVAR'        'I_OUTPUT'
                                              'Dis Ret Var'(031) 11.
  PERFORM fill_fieldcat USING 'ADJ_QTY_CT'    'I_OUTPUT'
                                           'Adjustments Qty'(035) 15.
  PERFORM fill_fieldcat USING 'ADJ_PR_CT'     'I_OUTPUT'
                                           'Adjustments Value'(036) 17.
  PERFORM fill_fieldcat USING 'SSEQTY'        'I_OUTPUT'
                                           'Special Ser Qty'(032) 15.
  PERFORM fill_fieldcat USING 'SSVAL'         'I_OUTPUT'
                                           'Special Ser Value'(033) 17.
ENDFORM.                    " build_fieldcat
*&      Form  fill_fieldcat
     Fill fieldcatalog for ALV                                       *
FORM fill_fieldcat USING    value(p_fieldname)
                            value(p_tabname)
                            value(p_seltext_m)
                            value(p_outputlen).
  w_fieldcatalog-fieldname = p_fieldname.
  w_fieldcatalog-ref_table = p_tabname.
  w_fieldcatalog-coltext = p_seltext_m.
  w_fieldcatalog-outputlen = p_outputlen.
  APPEND w_fieldcatalog TO i_fieldcatalog.
  CLEAR w_fieldcatalog.
ENDFORM.                    " fill_fieldcat
*&      Module  STATUS_0100  OUTPUT
Process Before output
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN1'.
  SET TITLEBAR 'TITLE'.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&      Module  alV_display  OUTPUT
ALv Display in PBO                                             *
MODULE alv_display OUTPUT.
  IF w_ccontainer IS INITIAL.
    PERFORM create_objects.
Excluding unnecessary function codes from the grid
    PERFORM exclude_fcodes.
    PERFORM display_alv_grid.
  ENDIF.
ENDMODULE.                 " alV_display  OUTPUT
*&      Form  create_objects
Create ALV Objects
FORM create_objects.
  IF w_alvgrid IS INITIAL .
*----Creating custom container instance
    CREATE OBJECT w_ccontainer
      EXPORTING
        container_name = 'CONTAINER'
      EXCEPTIONS
        cntl_error = 1
      cntl_system_error = 2
      create_error = 3
      lifetime_error = 4
      lifetime_dynpro_dynpro_link = 5
      others = 6 .
    IF sy-subrc <> 0.
*--Exception handling
    ENDIF.
*----Creating ALV Grid instance
    CREATE OBJECT w_alvgrid
       EXPORTING
           i_parent = w_ccontainer
       EXCEPTIONS
          error_cntl_create = 1
          error_cntl_init = 2
          error_cntl_link = 3
          error_dp_create = 4
          others = 5 .
    IF sy-subrc <> 0.
*--Exception handling
    ENDIF.
*--Create Event Receiver
    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_top_of_page FOR w_alvgrid.
  ENDIF.
ENDFORM.                    " create_objects
*&      Form  display_alv_grid
Display ALV Grid
FORM display_alv_grid.
  w_layout-grid_title  = 'Distribution Report'(042).
  IF NOT w_alvgrid IS INITIAL .
    MOVE 'COLOR_CELL' TO w_layout-ctab_fname.
    CALL METHOD w_alvgrid->set_table_for_first_display
           EXPORTING
             is_layout = w_layout
             it_toolbar_excluding  = i_toolbar_excluding[]
            I_DEFAULT = 'X'
           CHANGING
             it_outtab = i_output_tmp[]
             it_fieldcatalog = i_fieldcatalog[]
           EXCEPTIONS
              invalid_parameter_combination = 1
              program_error = 2
              too_many_lines = 3
              OTHERS = 4 .
    IF sy-subrc <> 0.
*--Exception handling
    ENDIF.
  ELSE .
    CALL METHOD w_alvgrid->refresh_table_display
    EXCEPTIONS
    finished = 1
    OTHERS = 2 .
    IF sy-subrc <> 0.
    ENDIF.
  ENDIF .
*--handler for ALV grid
  SET HANDLER event_receiver->handle_double_click FOR w_alvgrid.
ENDFORM.                    " display_alv_grid
*&      Module  USER_COMMAND_0100  INPUT
At User Command
MODULE user_command_0100 INPUT.
  MOVE sy-ucomm TO w_okcode.
  CASE w_okcode.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&      Form  populate_output
Populate internal table  for output
FORM populate_output.
  DATA: lv_invval  TYPE rbco-wrbtr.
  LOOP AT i_rbco INTO w_rbco.
*-Check whether ndisc is numeric value.
    IF w_rbco-sgtxt+4(2) CO '0123456789'.
      MOVE: w_rbco-sgtxt+4(2) TO w_output-ndisc.
    ENDIF.
    MOVE:w_rbco-cobl_nr TO w_output-cobl_nr,
         w_rbco-zzcou TO w_output-zzcou,
         w_rbco-zzmprd TO w_output-zzmprd,
         w_rbco-xnegp TO w_output-xnegp.
For Invoice
    READ TABLE i_invoice INTO w_invoice WITH KEY belnr = w_rbco-belnr
                                                 gjahr = w_rbco-gjahr
                                                 BINARY SEARCH.
    IF sy-subrc = 0.
      MOVE: w_invoice-bukrs       TO   w_output-bukrs,
            w_invoice-lifnr       TO   w_output-lifnr,
            w_invoice-zlspr       TO   w_output-zlspr,

Similar Messages

  • List display for ALV using class and methods

    Hi friends
    I want the list display for the ALV using Class and methods
    which class and methods i can use.
    Here we can't use the REUSE_ALV_LIST_DISPLAY and also GRID
    I was done GRID display using class and methods but i want only list display for using class.
    plz Give me sample code of list display not for grid.
    Thanks
    Nani.

    hi
    please check with this code...
    declare grid and container.
    DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,
    o_dockingcontainer TYPE REF TO cl_gui_docking_container,
    i_fieldcat TYPE lvc_t_fcat,"fieldcatalogue
    w_layout TYPE lvc_s_layo."layout
    If any events like double click,etc., are needed we have to add additional functionality.
    call the screen in program.
    Then , create the container as follows
    IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    CREATE OBJECT o_dockingcontainer
    EXPORTING
    ratio = '95'
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6.
    ENDIF.
    CREATE OBJECT o_alvgrid
    EXPORTING
    i_parent = o_dockingcontainer.
    Build the fieldcatalog
    create a output structure in SEll for the ALV output
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    i_structure_name = <alv output>
    CHANGING
    ct_fieldcat = i_fieldcat[]
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE i030."Error in building the field catalogue
    LEAVE LIST-PROCESSING.
    ENDIF.
    *If you need to modify the field catalog,modify it using field sysmbols
    *setting the layout
    w_layout-grid_title = title.
    w_layout-zebra = 'X'.
    then displaying the output
    CALL METHOD o_alvgrid->set_table_for_first_display
    EXPORTING
    i_save = 'A'
    is_layout = w_layout
    CHANGING
    it_outtab = i_output[]
    it_fieldcatalog = i_fieldcat[]
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc <> 0.
    MESSAGE i032 ."Error in Displaying
    LEAVE LIST-PROCESSING.
    ENDIF.
    *After that in PAI of the screen, you need to free the *object while going back from the screen(according to *your requirement)
    MODULE user_command_9001 INPUT.
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    PERFORM f9600_free_objects:
    USING o_alvgrid 'ALV' text-e02,
    USING o_dockingcontainer 'DOCKING'
    text-e01.
    LEAVE PROGRAM.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_9001 INPUT
    *in the program, write the follwoing code
    FORM f9600_free_objects USING pobject
    value(ptype)
    value(ptext).
    DATA: l_objectalv TYPE REF TO cl_gui_alv_grid.
    CASE ptype.
    WHEN 'ALV'.
    l_objectalv = pobject.
    IF NOT ( l_objectalv IS INITIAL ).
    CALL METHOD l_objectalv->free
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    OTHERS = 3.
    CLEAR: pobject, l_objectalv.
    PERFORM f9700_error_handle USING ptext.
    ENDIF.
    WHEN 'DOCKING'.
    DATA: lobjectdock TYPE REF TO cl_gui_docking_container.
    lobjectdock = pobject.
    IF NOT ( lobjectdock IS INITIAL ).
    CALL METHOD lobjectdock->free
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    OTHERS = 3.
    CLEAR: pobject, lobjectdock.
    PERFORM f9700_error_handle USING ptext.
    ENDIF.
    WHEN 'CONTAINER'.
    DATA: lobjectcontainer TYPE REF TO cl_gui_container.
    lobjectcontainer = pobject.
    IF NOT ( lobjectcontainer IS INITIAL ).
    CALL METHOD lobjectcontainer->free
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    OTHERS = 3.
    CLEAR: pobject, lobjectcontainer.
    PERFORM f9700_error_handle USING ptext.
    ENDIF.
    WHEN OTHERS.
    sy-subrc = 1.
    PERFORM f9700_error_handle USING
    text-e04.
    ENDCASE.
    ENDFORM. " f9600_free_objects
    FORM f9700_error_handle USING value(ptext).
    IF sy-subrc NE 0.
    CALL FUNCTION 'POPUP_TO_INFORM'
    EXPORTING
    titel = text-e03
    txt2 = sy-subrc
    txt1 = ptext.
    ENDIF.
    endform.
    also check with this
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    Hope this helps
    if it helped, you can acknowledge the same by rewarding
    regards
    dinesh

  • Can I use classes and methods for a maintenance view events?

    Hello experts,
    Instead of perform/form, can I instead use classes and methods, etc for a given maintenance view event, lets say for example I want to use event '01' which is before saving records in the database. Help would be greatly appreciated. Thanks a lot guys!

    Hi viraylab,
    1. The architecture provided by maintenance view
       for using EVENTS and our own code inside it -
       It is provided using FORM/PERFORM
       concept only.
    2. At this stage,we cannot use classes.
    3. However, inside the FORM routine,
       we can write what ever we want.
       We can aswell use any abap code, including
       classes and methods.
      (But this classes and methods won't have any
       effect on the EVENT provided by maintenance view)
    regards,
    amit m.

  • ALV report for 5 Grids using Objects and Method

    I have few questions in ALV 5Grids ,could you please correct me in the following program logic...
    Using this program logic i am able to generate the five Grids and able to populate Header details from VBAK into Grid1,If you click in the Grid 1 and it is populating item details in Grid2 from VBAP,parallally populating the customer data in Grid5 from KNA1.
    Now the pending issue is ,
    if you click in the Grid2 then we should populate the shipping details in Grid3 and
    if you click in the Grid3 then we should populate the billing details in Grid4.
    Program Logic;
    REPORT  ZAREPAS20.
    Tables : vbak,vbap,likp,lips,vbrk,vbrp,kna1.
    DATA : OK_CODE              LIKE        SY-UCOMM,
           G_CONTAINER          TYPE SCRFNAME VALUE 'BCALV7_GRID_DEMO_0100_VASU',
           DOCKING              TYPE REF TO CL_GUI_DOCKING_CONTAINER,
           SPLITTER_1           TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
           SPLITTER_2           TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
           splitter_3           TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
           CELL_TOP1            TYPE REF TO CL_GUI_CONTAINER,
           CELL_BOTTOM1         TYPE REF TO CL_GUI_CONTAINER,
           CELL_TOP2            TYPE REF TO CL_GUI_CONTAINER,
           CELL_BOTTOM2         TYPE REF TO CL_GUI_CONTAINER,
           CELL_LEFT            TYPE REF TO CL_GUI_CONTAINER,
           CELL_middle          TYPE REF TO CL_GUI_CONTAINER,
           CELL_RIGHT           TYPE REF TO CL_GUI_CONTAINER,
           GRID1                TYPE REF TO CL_GUI_ALV_GRID,
           GRID2                TYPE REF TO CL_GUI_ALV_GRID,
           GRID3                TYPE REF TO CL_GUI_ALV_GRID,
           GRID4                TYPE REF TO CL_GUI_ALV_GRID,
           GRID5                TYPE REF TO CL_GUI_ALV_GRID.
    DATA : GT_VBAK              TYPE STANDARD TABLE OF VBAK,
           GT_VBAP              TYPE STANDARD TABLE OF VBAP,
           GT_LIKP              TYPE STANDARD TABLE OF likp,
           GT_LIPS              TYPE STANDARD TABLE OF lips,
           GT_VBRK              TYPE STANDARD TABLE OF vbrk,
           GT_VBRP              TYPE STANDARD TABLE OF vbrp,
           GT_KNA1              TYPE STANDARD TABLE OF kna1.
    DATA:begin of itab1 occurs 0,
         vbeln type likp-VBELN,                            
         erzet type likp-ERZET,                             
         lfart type likp-LFART,                             
         posnr type lips-POSNR,
         END OF ITAB1.
    DATA:begin of itab2 occurs 0,
         vbeln like vbrk-vbeln,                            
         posnr like vbrk-fktyp,                            
         fkart like vbrk-fkart,                             
         fklmg like vbrp-fklmg,                             
         end of itab2.
    *selection screen for selecting range of values
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.
    select-options: S_vbeln for VBAK-vbeln.     
    selection-screen end of block b1.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.  " sending control, i.e. ALV grid that raised event
    ENDCLASS.                    "lcl_eventhandler DEFINITION
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
    METHOD HANDLE_DOUBLE_CLICK.
    *DEFINE LOCAL DATA.
    DATA : itab_vbak type VBAK,
           itab_vbap type VBAP,
           itab_likp type likp,
           itab_lips type lips,
           itab_vbrk type vbrk,
           itab_vbrp type vbrp,
           itab_kna1 type kna1.
    *DISTINGUISH ACCORDING TO SENDING GRID INSTANCE
    CASE SENDER.
    WHEN GRID1.
       READ TABLE gt_VBAK INTO itab_vbak INDEX e_row-index.
           CHECK ( itab_vbak-vbeln IS NOT INITIAL ).
            CALL METHOD GRID1->set_current_cell_via_id
              EXPORTING
                 is_ROW_ID    =
                 is_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
    WHEN GRID2.
            READ TABLE gt_VBAP INTO itab_vbap INDEX e_row-index.
            CHECK ( itab_vbap-vbeln IS NOT INITIAL ).
            CALL METHOD GRID2->set_current_cell_via_id
              EXPORTING
                 is_ROW_ID    =
                 is_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
    WHEN GRID3.
            READ TABLE gt_LIPS INTO itab_LIPS INDEX e_row-index.
            CHECK ( itab_lips-vgbel IS NOT INITIAL ).
            CALL METHOD GRID3->set_current_cell_via_id
              EXPORTING
                 is_ROW_ID    =
                 is_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DELIVERY_DETAILS' ).
    WHEN GRID4.
            READ TABLE gt_VBRP INTO itab_VBRP INDEX e_row-index.
            CHECK ( itab_vbrp-vgbel IS NOT INITIAL ).
            CALL METHOD GRID4->set_current_cell_via_id
              EXPORTING
                 is_ROW_ID    =
                 is_COLUMN_ID =
                is_row_no    = es_row_no.
            Triggers PAI of the dynpro with the specified ok-code
            CALL METHOD cl_gui_cfw=>set_new_ok_code( 'BILLING_DETAILS' ).
    WHEN GRID5.
            READ TABLE gt_KNA1 INTO itab_KNA1 INDEX e_row-index.
            CHECK ( itab_kna1-kunnr IS NOT INITIAL ).
          SET PARAMETER ID 'KUN' FIELD itab_KNA1-KUNNR.
           CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
            RETURN.
        ENDCASE.
    endmethod.
    endclass.    "lcl_eventhandler IMPLEMENTATION
    start-of-selection.
    *write :/ 'FEDEX INT''''L' .
    SELECT        * FROM  vbak INTO TABLE gt_VBAK
    where vbeln IN  S_VBELN.
    creating docking container
    create object docking
       exporting
        parent     = cl_gui_container=>screen0
        ratio      = 90
      exceptions
       others      = 6.
      if sy-subrc eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Create splitter container
    CREATE OBJECT splitter_1
        EXPORTING
          parent            = docking
          rows              = 1
          columns           = 3
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD splitter_1->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = cell_left.
      CALL METHOD splitter_1->get_container
        EXPORTING
          row       = 1
          column    = 2
        RECEIVING
          container = cell_middle.
      CALL METHOD splitter_1->get_container
        EXPORTING
          row       = 1
          column    = 3
        RECEIVING
          container = cell_right.
    Create 2nd splitter container
      CREATE OBJECT splitter_2
      EXPORTING
          parent            = cell_left
          rows              = 2
          columns           = 1
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD splitter_2->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = cell_top1.
      CALL METHOD splitter_2->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = cell_bottom1.
    Create 3rd splitter container
    CREATE OBJECT splitter_3
        EXPORTING
          parent            = cell_middle
          rows              = 2
          columns           = 1
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD splitter_3->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = cell_top2.
      CALL METHOD splitter_3->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = cell_bottom2.
    Create ALV grids
      CREATE OBJECT grid1
        EXPORTING
          i_parent          = cell_top1
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT grid2
        EXPORTING
          i_parent          = cell_bottom1
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT grid3
        EXPORTING
          i_parent          = cell_top2
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT grid4
        EXPORTING
          i_parent          = cell_bottom2
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT grid5
        EXPORTING
          i_parent          = cell_right
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Set event handler
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid1.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid2.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid3.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid4.
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid5.
    Display data
      CALL METHOD grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAK'
        CHANGING
          it_outtab        = gt_VBAK
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    REFRESH: gt_vbap.
      CALL METHOD grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBAP'
        CHANGING
          it_outtab        = gt_VBAP    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    REFRESH: gt_LIPS.
      CALL METHOD grid3->set_table_for_first_display
        EXPORTING
          i_structure_name = 'LIPS'
        CHANGING
          it_outtab        = gt_LIPS    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    REFRESH: gt_VBRP.
      CALL METHOD grid4->set_table_for_first_display
        EXPORTING
          i_structure_name = 'VBRP'
        CHANGING
          it_outtab        = gt_VBRP    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    REFRESH: gt_KNA1.
      CALL METHOD grid5->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNA1'
        CHANGING
          it_outtab        = gt_KNA1    " empty !!!
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Link the docking container to the target dynpro
      CALL METHOD docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
         CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    NOTE: dynpro does not contain any elements (ok_code -> GD_OKCODE)
      CALL SCREEN '0100'.
    Flow logic of dynpro:
    *PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    end-of-selection.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    SET TITLEBAR 'xxx'.
    Refresh display of detail ALV list
      CALL METHOD grid2->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Refresh display of detail ALV list
      CALL METHOD grid3->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Refresh display of detail ALV list
      CALL METHOD grid4->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Refresh display of detail ALV list
      CALL METHOD grid5->refresh_table_display
       EXPORTING
         IS_STABLE      =
         I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc  eq 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
    CASE SY-UCOMM.
    WHEN 'BACK' OR
         'EXIT'  OR
         'CANCEL'.
         SET SCREEN 0.LEAVE SCREEN.
    USER HAS PUSHED BUTTON "DISPLAY OREDERS"
         WHEN 'ORDER_DETAILS'.
          PERFORM ORDER_SHOW_DETAILS.
          when 'DELIVERY_DETAILS'.
            PERFORM DELIVERY_SHOW_DETAILS.
          WHEN 'BILLING_DETAILS'.
             PERFORM BILLING_SHOW_DETAILS.
         WHEN OTHERS.
    ENDCASE.
    CLEAR : OK_CODE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  ORDER_SHOW_DETAILS
          text
    -->  p1        text
    <--  p2        text
    FORM order_show_details .
    define local data
      DATA:
        ld_row      TYPE i,
        itab_VBAK     TYPE VBAK.
      CALL METHOD grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_VBAK INTO itab_VBAK INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT        * FROM  KNA1 INTO TABLE gt_KNA1
             WHERE  KUNNR  = itab_VBAK-KUNNR.
      SELECT        * FROM  VBAP INTO TABLE gt_VBAP
             WHERE  VBELN  = ITAB_VBAK-VBELN.
    *REFRESH: gt_LIPS.
    ENDFORM.                    " ORDER_SHOW_DETAILS
    *&      Form  DELIVERY_SHOW_DETAILS
          text
    -->  p1        text
    <--  p2        text
    FORM DELIVERY_SHOW_DETAILS .
    define local data
      DATA:
        ld_row      TYPE i,
        itab_VBAP     TYPE VBAP.
      CALL METHOD grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_VBAP INTO itab_VBAP INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT LIKPVBELN LIKPERZET LIKPLFART LIPSVBELN
           INTO CORRESPONDING FIELDS OF TABLE ITAB1
           FROM ( LIKP INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN )
           WHERE LIKP~VBELN IN S_VBELN.
    *REFRESH: gt_LIPS.
    ENDFORM.                    " DELIVERY_SHOW_DETAILS
    *&      Form  BILLING_SHOW_DETAILS
          text
    -->  p1        text
    <--  p2        text
    FORM BILLING_SHOW_DETAILS .
    define local data
      DATA:
        ld_row      TYPE i,
        itab_LIPS     TYPE LIPS.
      CALL METHOD grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_LIPS INTO itab_LIPS INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT VBRKVBELN VBRKFKTYP VBRKFKART VBRPFKLMG
           INTO CORRESPONDING FIELDS OF TABLE ITAB2
           FROM ( VBRK INNER JOIN VBRP ON VBRKVBELN = VBRPVBELN )
           WHERE VBRK~VBELN IN S_VBELN.
    ENDFORM.                    " BILLING_SHOW_DETAILS

    Hi,
    ALV means ABAP List Viewer. Most convenient way to use it is through reuse library (cf.
    transaction se83) available from release 4.6 of SAP R/3.
    ALV is available in two modes: list and grid. List mode is good old list processing with
    standard functionnalities, and grid mode is using a new OCX object displaying grids.
    Classical reports needs more coding to set the horizontal and vertical lines.we need to adjust
    the lines manually.Even interactive also takes lot of code.
    ALV reports reduces the code when compared to classical reports.we use function modules to
    generate the output.
    that r REUSE_ALV_LIST_DISPLAY,REUSE_ALV_GRID_DISPLAY,REUSE_ALV_HIERSEQ_LIST_DISPLAY etc..
    the following threads will give some examples of the functions which you are expecting
    Header
    regarding function module
    hide ALV field
    Simply Display selection parameter values in the ALV OUTPUT
    Drag and drop in a report
    https://www.sdn.sap
    Reprots
    http://www.sapgenie.com/abap/reports.htm
    http://www.allsaplinks.com/material.html
    http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you
    use - ABAP Objects calls or simple function modules.

  • Automatic Display of NEW Data in ALV Report using Classes and Methods

    Hi,
    I have developed a ALV Report for displaying data from a set of DB tables using ABAP OO, Classes and Methods. The requirement is to have the report output to be automatically updated with the new entries from the DB table at a regular frequency of tiem may be every two minutes.
    Could anyone please tell me how can this be acheived.
    Thanks and regards,
    Raghavendra Goutham P.

    Yes its possible.
    Take a look at this thread
    Auto refresh of ALV Grid, without user interaction
    Or Rich's blog
    /people/rich.heilman2/blog/2005/10/18/a-look-at-clguitimer-in-46c
    Regards,
    Ravi
    Note : Please mark all the helpful answers

  • How we can use class and methods for the FM of reuse_alv_list_display

    Hi Abapers,
    Please provide the sample code of class and method of REUSE_ALV_LIST_DISPLAY.
    Which Class i can use for this Function module.
    I need to write a code using OOPS concept.
    I was done the GRID display  using this class cl_gui_alv_grid.
    But i want only List Display using the class & methods.
    Plz provide sample code.
    Thanks
    Nani.

    Hi Nani,
    This is the sample code..
    *&amp; Report Z_OO_ALV
    *& We can Use Two containers in OOALV
    REPORT z_oo_alv LINE-COUNT 50.
    *types gt_struct type sflight.
    DATA BEGIN OF gt_struct.
    INCLUDE STRUCTURE sflight.
    DATA rcol(4) TYPE c.
    DATA colors TYPE lvc_t_scol.
    DATA END OF gt_struct.
    *ALV GRIDs
    DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.
    DATA gr_alvgrid1 TYPE REF TO cl_gui_alv_grid.
    DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
    DATA gc_custom_control_name1 TYPE scrfname VALUE 'CC_ALV1'.
    *CONTAINERs
    DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.
    DATA gr_ccontainer1 TYPE REF TO cl_gui_custom_container.
    *FIELDCATALOGs
    DATA gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
    DATA gt_fieldcat1 TYPE lvc_t_fcat WITH HEADER LINE.
    *LAYOUTs
    DATA gs_layout TYPE lvc_s_layo.
    DATA gs_layout1 TYPE lvc_s_layo.
    DATA pt_exclude TYPE ui_functions. "internal table declaration to be passed.
    *DATA pt_cell TYPE lvc_t_cell with header line.
    DATA : gt_list LIKE gt_struct OCCURS 50 WITH HEADER LINE,
    gt_list1 LIKE gt_struct OCCURS 50 WITH HEADER LINE.
    *DATA v_ucomm TYPE sy-ucomm.
    CALL SCREEN 100.
    *& Module display_alv OUTPUT
    text
    MODULE display_alv OUTPUT.
    PERFORM display_alv.
    ENDMODULE. " display_alv OUTPUT
    *& Module PAI INPUT
    text
    MODULE pai INPUT.
    CASE sy-ucomm.
    WHEN 'EXIT'.
    PERFORM exit_program.
    WHEN 'PICK'.
    PERFORM cell_info.
    ENDCASE.
    ENDMODULE. " PAI INPUT
    *& Form display_alv
    text
    FORM display_alv.
    PERFORM prepare_field_catalog CHANGING gt_fieldcat[].
    PERFORM prepare_layout CHANGING gs_layout.
    PERFORM data_retrival.
    IF gr_alvgrid IS INITIAL.
    CREATE OBJECT gr_ccontainer
    EXPORTING
    container_name = gc_custom_control_name
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    OTHERS = 6.
    IF sy-subrc <> 0.
    ENDIF.
    CREATE OBJECT gr_alvgrid
    EXPORTING
    I_SHELLSTYLE = 0
    I_LIFETIME =
    i_parent = gr_ccontainer
    I_APPL_EVENTS = space
    I_PARENTDBG =
    I_APPLOGPARENT =
    I_GRAPHICSPARENT =
    I_NAME =
    I_FCAT_COMPLETE = SPACE
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    OTHERS = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    PERFORM exclude_tb_functions CHANGING pt_exclude.
    PERFORM set_col.
    CALL METHOD gr_alvgrid->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE =
    I_BYPASSING_BUFFER =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME =
    IS_VARIANT =
    I_SAVE =
    I_DEFAULT = 'X'
    is_layout = gs_layout
    IS_PRINT =
    IT_SPECIAL_GROUPS =
    it_toolbar_excluding = pt_exclude "excluding toolbar functions
    IT_HYPERLINK =
    IT_ALV_GRAPHICS =
    IT_EXCEPT_QINFO =
    IR_SALV_ADAPTER =
    CHANGING
    it_outtab = gt_list[]
    it_fieldcatalog = gt_fieldcat[]
    IT_SORT =
    IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ELSE.
    CALL METHOD gr_alvgrid->refresh_table_display
    EXPORTING
    IS_STABLE =
    I_SOFT_REFRESH =
    EXCEPTIONS
    finished = 1
    OTHERS = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDIF.
    PERFORM prepare_field_catalog1 CHANGING gt_fieldcat1[].
    PERFORM prepare_layout1 CHANGING gs_layout1.
    PERFORM data_retrival1.
    IF gr_alvgrid1 IS INITIAL.
    CREATE OBJECT gr_ccontainer1
    EXPORTING
    container_name = gc_custom_control_name1
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    OTHERS = 6.
    IF sy-subrc <> 0.
    ENDIF.
    CREATE OBJECT gr_alvgrid1
    EXPORTING
    I_SHELLSTYLE = 0
    I_LIFETIME =
    i_parent = gr_ccontainer1
    I_APPL_EVENTS = space
    I_PARENTDBG =
    I_APPLOGPARENT =
    I_GRAPHICSPARENT =
    I_NAME =
    I_FCAT_COMPLETE = SPACE
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    OTHERS = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    PERFORM set_col1.
    CALL METHOD gr_alvgrid1->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE =
    I_BYPASSING_BUFFER =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME =
    IS_VARIANT =
    I_SAVE =
    I_DEFAULT = 'X'
    is_layout = gs_layout1
    IS_PRINT =
    IT_SPECIAL_GROUPS =
    IT_TOOLBAR_EXCLUDING =
    IT_HYPERLINK =
    IT_ALV_GRAPHICS =
    IT_EXCEPT_QINFO =
    IR_SALV_ADAPTER =
    CHANGING
    it_outtab = gt_list1[]
    it_fieldcatalog = gt_fieldcat1[]
    IT_SORT =
    IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ELSE.
    CALL METHOD gr_alvgrid1->refresh_table_display
    EXPORTING
    IS_STABLE =
    I_SOFT_REFRESH =
    EXCEPTIONS
    finished = 1
    OTHERS = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDIF.
    ENDFORM. "display_alv
    *& Form prepare_field_catalog
    text
    -->GT_FIELDCAT text
    FORM prepare_field_catalog CHANGING pgt_fieldcat TYPE lvc_t_fcat.
    DATA ls_fieldcat TYPE lvc_s_fcat.
    ls_fieldcat-tabname = 'gt_list'.
    ls_fieldcat-fieldname = 'CARRID'.
    ls_fieldcat-scrtext_m = 'Air line code'.
    ls_fieldcat-col_pos = 0.
    ls_fieldcat-outputlen = 10.
    ls_fieldcat-emphasize = 'C400'.
    ls_fieldcat-key = 'X'.
    APPEND ls_fieldcat TO pgt_fieldcat.
    ls_fieldcat-tabname = 'gt_list'.
    ls_fieldcat-col_pos = 1.
    ls_fieldcat-fieldname = 'CONNID'.
    ls_fieldcat-scrtext_m = 'Connection code'.
    ls_fieldcat-emphasize = 'C900'.
    APPEND ls_fieldcat TO pgt_fieldcat.
    ls_fieldcat-tabname = 'gt_list'.
    ls_fieldcat-fieldname = 'PRICE'.
    ls_fieldcat-scrtext_m = 'PRICE'.
    APPEND ls_fieldcat TO pgt_fieldcat.
    ENDFORM. "prepare_field_catalog
    *& Form prepare_layout
    text
    -->GS_LAYOUT text
    FORM prepare_layout CHANGING gs_layout TYPE lvc_s_layo.
    gs_layout-stylefname = 'FIELD_STYLE'.
    gs_layout-zebra = 'X'.
    gs_layout-grid_title = 'FLIGHT'.
    gs_layout-sel_mode = 'A'.
    gs_layout-ctab_fname = 'COLORS'.
    ENDFORM. "prepare_layout
    *& Form data_retrival
    text
    FORM data_retrival.
    SELECT carrid
    connid
    price
    FROM sflight
    INTO CORRESPONDING FIELDS OF TABLE gt_list
    UP TO 50 ROWS.
    ENDFORM. "data_retrival
    FORM EXIT_PROGRAM *
    FORM exit_program.
    CALL METHOD gr_ccontainer->free.
    CALL METHOD gr_ccontainer1->free.
    LEAVE TO SCREEN 0.
    ENDFORM. "exit_program
    *& Module STATUS_0100 OUTPUT
    text
    MODULE status_0100 OUTPUT.
    SET PF-STATUS 'STAT'.
    SET TITLEBAR 'xxx'.
    IF W_CUSTOM_CONTAINER IS INITIAL.
    **sets TITLEBAR
    PERFORM TITLEBAR.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Form prepare_field_catalog1
    text
    -->GT_FIELDCAT text
    FORM prepare_field_catalog1 CHANGING pgt_fieldcat1 TYPE lvc_t_fcat.
    DATA ls_fieldcat TYPE lvc_s_fcat.
    ls_fieldcat-tabname = 'gt_list1'.
    ls_fieldcat-fieldname = 'SEATSMAX'.
    ls_fieldcat-scrtext_m = 'MAX. SEATS'.
    ls_fieldcat-col_pos = 0.
    ls_fieldcat-outputlen = 10.
    ls_fieldcat-emphasize = 'C400'.
    ls_fieldcat-key = ' '.
    APPEND ls_fieldcat TO pgt_fieldcat1.
    ls_fieldcat-tabname = 'gt_list1'.
    ls_fieldcat-col_pos = 1.
    ls_fieldcat-fieldname = 'SEATSOCC'.
    ls_fieldcat-scrtext_m = 'SEATS OCCUPIED'.
    APPEND ls_fieldcat TO pgt_fieldcat1.
    ENDFORM. "prepare_field_catalog
    *& Form prepare_layout1
    text
    -->GS_LAYOUT text
    FORM prepare_layout1 CHANGING gs_layout1 TYPE lvc_s_layo.
    gs_layout1-stylefname = 'FIELD_STYLE'.
    gs_layout1-zebra = 'X'.
    gs_layout1-grid_title = 'DETAILS'.
    gs_layout-sel_mode = 'C'.
    gs_layout1-info_fname = 'RCOL'.
    gs_layout-no_toolbar = 'X'.
    ENDFORM. "prepare_layout
    *& Form data_retrival1
    text
    FORM data_retrival1.
    SELECT seatsmax
    seatsocc
    FROM sflight
    INTO CORRESPONDING FIELDS OF TABLE gt_list1
    UP TO 50 ROWS.
    ENDFORM. "data_retrival
    *& Form exclude_tb_functions
    &---- subroutine to exclude toolbar options -
    text
    -->PT_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_maximum.
    APPEND ls_exclude TO pt_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_minimum.
    APPEND ls_exclude TO pt_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.
    APPEND ls_exclude TO pt_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_sort.
    APPEND ls_exclude TO pt_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
    APPEND ls_exclude TO pt_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_mb_subtot.
    APPEND ls_exclude TO pt_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_mb_sum.
    APPEND ls_exclude TO pt_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_mb_filter.
    APPEND ls_exclude TO pt_exclude.
    ENDFORM. "data_retrival1
    *& Form cell_info
    text
    FORM cell_info. "CHANGING pt_cell TYPE lvc_t_cell.
    DATA lt_cell TYPE lvc_t_cell WITH HEADER LINE.
    CALL METHOD gr_alvgrid->get_selected_cells
    IMPORTING
    et_cell = lt_cell[].
    LOOP AT lt_cell.
    WRITE : lt_cell-col_id , lt_cell-row_id.
    ENDLOOP.
    MODIFY pt_cell[] from lt_cell[].
    ENDFORM. "cell_info
    *& Form set_col
    text
    FORM set_col .
    DATA ls_cellcolor TYPE lvc_s_scol.
    LOOP AT gt_list.
    IF gt_list-price GT 500.
    ls_cellcolor-fname = 'PRICE'.
    ls_cellcolor-color-col = 5.
    ls_cellcolor-color-int = 1.
    ls_cellcolor-color-inv = 0.
    APPEND ls_cellcolor TO gt_list-colors.
    else.
    ls_cellcolor-fname = 'PRICE'.
    ls_cellcolor-color-col = 3.
    ls_cellcolor-color-int = 1.
    APPEND ls_cellcolor TO gt_list-colors.
    ENDIF.
    MODIFY gt_list.
    ENDLOOP.
    ENDFORM. "set_col
    *& Form set_col1
    text
    FORM set_col1.
    data : ind type sy-tabix,
    indx type sy-tabix.
    loop at gt_list1.
    ind = sy-tabix / 2.
    indx = sy-tabix - ind.
    if indx eq ind.
    gt_list1-rcol = 'C500'.
    endif.
    MODIFY gt_list1.
    endloop.
    ENDFORM. "set_col
    *FORM TITLEBAR.
    *SET TITLEBAR 'TITLE'.
    *ENDFORM.
    *double click on TITLE and write ur title
    Thanks,
    Samantak.
    Rewards points for useful answers.

  • Using Classes and Methods

    Hi Experts,
    I am studying ABAP Objects, before that I need to know How to use the exsiting classes and Methods in our program and how to search for particular class and methods?
    If it explanied with example well and good.
    Thanks
    sai

    Hi Saikar,
    Here i am sending you very useful content for the usage of classes and its methods.
    It helped me a lot.
    If you find it useful then do not forget to award points.
    Table of Contents
    Applies to:......................................................................................................................................1
    Summary........................................................................................................................................1
    Author Bio......................................................................................................................................1
    Main Class – CL_SALV_TABLE......................................................................................................3
    Functions – CL_SALV_FUNCTIONS..............................................................................................4
    Display Settings – CL_SALV_DISPLAY_SETTINGS......................................................................4
    Columns – CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE..............................5
    Sorts – CL_SALV_SORTS..............................................................................................................8
    Aggregations – CL_SALV_AGGREGATIONS..............................................................................10
    Filters – CL_SALV_FILTERS........................................................................................................12
    Layouts – CL_SALV_LAYOUT......................................................................................................14
    Related Content...........................................................................................................................15
    Disclaimer and Liability Notice.......................................................................................................16 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 3
    Main Class – CL_SALV_TABLE
    The main class used to create the simple 2D table is the class CL_SALV_TABLE. Create a reference variable for this class. Create an internal table and fill this internal table with data as show below.
    REPORT ZALVOM_DEMO1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. start-of-selection. select * into table ispfli from spfli.
    Next we need to create the ALV object for the 2D table. The FACTORY method allows you to create the ALV object in 3 ways. You can create the ALV Grid, as a classical list display, as a full screen grid, and finally embedded into a screen container. For this example, we will be working with the full screen grid. Create the call to the FACTORY method. We are importing the object reference into GR_TABLE and passing the internal table ISPFLI.
    cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ).
    Next we need to display the grid, for this we use the DISPLAY method . Simply call it.
    gr_table->display( ). 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 4
    Functions – CL_SALV_FUNCTIONS
    Next, add functions to the application toolbar. For this, use the CL_SALV_FUNCTIONS class. Create the object reference variable and receive the object using the GET_FUNCTIONS method of the GR_TABLE object. Call the method SET_ALL to force the ALV grid to show all standard functions.
    report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_table->display( ).
    The result is now you have the standard buttons on the application toolbar.
    Display Settings – CL_SALV_DISPLAY_SETTINGS
    Next, we can change some display settings using the class CL_SALV_DISPLAY_SETTINGS. Create the object reference variable and receive the object using the GET_DISPLAY_SETTINGS method of the GR_TABLE object. In this example, we are setting the “Striped Pattern” for the ALV Grid rows, and setting the heading in the title bar.
    report zalvom_demo1. 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 5
    ). data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' gr_table->display( ).
    Columns – CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN_TABLE
    Next, we can change some of the attributes of a specific column in the ALV grid. In this example we will change the Heading Text of a column as well as the color of a column. Create the object reference variable and receive the object using the GET_COLUMNS method of the GR_TABLE object. This will pass you the object for all columns of the ALV grid. To access just one column, call the method GET_COLUMN from the GR_COLUMNS object. In this example, we are accessing the CITYTO column and the CITYFROM column.
    report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 6
    data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table.
    data: color type lvc_s_colo.
    start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ).
    gr_column->set_short_text( 'This is sh' ).
    gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ).
    gr_table->display( ). 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 7 ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 8
    Sorts – CL_SALV_SORTS
    Next, we can add some sorting to the ALV grid. Create the object reference variable and receive the object using the GET_SORTS method of the GR_TABLE object. Next, add the sort by calling the ADD_SORT method of the GR_SORTS object.
    report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts.
    data: color type lvc_s_colo.
    start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort 'CITYTO' ). gr_table->display( ). 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 9 ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 10
    Aggregations – CL_SALV_AGGREGATIONS
    Since we sorted by CITYTO, we can add an aggregation to subtotal the DISTANCE by CITYTO. Create the object reference variable and receive the object using the GET_AGGREGATIONS method of the GR_TABLE object. Next, add the aggregation by calling the ADD_AGGREGATION method of the GR_SORTS object. We also need to modify the call to ADD_SORT to set the SUBTOTAL = ABAP_TRUE.
    report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations.
    data: color type lvc_s_colo.
    start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ). gr_agg->add_aggregation( 'DISTANCE' ). 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 11
    gr_table->display( ). 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 12
    Filters – CL_SALV_FILTERS
    Using the CL_SALV_FILTERS class we can setup some filters for the data in our ALV GRID. Create the object reference variable and receive the object using the GET_FILTERS method of the GR_TABLE object, and then simply called the method ADD_FILTER with the parameters.
    report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations. data: gr_filter type ref to cl_salv_filters.
    data: color type lvc_s_colo.
    start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ). gr_agg->add_aggregation( 'DISTANCE' ). 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 13
    gr_filter = gr_table->get_filters( ). gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ). gr_table->display( ). 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 14
    Layouts – CL_SALV_LAYOUT
    If you want to allow the user to manage layouts of the ALV grid, you must use the class CL_SALV_LAYOUT. Create the object reference variable and receive the object using the GET_LAYOUT method of the GR_TABLE object. Then simply call the method SET_KEY with the parameters and set the save restriction using the SET_SAVE_RESTRICTION method.
    report zalvom_demo1. data: ispfli type table of spfli. data: gr_table type ref to cl_salv_table. data: gr_functions type ref to cl_salv_functions. data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table. data: gr_column type ref to cl_salv_column_table. data: gr_sorts type ref to cl_salv_sorts. data: gr_agg type ref to cl_salv_aggregations. data: gr_filter type ref to cl_salv_filters. data: gr_layout type ref to cl_salv_layout. data: color type lvc_s_colo. data: key type salv_s_layout_key. start-of-selection. select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = ispfli ). gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ). gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ). gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ). gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'. color-int = '1'. color-inv = '0'. gr_column->set_color( color ). gr_sorts = gr_table->get_sorts( ). gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ). gr_agg = gr_table->get_aggregations( ). 
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 15
    gr_filter = gr_table->get_filters( ). gr_layout = gr_table->get_layout( ). gr_layout->set_key( ). gr_table->display( ). gr_agg->add_aggregation( 'DISTANCE' ). gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ). key-report = sy-repid. key gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
    Related Content
         • Help - ALV Object Model
         • Utilizing the New ALV Object Model
         • SDN ABAP Forum
    ALV Object Model – Simple 2D Table - The Basics SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2006 SAP AG 16
    Disclaimer and Liability Notice
    This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.
    SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.
    SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.
    Regards,
    Mandeep.
    Note: Award points if contents are useful.

  • Sort Icon/option in ALV tree repot using classes and methods

    Hi all,
    I have done an alv tree report using the class cl_gui_alv_tree
    and i need to let users re-sort the report by using a sort icon(as visible in a normal alv report).Is there any possibility to create an icon and set the functionality such that the entire tree structure gets resorted depending upon the sort criteria?Please give me an example of doing so if there is an option.

    if u want without classes then i can  give an example of Sort Icon/option.
    example:-
    DATA:   wa_sortinfo TYPE slis_sortinfo_alv.
           i_sortcat TYPE slis_t_sortinfo_alv.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program     = report_id
                i_grid_title           = ws_title
               i_callback_top_of_page = 'TOP-OF-PAGE'
                is_layout              = wa_layout
                it_fieldcat            = i_fieldcat[]
                it_sort                = i_sortcat
                i_save                 = 'A'
                it_events              = i_events
           TABLES
                t_outtab               = i_reportdata1
           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.
      PERFORM sortcat_init CHANGING i_sortcat.
    FORM sortcat_init CHANGING i_sortcat TYPE slis_t_sortinfo_alv.
      CLEAR wa_sortinfo.
      wa_sortinfo-fieldname = 'EBELN'. (sales order)
      wa_sortinfo-tabname = 'I_REPORTDATA1'.
      wa_sortinfo-spos = 1.            " First sort by this field.
      wa_sortinfo-up = 'X'.            "   Ascending
      wa_sortinfo-subtot = 'X'.        " Subtotal at Name1
      APPEND wa_sortinfo TO i_sortcat.
      CLEAR wa_sortinfo.
      wa_sortinfo-fieldname = 'EBELP'.
      wa_sortinfo-tabname = 'I_REPORTDATA1'.
      wa_sortinfo-spos = 2.            " Sec sort by this field.
      wa_sortinfo-up = 'X'.            "   Ascending
      wa_sortinfo-subtot = 'X'.        " Subtotal at Name1
      APPEND wa_sortinfo TO i_sortcat.
    ENDFORM.                    " sortcat_init

  • Hyper link in ALV by classes and methods

    Hiii,
    I developd report using alv report using  classes  cl_gui_alv_grid,cl_gui_custom_container...
    Output display contains field called as org_crmid..
    if i click on org_crmid i have to move to another transaction named BP( its saperate screen)
    kindly help me in solving this through classes..
    thanks in advance..

    hi,
             follow these steps.............
    1) while creating field catalog set the propertiey hotspot = 'X' to the field on which  we click.
    2) in local class define method for handling hotspot_click event.
        Hotspot clicking
          hotspot_click
               FOR EVENT hotspot_click OF cl_gui_alv_grid
                 IMPORTING e_row_id
                           e_column_id
                           es_row_no,
    3) in the implementation section provide the logic
      METHOD hotspot_click.
        PERFORM event_hotspot_click
                      USING e_row_id
                            e_column_id.
      ENDMETHOD.
    *form routine contains logic
    FORM event_hotspot_click
      USING
        p_row    TYPE lvc_s_row
        p_column TYPE lvc_s_col.
      DATA:
        lv_docnum TYPE kunnr.
      READ TABLE i_alv_data INTO v_alv_data INDEX p_row-index.
      IF p_column = 'CUST_ID'.
      call a transaction when the cust_id is clicked
        SET PARAMETER ID 'AUN' FIELD v_alv_data-cust_id.
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDIF.
    ENDFORM. 
    for more information follow this link...............
    http://www.watto.org/program/abap/download/Z_ALV_TEMPLATE.abap
    http://saplab.blogspot.com/2007/10/sample-abap-program-of-alv-grid-control.html
    http://help.sap.com/saphelp_nw04/helpdata/en/ee/c8e080d52611d2b468006094192fe3/content.htm
    regards,
    Ashok

  • ALV using chekbox and icon

    1)  Needs to create two icons for a row in ALV.
    With One Icon, she should be able to Edit a ROW. Other icon should support save option and should save the changes in the database table.
      How can we do this????
    2)  Needs to create a checkbox by creating a Field in the database table.
    Each row in the table will have a checkbox in ALV.
    If a checkbox is selected , that particular row should be selected in the ALV
    Regards,
    Rajkumar

    Rajkumar,
    Check the following code
    Types: begin of lt_io.
    include structure mara. " Your Structure
    Types: style_table type lvc_t_style.
    Types: end of lt_io.
    data: lt_io type table of lt_io,
    ls_layout type lvc_s_layo,
    lt_fcat type lvc_t_fcat,
    lo_grid type ref to cl_gui_alv_grid.
    field-symbols: <io> type lt_io,
    <fcat> type lvc_s_fcat.
    ... fill your output table ....
    ls_layout-stylefname = 'STYLE_TABLE'.
    loop at lt_io assigning <io>.
    PERFORM set_style USING 'CHECKBOX' "Your Filename
    CHANGING <io>.
    endloop.
    ... Fill Your Field Catalog lt_fcat
    read table lt_fcat assigning <fcat>
    where fieldname = 'CHECKBOX'.
    <fcat>-checkbox = 'X'.
    create grid control lo_grid.
    CALL METHOD lo_grid->set_table_for_first_display
    EXPORTING
    is_layout = ls_layout
    CHANGING
    it_fieldcatalog = lt_fcat
    it_outtab = lt_io[].
    FORM set_button_to_line
    USING iv_fieldname TYPE lvc_fname
    CHANGING cs_io TYPE io.
    DATA: ls_style TYPE lvc_s_styl,
    lt_style TYPE lvc_t_styl.
    ls_style-fieldname = iv_fieldname.
    if cs_io-checkbox = ' '.
    ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
    else.
    ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
    endif.
    ls_style-maxlen = 2.
    INSERT ls_style INTO TABLE io-style_table.
    ENDFORM. "set_icon_to_status_line
    [/code].
    Vinodh

  • SOAP Receiver to use operations and methods

    Hi.
    I have got a WSDL with 3 methods and I have to call one of them.
    However, the SOAP Receiver adapter only has a Action section which can be maintained.
    How can this be attained?
    The WSDL I am using is as follows:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:tns="urn:uniface:applic:services:CSYV1000" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="urn:uniface:applic:services:CSYV1000" name="CSYV1000">
         <wsdl:types />
         <wsdl:message name="EXTERNALRequest">
              <wsdl:part name="REQUEST" type="s:string" />
              <wsdl:part name="REQUESTDATA" type="s:string" />
         </wsdl:message>
         <wsdl:message name="LOGOFFRequest">
              <wsdl:part name="REQUEST" type="s:string" />
         </wsdl:message>
         <wsdl:message name="LOGONRequest">
              <wsdl:part name="REQUEST" type="s:string" />
         </wsdl:message>
         <wsdl:message name="EXTERNALResponse">
              <wsdl:part name="return" type="s:int" />
              <wsdl:part name="RESPONSE" type="s:string" />
              <wsdl:part name="RESPONSEDATA" type="s:string" />
              <wsdl:part name="RESPONSEERROR" type="s:string" />
         </wsdl:message>
         <wsdl:message name="LOGOFFResponse">
              <wsdl:part name="return" type="s:int" />
              <wsdl:part name="RESPONSE" type="s:string" />
              <wsdl:part name="RESPONSEERROR" type="s:string" />
         </wsdl:message>
         <wsdl:message name="LOGONResponse">
              <wsdl:part name="return" type="s:int" />
              <wsdl:part name="RESPONSE" type="s:string" />
              <wsdl:part name="RESPONSEERROR" type="s:string" />
         </wsdl:message>
         <wsdl:portType name="CSYV1000PortType">
              <wsdl:operation name="EXTERNAL" parameterOrder="REQUEST REQUESTDATA RESPONSE RESPONSEDATA RESPONSEERROR">
                   <wsdl:input message="tns:EXTERNALRequest" />
                   <wsdl:output message="tns:EXTERNALResponse" />
              </wsdl:operation>
              <wsdl:operation name="LOGOFF" parameterOrder="REQUEST RESPONSE RESPONSEERROR">
                   <wsdl:input message="tns:LOGOFFRequest" />
                   <wsdl:output message="tns:LOGOFFResponse" />
              </wsdl:operation>
              <wsdl:operation name="LOGON" parameterOrder="REQUEST RESPONSE RESPONSEERROR">
                   <wsdl:input message="tns:LOGONRequest" />
                   <wsdl:output message="tns:LOGONResponse" />
              </wsdl:operation>
         </wsdl:portType>
         <wsdl:binding name="CSYV1000Binding" type="tns:CSYV1000PortType">
              <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
              <wsdl:operation name="EXTERNAL">
                   <soap:operation soapAction="" />
                   <wsdl:input>
                        <soap:body use="encoded" namespace="urn:uniface:applic:services:CSYV1000" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                   </wsdl:input>
                   <wsdl:output>
                        <soap:body use="encoded" namespace="urn:uniface:applic:services:CSYV1000" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                   </wsdl:output>
              </wsdl:operation>
              <wsdl:operation name="LOGOFF">
                   <soap:operation soapAction="" />
                   <wsdl:input>
                        <soap:body use="encoded" namespace="urn:uniface:applic:services:CSYV1000" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                   </wsdl:input>
                   <wsdl:output>
                        <soap:body use="encoded" namespace="urn:uniface:applic:services:CSYV1000" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                   </wsdl:output>
              </wsdl:operation>
              <wsdl:operation name="LOGON">
                   <soap:operation soapAction="" />
                   <wsdl:input>
                        <soap:body use="encoded" namespace="urn:uniface:applic:services:CSYV1000" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                   </wsdl:input>
                   <wsdl:output>
                        <soap:body use="encoded" namespace="urn:uniface:applic:services:CSYV1000" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                   </wsdl:output>
              </wsdl:operation>
         </wsdl:binding>
         <wsdl:service name="CSYV1000Service">
              <wsdl:port name="CSYV1000" binding="tns:CSYV1000Binding">
                   <soap:address location="http://localhost/pathway/environment.pathway" />
              </wsdl:port>
         </wsdl:service>
    </wsdl:definitions>
    Your help is appreciated.
    Regards,
    Reenal

    Hi, Amit.
    The problem arises when I send a logon messages from XI, it fails.
    The request which works is:
    <?xml version="1.0" encoding="utf-16"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:uniface:applic:services:CSYV1000" xmlns:types="urn:uniface:applic:services:CSYV1000/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <tns:LOGON>
          <ns0:REQUEST xmlns:ns0="urn:aucklandcity-govt-nz:filenet:property_search"><service>CSYV1000</service><trace/><groupId/><product>SAP XI</product><processId/><threadId/><nodeId/><ipAddress/><sourceUserId/><sourceOSUserId/><uiForm>CMNQ1030</uiForm><groupIdPrevious/><userId>albadryh</userId><password>husain</password><osUserId></osUserId></ns0:REQUEST>
        </tns:LOGON>
      </soap:Body>
    </soap:Envelope>
    The problem is that XI is not adding the  <tns:LOGON> tags.
    Regards,
    Reenal

  • Creating of Notes for Transaction Code RECN(Using Classes and Methods)

    Hi Experts,
    I want to Create Notes for Transaction Code RECN, This should not done manually but should be done programatically.
    I had used the Class CL_GOS_SRV_NOTE_CREATE to create the notes.....but here comes the doubt for me.....note will be created by using this class and how this can be created for the Tcode RECN........
    I am using the Real Estate Module.....Plz help me....awaiting for ur helpful answers....
    Thanks in Advance.....!
    Brahma

    Hi kanagaraja,
    Thanks...!
    The BADI which u have given is not existing in my system...i had gone through the se18 and se19 tcodes....
    Awaiting for ur response......!
    Thanks,
    Brahma...

  • UNLOCKING single row in ALV using Funtions

    hai,
    Actually i am displaying a table in ALV USING FUNCTIONS and i am locking key values.
    Now my reqment is , if i press (NEW, COPY )button then i have to add one new row and that row should be Unlocked to insert values.
    Is it possible USING FUNCTIONS(I have a solution using CLASSES)

    Hi ramesh,
    it is possible with the LVC FM.i gave the sample yesterday did you check that..
    if not check it to day..
    REPORT ZTESTALV.
    TYPE-POOLS: SLIS.
    *- Fieldcatalog
    DATA: IT_FIELDCAT  TYPE LVC_T_FCAT,
          IT_FIELDCAT1  TYPE SLIS_T_FIELDCAT_ALV..
    *- For Events
    DATA:IT_EVENTS TYPE SLIS_T_EVENT.
    DATA:  X_FIELDCAT  TYPE LVC_S_FCAT,
            X_FIELDCAT1  TYPE SLIS_FIELDCAT_ALV.
    DATA:X_LAYOUT TYPE LVC_S_LAYO.
    "{ FOR DISABLE
    DATA: LS_EDIT TYPE LVC_S_STYL,
          LT_EDIT TYPE LVC_T_STYL.
    "} FOR DISABLE
    DATA: BEGIN OF IT_VBAP OCCURS 0,
          VBELN LIKE VBAP-VBELN,
          POSNR LIKE VBAP-POSNR,
          HANDLE_STYLE TYPE LVC_T_STYL, "FOR DISABLE
         END OF IT_VBAP.
    DATA: LS_OUTTAB LIKE LINE OF IT_VBAP.
    SELECT VBELN
           POSNR
           UP TO 10 ROWS
          INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
          FROM VBAP.
    DATA:L_POS TYPE I VALUE 1.
    CLEAR: L_POS.
    L_POS = L_POS + 1.
    X_FIELDCAT-SELTEXT = 'VBELN'.
    X_FIELDCAT-FIELDNAME = 'VBELN'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-OUTPUTLEN = '10'.
    x_fieldcat-ref_field = 'VBELN'.
    x_fieldcat-ref_table = 'VBAK'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-SELTEXT = 'POSNR'.
    X_FIELDCAT-FIELDNAME = 'POSNR'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-EDIT = 'X'.
    X_FIELDCAT-OUTPUTLEN = '5'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    "{FOR DISABLE HERE 6ROW IS DISABLED
    SY-TABIX = 6.
    LS_EDIT-FIELDNAME = 'VBELN'.
    LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    LS_EDIT-STYLE2 = SPACE.
    LS_EDIT-STYLE3 = SPACE.
    LS_EDIT-STYLE4 = SPACE.
    LS_EDIT-MAXLEN = 10.
    INSERT LS_EDIT INTO TABLE LT_EDIT.
    LS_EDIT-FIELDNAME = 'POSNR'.
    LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    LS_EDIT-STYLE2 = SPACE.
    LS_EDIT-STYLE3 = SPACE.
    LS_EDIT-STYLE4 = SPACE.
    LS_EDIT-MAXLEN = 6.
    INSERT LS_EDIT INTO TABLE LT_EDIT.
    INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
    MODIFY IT_VBAP INDEX SY-TABIX FROM LS_OUTTAB  TRANSPORTING
                                      HANDLE_STYLE .
    X_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.
    "} UP TO HERE
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
      EXPORTING
        I_CALLBACK_PROGRAM = SY-REPID
        IS_LAYOUT_LVC      = X_LAYOUT
        IT_FIELDCAT_LVC    = IT_FIELDCAT
      TABLES
        T_OUTTAB           = IT_VBAP[]
      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.
    Regards
    vijay

  • How to create MRP view using BO BUS1001006 & Method CreateViews.

    Guys,
    I need to create MRP view using BO BUS1001006 & Method CreateViews.
    i am not able to unterstand, what i need to specify to create MRP view, other than material number.
    what field i need to send for MRP view.
    Regards.
    santosh.
    Edited by: santosh koraddi on Jun 23, 2010 6:14 PM

    Hi,
    I have a similar question, have done a search and I see this sort of thing has come up a few times but with no definitive answer.... this thread seems close but don't really understand the solution (I'm not an ABAPER)
    I have a material master creation workflow under construction, it uses BUS1001006 and method createviews.
    The issues is that I want to restrict creation of certain views to certain agents, I have a fork in my workflow and its meant to split up the various views for various agents.
    The problem is that if an agent in one of the forks completes their views the workflow tries to get them to completes teh other views which they do not have authoisation to do... anyway the end result is that the workflow thinks all teh views have been created and the workflow items dissappear from the others inboxes.
    How do I setup my workflow such that each agent in each fork only has to complete the views they have authorisation to maintain and leaves work items in the inboxes of other agents for them to complete?

  • ALV Tree list output using the Class and method

    Hi,
    How to get the internal table values of ALV Tree List in classes.
    My requirement is i need to store the output values in Ztable of a SAP Transaction of CK86_99.
    for this, i copied the SAP Standard Transaction into Z tcode and i am trying to poplulate the output display into Ztable. But this standard tcode CK86_99 is using the classes of ALV tree list to display output.
    CL_STRUCTURE_EXPLOSION_TREE -- Class
    CONSTRUCTOR - method
    Finally in the above mentioned method, i am able to see the output values of ALV tree list in the internal table of mt_output_table.
    But these are SAP Standard Class and method.
    My doubt is, How to get these internal table values in my Zprogram.
    is there any user exit or badi can we use in the method of class???? Actually my system is 4.6C
    Please suggest me on this problem.
    Thanks in advance
    KBS Reddy

    First your getInstance() method returns 'singleton' which you havent declared/init anywhere.
    your getAll() method needs to be static if you need to call it the way you are doing.
    In your getAll() method u are passing a parameter called patientRecord ... where have you declared/init it.
    i think you have to do something like this ... if i have understood you correctly.
    /* THIS IS IN YOUR SERVLET*/
    Collections c = database.getAll();
    out.println(C);
    /* YOUR FlatfileDatabase CLASS HAS SOMETHING LIKE THIS*/
    public static FlatfileDatabase getInstance() {
    return new FlatfileDatabase();
    public static Collections getAll() {

Maybe you are looking for

  • An issue with the computer crashing.

    My Macbook bought in 2007 recently has gone through some running issues.  Every now and then when I am running a facebook program that uses an Adobe Flash application the laptop stops running and requires a restart.  This is becoming almost a daily i

  • Add a new tab to General data in XD01

    Hi, I want to add a new tab to General data in XD01. I came across some BADI's(CUSTOMER_ADD_DATA, CUSTOMER_ADD_DATA_CS) which can be used to add pushbuttons(like General Data, Sales Area) and inside that we were able to add tabs. But i need to add a

  • I backed up my iPhoto library manually to an external hard drive. How do I restore it?

    I backed up select portions of my hard drive to an external hard drive. At the time, I didn't realize that it was going to be so hard to recover the original photos from the iPhoto library. The backup is basically just a command-line "cp" of the iPho

  • Itunes - third party creations/utilities?

    is there any third party software to help clean up your music library. I've somehow totally f'ed my up when trying to back up to a usb drive. my lib lost all of my music even though the files were still there. so i replaced the files so now my librar

  • Trial download (error 110)

    today download CS6 master collection (chinese traditional) when the download is 69% (Error 110), tried 6 times.