Sample ALV Report

Hi,
Please help me with some sample ALV reports for SAP HR.
Rgds
Preeti Saun

Hi,
See the sample report and design with HR data
report ZRGRIRNA no standard page heading
       line-count 65
       line-size 255
       message-id mm.
                   GR IR Detail Report                               *
Description          : The output has to be displayed
                       in the ALV Grid format with the Selection     *
                       screen appearing on the output. In The Output *
                       Subtotals for Vendor, Plant, Period, Material,*
                       Valuation Class, Purchase Order,Cost Center,  *
                       Cost Element and Receipt Date are displayed   *
                       after sorting the data by same fields.        *
Declaration for Tables
tables: t001,      " Company Codes
        t001w,     " Plants/Branches
        lfa1,      " Vendor Master
        ska1,      " GL Account Master
        mara,      " Material Master
        mbew,      " Material Valuation
        ekko,      " PO Header Data
        cska,      " Cost Elements
        csks,      " Cost Centers
        bsis,      " GL Accounts: Open Items Data
        bkpf.      " Accounting Doc: Header Data
Type-pools
Type pools for ALV display
type-pools : slis.
Global variables
data: g_repid       like sy-repid,
      g_exit        type c,
      g_events      type slis_t_event,
      g_list_top_of_page type slis_t_listheader,
      g_exit_caused_by_caller,
      g_exit_caused_by_user type slis_exit_by_user,
      g_top_of_page  type slis_formname value 'TOP_OF_PAGE',
      g_variant like disvariant,
      g_save.
Declaration for Constants
constants : c_x  type c  value 'X',         " Flag
            c_c  type c  value 'C',         " Flag
            c_l  type c  value 'L',         " Flag
            c_a  type c  value 'A',         " Line Type
            c_h  type c  value 'H',         " Dr/Cr
            c_s  type c  value 'S',         " Line Type
            c_mkpf(4) type c value 'MKPF'.  " Table
Declaration of Internal Tables
Internal Table for BSIS Table data
data: begin of i_bsis occurs 0,
        bukrs like bsis-bukrs,          " Company Code
        hkont like bsis-hkont,          " GR IR Account
        gjahr like bsis-gjahr,          " Fiscal Year
        belnr like bsis-belnr,          " Acc Document
        buzei like bsis-buzei,          " Item No
        budat like bsis-budat,          " Receipt Date(Posting)
        monat like bsis-monat,          " Period
      end of i_bsis.
Internal Table for BSEG Table data
data: begin of i_bseg occurs 0,
        bukrs like bsis-bukrs,          " Company Code
        belnr like bsis-belnr,          " Acc Document
        buzei like bsis-buzei,          " Item No
        gjahr like bsis-gjahr,          " Fiscal Year
        shkzg like bseg-shkzg,          " Dr/Cr Indicator
        lifnr like bseg-lifnr,          " Vendor Code
        matnr like bseg-matnr,          " Material No
        ebeln like bseg-ebeln,          " Purchase Order
        ebelp like bseg-ebelp,          " PO Item
        werks like bseg-werks,          " Plant
        menge like bseg-menge,          " PO Quantity
        meins like bseg-meins,          " UOM
        dmbtr like bseg-dmbtr,          " Amount in Local Currency
        wrbtr like bseg-wrbtr,          " Amount in Trans.Currency
      end of i_bseg.
Internal Table for BKPF Table data
data: begin of i_bkpf occurs 0,
        bukrs like bkpf-bukrs,          " Company Code
        belnr like bkpf-belnr,          " Acc Document
        gjahr like bkpf-gjahr,          " Fiscal Year
        waers like bkpf-waers,          " Trans. Currency
        awkey like bkpf-awkey,          " Object Key
        awtyp like bkpf-awtyp,          " Reference Procedure
      end of i_bkpf.
Internal Table for MSEG Table data
data: begin of i_mseg occurs 0,
        mblnr like mseg-mblnr,          " Material Document
        mjahr like mseg-mjahr,          " Fiscal Year
        bwart like mseg-bwart,          " Movement Type
        matnr like mseg-matnr,          " Material No
        menge like mseg-menge,          " PO Quantity
        meins like mseg-meins,          " UOM
      end of i_mseg.
Internal Table for MBEW Table data
data: begin of i_mbew occurs 0,
        matnr like mbew-matnr,          " Material No
        werks like mbew-bwkey,          " Plant
        bklas like mbew-bklas,          " Valuation Class
      end of i_mbew.
Internal Table for EKPO Table data
data: begin of i_ekpo occurs 0,
        ebeln like ekpo-ebeln,          " Purchase Order
        ebelp like ekpo-ebelp,          " PO Item
        matnr like ekpo-matnr,          " Material No
        txz01 like ekpo-txz01,          " Material Text
      end of i_ekpo.
Internal Table for EKKN Table data
data: begin of i_ekkn occurs 0,
        ebeln like ekkn-ebeln,          " Purchase Order
        ebelp like ekkn-ebelp,          " PO Item
        kostl like ekkn-kostl,          " Cost Center
        sakto like ekkn-sakto,          " Cost Element
      end of i_ekkn.
Internal Table for LFA1 Table data
data: begin of i_lfa1 occurs 0,
        lifnr like lfa1-lifnr,          " Vendor
        name1 like lfa1-name1,          " Name
      end of i_lfa1.
Declaration of Output Internal Table
data: begin of i_final occurs 0,
        lifnr like lfa1-lifnr,     " Vendor
        werks like bseg-werks,     " Plant
        monat like bsis-monat,     " Period
        matnr like mara-matnr,     " Material Number
        bklas like mbew-bklas,     " Val Class
        ebeln like bseg-ebeln,     " PO
        kostl like ekkn-kostl,     " Cost Center
        sakto like ekkn-sakto,     " Cost Element
        budat like bsis-budat,     " Rec. Date
        name1 like lfa1-name1,     " Vendor Name
        belnr like bsis-belnr,     " FI Document
        bwart like mseg-bwart,     " Movement Type
        txz01 like ekpo-txz01,     " Material Text
        menge like bseg-menge,     " Quantity
        meins like bseg-meins,     " UOM
        dmbtr like bseg-dmbtr,     " Local Amount
        wrbtr like bseg-wrbtr,     " Tran.Amount
        waers like bkpf-waers,     " Tran.Currency
        status type c,             " Material Status
      end of i_final.
Internal table to hold field catgory data
data:  i_fldcat  type slis_t_fieldcat_alv.   " Table - field catgory
Internal table to hold Sort/Subtotals criteria data
data:  i_sort  type slis_t_sortinfo_alv.     " Table - sort/Subtotals
Structure
data:  x_layout   type slis_layout_alv,      " Structure-layout
       x_fldcat   like line of i_fldcat,     " Structure-field catagory
       x_sort     like line of i_sort.       " Structure-Sort/Subtotals
       Selection screen
selection-screen : begin of block b1 with frame title text-000.
parameters:
   p_bukrs like t001-bukrs obligatory,          " Company Code
   p_grira like ska1-saknr default '0241101000' obligatory. " Account
select-options:
   s_budat for bkpf-budat,        " Posting Date
   s_werks for t001w-werks,       " Plant
   s_lifnr for lfa1-lifnr,        " Vendor
   s_matnr for mara-matnr,        " Material Number
   s_kostl for csks-kostl,        " Cost Center
   s_kstar for cska-kstar,        " Cost Element
   s_ebeln for ekko-ebeln,        " Purchase Order
   s_monat for bsis-monat.        " Period
selection-screen skip.
parameters:
   p_incmt as checkbox default 'X',
   p_incnm as checkbox default 'X'.
selection-screen end of block b1.
Initialization
initialization.
  g_repid = sy-repid.
  perform layout_init using x_layout.
  perform eventtab_build using g_events[].
  g_variant-report = g_repid.
  g_save           = 'A'.
At selection screen
at selection-screen.
Validation of Selection Screen Fields
  perform validate_screen.
Start of selection
start-of-selection.
Read Data from Database Tables
  perform read_data.
End of selection
end-of-selection.
Build layout report layout.
  perform populate_layout_stucture.
Perform build_field_catalog and Sort Table
  perform build_field_catalog.
  perform build_sort_totals.
List Header for Top-Of-Page
  perform comment_build using g_list_top_of_page[].
Call list viewer function module
  perform call_list_viewer .
****************Form - Routines**************************************
      Form        : layout_init
      Description : Form to Build layout for list display
form layout_init using rs_layout type slis_layout_alv.
  rs_layout-detail_popup      = c_x.
endform.
Form         : Eventtab_build
Description  : Registration of events to happen during list display
form eventtab_build using rt_events type slis_t_event.
Registration of events to happen during list display
  data: ls_event type slis_alv_event.
  call function 'REUSE_ALV_EVENTS_GET'
       exporting
            i_list_type = 0
       importing
            et_events   = rt_events.
  read table rt_events with key name = slis_ev_top_of_page
                           into ls_event.
  if sy-subrc = 0.
    move g_top_of_page to ls_event-form.
    append ls_event to rt_events.
  endif.
endform.                                   "eventtab_build
      Form : top_of_page
form top_of_page.
  call function 'REUSE_ALV_COMMENTARY_WRITE'
       exporting
         I_LOGO             = 'ENJOYSAP_LOGO'
            it_list_commentary = g_list_top_of_page.
endform.
      Form validate_screen
Validation of Selection Screen fields
form validate_screen.
Validation of Company Code
  clear t001.
  if not p_bukrs is initial.
    select single bukrs
      into t001-bukrs
      from t001
      where bukrs eq p_bukrs.
    if sy-subrc <> 0.
      message e899 with 'Enter Valid Company Code'(012).
    endif.
  endif.
Validation of GL Account (GR/IR)
  clear ska1.
  if not p_grira is initial.
    select saknr
      into ska1-saknr
      from ska1
      up to 1 rows
      where saknr eq p_grira.
    endselect.
    if sy-subrc <> 0.
      message e899 with 'Enter Valid GR/IR Account'(013).
    endif.
  endif.
Validation of Vendor Code
  clear lfa1.
  if not s_lifnr[] is initial.
    select single lifnr
      into lfa1-lifnr
      from lfa1
      where lifnr in s_lifnr.
    if sy-subrc <> 0.
      message e899 with 'Enter Valid Vendor'(001).
    endif.
  endif.
Validation of Plant Code
  clear t001w.
  if not s_werks[] is initial.
    select single werks
      into t001w-werks
      from t001w
      where werks in s_werks.
    if sy-subrc <> 0.
      message e899 with 'Enter Valid Plant'(014).
    endif.
  endif.
Validation of Material Code
  clear mara.
  if not s_matnr[] is initial.
    select single matnr
      into mara-matnr
      from mara
      where matnr in s_matnr.
    if sy-subrc <> 0.
      message e899 with 'Enter Valid Material'(015).
    endif.
  endif.
Validation of Purchase Order
  clear ekko.
  if not s_ebeln[] is initial.
    select single ebeln
      into ekko-ebeln
      from ekko
      where ebeln in s_ebeln.
    if sy-subrc <> 0.
      message e899 with 'Enter Valid Purchase Order'(016).
    endif.
  endif.
Validation of Cost Center
  clear csks.
  if not s_kostl[] is initial.
    select kostl
      into csks-kostl
      from csks
      up to 1 rows
      where kostl in s_kostl.
    endselect.
    if sy-subrc <> 0.
      message e899 with 'Enter Valid Cost Center'(017).
    endif.
  endif.
Validation of Cost Element
  clear cska.
  if not s_kstar[] is initial.
    select kstar
      into cska-kstar
      from cska
      up to 1 rows
      where kstar in s_kstar.
    endselect.
    if sy-subrc <> 0.
      message e899 with 'Enter Valid Cost Element'(018).
    endif.
  endif.
endform.                          "validate_screen
*&      Form  read_data
Read the Data from the database Tables
form read_data.
Get the Accounting Documents for the GR/IR Account Entered on
Selection Screen
  clear i_bsis.
  refresh i_bsis.
  select bukrs           " Company Code
         hkont           " GR IR Account
         gjahr           " Fiscal Year
         belnr           " Acc Document
         buzei           " Item No
         budat           " Receipt Date(Posting)
         monat           " Period
   into table i_bsis
   from  bsis
   where  bukrs = p_bukrs
     and  hkont = p_grira
     and  budat in s_budat
     and  monat in s_monat .
  if sy-subrc <> 0.
    message i899 with 'No data found'(043).
    g_exit = c_x.
    stop.
  endif.
  sort i_bsis by bukrs hkont gjahr belnr buzei.
Get the Vendor,PO,Material,Qty details from BSEG Table
  if not i_bsis[] is initial.
    clear i_bseg.
    refresh i_bseg.
    select bukrs           " Company Code
           belnr           " Acc Document
           buzei           " Item No
           gjahr           " Fiscal Year
           shkzg           " Dr/Cr Indicator
           lifnr           " Vendor Code
           matnr           " Material No
           ebeln           " Purchase Order
           ebelp           " PO Item
           werks           " Plant
           menge           " PO Quantity
           meins           " UOM
           dmbtr           " Amount in Local Currency
           wrbtr           " Amount in Trans.Currency
    into table i_bseg
    from   bseg
    for all entries in i_bsis
    where  bukrs = p_bukrs
    and    belnr = i_bsis-belnr
    and    gjahr = i_bsis-gjahr
    and    buzei = i_bsis-buzei
    and    lifnr in s_lifnr
    and    werks in s_werks
    and    matnr in s_matnr
    and    ebeln in s_ebeln.
    sort i_bseg by bukrs belnr buzei gjahr.
Select the Trans.Currency from BKPF Table
    clear i_bkpf.
    refresh i_bkpf.
    select bukrs           " Company Code
           belnr           " Acc Document
           gjahr           " Fiscal Year
           waers           " Trans. Currency
           awkey           " Object Key
           awtyp           " Reference Procedure
    into table i_bkpf
    from   bkpf
    for all entries in i_bsis
    where  bukrs = p_bukrs
    and    belnr = i_bsis-belnr
    and    gjahr = i_bsis-gjahr.
  endif.
  sort i_bkpf by bukrs belnr gjahr.
Get the Quantity and UOM of Material from MSEG Table
  if not i_bkpf[] is initial.
    clear i_mseg.
    refresh i_mseg.
    select mblnr           " Material Document
           mjahr           " Fiscal Year
           bwart           " Movement Type
           matnr           " Material No
           menge           " PO Quantity
           meins           " UOM
      into table i_mseg
      from   mseg
      for all entries in i_bkpf
      where  mblnr = i_bkpf-awkey(10).
  endif.
  sort i_mseg by mblnr mjahr.
Get the Material And Description from EKPO Table
  if not i_bseg[] is initial.
    clear i_ekpo.
    refresh i_ekpo.
    select ebeln           " Purchase Order
           ebelp           " PO Item
           matnr           " Material No
           txz01           " Material Text
    into table i_ekpo
    from   ekpo
    for all entries in i_bseg
    where  ebeln = i_bseg-ebeln
    and    ebelp = i_bseg-ebelp.
    sort i_ekpo by ebeln ebelp.
Get the Valuation Class from MBEW Table
    clear i_mbew.
    refresh i_mbew.
    select matnr           " Material No
           bwkey           " Plant
           bklas           " Valuation Class
    into table i_mbew
    from   mbew
    for all entries in i_bseg
    where  matnr = i_bseg-matnr
    and    bwkey = i_bseg-werks.
    sort i_mbew by matnr werks.
Get the Cost Center and Cost Element of the PO from EKKN Table
    clear i_ekkn.
    refresh i_ekkn.
    select ebeln           " Purchase Order
           ebelp           " PO Item
           kostl           " Cost Center
           sakto           " Cost Element
    into table i_ekkn
    from   ekkn
    for all entries in i_bseg
    where  ebeln = i_bseg-ebeln
    and    ebelp = i_bseg-ebelp
    and    kostl in s_kostl
    and    sakto in s_kstar.
    sort i_ekkn by ebeln ebelp.
Get the Vendor Name
    clear i_lfa1.
    refresh i_lfa1.
    select lifnr            " Vendor
           name1            " Name
    into table i_lfa1
    from   lfa1
    for all entries in i_bseg
    where  lifnr = i_bseg-lifnr.
  endif.
  sort i_lfa1 by lifnr.
Move the data to Final Output Internal Table
  loop at i_bsis.
    i_final-belnr = i_bsis-belnr.     " FI Document
    i_final-monat = i_bsis-monat.     " Period
    i_final-budat = i_bsis-budat.     " Rec. Date
Read the Transaction Currency from BKPF Internal Table
    read table i_bkpf with key bukrs = i_bsis-bukrs
                               belnr = i_bsis-belnr
                               gjahr = i_bsis-gjahr
                               binary search.
    if sy-subrc = 0.
      i_final-waers = i_bkpf-waers.     " Tran.Currency
Read the Movement Type for all Material Related
Documents from MSEG Internal Table
      if i_bkpf-awtyp = c_mkpf.
        read table i_mseg with key mblnr = i_bkpf-awkey(10)
                                   mjahr = i_bkpf-awkey+10(4).
        if sy-subrc = 0.
          i_final-bwart = i_mseg-bwart.     " Movement Type
        endif.
      endif.
    endif.
Read Vendor, Plant, PO Document, Local And Trans.Amounts
from BSEG Internal Table
    read table i_bseg with key bukrs = i_bsis-bukrs
                               belnr = i_bsis-belnr
                               gjahr = i_bsis-gjahr
                               buzei = i_bsis-buzei
                               binary search.
    if sy-subrc = 0.
      i_final-lifnr = i_bseg-lifnr.     " Vendor
      i_final-werks = i_bseg-werks.     " Plant
      i_final-ebeln = i_bseg-ebeln.     " PO
      i_final-dmbtr = i_bseg-dmbtr.     " Local Amount
      i_final-wrbtr = i_bseg-wrbtr.     " Tran.Amount
      i_final-menge = i_bseg-menge.     " Quantity
      i_final-meins = i_bseg-meins.     " UOM
For Credit Indicator(SHKZG = H) amounts should be (-)ve
      if i_bseg-shkzg = c_h.
        i_final-dmbtr = i_final-dmbtr * -1.
        i_final-wrbtr = i_final-wrbtr * -1.
        i_final-menge = i_final-menge * -1.
      endif.
Read the Material and its Description from EKPO Internal Table
      read table i_ekpo with key ebeln = i_bseg-ebeln
                                 ebelp = i_bseg-ebelp
                                 matnr = i_bseg-matnr
                                 binary search.
      if sy-subrc = 0.
        i_final-matnr = i_ekpo-matnr.     " Material Number
        i_final-txz01 = i_ekpo-txz01.     " Material Text
Populate the Material Status depending on the Input Checkbox
On Selection Screen
        if not i_ekpo-matnr is initial.
          i_final-status = c_x.
        endif.
      endif.
Read the PO related Cost Element and Cost Centers
from EKKN Internal Table
      read table i_ekkn with key ebeln = i_bseg-ebeln
                                 ebelp = i_bseg-ebelp
                                 binary search.
      if sy-subrc = 0.
        i_final-kostl = i_ekkn-kostl.     " Cost Center
        i_final-sakto = i_ekkn-sakto.     " Cost Element
      endif.
Read the Valuation Class from MBEW Internal Table
      read table i_mbew with key matnr = i_bseg-matnr
                                 werks = i_bseg-werks
                                 binary search.
      if sy-subrc = 0.
        i_final-bklas = i_mbew-bklas.     " Val Class
      endif.
Read the Vendor Name from LFA1 Internal Table
      read table i_lfa1 with key lifnr = i_bseg-lifnr
                                 binary search.
      if sy-subrc = 0.
        i_final-name1 = i_lfa1-name1.     " Vendor Name
      endif.
    endif.
    append i_final.
    clear i_final.
  endloop.
  sort i_final by lifnr werks monat matnr.
Depending on the check Box Selected display the data
  if p_incmt = c_x and p_incnm ne c_x.
    delete i_final where matnr eq space.
  elseif p_incnm = c_x and p_incmt ne c_x.
    delete i_final where matnr ne space.
  endif.
endform.           "Read Data
     Form        : populate_layout_stucture
     Description : Populating the layout structure
form populate_layout_stucture.
  clear x_layout .
Layout properties
  x_layout-zebra                = c_x.
  x_layout-detail_popup         = c_x.
  x_layout-detail_initial_lines = c_x.
  x_layout-colwidth_optimize    = c_x.
endform.                    " populate_layout_stucture
     Form        : build_field_catalog
     Description : Building the field catalog data
form build_field_catalog.
  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
       exporting
            i_program_name         = g_repid
            i_internal_tabname     = 'I_FINAL'
            i_inclname             = g_repid
       changing
            ct_fieldcat            = i_fldcat
       exceptions
            inconsistent_interface = 1
            program_error          = 2
            others                 = 3.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.
Getting the Header text for the coloums
  loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or
                                       fieldname = 'NAME1' or
                                       fieldname = 'WERKS' or
                                       fieldname = 'MONAT' or
                                       fieldname = 'MATNR' or
                                       fieldname = 'BKLAS' or
                                       fieldname = 'EBELN' or
                                       fieldname = 'KOSTL' or
                                       fieldname = 'SAKTO' or
                                       fieldname = 'BUDAT' or
                                       fieldname = 'BELNR' or
                                       fieldname = 'BWART' or
                                       fieldname = 'TXZ01' or
                                       fieldname = 'MENGE' or
                                       fieldname = 'MEINS' or
                                       fieldname = 'DMBTR' or
                                       fieldname = 'WRBTR' or
                                       fieldname = 'WAERS' or
                                       fieldname = 'STATUS'.
    if x_fldcat-fieldname = 'LIFNR'.
      x_fldcat-seltext_l   = 'Vendor'(003).
      x_fldcat-seltext_m   = 'Vendor'(003).
      x_fldcat-seltext_s   = 'Vendor'(003).
      x_fldcat-reptext_ddic = 'Vendor'(003).
      x_fldcat-inttype   = c_c.
    endif.
    if x_fldcat-fieldname = 'NAME1'.
      x_fldcat-seltext_l   = 'Vendor Name'(002).
      x_fldcat-seltext_m   = 'Vendor Name'(002).
      x_fldcat-seltext_s   = 'Vendor Name'(002).
      x_fldcat-reptext_ddic = 'Vendor Name'(002).
      x_fldcat-inttype   = c_c.
    endif.
    if x_fldcat-fieldname = 'WERKS'.
      x_fldcat-seltext_l   = 'Plant'(010).
      x_fldcat-seltext_m   = 'Plant'(010).
      x_fldcat-seltext_s   = 'Plant'(010).
      x_fldcat-reptext_ddic   = 'Plant'(010).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'MONAT'.
      x_fldcat-seltext_l   = 'Period'(011).
      x_fldcat-seltext_m   = 'Period'(011).
      x_fldcat-seltext_s   = 'Period'(011).
      x_fldcat-reptext_ddic   = 'Period'(011).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'MATNR'.
      x_fldcat-seltext_l   = 'Material'(004).
      x_fldcat-seltext_m   = 'Material'(004).
      x_fldcat-seltext_s   = 'Material'(004).
      x_fldcat-reptext_ddic   = 'Material'(004).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'BKLAS'.
      x_fldcat-seltext_l   = 'Valuation Class'(009).
      x_fldcat-seltext_m   = 'Valuation Class'(009).
      x_fldcat-seltext_s   = 'Valuation Class'(009).
      x_fldcat-reptext_ddic   = 'Valuation Class'(009).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'EBELN'.
      x_fldcat-seltext_l   = 'Purchase Order'(005).
      x_fldcat-seltext_m   = 'Purchase Order'(005).
      x_fldcat-seltext_s   = 'Purchase Order'(005).
      x_fldcat-reptext_ddic   = 'Purchase Order'(005).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'KOSTL'.
      x_fldcat-seltext_l   = 'Cost Center'(006).
      x_fldcat-seltext_m   = 'Cost Center'(006).
      x_fldcat-seltext_s   = 'Cost Center'(006).
      x_fldcat-reptext_ddic   = 'Cost Center'(006).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'SAKTO'.
      x_fldcat-seltext_l   = 'Cost Element'(007).
      x_fldcat-seltext_m   = 'Cost Element'(007).
      x_fldcat-seltext_s   = 'Cost Element'(007).
      x_fldcat-reptext_ddic   = 'Cost Element'(007).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'BUDAT'.
      x_fldcat-seltext_l   = 'Receipt Date'(008).
      x_fldcat-seltext_m   = 'Receipt Date'(008).
      x_fldcat-seltext_s   = 'Receipt Date'(008).
      x_fldcat-reptext_ddic   = 'Receipt Date'(008).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'BELNR'.
      x_fldcat-seltext_l   = 'Acc.Document'(100).
      x_fldcat-seltext_m   = 'Acc.Document'(100).
      x_fldcat-seltext_s   = 'Acc.Document'(100).
      x_fldcat-reptext_ddic   = 'Acc.Document'(100).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'BWART'.
      x_fldcat-seltext_l   = 'Movement Type'(101).
      x_fldcat-seltext_m   = 'Movement Type'(101).
      x_fldcat-seltext_s   = 'Movement Type'(101).
      x_fldcat-reptext_ddic   = 'Movement Type'(101).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'TXZ01'.
      x_fldcat-seltext_l   = 'Material Text'(102).
      x_fldcat-seltext_m   = 'Material Text'(102).
      x_fldcat-seltext_s   = 'Material Text'(102).
      x_fldcat-reptext_ddic   = 'Material Text'(102).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'MENGE'.
      x_fldcat-seltext_l   = 'Quantity'(103).
      x_fldcat-seltext_m   = 'Quantity'(103).
      x_fldcat-seltext_s   = 'Quantity'(103).
      x_fldcat-reptext_ddic   = 'Quantity'(103).
      x_fldcat-ddictxt   = c_l.
      x_fldcat-do_sum    = c_x.
    endif.
    if x_fldcat-fieldname = 'MEINS'.
      x_fldcat-seltext_l   = 'UOM'(104).
      x_fldcat-seltext_m   = 'UOM'(104).
      x_fldcat-seltext_s   = 'UOM'(104).
      x_fldcat-reptext_ddic   = 'UOM'(104).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'DMBTR'.
      x_fldcat-seltext_l   = 'Amount in Local Curr'(105).
      x_fldcat-seltext_m   = 'Amount in Local Curr'(105).
      x_fldcat-seltext_s   = 'Amount in Local Curr'(105).
      x_fldcat-reptext_ddic   = 'Amount in Local Curr'(105).
      x_fldcat-ddictxt   = c_l.
      x_fldcat-do_sum    = c_x.
    endif.
    if x_fldcat-fieldname = 'WRBTR'.
      x_fldcat-seltext_l   = 'Amount in Trans.Curr'(106).
      x_fldcat-seltext_m   = 'Amount in Trans.Curr'(106).
      x_fldcat-seltext_s   = 'Amount in Trans.Curr'(106).
      x_fldcat-reptext_ddic   = 'Amount in Trans.Curr'(106).
      x_fldcat-ddictxt   = c_l.
      x_fldcat-do_sum    = c_x.
    endif.
    if x_fldcat-fieldname = 'WAERS'.
      x_fldcat-seltext_l   = 'Trans.Currency'(107).
      x_fldcat-seltext_m   = 'Trans.Currency'(107).
      x_fldcat-seltext_s   = 'Trans.Currency'(107).
      x_fldcat-reptext_ddic   = 'Trans.Currency'(107).
      x_fldcat-ddictxt   = c_l.
    endif.
    if x_fldcat-fieldname = 'STATUS'.
      x_fldcat-seltext_l   = 'Material Status'(019).
      x_fldcat-seltext_m   = 'Material Status'(019).
      x_fldcat-seltext_s   = 'Material Status'(019).
      x_fldcat-reptext_ddic   = 'Material Status'(019).
      x_fldcat-ddictxt   = c_l.
    endif.
    modify i_fldcat from x_fldcat index sy-tabix.
  endloop.
endform.                    " build_field_catalog
     Form        : build_sort_totals
     Description : Building the Criteria for Sort/Subtotals
form build_sort_totals.
  x_sort-fieldname = 'LIFNR'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  1.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
  x_sort-fieldname = 'WERKS'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  2.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
  x_sort-fieldname = 'MONAT'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  3.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
  x_sort-fieldname = 'MATNR'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  4.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
  x_sort-fieldname = 'BKLAS'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  5.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
  x_sort-fieldname = 'EBELN'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  6.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
  x_sort-fieldname = 'KOSTL'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  7.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
  x_sort-fieldname = 'SAKTO'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  8.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
  x_sort-fieldname = 'BUDAT'.
  x_sort-tabname   = 'I_FINAL'.
  x_sort-spos      =  9.
  x_sort-up        =  c_x.
  x_sort-subtot    = c_x.
  append x_sort to i_sort.
  clear  x_sort.
endform.                    " build_sort_totals
  Form        : comment_build
  Description : This form is used to display the Report Header(ALV)
form comment_build using lt_top_of_page type
                                        slis_t_listheader.
  data: l_line type slis_listheader,
        l_heading1 like rs38m-repti,
        l_date(10), l_time(8).
  clear l_line.
  l_heading1 = 'GR/IR DETAIL REPORT'(021).
  g_repid = sy-repid.
  write sy-uzeit to l_time.
  write sy-datum to l_date.
  l_line-typ = c_h.
  move l_heading1 to l_line-info.
  append l_line to lt_top_of_page.
  clear l_line.
  l_line-typ  = c_s.
  concatenate 'System:'(023) sy-sysid
              'Date:'(024) l_date
              ' Time:'(025)
              l_time into l_line-info.
  append l_line to lt_top_of_page.
  concatenate 'Report:'(026) g_repid
              ' User:'(027) sy-uname into
              l_line-info.
  append l_line to lt_top_of_page.
  l_line-typ = c_a.
  move 'SELECTION CRITERIA:'(028) to l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Company Code : '(029)
              p_bukrs into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' GR/IR Account: '(030)
              p_grira into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Posting Date : '(032) s_budat-low
              ' To: '(031) s_budat-high into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Plant : '(033) s_werks-low
              ' To: '(031) s_werks-high into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Vendor: '(034) s_lifnr-low
              ' To: '(031) s_lifnr-high into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Material: '(035) s_matnr-low
              ' To: '(031) s_matnr-high into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Cost Center : '(036) s_kostl-low
              ' To: '(031) s_kostl-high into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Cost Element: '(037) s_kstar-low
              ' To: '(031) s_kstar-high into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Purchase Order: '(038) s_ebeln-low
              ' To: '(031) s_ebeln-high into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Period : '(039) s_monat-low
              ' To: '(031) s_monat-high into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Include Material Items: '(040)
              p_incmt into l_line-info.
  append l_line to lt_top_of_page.
  concatenate ' Include Non-Material Items: '(041)
              p_incnm into l_line-info.
  append l_line to lt_top_of_page.
endform.
     Form        : call_list_viewer
     Description : This form is used to display the grid through ALV
form call_list_viewer.
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = g_repid
            is_layout               = x_layout
            it_fieldcat             = i_fldcat[]
            i_default               = c_x
            it_sort                 = i_sort[]
            i_save                  = g_save
            is_variant              = g_variant
            it_events               = g_events[]
       importing
            e_exit_caused_by_caller = g_exit_caused_by_caller
            es_exit_caused_by_user  = g_exit_caused_by_user
       tables
            t_outtab                = i_final
       exceptions
            program_error           = 1
            others                  = 2.
  if sy-subrc <> 0.
    write: / 'Problem in calling the ALV report'(042).
  endif.
endform.                    " call_list_viewer
reward if useful
regards,
Anji

Similar Messages

  • Sample ALV report required for FI module

    Hello friends,
    I am develoing ALV report for FI module for that i need some sample ALV report. If someone have than please send it to me.
    Thanx & Regards,
    Rahul Talele

    HI,
    SEE THE SAMPLE REPORT
                 Fringe Benefit Tax Report
    Program Name            :
    Object ID               :
    Functional Analyst      :
    Programmer              :
    Start date              :
    Initial CTS             :
    Description             : FRINGE Benefit Tax
    Includes                :
    Function Modules        :
    Logical database        :
    Transaction Code        :
    External references     :
                       Modification Log
    Date      | Modified by    | CTS number   | Comments
              |                |              | Initial Version          *
    REPORT  ZFI_FBT NO STANDARD PAGE HEADING LINE-SIZE 255.
    TYPE-POOLS: SLIS.
    TYPES : BEGIN OF
      T_BSIS,
              BUKRS TYPE BUKRS,         " Company Code
              HKONT TYPE HKONT,         " General Ledger Account
              GJAHR TYPE GJAHR,
              BELNR TYPE BELNR_D,       " Accounting Document Number
              BUDAT TYPE BUDAT,         " Posting Date in the Document
              BLDAT TYPE BLDAT,         " Document Date in Document
              XBLNR TYPE XBLNR1,        " Reference Document Number
              BSCHL TYPE BSCHL,         " Posting Key
              DMBTR TYPE DMBTR,         " Amount in Local Currency
              AUFNR TYPE AUFNR_NEU,     " Order Number
              NONFBT TYPE DMBTR,        " non fbt amount
              SUBFBT TYPE DMBTR,        " subject to fbt amount
              ZFI_FBT TYPE ZFI_FBT,     " Qualifying amount.
              AMOUNT TYPE DMBTR,
              FBTPAY TYPE DMBTR,
              ZFI_PAY TYPE ZFI_PAY,
            END OF T_BSIS,
            T_IT_BSIS TYPE STANDARD TABLE OF T_BSIS.
    TYPES : BEGIN OF T_FRINGE,
               ZFI_HKONT TYPE HKONT,
               ZFI_FBT TYPE ZFI_FBT,
               ZFI_PAY TYPE ZFI_PAY,
            END OF T_FRINGE,
            T_IT_FRINGE TYPE STANDARD TABLE OF T_FRINGE.
    DATA  : GIT_FRINGE TYPE T_IT_FRINGE,
            GWA_FRINGE TYPE T_FRINGE.
    DATA  : GIT_BSIS TYPE T_IT_BSIS,
            GWA_BSIS TYPE T_BSIS.
    DATA  : G_HKONT TYPE HKONT,
            G_BUDAT TYPE BUDAT,
            G_AUFNR TYPE AUFNR_NEU.
    FIELD-SYMBOLS : <BSIS> TYPE T_BSIS.
    DATA : G_REPID TYPE SY-REPID,
           GIT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
           GWA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
           GT_SORT TYPE SLIS_T_SORTINFO_ALV,
           GT_EVENTS TYPE SLIS_T_EVENT,
           GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
           GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
    GS_LAYOUT-ZEBRA = 'X'.
    GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    CONSTANTS : C_50(2) TYPE C VALUE '50'.
      SELECTION SCREEN DEFINITIONS
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS     : P_BUKRS TYPE BUKRS DEFAULT 'H901' OBLIGATORY.
    SELECT-OPTIONS : S_HKONT FOR G_HKONT,
                     S_BUDAT FOR G_BUDAT.
    *PARAMETERS     : P_AUFNR TYPE AUFNR_NEU DEFAULT '000000100001' OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
      EVENTS
      INITIALIZATION.
    INITIALIZATION.
      G_REPID = SY-REPID.
      AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      PERFORM GET_ZTABLE.         " get data from ZFII_FRINGE table
      START-OF-SELECTION.
    START-OF-SELECTION.
      PERFORM GET_DATA.           "  get data from BSIS table
      IF NOT GIT_BSIS IS INITIAL.
        PERFORM GET_PERCENTAGE.   " to get the percentages from table ZFII_FRINGE
        PERFORM CHK4_INTERNAL.    " checking for the posting key wheather th document is reversed
        " and checking wheather internal order is FBT or non-FBT
      ENDIF.
      END-OF-SELECTION.
    END-OF-SELECTION.
      IF NOT GIT_BSIS IS INITIAL.
        PERFORM DISPLAY.        " display ALV GRID display
      ENDIF.
    *&      Form  get_data
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DATA .
      SELECT
             BUKRS
             HKONT
             GJAHR
             BELNR
             BUDAT
             BLDAT
             XBLNR
             BSCHL
             DMBTR
             AUFNR FROM BSIS
                   INTO TABLE GIT_BSIS
                   WHERE BUKRS EQ P_BUKRS AND
                         HKONT IN S_HKONT AND
                         BUDAT IN S_BUDAT.
      IF SY-SUBRC NE 0.
        MESSAGE I000(ZFI) WITH 'No data exist'.
        EXIT.
      ENDIF.
    ENDFORM.                    " get_data
    *&      Form  display
    FORM DISPLAY .
      PERFORM BUILD_FIELD_CATALOUGE.
      PERFORM GET_EVENTS.
      PERFORM DETERMINE_SORT_SEQUENCE.
      PERFORM SUB_COMMENTERY_BUILD.
      PERFORM ALV_DISPLAY.
    ENDFORM.                    " display
    *&      Form  build_field_catalouge
    FORM BUILD_FIELD_CATALOUGE.
      DATA : L_POS TYPE I.
      L_POS = 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'HKONT'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '10'            " Output Length
                                       'GL Account'  " Column Name Text
                                       ' '             " Datatype
                                       'X'             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       ' '.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'BELNR'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '10'            " Output Length
                                       'Document No.'  " Column Name Text
                                       ' '             " Datatype
                                       'X'             " Key?
                                       '1'             " Row Position
                                       'X'             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       ' '.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'BUDAT'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '10'             " Output Length
                                       'Posting Date'             " Column Name Text
                                       ' '             " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       ' '.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'BLDAT'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '10'             " Output Length
                                       'Docu. Date'             " Column Name Text
                                       ' '             " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       ' '.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'XBLNR'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '16'             " Output Length
                                       'Ref. Doc. Number'             " Column Name Text
                                       ' '             " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       'X'.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'DMBTR'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '16'             " Output Length
                                       'Gross Amount'             " Column Name Text
                                       ' '             " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       'X'.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'SUBFBT'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '16'             " Output Length
                                       'FBT Amount'             " Column Name Text
                                       ' '             " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       'X'.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'NONFBT'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '16'             " Output Length
                                       'Non FBT Amount'             " Column Name Text
                                       ' '             " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       'X'.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'ZFI_FBT'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '12'            " Output Length
                                       'Percentage'    " Column Name Text
                                       ' '              " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       ' '.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'AMOUNT'        " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '16'            " Output Length
                                       'Qualifying Amount'  " Column Name Text
                                       ' '             " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       'X'.            " Sum field?
      L_POS = L_POS + 1 .
      PERFORM INIT_FIELD_CATALOG USING GIT_FIELDCAT[]  " Field Catalog
                                        L_POS          " Column Position
                                       'FBTPAY'         " InTab Field Name
                                       'GIT_BSIS'      " InTab Name
                                       '12'            " Output Length
                                       'FBT payable'   " Column Name Text
                                       ' '             " Datatype
                                       ' '             " Key?
                                       '1'             " Row Position
                                       ' '             " Hotspot
                                       ' '             " Emphasize
                                       ' '             " key_sel
                                       ' '             " justification
                                       'X'.            " Sum field?
    ENDFORM.                    " build_field_catalouge
    *&      Form  init_field_catalog
          text
    FORM INIT_FIELD_CATALOG  USING    P_GIT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV
                                      PV_POS       LIKE GWA_FIELDCAT-COL_POS
                                      PV_FIELDNAME LIKE GWA_FIELDCAT-FIELDNAME
                                      PV_TABNAME   LIKE GWA_FIELDCAT-TABNAME
                                      PV_OUTPUT    LIKE GWA_FIELDCAT-OUTPUTLEN
                                      PV_SELTEXT   LIKE GWA_FIELDCAT-SELTEXT_M
                                      PV_DATATYPE  LIKE GWA_FIELDCAT-DATATYPE
                                      PV_KEY       LIKE GWA_FIELDCAT-KEY
                                      PV_ROW       LIKE GWA_FIELDCAT-ROW_POS
                                      PV_HOTSPOT   LIKE GWA_FIELDCAT-HOTSPOT
                                      PV_EMPHASIZE LIKE GWA_FIELDCAT-EMPHASIZE
                                      PV_KEY_SEL   LIKE GWA_FIELDCAT-KEY_SEL
                                      PV_JUST      LIKE GWA_FIELDCAT-JUST
                                      PV_SUM       LIKE GWA_FIELDCAT-DO_SUM.
      DATA:  LT_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
      LT_FIELDCAT-OUTPUTLEN     = PV_OUTPUT.
      LT_FIELDCAT-COL_POS       = PV_POS.
      LT_FIELDCAT-FIELDNAME     = PV_FIELDNAME.
      LT_FIELDCAT-TABNAME       = PV_TABNAME.
      LT_FIELDCAT-SELTEXT_M     = PV_SELTEXT.
      LT_FIELDCAT-KEY           = PV_KEY.
      LT_FIELDCAT-ROW_POS       = PV_ROW.
      LT_FIELDCAT-HOTSPOT       = PV_HOTSPOT.
      LT_FIELDCAT-EMPHASIZE     = PV_EMPHASIZE.
      LT_FIELDCAT-KEY_SEL       = PV_KEY_SEL.
      LT_FIELDCAT-DO_SUM        = PV_SUM.
      LT_FIELDCAT-JUST          = PV_JUST.
      LT_FIELDCAT-DATATYPE      = PV_DATATYPE.
      APPEND LT_FIELDCAT TO  P_GIT_FIELDCAT.
      CLEAR  LT_FIELDCAT.
    ENDFORM.                    " init_field_catalog
    *&      Form  alv_display
          text
    -->  p1        text
    <--  p2        text
    FORM ALV_DISPLAY .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
        I_INTERFACE_CHECK                 = ' '
        I_BYPASSING_BUFFER                = ' '
        I_BUFFER_ACTIVE                   = ' '
          I_CALLBACK_PROGRAM                = G_REPID
         I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
         I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
        I_CALLBACK_TOP_OF_PAGE            = ' '
        I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
        I_CALLBACK_HTML_END_OF_LIST       = ' '
        I_STRUCTURE_NAME                  =
        I_BACKGROUND_ID                   = ' '
        i_grid_title                      = 'Fringe Benefit Tax'
        I_GRID_SETTINGS                   =
         IS_LAYOUT                         = GS_LAYOUT
          IT_FIELDCAT                       = GIT_FIELDCAT
        IT_EXCLUDING                      =
        IT_SPECIAL_GROUPS                 =
         IT_SORT                           = GT_SORT
        IT_FILTER                         =
        IS_SEL_HIDE                       =
        I_DEFAULT                         = 'X'
        I_SAVE                            = ' '
        IS_VARIANT                        =
         IT_EVENTS                         = GT_EVENTS[]
        IT_EVENT_EXIT                     =
        IS_PRINT                          =
        IS_REPREP_ID                      =
        I_SCREEN_START_COLUMN             = 0
        I_SCREEN_START_LINE               = 0
        I_SCREEN_END_COLUMN               = 0
        I_SCREEN_END_LINE                 = 0
        I_HTML_HEIGHT_TOP                 = 0
        I_HTML_HEIGHT_END                 = 0
        IT_ALV_GRAPHICS                   =
        IT_HYPERLINK                      =
        IT_ADD_FIELDCAT                   =
        IT_EXCEPT_QINFO                   =
        IR_SALV_FULLSCREEN_ADAPTER        =
      IMPORTING
        E_EXIT_CAUSED_BY_CALLER           =
        ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = GIT_BSIS
       EXCEPTIONS
         PROGRAM_ERROR                     = 1
         OTHERS                            = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " alv_display
    *&      Form  chk4_internal
          text
    -->  p1        text
    <--  p2        text
    FORM CHK4_INTERNAL .
      LOOP AT GIT_BSIS ASSIGNING <BSIS>.
        IF <BSIS> IS ASSIGNED.
          IF  <BSIS>-BSCHL = C_50.
            <BSIS>-DMBTR = <BSIS>-DMBTR * -1.
          ENDIF.
       IF NOT <bsis>-aufnr IS INITIAL.
          IF <BSIS>-AUFNR = '000000100000'.         "    P_AUFNR.
            <BSIS>-SUBFBT = <BSIS>-DMBTR.
            <BSIS>-AMOUNT = ( <BSIS>-SUBFBT * <BSIS>-ZFI_FBT ) / 100.
          ELSE.
           IF <bsis>-aufnr = '000000100020'.
            <BSIS>-NONFBT = <BSIS>-DMBTR.
          ENDIF.
       ENDIF.
          <BSIS>-FBTPAY = ( <BSIS>-AMOUNT * <BSIS>-ZFI_PAY ) / 100.
        ENDIF.
      ENDLOOP.
      UNASSIGN <BSIS>.
    ENDFORM.                    " chk4_internal
    *&      Form  get_ztable
          text
    -->  p1        text
    <--  p2        text
    FORM GET_ZTABLE .
      REFRESH : GIT_FRINGE.
      SELECT   HKONT
               ZFI_FBT
               ZFI_PAY
                       FROM ZFI_FBT_DETL
                       INTO TABLE GIT_FRINGE
                     FOR ALL ENTRIES IN s_hkont
                       WHERE HKONT IN S_HKONT.
      CHECK SY-SUBRC EQ 0.
      SORT GIT_FRINGE BY ZFI_HKONT.
    ENDFORM.                    " get_ztable
    *&      Form  get_percentage
          text
    -->  p1        text
    <--  p2        text
    FORM GET_PERCENTAGE .
      CLEAR : GWA_FRINGE.
      LOOP AT GIT_BSIS ASSIGNING <BSIS>.
        IF <BSIS> IS ASSIGNED.
          READ TABLE GIT_FRINGE INTO GWA_FRINGE WITH KEY
                                                       ZFI_HKONT = <BSIS>-HKONT
                                                       BINARY SEARCH.
          CHECK SY-SUBRC EQ 0.
          <BSIS>-ZFI_FBT = GWA_FRINGE-ZFI_FBT.
          <BSIS>-ZFI_PAY = GWA_FRINGE-ZFI_PAY.
        ENDIF.
      ENDLOOP.
      UNASSIGN <BSIS>.
    ENDFORM.                    " get_percentage
    *&      Form  determine_sort_sequence
          text
    -->  p1        text
    <--  p2        text
    FORM DETERMINE_SORT_SEQUENCE .
      DATA : LS_SORT TYPE SLIS_SORTINFO_ALV.
      LS_SORT-SPOS = 1.                           " Sort order
      LS_SORT-FIELDNAME = 'HKONT'.
      LS_SORT-TABNAME = 'GIT_BSIS'.
      LS_SORT-UP = 'X'.
      LS_SORT-SUBTOT = 'X'.                      " Sub total allowed
      APPEND LS_SORT TO GT_SORT.
      CLEAR LS_SORT.
    ENDFORM.                    " determine_sort_sequence
    *&      Form  get_events
          text
    -->  p1        text
    <--  p2        text
    FORM GET_EVENTS .
      CONSTANTS:
      GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
      GC_FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE = 0
        IMPORTING
          ET_EVENTS   = GT_EVENTS.
      READ TABLE GT_EVENTS WITH KEY NAME =  SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO GT_EVENTS.
      ENDIF.
      READ TABLE GT_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_USER_COMMAND TO LS_EVENT-FORM.
        APPEND LS_EVENT TO GT_EVENTS.
      ENDIF.
    ENDFORM.                    " get_events
    *&      Form  sub_commentery_build
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_COMMENTERY_BUILD .
      DATA: LS_LINE TYPE SLIS_LISTHEADER.
      DATA : L_LOW  TYPE CHAR10,
            L_HIGH TYPE CHAR10,
            L_DATE TYPE CHAR25.
      CONCATENATE S_BUDAT-LOW6(2) '.' S_BUDAT-LOW4(2) '.' S_BUDAT-LOW+0(4) INTO  L_LOW.
      CONCATENATE S_BUDAT-HIGH6(2) '.' S_BUDAT-HIGH4(2) '.' S_BUDAT-HIGH+0(4) INTO  L_HIGH.
      CONCATENATE L_LOW  ' - ' L_HIGH INTO L_DATE.
    ***header
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'H'.
    LS_LINE-KEY: not used for this type
      LS_LINE-INFO = 'Fringe Benefit Tax'.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
    ***Selection
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'S'.
      LS_LINE-KEY  = 'Company Code'.
      LS_LINE-INFO = P_BUKRS.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'S'.
      LS_LINE-KEY  = 'Posting Date'.
      LS_LINE-INFO = L_DATE.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
    ENDFORM.                    " sub_commentery_build
          FORM TOP_OF_PAGE                                              *
    When TOP-OF-PAGE will be fired , this event will be called and it
    will use the contents of i_list_top_of_page for output in the header
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
               i_logo             = 'ENJOYSAP_LOGO'
                 IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    ENDFORM.                    "top_of_page
    *&      Form  USER_COMMAND
    Called from within the ALV processes. Currently, '&IC1' is used to
    process the hotspot and display the document 'picked' by the user.
    FORM USER_COMMAND USING PV_UCOMM LIKE SY-UCOMM
                            SELFIELD TYPE SLIS_SELFIELD.
      CLEAR : GWA_BSIS.
      CASE PV_UCOMM.
        WHEN '&IC1'.
          READ TABLE GIT_BSIS INTO GWA_BSIS INDEX SELFIELD-TABINDEX.
          CASE SELFIELD-SEL_TAB_FIELD.
            WHEN 'GIT_BSIS-BELNR'.
              IF NOT GWA_BSIS-BELNR IS INITIAL.
                SET PARAMETER ID: 'BUK' FIELD GWA_BSIS-BUKRS,
                                  'BLN' FIELD GWA_BSIS-BELNR,
                                  'GJR' FIELD GWA_BSIS-GJAHR.
                CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
              ENDIF.
            WHEN OTHERS.
          ENDCASE.
        WHEN OTHERS.
      ENDCASE.
      CLEAR : GWA_BSIS.
    ENDFORM.                    "user_command
    *&      Form  SET_PF_STATUS
          text
    FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'.
    ENDFORM.                    "SET_PF_STATUSENDFORM.                    "SET_PF_STATUS
    AWARD POINTS IF USEFUL....

  • Devloped an ALV report for daily cash receipts for selected date range

    hi,   
                 how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.

    Hi,
    You can develop simple reports using Report Painter.
    You may be also interested in:
    Check report SAPMF05A for credit memo
    See the following Std reports on Payment Advices execute the Tcodes:
    S_ALR_87009888
    S_ALR_87009889
    S_ALR_87009890
    S_ALR_87009891
    S_ALR_87009892
    S_ALR_87009893
    S_ALR_87009978
    S_ALR_87009979
    S_ALR_87009980
    S_ALR_87009981
    S_ALR_87009982
    S_ALR_87009983
    S_ALR_87010056
    S_ALR_87010057
    S_ALR_87010058
    S_ALR_87010059
    S_ALR_87010060
    S_ALR_87010061
    S_ALR_87010066
    S_ALR_87010067
    S_ALR_87012106
    S_ALR_87012107
    S_ALR_87012108
    S_ALR_87012109
    S_ALR_87012110
    S_ALR_87012111
    S_ALR_87012116
    S_ALR_87012117
    S_ALR_87012200
    S_ALR_87012201
    S_ALR_87012202
    S_ALR_870122
    S_ALR_87012204
    S_ALR_87012205
    S_ALR_87012350
    S_ALR_87012351
    S_ALR_87012352
    S_ALR_87012353
    S_ALR_87012354
    S_ALR_87012355
    sample ALV report:
    tables:
    marav. "Table MARA and table MAKT
    Data to be displayed in ALV
    Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
    matically determine the fieldstructure from this source program
    Data:
    begin of imat occurs 100,
    matnr like marav-matnr, "Material number
    maktx like marav-maktx, "Material short text
    matkl like marav-matkl, "Material group (so you can test to make
                            " intermediate sums)
    ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
                            "make sums)
    gewei like marav-gewei, "weight unit (just to be complete)
    end of imat.
    Other data needed
    field to store report name
    data i_repid like sy-repid.
    field to check table length
    data i_lines like sy-tabix.
    Data for ALV display
    TYPE-POOLS: SLIS.
    data int_fcat type SLIS_T_FIELDCAT_ALV.
    select-options:
    s_matnr for marav-matnr matchcode object MAT1.
    start-of-selection.
    read data into table imat
      select * from marav
      into corresponding fields of table imat
      where
      matnr in s_matnr.
    end-of-selection.
    Now, we start with ALV
    To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
    The fieldcatalouge can be generated by FUNCTION
    'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
    report source, including this report.
    The only problem one might have is that the report and table names
    need to be in capital letters. (I had it )
    Store report name
    i_repid = sy-repid.
    Create Fieldcatalogue from internal table
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME         = sy-repid
                I_INTERNAL_TABNAME     = 'IMAT'  "capital letters!
                I_INCLNAME             = sy-repid
           CHANGING
                CT_FIELDCAT            = int_fcat
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM       = i_repid
                I_STRUCTURE_NAME         = 'marav'
                I_DEFAULT                = 'X'
                I_SAVE                   = 'A'
           TABLES
                T_OUTTAB                 = imat.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC .
      ENDIF.
    Hope this will help.
    Regards,
    Naveen.

  • Need a sample program for hierarchial oops ALV report

    Hello experts,
                     I Need a sample program for hierarchial oops ALV report.

    Hi,
       Check the following sample code...
    T A B L E S
    tables : ekko.
      data definition
    types : begin of ty_ekko,
              ebeln type ekko-ebeln,
              lifnr type ekko-lifnr,
              bsart type ekko-bsart,
              aedat type ekko-aedat,
              ernam type ekko-ernam,
            end of ty_ekko.
    types : begin of ty_eket,
               ebeln type ekpo-ebeln,
               ebelp type ekpo-ebelp,
               werks type ekpo-werks,
               matnr type ekpo-matnr,
               menge type eket-menge,
               wamng type eket-wamng,
               netpr type ekpo-netpr,
            end of ty_eket.
    data : it_ekko type table of ty_ekko,
           it_eket type table of ty_eket.
    data: ob_hieralv type ref to cl_salv_hierseq_table.
    data: it_binding type salv_t_hierseq_binding,
          is_binding type salv_s_hierseq_binding.
    S E L C T O P T I O N S
    select-options : s_ebeln for ekko-ebeln.
    S T A R T O F S E L E C T I O N
    start-of-selection.
    select ebeln
           lifnr
           bsart
           aedat
           ernam from ekko
    into corresponding fields of table it_ekko
    where ebeln in s_ebeln.
    if sy-subrc eq 0.
    select aebeln aebelp
           awerks amatnr
           bmenge bwamng
           a~netpr from ekpo as a join eket as b
                     on  amandt = bmandt
                     and aebeln = bebeln
                     and aebelp = bebelp
                   into corresponding fields of table it_eket
                  where a~ebeln in s_ebeln.
    endif.
    is_binding-master = 'EBELN'.
    is_binding-slave = 'EBELN'.
    append is_binding to it_binding.
    *TRY.
    call method cl_salv_hierseq_table=>factory
    exporting
    t_binding_level1_level2 = it_binding
    importing
    r_hierseq = ob_hieralv
    changing
    t_table_level1 = it_ekko
    t_table_level2 = it_eket .
    *CATCH cx_salv_data_error .
    *CATCH cx_salv_not_found .
    *ENDTRY.
    call method ob_hieralv->display( ).
    Cheers,
    Ram

  • Send some sample program for ALV reports

    Hi all ,
    send some sample program for ALV reports for learing purpose
    tahnks.

    Hi ,
    Resource Master
    Program                     YPPCRR                  *
    Program type                Report Program                     *
    Title                       Resource Master Dara for Updation  *
    Author                      Naga Raju                          *
    Requested By                Balaji                             *
    Date Written                24.05.2007                         *
    Specification Id            F2-DP-FS-2-0002                    *
    Transport Request                                              *
    On-line Documentation
    Description
    This Program updates the Location Mater through the Transaction
    /SAPAPO/LOC3 Based on the User Selection
    Update
    Reset
    No Action
    Output
    ALV List output of the main Program
    ALV List output of the Error Log
    REPORT  YPPCRR NO STANDARD PAGE HEADING
                   LINE-SIZE 120
                   LINE-COUNT 62(4)
                   MESSAGE-ID yap..
    Global data
    Include where all the data declarations are coded.
      INCLUDE YPPCRR_data.
    *Initialization
    INITIALIZATION.
    perform init_variant.
    Constants
    CONSTANTS: c_formname_top_of_page TYPE slis_formname
    VALUE 'F_TOP_OF_PAGE'.
    Selection-Screen
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-040.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS:p_prs RADIOBUTTON GROUP ztyp USER-COMMAND ucom DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 3(28) text-003.
    position 40.
    parameters: p_file1 TYPE rlgrap-filename.
    SELECTION-SCREEN END OF LINE.
    skip 5.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: p_aps RADIOBUTTON GROUP ztyp.
    SELECTION-SCREEN COMMENT 3(28) text-004.
    position 40.
    parameters: p_file2 type rlgrap-filename.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN .
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
       EXPORTING
         program_name        = syst-repid
      DYNPRO_NUMBER       = SYST-DYNNR
         field_name          = p_file1
      STATIC              = ' '
      MASK                = ' '
        CHANGING
          file_name           = p_file1
    EXCEPTIONS
      MASK_TOO_LONG       = 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.
    START-OF-SELECTION.
    if p_prs = 'X'.
         PERFORM f_read_datum1 TABLES t_res_head
                          USING p_file1
                          CHANGING w_subrc.
      elseif p_aps = 'X'.
         PERFORM f_read_datum2 TABLES t_res_head
                          USING p_file2
                          CHANGING w_subrc.
    endif.
    IF w_subrc = 0.
    Validations
    PERFORM VALIDATION.
    PERFORM display_alv.
    IF SY-UCOMM = '&F03'
    or SY-UCOMM = '&F12'
    or SY-UCOMM = '&F15'.
    LEAVE LIST-PROCESSING.
    ELSE.
    ENDIF.
    ELSE.
    Message s100 with text-002.
    ENDIF.
    END-OF-SELECTION.
    Forms part*
    INCLUDE YPPCRR_forms.
    *&  Include           YPPCRR_DATA
    Type-Pools
      TYPE-POOLS: slis.
    *TYPES
    DATA:  BEGIN OF tl_res_head.
            INCLUDE STRUCTURE ypp_res_head.
    DATA:  END OF tl_res_head.
    DATA:  BEGIN OF tl_res_head_val.
            INCLUDE STRUCTURE ypp_resv.
    DATA:  END OF tl_res_head_val.
    DATA : BEGIN OF ty_errlog ,
             counter type i,
             type(2) ,
             name(10) TYPE c,
             vrsioid(22) TYPE c,
             restype TYPE c,
             message(80) TYPE c,
           END OF ty_errlog.
    Global Variables
    DATA : gc_flag(1) TYPE c,
           w_val_err_flag(1) type c.
    DATA: w_filename TYPE rlgrap-filename,
          w_subrc TYPE sy-subrc,
          w_t_res_head TYPE slis_t_fieldcat_alv,
          wa_t_res_head TYPE slis_fieldcat_alv.
    DATA :  wa_date(10) TYPE c,
            wa_time(10) TYPE c,
           wa_title(40) TYPE c,
           wa_type(4) TYPE c  .
    DATA: BAPI_RUN_YES_NO TYPE C.
    *Structure
    *INTERNAL TABLES USED BY ALV
    DATA:
    it_fieldcat_alv  TYPE slis_t_fieldcat_alv,
    IT_FIELDCAT_ALV_ERR  TYPE SLIS_T_FIELDCAT_ALV,
    it_status TYPE slis_formname VALUE 'F_MAIN',
    it_user_command TYPE slis_formname VALUE 'F_USER_COMMAND',
    it_events        TYPE slis_t_event,
    it_event_exit    TYPE slis_t_event_exit,
    it_list_comments TYPE slis_t_listheader,
    it_excluding     TYPE slis_t_extab,
    it_sort          TYPE slis_t_sortinfo_alv.
    *Internal Table Declarations
    DATA : BEGIN OF t_imex OCCURS 0 ,
                    string(256) TYPE c,
           END OF t_imex.
    DATA : fcode TYPE TABLE OF sy-ucomm.
    DATA : fcode_bdc TYPE TABLE OF sy-ucomm.
    DATA : fcode_error TYPE TABLE OF sy-ucomm.
    DATA : fcode_final TYPE TABLE OF sy-ucomm.
    STRUCTURE and WORKARES
    *Internal Table Declarations
    DATA : t_res_head  like  tl_res_head occurs 0 WITH HEADER LINE.
    DATA : t_res_head_val like tl_res_head_val occurs 0 with header line.
    data :l_res_head LIKE LINE OF t_res_head.
    DATA : w_file TYPE string.
    *DATA : wa_vrsioid(22) type c,
          wa_locno(20) type c,
          wa_calendar(2) type c,
          wa_planner(3) type c.
    DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
    DATA: RESOURCE_HEAD LIKE BAPI10004RESHEAD OCCURS 0 WITH HEADER LINE,
          RESOURCE_HEAD_X LIKE BAPI10004RESHEADX OCCURS 0 WITH HEADER LINE,
          RESOURCE_TEXT LIKE BAPI10004RESTEXT OCCURS 0 WITH HEADER LINE,
          RESOURCE_TEXT_X LIKE BAPI10004RESTEXTX OCCURS 0 WITH HEADER LINE.
    data : t_errlog like ty_errlog occurs 0 with header line.
    DATA : wk_lines TYPE i,
           wk_errlines TYPE i,
           wk_count TYPE i.
    DATA:   g_tabname TYPE slis_tabname VALUE 'T_RES_HEAD'.
    Variables to be used by ALV
    DATA:
      wk_variant          LIKE disvariant,
      wx_variant         LIKE disvariant,
      wk_variant_save(1)  TYPE c,
      wk_exit(1)          TYPE c,
      wk_repid            LIKE sy-repid,
      wk_user_specific(1) TYPE c,
      wk_callback_ucomm   TYPE slis_formname,
      wk_callback_status   TYPE slis_formname,
    wk_callback_status1  TYPE slis_formname,
      wk_print            TYPE slis_print_alv,
      wk_layout           TYPE slis_layout_alv,
      wk_html_top_of_page TYPE  slis_formname,
      wk_fieldcat_alv     LIKE LINE OF it_fieldcat_alv,
      wk_excluding        LIKE LINE OF it_excluding,
      wk_events           LIKE LINE OF it_events,
      wk_event_exit       LIKE LINE OF it_event_exit,
      wk_list_comments    LIKE LINE OF it_list_comments,
      wk_list1_comments    LIKE LINE OF it_list_comments,
      wk_list2_comments    LIKE LINE OF it_list_comments,
      wk_sort             LIKE LINE OF it_sort.
    *DATA :gc_delete_flag(1).
    *&  Include           YAPOLOC_FORMS
    FORM display_alv .
      PERFORM f_fieldcat_build.
      PERFORM f_event_build.
      PERFORM f_exclude_build.
      PERFORM f_print_build.
      PERFORM f_layout_build.
      PERFORM f_display_data.
    ENDFORM.                    " display_alv
    *&      Form  f_fieldcat_build
          text
    FORM f_fieldcat_build .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name   = wk_repid
          i_structure_name = 'YPP_RESV'
          i_inclname       = wk_repid
        CHANGING
          ct_fieldcat      = it_fieldcat_alv.
    ENDFORM.                    " F_FIELDCAT_BUILD
    *&      Form  F_EVENT_BUILD
          text
    >  p1        text*  <  p2        text
    FORM f_event_build .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = it_events.
      READ TABLE it_events WITH KEY
      name = slis_ev_top_of_page INTO wk_events.
      IF sy-subrc = 0.
        MOVE c_formname_top_of_page TO wk_events-form.
        MODIFY it_events FROM wk_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " F_EVENT_BUILD
    *&      Form  F_EXCLUDE_BUILD
          text
    -->  p1        text
    <--  p2        text
    FORM f_exclude_build .
      wk_excluding = '&GRAPH'. "Graphic
      APPEND wk_excluding TO it_excluding.
    ENDFORM.                    " F_EXCLUDE_BUILD
    *&      Form  F_PRINT_BUILD
          text
    -->  p1        text
    <--  p2        text
    FORM f_print_build .
      wk_print-no_print_listinfos = 'X'.
    ENDFORM.                    " F_PRINT_BUILD
    *&      Form  F_LAYOUT_BUILD
          text
    -->  p1        text
    <--  p2        text
    FORM f_layout_build .
      wk_layout-zebra                = 'X'.
    WK_LAYOUT-COLWIDTH_OPTIMIZE    = 'X'.
      wk_layout-detail_popup         = 'X'.
      wk_layout-detail_initial_lines = 'X'.
      wk_layout-detail_titlebar      = 'Details '.
    ENDFORM.                    " F_LAYOUT_BUILD
    *&      Form  F_DISPLAY_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM f_display_data .
      wk_callback_ucomm = 'CALLBACK_UCOMM'.
      IF sy-ucomm = 'UPD' OR sy-ucomm = space .
        wk_callback_status   = 'CALLBACK_STATUS'.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_background_id             = 'SIWB_WALLPAPER'
          i_callback_program          = wk_repid
         i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE'
          i_callback_pf_status_set    = wk_callback_status
          i_callback_user_command     = wk_callback_ucomm
          it_sort                     = it_sort
          i_default                   = 'X'
          i_save                      = 'A'
          is_variant                  = wk_variant
          is_layout                   = wk_layout
          it_fieldcat                 = it_fieldcat_alv
          it_events                   = it_events
          it_event_exit               = it_event_exit
          it_excluding                = it_excluding
          is_print                    = wk_print
        TABLES
          t_outtab                    = t_res_head_val.
    ENDFORM.                    " F_DISPLAY_DATA
    ALV for Error Log
    *&      Form  display_alv_ERR
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv_err .
      PERFORM f_fieldcat_build_err.
      PERFORM f_event_build_err.
      PERFORM f_exclude_build_err.
      PERFORM f_print_build_err.
      PERFORM f_layout_build_err.
      PERFORM f_display_data_err.
    ENDFORM.                    " display_alv_ERR
    *&      Form  F_FIELDCAT_BUILD_err
          text
    -->  p1        text
    <--  p2        text
    FORM f_fieldcat_build_err .
    BREAK-POINT.
      REFRESH it_fieldcat_alv.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name     = wk_repid
          i_internal_tabname = 'TY_ERRLOG'
      i_structure_name = 'YPP_ERR_LOG'
          i_inclname         = wk_repid
        CHANGING
          ct_fieldcat        = it_fieldcat_alv_err.
      LOOP AT it_fieldcat_alv INTO wk_fieldcat_alv.
        CASE wk_fieldcat_alv-fieldname.
          WHEN 'COUNTER'.
            wk_fieldcat_alv-seltext_s = text-023.
            wk_fieldcat_alv-seltext_m = text-023.
            wk_fieldcat_alv-seltext_l = text-023.
            wk_fieldcat_alv-reptext_ddic = text-023.
            wk_fieldcat_alv-edit         = 'X'.
          WHEN 'TYPE'.
            wk_fieldcat_alv-seltext_s = text-009.
            wk_fieldcat_alv-seltext_m = text-009.
            wk_fieldcat_alv-seltext_l = text-009.
            wk_fieldcat_alv-reptext_ddic = text-009.
            wk_fieldcat_alv-edit         = 'X'.
          WHEN 'NAME'.
            wk_fieldcat_alv-seltext_s = text-010.
            wk_fieldcat_alv-seltext_m = text-010.
            wk_fieldcat_alv-seltext_l = text-010.
            wk_fieldcat_alv-reptext_ddic = text-010.
            wk_fieldcat_alv-edit         = 'X'.
          WHEN 'VRSIOID'.
            wk_fieldcat_alv-seltext_s = text-011.
            wk_fieldcat_alv-seltext_m = text-011.
            wk_fieldcat_alv-seltext_l = text-011.
            wk_fieldcat_alv-reptext_ddic = text-011.
            wk_fieldcat_alv-edit         = 'X'.
          WHEN 'RESTYPE'.
            wk_fieldcat_alv-seltext_s = text-012.
            wk_fieldcat_alv-seltext_m = text-012.
            wk_fieldcat_alv-seltext_l = text-012.
            wk_fieldcat_alv-reptext_ddic = text-012.
            wk_fieldcat_alv-edit         = 'X'.
          WHEN 'MESSAGE'.
            wk_fieldcat_alv-seltext_s = text-013.
            wk_fieldcat_alv-seltext_m = text-013.
            wk_fieldcat_alv-seltext_l = text-013.
            wk_fieldcat_alv-reptext_ddic = text-013.
            wk_fieldcat_alv-edit         = 'X'.
          WHEN OTHERS.
        ENDCASE.
        MODIFY it_fieldcat_alv FROM wk_fieldcat_alv.
      ENDLOOP.
    ENDFORM.                    " F_FIELDCAT_BUILD_err
    *&      Form  F_EVENT_BUILD_err
          text
    -->  p1        text
    <--  p2        text
    FORM f_event_build_err .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = it_events.
      READ TABLE it_events WITH KEY name = slis_ev_top_of_page
                                   INTO wk_events.
      IF sy-subrc = 0.
        MOVE c_formname_top_of_page TO wk_events-form.
        MODIFY it_events FROM wk_events INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " F_EVENT_BUILD_err
    *&      Form  F_EXCLUDE_BUILD_err
          text
    -->  p1        text
    <--  p2        text
    FORM f_exclude_build_err .
      wk_excluding = '&GRAPH'. "Graphic
      APPEND wk_excluding TO it_excluding.
    ENDFORM.                    " F_EXCLUDE_BUILD_err
    *&      Form  F_PRINT_BUILD_err
          text
    -->  p1        text
    <--  p2        text
    FORM f_print_build_err .
      wk_print-no_print_listinfos = 'X'.
    ENDFORM.                    " F_PRINT_BUILD_err
    *&      Form  F_LAYOUT_BUILD_err
          text
    -->  p1        text
    <--  p2        text
    FORM f_layout_build_err .
      wk_layout-zebra                = 'X'.
    WK_LAYOUT-COLWIDTH_OPTIMIZE    = 'X'.
      wk_layout-detail_popup         = 'X'.
      wk_layout-detail_initial_lines = 'X'.
      wk_layout-detail_titlebar      = 'Details '.
    ENDFORM.                    " F_LAYOUT_BUILD_err
    *&      Form  F_DISPLAY_DATA_err
          text
    -->  p1        text
    <--  p2        text
    FORM f_display_data_err .
      wk_callback_ucomm = 'CALLBACK_UCOMM'.
    IF SY-UCOMM ne '&F03'.
      wk_callback_status = 'CALLBACK_STATUS'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_background_id          = 'SIWB_WALLPAPER'
          i_callback_program       = wk_repid
          i_callback_pf_status_set = wk_callback_status
          i_callback_user_command  = wk_callback_ucomm
          it_sort                  = it_sort
          i_default                = 'X'
          i_save                   = 'A'
          is_variant               = wk_variant
          is_layout                = wk_layout
          it_fieldcat              = it_fieldcat_alv_err
          it_events                = it_events
          it_event_exit            = it_event_exit
          it_excluding             = it_excluding
          is_print                 = wk_print
        TABLES
          t_outtab                 = t_errlog.
        KEEP EERRLOG BUTTON
      SET PF-STATUS 'ZSTANDARD' EXCLUDING 'UPD' IMMEDIATELY.
    ENDFORM.                    "f_display_data_err
    **&      Form  F_TOP_OF_PAGE
          text
    FORM f_top_of_page.
      CLEAR: it_list_comments[],
             wk_list_comments,
             wk_list1_comments,
             wk_list2_comments.
      wk_list_comments-typ  = 'H'. "H=Header,S=Selection, A=Action
      wk_list_comments-key  = ''.
      CASE sy-ucomm.
        WHEN ''.
          wk_list_comments-info = text-030.
        WHEN 'UPD'.
          IF t_errlog[] IS INITIAL.
            wk_list_comments-info = text-031.
          ELSE.
            wk_list_comments-info = text-032.
          ENDIF.
        WHEN 'ERRLOG'.
          wk_list_comments-info = text-032.
        WHEN '&F03'.
          wk_list_comments-info = text-031.
        WHEN '&F15'.
          wk_list_comments-info = text-031.
        WHEN '&F12'.
          wk_list_comments-info = text-031.
      ENDCASE.
      APPEND wk_list_comments TO it_list_comments.
      WRITE sy-datum TO wa_date.
      WRITE sy-uzeit TO wa_time.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      wk_list_comments-info = 'User:'.
      wk_list1_comments-info = sy-uname.
      CONCATENATE wk_list_comments wk_list1_comments
      INTO wk_list2_comments.
      APPEND wk_list2_comments TO it_list_comments.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      wk_list_comments-info = '                   Run Date : '.
      wk_list1_comments-info = wa_date.
      CONCATENATE wk_list_comments wk_list1_comments
      INTO wk_list2_comments .
      APPEND wk_list2_comments TO it_list_comments.
      wk_list_comments-typ  = 'S'. "H=Header, S=Selection, A=Action
      wk_list_comments-key  = ''.
      wk_list_comments-info = 'Run Time : '.
      wk_list1_comments-info = wa_time.
      CONCATENATE wk_list_comments wk_list1_comments
      INTO wk_list2_comments .
      APPEND wk_list2_comments TO it_list_comments.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
         I_LOGO             = 'ENJOYSAP_LOGO'
          it_list_commentary =  it_list_comments.
    ENDFORM.                    "F_TOP_OF_PAGE
          FORM USER_COMMAND_SAMPLE                                  *
    -->  UCOMM                                                     *
    -->  SELFIELD                                                  *
    FORM callback_ucomm USING ucomm LIKE sy-ucomm
                         selfield TYPE slis_selfield.
      DATA: v_langu(2) ,
             v_loctype TYPE  /sapapo/c_loctype.
      data err_flg(1).
      IF  bapi_run_yes_no IS INITIAL.
        CASE sy-ucomm.
          WHEN 'UPD'.
            bapi_run_yes_no = 'X'.
            LOOP AT t_res_head_val  WHERE val_err_msg  EQ space.
              v_langu = 'EN'.
               refresh tables
              REFRESH : resource_head ,
                        resource_head_x ,
                        resource_text ,
                        resource_text_x,
                        t_return.
              CLEAR   : resource_head ,
                        resource_head_x ,
                        resource_text ,
                        resource_text_x,
                        t_return .
              resource_head-resource   = t_res_head-name .
              resource_head-restype    = t_res_head-restype.
              resource_head-location   = t_res_head-locno.
              CLEAR : v_loctype .
              SELECT SINGLE loctype  FROM  /sapapo/loc CLIENT SPECIFIED
                     INTO v_loctype
                     WHERE  mandt    = sy-mandt
                     AND    locno    = t_res_head-locno.
              resource_head-loctype  = v_loctype.
              resource_head-calendar   = t_res_head-calendar.
              resource_head-type       = t_res_head-type.
              IF t_res_head-type = '03'.
                resource_head-dimension_bucket = t_res_head-dimension_bucket.
              ELSE.
                resource_head-dimension_bucket = space.
              ENDIF.
              APPEND resource_head.
              CLEAR  resource_head.
              resource_head_x-resource = t_res_head-name.
              resource_head_x-restype  = 'X'.
              resource_head_x-location = 'X'.
              resource_head_x-loctype  = 'X'.
              resource_head_x-calendar = 'X'.
              resource_head_x-type     = 'X'.
              IF t_res_head-type = '03'.
                resource_head_x-dimension_bucket = 'X'.
              ELSE.
                resource_head_x-dimension_bucket = space.
              ENDIF.
              APPEND resource_head_x.
              CLEAR  resource_head_x.
              resource_text-resource = t_res_head-name.
              resource_text-langu    = v_langu.
              resource_text-res_short_text = t_res_head-text.
              APPEND resource_text.
              CLEAR  resource_text.
              resource_text_x-resource = t_res_head-name.
              resource_text_x-langu    = v_langu.
              resource_text_x-res_short_text = 'X'.
              APPEND resource_text_x.
              CLEAR  resource_text_x.
               call bapi
              CALL FUNCTION 'BAPI_RSSRVAPS_SAVEMULTI_30A'
                EXPORTING
                  logical_system                      = 'AD2CLNT200'
                 business_system_group               =  'BSG001'
                 commit_control                      = 'E'
               NO_CREATE                           = ' '
               TABLES
                 resource_head                       =  resource_head
                 resource_head_x                     =  resource_head_x
                 resource_text                       =  resource_text
                 resource_text_x                     =  resource_text_x
                 return                              =  t_return.
              IF sy-subrc = 0.
                LOOP AT t_return WHERE type = 'E'
                              OR type = 'A'.
                  MOVE t_res_head_val-counter TO t_errlog-counter.
                  MOVE t_res_head_val-type TO t_errlog-type.
                  MOVE t_res_head_val-name TO t_errlog-name.
                  MOVE t_res_head_val-vrsioid TO t_errlog-vrsioid.
                  MOVE t_res_head_val-restype TO t_errlog-restype.
                  MOVE t_return-message TO t_errlog-message.
                  APPEND t_errlog.
                  CLEAR t_errlog..
                ENDLOOP.
    IF not t_errlog[] is initial..
               IF sy-subrc = 0.
                ERROR POP UP
                  MESSAGE  text-007 type 'I'.
                ELSE.
                   err_flg = 'X'.
               SUCC POP UP
                 MESSAGE text-008 type 'I'.
                ENDIF.
              ELSE.                                             "NE 0
                LOOP AT t_return WHERE type = 'E'
                              OR type = 'A'.
                  MOVE t_res_head_val-counter TO t_errlog-counter.
                  MOVE t_res_head_val-type TO t_errlog-type.
                  MOVE t_res_head_val-name TO t_errlog-name.
                  MOVE t_res_head_val-vrsioid TO t_errlog-vrsioid.
                  MOVE t_res_head_val-restype TO t_errlog-restype.
                  MOVE t_return-message TO t_errlog-message.
                  APPEND t_errlog.
                  CLEAR t_errlog..
             ENDLOOP.
                IF sy-subrc = 0.
                ELSE.
                  MOVE t_res_head_val-counter TO t_errlog-counter.
                  MOVE t_res_head_val-type TO t_errlog-type.
                  MOVE t_res_head_val-name TO t_errlog-name.
                  MOVE t_res_head_val-vrsioid TO t_errlog-vrsioid.
                  MOVE t_res_head_val-restype TO t_errlog-restype.
                  MOVE 'Error in Creation' TO t_errlog-message.
                  APPEND t_errlog.
                  CLEAR t_errlog..
                ENDIF.
              ENDIF.
          ENDLOOP.
            gc_flag = 'X'.
            REFRESH fcode.
       if err_flg = 'X'.
                  MESSAGE text-008 type 'I'.
       endif.
        ENDCASE.
      ENDIF.
      IF NOT t_errlog[] IS INITIAL.
        wk_list_comments-info = text-032.
        APPEND wk_list_comments TO it_list_comments.
        APPEND 'UPD' TO fcode_error.
        APPEND 'ERRLOG' TO fcode_error.
        SET PF-STATUS 'ZSTANDARD' EXCLUDING fcode_error.
        PERFORM display_alv_err.
      ELSE.
      ENDIF.
    ENDFORM.                    "CALLBACK_UCOMM=
    *&      Form  CALLBACK_STATUS
          text
         -->RT_EXTAB   text
    FORM callback_status USING rt_extab TYPE slis_t_extab.
    IF  bapi_run_yes_no IS NOT INITIAL .
        IF t_errlog[] IS INITIAL.
          REFRESH fcode.
          APPEND 'UPD' TO fcode.
          APPEND 'ERRLOG' TO fcode.
            SET PF-STATUS 'ZSTANDARD' EXCLUDING 'ERRLOG'.
          SET PF-STATUS 'ZSTANDARD' EXCLUDING fcode IMMEDIATELY .
        ENDIF.
      ELSE.
        SET PF-STATUS 'ZSTANDARD' EXCLUDING 'ERRLOG' IMMEDIATELY .
      ENDIF.
    ENDFORM.                    "CALLBACK_STATUS
    *&      Form  CALLBACK_STATUS1
          text
         -->RT_EXTAB   text
    FORM callback_status1 USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZSTANDARD' EXCLUDING 'UPD'.
    ENDFORM. " CALLBACK_STATUS
    *&      Form  CALLBACK_STATUS2
          text
         -->RT_EXTAB   text
    FORM callback_status2 USING rt_extab TYPE slis_t_extab.
      REFRESH fcode_final.
      IF sy-ucomm NE '&F03'.
        APPEND 'UPD'  TO fcode_final.
        APPEND 'ERRLOG' TO fcode_final.
        SET PF-STATUS 'ZSTANDARD' EXCLUDING fcode_final.
      ELSE.
        SET PF-STATUS 'ZSTANDARD' EXCLUDING 'UPD'.
      ENDIF.
    ENDFORM.                    "CALLBACK_STATUS2
    *&      Form  callback_ucomm_E
          text
         -->UCOMM      text
         -->SELFIELD   text
    FORM callback_ucomm_e USING ucomm LIKE sy-ucomm
                         selfield TYPE slis_selfield.
      CASE sy-ucomm.
        WHEN 'ERRLOG' .
          PERFORM display_alv_err.
        WHEN '&F03'.
          SET PF-STATUS 'ZSTANDARD' EXCLUDING 'UPD' IMMEDIATELY .
          PERFORM display_alv .
      ENDCASE.
    ENDFORM.                    "CALLBACK_UCOMM=
    *&      Form  init_variant
          text
    -->  p1        text
    <--  p2        text
    FORM init_variant .
      CLEAR: wk_variant.
      wk_repid              = sy-repid.
      wk_variant-report     = wk_repid.
      wk_variant-username   = sy-uname.
      wk_variant_save       = 'A'. "All types
    ENDFORM.                    " init_variant
    *&      Form  f_read_datum1
          text
         -->P_T_RES_HEAD  text
         -->P_P_FILE1  text
         <--P_W_SUBRC  text
    FORM f_read_datum1  TABLES   p_t_res_head STRUCTURE ypp_res_head
                        USING    p_p_file1
                        CHANGING p_w_subrc.
      DATA : iexcel LIKE zexcel_read OCCURS 0 WITH HEADER LINE.
      CLEAR  p_w_subrc.
      CALL FUNCTION 'ZALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_p_file1
          i_begin_col             = 1
          i_begin_row             = 1
          i_end_col               = 62
          i_end_row               = 50000
        TABLES
          intern                  = iexcel
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        p_w_subrc = 0 .
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      LOOP AT iexcel WHERE row > 2.
        IF iexcel-col = '0001'.
          p_t_res_head-type = iexcel-value.
        ENDIF.
        IF iexcel-col = '0002'.
          p_t_res_head-name = iexcel-value.
        ENDIF.
        IF iexcel-col = '0003'.
          p_t_res_head-vrsioid = iexcel-value.
        ENDIF.
        IF iexcel-col = '0004'.
          p_t_res_head-restype = iexcel-value.
        ENDIF.
        IF iexcel-col = '0005'.
          p_t_res_head-locno = iexcel-value.
        ENDIF.
        IF iexcel-col = '0006'.
          p_t_res_head-tzone = iexcel-value.
        ENDIF.
        IF iexcel-col = '0007'.
          p_t_res_head-calendar = iexcel-value.
        ENDIF.
        IF iexcel-col = '0008'.
          p_t_res_head-planner = iexcel-value.
        ENDIF.
        IF iexcel-col = '0009'.
          p_t_res_h

  • Alv reports sample example req..

    can anybody help me out with a simple example regarding ALV Reports.(simple ALV Reports , Blocked ALV Reports & Hierarchy ALV Reports).
    or pls send me a word document regarding the same ..to [email protected]
    response is highly appreciated..
    bye--
    Pradeepa

    Following document should get you started.
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference For ALV Grid Control.pdf</a>
    tip : if you do a <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/advancedsearch?query=alv%20grid&cat=sdn_all">search for alv grid</a> on the sdn homepage, this is the first result.
    Message was edited by:
            Dries Horions

  • Need sample prog for ALV reporting

    Hi All,
    I need some sample ALV programs, Please mail docs  to below
    avinavpratapsinghDOTseATmail.com
    Thanks n Rgds,
    Kali

    Hi,
    check link.
    link:[https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/sampleALVHEIRARCHYreportprogram]
    link:[www.blogcatalog.com/blogs/all-sap-abap-programming/posts/tag/abap%20alv%20reports%20sample%20codes/ ]
    hope it'll help.
    Regards,
    Sneha.

  • Some doubts in alv report

    how can i page breakin alv report ?
    what are the types of variants and events in alv report?
    how to hide field in alv?
    how to change standard pf status in alv reports?
    plz give me sample program for how to use variants in alv?
    <THREAD LOCKED. Please stop asking interview questions. There is already a lot of information out there, refer to the [Rules of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] on how to ask a good question and learn to search>
    Edited by: Mike Pokraka on Oct 15, 2008 4:52 PM

    how can i page breakin alv report ?
    - Yes... using NEW-PAGE
    what are the types of variants and events in alv report?
    - DATA: g_variant LIKE disvariant.
    - DATA: gt_eventos          TYPE slis_t_event.
    how to hide field in alv?
    - When you define the field catalog mark this field ls_fieldcat-no_out = 'X'.
    how to change standard pf status in alv reports?
    CLEAR ls_extab.
    ls_extab-fcode = 'ZASSIG'.
    APPEND ls_extab TO extab.
    SET PF-STATUS 'Z09_STATUS' EXCLUDING extab.

  • In ALV report doubt

    Hi Expart,
    In ALV report ,what is the work of
    1) REUSE_ALV_VARIANT_DEFAULT_GET function module
    2) SLIS_LAYOUT_ALV
    Regards
    Bhabani

    Hi,
    1.SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT)
    The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) variant for list display.
    The default variant can be found using the function module 'REUSE_ALV_VARIANT_DEFAULT_GET'.
    Sample code:
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                i_save     = variant save condition ( A=all, U = user-specific )
           CHANGING
                cs_variant = internal table containing the program name (and the default variant---optional )
           EXCEPTIONS
                not_found  = 2.
    2.A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).
    Output list description structure.
         The parameters are described under the following heads:
    •     Display options
    •     Exceptions
    •     Totals
    •     Interaction
    •     Detail screen
    •     Display variants (only for hierarchical-sequential lists)
    •     Color
    •     Other
    The layout table is of type slis_layout_alv_spec and has the following fields:
    Reward,if useful.
    Thanks,
    Chandu

  • Field width in ALV report

    Hi,
    How to increase the field width of a field in ALV report.
    I mean, in a ALV report, the field description of a field is not showing correctly. IF i try to extend the field width by the mouse/coursor, it displays the correct description.
    IS there any way where for displaying the  field description correctly?
    Thanks,
    Kumar

    Hi,
    Go through the sample code,
    *& Report ZDEMO_ALVLIST *
    *& Example of a simple ALV List Report *
    *& The basic requirement for this demo is to display a number of *
    *& fields from the EKKO table. *
    REPORT zdemo_alvlist .
    TABLES: ekko.
    type-pools: slis. "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
    ebeln TYPE ekpo-ebeln,
    ebelp TYPE ekpo-ebelp,
    statu TYPE ekpo-statu,
    aedat TYPE ekpo-aedat,
    matnr TYPE ekpo-matnr,
    menge TYPE ekpo-menge,
    meins TYPE ekpo-meins,
    netpr TYPE ekpo-netpr,
    peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
    wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
    gd_tab_group type slis_t_sp_group_alv,
    gd_layout type slis_layout_alv,
    gd_repid like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *& Form BUILD_FIELDCATALOG
    Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
    I.e. Field type may be required in-order for
    the 'TOTAL' function to work.
    fieldcatalog-fieldname = 'EBELN'.
    fieldcatalog-seltext_m = 'Purchase Order'.
    fieldcatalog-col_pos = 0.
    fieldcatalog-outputlen = 10.
    fieldcatalog-emphasize = 'X'.
    fieldcatalog-key = 'X'.
    fieldcatalog-do_sum = 'X'.
    fieldcatalog-no_zero = 'X'.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'EBELP'.
    fieldcatalog-seltext_m = 'PO Item'.
    fieldcatalog-col_pos = 1.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'STATU'.
    fieldcatalog-seltext_m = 'Status'.
    fieldcatalog-col_pos = 2.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'AEDAT'.
    fieldcatalog-seltext_m = 'Item change date'.
    fieldcatalog-col_pos = 3.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MATNR'.
    fieldcatalog-seltext_m = 'Material Number'.
    fieldcatalog-col_pos = 4.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MENGE'.
    fieldcatalog-seltext_m = 'PO quantity'.
    fieldcatalog-col_pos = 5.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MEINS'.
    fieldcatalog-seltext_m = 'Order Unit'.
    fieldcatalog-col_pos = 6.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'NETPR'.
    fieldcatalog-seltext_m = 'Net Price'.
    fieldcatalog-col_pos = 7.
    fieldcatalog-outputlen = 15.
    fieldcatalog-datatype = 'CURR'.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'PEINH'.
    fieldcatalog-seltext_m = 'Price Unit'.
    fieldcatalog-col_pos = 8.
    append fieldcatalog to fieldcatalog.
    clear fieldcatalog.
    endform. " BUILD_FIELDCATALOG
    *& Form BUILD_LAYOUT
    Build layout for ALV grid report
    form build_layout.
    gd_layout-no_input = 'X'.
    gd_layout-colwidth_optimize = 'X'.
    gd_layout-totals_text = 'Totals'(201).
    gd_layout-totals_only = 'X'.
    gd_layout-f2code = 'DISP'. "Sets fcode for when double
    "click(press f2)
    gd_layout-zebra = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text = 'helllllo'.
    endform. " BUILD_LAYOUT
    *& Form DISPLAY_ALV_REPORT
    Display report using ALV grid
    form display_alv_report.
    gd_repid = sy-repid.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    i_callback_program = gd_repid
    i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
    i_callback_user_command = 'USER_COMMAND'
    i_grid_title = outtext
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    it_special_groups = gd_tabgroup
    IT_EVENTS = GT_XEVENTS
    i_save = 'X'
    is_variant = z_template
    tables
    t_outtab = it_ekko
    exceptions
    program_error = 1
    others = 2.
    if sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform. " DISPLAY_ALV_REPORT
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
    from ekpo
    into table it_ekko.
    endform. " DATA_RETRIEVAL
    Form TOP-OF-PAGE *
    ALV Report Header *
    Form top-of-page.
    *ALV Header declarations
    data: t_header type slis_t_listheader,
    wa_header type slis_listheader,
    t_line like wa_header-info,
    ld_lines type i,
    ld_linesc(10) type c.
    Title
    wa_header-typ = 'H'.
    wa_header-info = 'EKKO Table Report'.
    append wa_header to t_header.
    clear wa_header.
    Date
    wa_header-typ = 'S'.
    wa_header-key = 'Date: '.
    CONCATENATE sy-datum+6(2) '.'
    sy-datum+4(2) '.'
    sy-datum(4) INTO wa_header-info. "todays date
    append wa_header to t_header.
    clear: wa_header.
    Total No. of Records Selected
    describe table it_ekko lines ld_lines.
    ld_linesc = ld_lines.
    concatenate 'Total No. of Records Selected: ' ld_linesc
    into t_line separated by space.
    wa_header-typ = 'A'.
    wa_header-info = t_line.
    append wa_header to t_header.
    clear: wa_header, t_line.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = t_header.
    i_logo = 'Z_LOGO'.
    endform.
    Regards,
    Raj.

  • Why do i get f4 on field in alv report  ?

    i done general (MM) alv report
    And i display "MATKL" (Material Group) in one of the column.
    I don't know why, but when i stand on the data  , i get f4 option
    , when i asking for f4 i get message, u201CNo input help is availableu201D.
    In the definition, I didnu2019t put the matkl original data element  ,
    I just put char9, i didnu2019t ask/build and double click or
    Event for it.
    so why do i get f4 option in this column  ?
    thanks  .

    Ajay said the correct answer...
    chech this sample code:
    CLEAR  wa_catalog.
      wa_catalog-fieldname = 'BANFN'.
      wa_catalog-ref_table = 'EBAN'.
      APPEND wa_catalog TO catalog.
    Edited by: Sebastian Bustamante on Oct 6, 2008 9:40 PM

  • Regd: Calculation of TOTAL field in ALV report

    Hi All,
    We have a scenario that we are not getting the total value for numeric fields in ALV report.
    Below i have given the code used for it.
    G_KEY = 'X'.
      G_NOKEY = SPACE.
      G_SUM = 'X'.
      G_NOSUM = SPACE.
      PERFORM BUILD_FIELDCAT USING 'VBELN'  G_KEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'BLDAT'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'VGBEL'  G_KEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'POSNR'  G_KEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'MATNR'  G_KEY G_NOSUM..
      PERFORM BUILD_FIELDCAT USING 'LFIMG'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'VRKME'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'NETPR'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'BRTWR'  G_NOKEY G_NOSUM.
      PERFORM BUILD_FIELDCAT USING 'VALUE_INR'  G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'B_DUTY'     G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'S_TOTAL1'   G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'CV_DUTY'    G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'C_CVD'      G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'S_TOTAL2'   G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'C_DUTY'     G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'S_TOTAL3'   G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'A_DUTY'     G_NOKEY G_SUM.
      PERFORM BUILD_FIELDCAT USING 'T_DUTY'     G_NOKEY G_SUM.
    PERFORM BUILD_LAYOUT.
      PERFORM BUILD_DISPLAY.
    *&      Form  DISPLAY
          text
    FORM BUILD_DISPLAY.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = ' '
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                      = TEXT-000
      I_GRID_SETTINGS                   =
       IS_LAYOUT                         = IG_LAYOUT
         IT_FIELDCAT                       = IG_FIELDCAT
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
         I_SAVE                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = IG_INBOUND
       EXCEPTIONS
         PROGRAM_ERROR                     = 1
         OTHERS                            = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "DISPLAY
    *&      Form  BUILD_FIELDCAT
          text
         -->G_FIELDNAME  text
         -->L_KEY        text
         -->L_SUM        text
    FORM BUILD_FIELDCAT USING L_FIELDNAME LIKE DD03L-FIELDNAME L_KEY TYPE C L_SUM TYPE C.
      CLEAR WG_FIELDCAT_LN.
      ADD 1 TO G_COL_POS.
      WG_FIELDCAT_LN-REF_TABNAME = 'IG_INBOUND'.
      WG_FIELDCAT_LN-FIELDNAME = L_FIELDNAME.
      WG_FIELDCAT_LN-KEY = L_KEY.
      WG_FIELDCAT_LN-DO_SUM = L_SUM.
      WG_FIELDCAT_LN-COL_POS = G_COL_POS.
      WG_FIELDCAT_LN-NO_OUT = SPACE.
      WG_FIELDCAT_LN-QFIELDNAME = SPACE.
      WG_FIELDCAT_LN-HOTSPOT = SPACE.
      APPEND WG_FIELDCAT_LN TO IG_FIELDCAT.
    ENDFORM.                    "BUILD_FIELDCAT
    *&      Form  BUILD_LAYOUT
          text
    FORM BUILD_LAYOUT.
    IG_LAYOUT-TOTALS_TEXT = 'Total Amount'.
    *IG_LAYOUT-SUBTOTALS_TEXT = 'A'.
    IG_LAYOUT-ZEBRA = 'X'.
    ENDFORM.
    Help and Sugesstions will be much appreciated.
    Thanks & Regds.
    Ramesh.

    This is sample program for the same
    REPORT  Z_50657_ALV_EX2
            NO STANDARD PAGE HEADING
            LINE-COUNT 65(3)
            LINE-SIZE 220
            MESSAGE-ID ZZ.
    *                             Type Pools                               *
    TYPE-POOLS: SLIS, ICON.
    *                              Tables                                  *
    TABLES: VBAK. "Sales Document Data
    *                         Internal Tables                              *
    * TABLE TO HOLD DATA OF SALES DOCUMENT
    DATA: BEGIN OF IT_VBAK OCCURS 0,
          VBELN LIKE VBAK-VBELN, "Sales Document
          VBTYP LIKE VBAK-VBTYP, "SD document category
          AUDAT LIKE VBAK-AUDAT, "Document date (date received/sent)
          AUGRU LIKE VBAK-AUGRU, "Order reason (reason for the business)
          AUART LIKE VBAK-AUART, "Sales Document Type
          NETWR LIKE VBAK-NETWR, "Net Sales Order in Doc. Currency
          WAERK LIKE VBAK-WAERK, "SD document currency
          ICON TYPE ICON-ID,     "traffic lights
          END OF IT_VBAK.
    *                             Work Areas                               *
    *WORK AREAS DEFINED FOR ALV'S
    DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,      "field catalog
          IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,     "field catalog ITAB
          WA_SORT TYPE SLIS_SORTINFO_ALV,           "SORT work area
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,         "SORT ITAB
          LAYOUT TYPE SLIS_LAYOUT_ALV,              "LAYOUT
          WA_FCODE TYPE SLIS_EXTAB,                 "FUN CODE
          I_FCODE_EXTAB TYPE SLIS_T_EXTAB,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_EVENTS TYPE SLIS_T_EVENT.
    *                       Selection-Screen                               *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
    PARAMETERS: P_VBTYP LIKE VBAK-VBTYP DEFAULT 'C'.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME.
    PARAMETERS: LIST RADIOBUTTON GROUP G1,
                GRID RADIOBUTTON GROUP G1.
    SELECTION-SCREEN END OF BLOCK B2.
    *                     At  Selection-Screen                             *
    *VALIDATION
    *                       Start of Selection                             *
    START-OF-SELECTION.
    *POPULATION OF DATA INTO INTERNAL TABLE ITAB
      PERFORM GET_DATA.
    *DEFINE USER DEFINED FIELDCATALOG
      PERFORM DEFINE_FIELDCATALOG.
    *SUBTOTALS AND TOTALS DISPLAY USING SORT
      PERFORM SORT_LIST.
    *CHANGE FCODE OF STATUS
      PERFORM CHANGE_FCODE.
    *CHECK RADIOBUTTON OPTION AND ACCORDINGLY FINAL DISPLAY
      PERFORM CHECK_OPTION.
    *&      Form  GET_DATA
    *       text
    FORM GET_DATA.
      SELECT VBELN
             VBTYP
             AUDAT
             AUGRU
             AUART
             NETWR
             WAERK FROM VBAK INTO TABLE IT_VBAK
             WHERE VBELN IN S_VBELN AND VBTYP = P_VBTYP
             AND ERDAT > '01.01.2004' AND NETWR > 0.
      LOOP AT IT_VBAK.
        IF IT_VBAK-NETWR < 10000.
          IT_VBAK-ICON = '@08@'.
        ELSEIF IT_VBAK-NETWR > 100000.
          IT_VBAK-ICON = '@0A@'.
        ELSE.
          IT_VBAK-ICON = '@09@'.
        ENDIF.
        MODIFY IT_VBAK INDEX SY-TABIX.
      ENDLOOP.
    ENDFORM.                    "GET_DATA
    *&      Form  CHECK_OPTION
    *       text
    FORM CHECK_OPTION.
      WA_EVENTS-NAME = 'TOP_OF_PAGE'.
      WA_EVENTS-FORM = 'TOP'.
      APPEND WA_EVENTS TO IT_EVENTS.
      CLEAR WA_EVENTS.
      WA_EVENTS-NAME = 'END_OF_LIST'.
      WA_EVENTS-FORM = 'END_LIST'.
      APPEND WA_EVENTS TO IT_EVENTS.
      CLEAR WA_EVENTS.
      IF LIST = 'X'.
        PERFORM LIST_DISP.
      ENDIF.
      IF GRID = 'X'.
        PERFORM GRID_DISP.
      ENDIF.
    ENDFORM.                    "CHECK_OPTION
    *&      Form  DEFINE_FIELDCATALOG
    *       text
    FORM DEFINE_FIELDCATALOG.
      WA_FIELDCAT-COL_POS = 1.
      WA_FIELDCAT-FIELDNAME = 'ICON'.
      WA_FIELDCAT-SELTEXT_L = 'ICON'.
      WA_FIELDCAT-ICON = 'X'.
      WA_FIELDCAT-OUTPUTLEN = 8.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 2.
      WA_FIELDCAT-FIELDNAME = 'VBELN'.
      WA_FIELDCAT-SELTEXT_L = 'SALES DOC NO.'.
      WA_FIELDCAT-OUTPUTLEN = 10.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 3.
      WA_FIELDCAT-FIELDNAME = 'AUDAT'.
      WA_FIELDCAT-SELTEXT_L = 'CREATED ON'.
      WA_FIELDCAT-OUTPUTLEN = 10.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 4.
      WA_FIELDCAT-FIELDNAME = 'VBTYP'.
      WA_FIELDCAT-SELTEXT_L = 'CATEGORY'.
      WA_FIELDCAT-OUTPUTLEN = 1.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 6.
      WA_FIELDCAT-FIELDNAME = 'AUGRU'.
      WA_FIELDCAT-SELTEXT_L = 'REASON'.
      WA_FIELDCAT-OUTPUTLEN = 3.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 5.
      WA_FIELDCAT-FIELDNAME = 'AUART'.
      WA_FIELDCAT-SELTEXT_L = 'DOC TYPE'.
      WA_FIELDCAT-OUTPUTLEN = 4.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 7.
      WA_FIELDCAT-FIELDNAME = 'NETWR'.
      WA_FIELDCAT-SELTEXT_L = 'NET VALUE'.
      WA_FIELDCAT-OUTPUTLEN = 17.
      WA_FIELDCAT-DECIMALS_OUT = 2.
    *  WA_FIELDCAT-DO_SUM = 'X'.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-COL_POS = 8.
      WA_FIELDCAT-FIELDNAME = 'WAERK'.
      WA_FIELDCAT-SELTEXT_L = 'UNIT'.
      WA_FIELDCAT-OUTPUTLEN = 50.
      WA_FIELDCAT-TABNAME = 'IT_VBAK'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "DEFINE_FIELDCATALOG
    *&      Form  DEFINE_LAYOUT
    *       text
    FORM DEFINE_LAYOUT.
      LAYOUT-ZEBRA = 'X'.
      LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL SUM'.
      LAYOUT-WINDOW_TITLEBAR = 'EXERCISE 2'.
      LAYOUT-TOTALS_TEXT  = 'TOTAL'.
    ENDFORM.                    "DEFINE_LAYOUT
    *&      Form  SORT_LIST
    *       text
    FORM SORT_LIST.
      WA_SORT-FIELDNAME = 'VBELN'.
      WA_SORT-TABNAME = 'IT_VBAK'.
      WA_SORT-SPOS = 1.
      WA_SORT-UP = 'X'.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
      WA_SORT-FIELDNAME = 'NETWR'.
      WA_SORT-TABNAME = 'IT_VBAK'.
      WA_SORT-UP = 'X'.
      WA_SORT-SPOS = 2.
      WA_SORT-SUBTOT = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR WA_SORT.
    ENDFORM.                    "SORT_LIST
    *&      Form  LIST_DISP
    *       text
    FORM LIST_DISP.
      PERFORM DEFINE_LAYOUT.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM             = SY-REPID
         IT_FIELDCAT                    = IT_FIELDCAT
         IS_LAYOUT                      = LAYOUT
         IT_SORT                        = IT_SORT
         I_CALLBACK_PF_STATUS_SET       = 'STATUS'
         IT_EXCLUDING                   = I_FCODE_EXTAB
         I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
         IT_EVENTS                      = IT_EVENTS[]
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER        =
    *     ES_EXIT_CAUSED_BY_USER         =
        TABLES
         T_OUTTAB                       = IT_VBAK
    *   EXCEPTIONS
    *     PROGRAM_ERROR                  = 1
    *     OTHERS                         = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "LIST_DISP
    *&      Form  GRID_DISP
    *       text
    FORM GRID_DISP.
      PERFORM DEFINE_LAYOUT.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = SY-REPID
          IS_LAYOUT                = LAYOUT
          IT_FIELDCAT              = IT_FIELDCAT
          IT_SORT                  = IT_SORT
          I_CALLBACK_PF_STATUS_SET = 'STATUS'
          IT_EXCLUDING             = I_FCODE_EXTAB
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          IT_EVENTS                = IT_EVENTS[]
        TABLES
          T_OUTTAB                 = IT_VBAK.
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "GRID_DISP
    *&      Form  STATUS
    *       text
    *      -->P_EXTAB    text
    FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STATUS' EXCLUDING P_EXTAB.
    ENDFORM.                    "STATUS
    *&      Form  USER_COMMAND
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                                   RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN 'BACK' OR 'CANC' OR 'EXIT'.
          LEAVE TO SCREEN 0.
        WHEN '&IC1'.
          SET PARAMETER ID 'AUN' FIELD RS_SELFIELD-VALUE.
          CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    *&      Form  CHANGE_FCODE
    *       text
    FORM CHANGE_FCODE.
      WA_FCODE = 'PRNT'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&OAD'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&AVE'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&EB9'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&SUM'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&UMC'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&XPA'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
      WA_FCODE = '&OMP'.
      APPEND WA_FCODE TO I_FCODE_EXTAB.
    ENDFORM.                    "CHANGE_FCODE
    *&      Form  TOP
    *       text
    FORM TOP.
      IF LIST = 'X'.
        WRITE:/ SY-ULINE.
        WRITE:/ 'DATE:', SY-DATUM,55 'INTELLIGROUP ASIA PVT LTD'.
        WRITE:/ 'TIME:', SY-UZEIT.
        WRITE:/ 'USER NAME:', SY-UNAME,60 SY-TITLE.
        WRITE:/ 'PAGE', SY-PAGNO.
        WRITE:/ SY-ULINE.
      ENDIF.
      IF GRID = 'X'.
        DATA: LS_LINE TYPE SLIS_LISTHEADER,
              E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
    *   Listenüberschrift: Typ H
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'H'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'Summary'.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    *   Kopfinfo: Typ S
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'S'.
        LS_LINE-KEY  = 'Intelligroup'.
        LS_LINE-INFO = ''.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
        LS_LINE-KEY  = 'ASIA'.
        LS_LINE-INFO = 'PVT LTD'.
        APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.
    *   Aktionsinfo: Typ A
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'A'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'truman'.
        APPEND LS_LINE TO  E04_LT_TOP_OF_PAGE.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY = E04_LT_TOP_OF_PAGE
            I_LOGO             = 'ENJOY_SAP_LOGO'.
      ENDIF.
    ENDFORM.                    "TOP
    *&      Form  END_LIST
    *       text
    FORM END_LIST.
      IF LIST = 'X'.
        SKIP 2.
        WRITE:/60 'END OF PAGE'.
      ENDIF.
      IF GRID = 'X'.
          DATA: LS_LINE TYPE SLIS_LISTHEADER,
              E04_LT_END_OF_LIST TYPE SLIS_T_LISTHEADER.
    *   Listenüberschrift: Typ H
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'H'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = 'Summary'.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
    *   Kopfinfo: Typ S
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'S'.
        LS_LINE-KEY  = 'Intelligroup'.
        LS_LINE-INFO = ''.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
        LS_LINE-KEY  = 'ASIA'.
        LS_LINE-INFO = 'PVT LTD'.
        APPEND LS_LINE TO E04_LT_END_OF_LIST.
    *   Aktionsinfo: Typ A
        CLEAR LS_LINE.
        LS_LINE-TYP  = 'A'.
    *   LS_LINE-KEY:  not used for this type
        LS_LINE-INFO = TEXT-105.
        APPEND LS_LINE TO  E04_LT_END_OF_LIST.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY = E04_LT_END_OF_LIST.
      ENDIF.
    ENDFORM.                    "END_LIST

  • Devolped an ALV report for daily cash receipts for selected date range

    hi,   
                 how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.

    hi,   
                 how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.

  • Adding Button to REPORT to call a ALV report

    Hi,
          I have a standard report RPT1. In this report I have a button in the application toolbar which I created using the statement.
    <b>SELECTION-SCREEN FUNCTION KEY 1.</b>
             When I click on this button it should take me to an ALV report which is coded in the <u>same program RPT1</u> in a <i>subroutine f_alv_sub</i>.
         But when I click on the button it does not take me to the report.
          How do we go about it? Points will be awarded to the best answer.THANKS.
                        regards,
                           dev.

    Hi,
    Check this sample code.
    tables:sscrfields. "Fields on selection screens
    selection-screen function key 1.
    selection-screen function key 2.
    Initialization.
      sscrfields-functxt_01 = 'Report'.
      sscrfields-functxt_02 = 'Exit'.
    at selection-screen.
       if sscrfields-ucomm = 'FC01'.
      perform f_alv_sub.
       elseif sscrfields-ucomm = 'FC02'.
       endif.
    Hope it helps.

  • Exporting data from ALV Report...

    Dear All,
    While I am exporting data from ALV report to any other Format (Excel, Txt, HTML) it only export the data of last column, but the heading is comming properly and also the column heading is displaying properly.
    So how to rectify it. (the report is Object Oriented).
    Regards,
    Dahrmesh

    Hi Davabap,
    Refer this sample program "BCALV_GRID_VERIFY" . I hope it is problem with structure mismatching.
    Otherwise can you paste your code ?
    Regards,
    Vicky
    PS: Award points if helpful

Maybe you are looking for

  • There was an error in the App Store. Please try again later. (18)

    I cannot download the updates for imovie, garage band, and iphoto.   I get this error message.   There was an error in the App Store. Please try again later. (18)

  • Known Issue in Nokia Lumia 720 - Virtual keys stop...

    Hi Nokia lumia 720 bottom virtual keys stops working after some time.............. only solution is to replace screen which costs 7000....     Is there any permanent solution? pls help

  • Progress Indicator not displaying

    Hello, We have an existing web application built using older version of Crystal Viewer control that doesn't display any progress indicator when the report starts running. However I see with CR 2008, it's possible to display a progress indicator. I ha

  • RAID Failure Reported

    My Arch Linux system is reporting a failure when I login via Gnome. The system has the RAID partitions: md0 = swap md1 = /boot md2 = / When I login via Gnome, the system alerts me with a serious looking warning that one of two disks has multiple bad

  • How can I encrypted my SWF file

    Hi I will create  some SWFs and will want it to be played on WINCE device platform, but i need the SWF be encrypted and only played on my device. How can we do?