Sunday, 27 May 2012

ALV REPORTS

*********** (1) ALV REPORT USING REUSE_ALV_LIST_DISPLAY FUNCTION MODULE************

data : it_flight type table of sflight,
           wa_flight type sflight.
select-options : s_carrid for wa_flight-carrid.
start-of-selection.
  select * from sflight into table it_flight where carrid in                                                                         s_carrid.

end-of-selection.
call function 'REUSE_ALV_LIST_DISPLAY'
 EXPORTING
  I_CALLBACK_PROGRAM  = SY-REPID " Pass the program name                                    "which is stored in the system variable
  I_STRUCTURE_NAME  = 'SFLIGHT'  " Passing the name of                                   "  the Global dictionary structure 
  tables
    t_outtab    = it_flight . " Passing the                                 "internal table name which holds the records to display


Output
























------------------------------------------------------------------

 ALV REPORT USING REUSE_ALV_GRID_DISPLAY_LVC  FUNCTION MODULE

data itab type table of vbak.
start-of-selection.
select from vbak into table itab UP TO 20 ROWS .
  end-of-selection.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
 EXPORTING
   I_CALLBACK_PROGRAM                SY-CPROG
   I_STRUCTURE_NAME                  'VBAK'
  TABLES
    T_OUTTAB                          ITAB.

Output-















------------------------------------------------------------

* (3) ALV REPORT USING REUSE_ALV_GRID_DISPLAY FUNCTION MODULE*

data : it_flight type table of sflight,
         wa_flight type sflight.
select-options : s_carrid for wa_flight-carrid.

start-of-selection.
  select * from sflight into table it_flight where carrid in s_carrid.

end-of-selection.
call function 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
   I_CALLBACK_PROGRAM                = SY-REPID
   I_STRUCTURE_NAME                  = 'SFLIGHT'
  tables
    t_outtab                          = IT_FLIGHT.


Output-






























----------------------------------------------------------------------------------------------------------------------

(4) ALV REPORT USING REUSE_ALV_GRID_DISPLAY FUNCTION MODULE***

TYPE-POOLS : SLIS.
data : it_flight type table of sflight,
       wa_flight type sflight.

DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
       WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
select-options : s_carrid for wa_flight-carrid.

start-of-selection.
  select * from sflight into table it_flight where carrid in s_carrid.

    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
     EXPORTING
       I_PROGRAM_NAME               = SY-CPROG
       I_STRUCTURE_NAME             = 'SFLIGHT'
      changing
        ct_fieldcat                  = IT_FIELDCAT.


    call function 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       I_CALLBACK_PROGRAM                = SY-REPID
       IT_FIELDCAT                       = IT_FIELDCAT
      tables
        t_outtab                          = IT_FLIGHT.

Output-




























------------------------------------------------------------

 (5) ALV REPORT USING REUSE_ALV_GRID_DISPLAY FUNCTION MODULE& FIELD CATALOG & LAYOUT

type-pools : slis.
types : begin of ty_flight,
        CH TYPE C,
        carrid type sflight-carrid,
        connid type sflight-connid,
        fldate type sflight-fldate,
        price type sflight-price,
        seatsmax type sflight-seatsmax,
        seatsocc type sflight-seatsocc,
       end of ty_flight.

 data : it_flight type table of ty_flight,
        wa_flight type ty_flight.

data : it_fieldcat type slis_t_fieldcat_alv,
       wa_fieldcat type slis_fieldcat_alv.

DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
select-options : s_carrid for wa_flight-carrid.

start-of-selection.
  select * from sflight into corresponding fields of table it_flight                          where carrid in s_carrid.
****** Building field catalog for the ALV ****************
wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 1.
 wa_fieldcat-fieldname = 'CH'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-CHECKBOX = 'X'.
 wa_fieldcat-SELTEXT_S = 'CHECK'.

 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

 wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 2.
 wa_fieldcat-fieldname = 'CARRID'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-KEY = 'X'.
 wa_fieldcat-SELTEXT_S = 'FLIGHT CODE'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 3.
 wa_fieldcat-fieldname = 'CONNID'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-KEY = 'X'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 4.
 wa_fieldcat-fieldname = 'FLDATE'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-KEY = 'X'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 5.
 wa_fieldcat-fieldname = 'PRICE'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-EMPHASIZE = 'C515'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 6.
 wa_fieldcat-fieldname = 'SEATSMAX'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-EMPHASIZE = 'C615'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 7.
 wa_fieldcat-fieldname = 'SEATSOCC'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-EMPHASIZE = 'C300'.
* wa_fieldcat-no_out = 'X'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.
****** Building Layout for the ALV **********
 WA_LAYOUT-NO_COLHEAD = 'X'.
 WA_LAYOUT-NO_VLINE = 'X'.
 WA_LAYOUT-NO_HLINE = 'X'.
 WA_LAYOUT-EDIT = 'X'.
 WA_LAYOUT-zebra = 'X'.
 WA_LAYOUT-colwidth_optimize = 'X'.

 call function 'REUSE_ALV_GRID_DISPLAY'

  EXPORTING
    I_CALLBACK_PROGRAM     = SY-CPROG
    I_GRID_TITLE           = 'Flight Details'
    IS_LAYOUT    = WA_LAYOUT  " pass the layout to the Func mod
    IT_FIELDCAT  = IT_FIELDCAT " pass the fieldcatlog to func Mod
   tables
     t_outtab    = IT_FLIGHT.

Output-









































---------------------------------------------------------------

 (6) ALV REPORT USING REUSE_ALV_GRID_DISPLAY FUNCTION MODULE& FIELD CATALOG & LAYOUT & WITH HEADER LOGO

type-pools : slis.
types : begin of ty_flight,
        CH TYPE C,
        carrid type sflight-carrid,
        connid type sflight-connid,
        fldate type sflight-fldate,
        price type sflight-price,
        seatsmax type sflight-seatsmax,
        seatsocc type sflight-seatsocc,
       end of ty_flight.

 data : it_flight type table of ty_flight,
        wa_flight type ty_flight.

data : it_fieldcat type slis_t_fieldcat_alv,
         wa_fieldcat type slis_fieldcat_alv.

DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA : IT_HEADER TYPE SLIS_T_LISTHEADER,
           WA_HEADER TYPE SLIS_LISTHEADER.

select-options : s_carrid for wa_flight-carrid.

start-of-selection.
  select * from sflight into corresponding fields of table it_flight where carrid in s_carrid.


wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 1.
 wa_fieldcat-fieldname = 'CH'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-CHECKBOX = 'X'.
 wa_fieldcat-SELTEXT_S = 'CHECK'.

 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

 wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 2.
 wa_fieldcat-fieldname = 'CARRID'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-KEY = 'X'.
 wa_fieldcat-SELTEXT_S = 'FLIGHT CODE'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 3.
 wa_fieldcat-fieldname = 'CONNID'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-KEY = 'X'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 4.
 wa_fieldcat-fieldname = 'FLDATE'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-KEY = 'X'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 5.
 wa_fieldcat-fieldname = 'PRICE'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-EMPHASIZE = 'C515'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 6.
 wa_fieldcat-fieldname = 'SEATSMAX'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-EMPHASIZE = 'C615'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

  wa_fieldcat-row_pos = 1.
 wa_fieldcat-col_pos = 7.
 wa_fieldcat-fieldname = 'SEATSOCC'.
 wa_fieldcat-TABNAME = 'IT_FLIGHT'.
 wa_fieldcat-REF_TABNAME = 'SFLIGHT'.
 wa_fieldcat-EMPHASIZE = 'C300'.
* wa_fieldcat-no_out = 'X'.
 APPEND WA_FIELDCAT TO IT_FIELDCAT.
 CLEAR WA_FIELDCAT.

 WA_LAYOUT-NO_COLHEAD = 'X'.
 WA_LAYOUT-NO_VLINE = 'X'.
 WA_LAYOUT-NO_HLINE = 'X'.
 WA_LAYOUT-EDIT = 'X'.
 WA_LAYOUT-zebra = 'X'.
 WA_LAYOUT-colwidth_optimize = 'X'.


 call function 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM     = SY-CPROG
    I_CALLBACK_TOP_OF_PAGE  = 'DISPLAY_LOGO'  " SUBROUTINE NAME  TO                                                "DISPLAY LOGO
    I_GRID_TITLE   = 'Flight Details'
    IS_LAYOUT      = WA_LAYOUT
    IT_FIELDCAT    = IT_FIELDCAT
   tables
     t_outtab       = IT_FLIGHT.


 FORM DISPLAY_LOGO.

   WA_HEADER-TYP = 'H'.
   WA_HEADER-INFO  = 'INDIAN AIRLINES'.
   APPEND WA_HEADER TO IT_HEADER.
   CLEAR WA_HEADER.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      it_list_commentary  = IT_HEADER
     I_LOGO  = 'AEROPLANE'. " INSERT A LOGO IN ( OAER ) TRANSACTION
   ENDFORM.

*********** (7) INTERACTIVE ALV REPORT USING REUSE_ALV_GRID_DISPLAY FUNCTION MODULE& FIELD CATALOG & LAYOUT & WITH HEADER LOGO*******

type-pools : slis.
types : begin of ty_flight,
        carrid type sflight-carrid,
        connid type sflight-connid,
        fldate type sflight-fldate,
        price type sflight-price,
        seatsmax type sflight-seatsmax,
        seatsocc type sflight-seatsocc,
       end of ty_flight.

types : begin of ty_spfli,
        carrid type spfli-carrid,
        connid type spfli-connid,
        countryfr type spfli-countryfr,
        countryto type spfli-countryto,
        airpfrom type spfli-airpfrom,
        airpto type spfli-airpto,
        cityfrom type spfli-cityfrom,
        cityto type spfli-cityto,
       end of ty_spfli.

data : it_flight type table of ty_flight,
        wa_flight type ty_flight.
data : it_spfli type table of ty_spfli,
        wa_spfli type ty_spfli.

data : it_fieldcat type slis_t_fieldcat_alv,
       wa_fieldcat type slis_fieldcat_alv.

data : it_fieldcat1 type slis_t_fieldcat_alv,
       wa_fieldcat1 type slis_fieldcat_alv.

data : wa_layout type slis_layout_alv.
data : wa_layout1 type slis_layout_alv.

data : it_header type slis_t_listheader,
       wa_header type slis_listheader.

data : it_header1 type slis_t_listheader,
       wa_header1 type slis_listheader.

select-options : s_carrid for wa_flight-carrid.

start-of-selection.
  select * from sflight into corresponding fields of table it_flight                                        where carrid in s_carrid.

  wa_fieldcat-row_pos = 1.
  wa_fieldcat-col_pos = 1.
  wa_fieldcat-fieldname = 'CARRID'.
  wa_fieldcat-tabname = 'IT_FLIGHT'.
  wa_fieldcat-ref_tabname = 'SFLIGHT'.
  wa_fieldcat-key = 'X'.
  wa_fieldcat-seltext_s = 'FLIGHT CODE'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-row_pos = 1.
  wa_fieldcat-col_pos = 2.
  wa_fieldcat-fieldname = 'CONNID'.
  wa_fieldcat-tabname = 'IT_FLIGHT'.
  wa_fieldcat-ref_tabname = 'SFLIGHT'.
  wa_fieldcat-key = 'X'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-row_pos = 1.
  wa_fieldcat-col_pos = 3.
  wa_fieldcat-fieldname = 'FLDATE'.
  wa_fieldcat-tabname = 'IT_FLIGHT'.
  wa_fieldcat-ref_tabname = 'SFLIGHT'.
  wa_fieldcat-key = 'X'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-row_pos = 1.
  wa_fieldcat-col_pos = 4.
  wa_fieldcat-fieldname = 'PRICE'.
  wa_fieldcat-tabname = 'IT_FLIGHT'.
  wa_fieldcat-ref_tabname = 'SFLIGHT'.
  wa_fieldcat-emphasize = 'C515'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-row_pos = 1.
  wa_fieldcat-col_pos = 5.
  wa_fieldcat-fieldname = 'SEATSMAX'.
  wa_fieldcat-tabname = 'IT_FLIGHT'.
  wa_fieldcat-ref_tabname = 'SFLIGHT'.
  wa_fieldcat-emphasize = 'C615'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-row_pos = 1.
  wa_fieldcat-col_pos = 6.
  wa_fieldcat-fieldname = 'SEATSOCC'.
  wa_fieldcat-tabname = 'IT_FLIGHT'.
  wa_fieldcat-ref_tabname = 'SFLIGHT'.
  wa_fieldcat-emphasize = 'C300'.
* wa_fieldcat-no_out = 'X'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

 WA_LAYOUT-NO_COLHEAD = 'X'.
 WA_LAYOUT-NO_VLINE = 'X'.
 WA_LAYOUT-NO_HLINE = 'X'.
 WA_LAYOUT-EDIT = 'X'.
 WA_LAYOUT-zebra = 'X'.
  wa_layout-colwidth_optimize = 'X'.

  call function 'REUSE_ALV_GRID_DISPLAY'

   exporting
     i_callback_program          = sy-cprog
     i_callback_user_command  = 'DISPLAY_SECOND_ALV' " SUBROUTINE                                          " NAME FOR INERACTIVE  LIST
     i_callback_top_of_page  = 'DISPLAY_LOGO' " SUBROUTINE NAME FOR                                                         "LOGO
     i_grid_title   = 'Flight Details'
     is_layout      = wa_layout
     it_fieldcat    = it_fieldcat
    tables
      t_outtab       = it_flight.

*----------------------------------------------------------------------*

form display_logo.

  wa_header-typ = 'H'.
  wa_header-info  = 'INDIAN AIRLINES'.
  append wa_header to it_header.
  clear wa_header.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      it_list_commentary     = it_header
     i_logo                 = 'AEROPLANE'.


  refresh it_header.
endform.                    "DISPLAY_LOGO

*----------------------------------------------------------------------*

form display_second_alv using ok_code type sy-ucomm
                                  selfield type slis_selfield.

  case ok_code.
    when '&IC1'." fcode for double click
      read table it_flight into wa_flight index selfield-tabindex.

      select * from spfli into corresponding fields of table                        it_spfli where carrid = wa_flight-carrid.

      wa_fieldcat1-row_pos = 1.
      wa_fieldcat1-col_pos = 1.
      wa_fieldcat1-fieldname = 'CARRID'.
      wa_fieldcat1-tabname = 'IT_SPFLI'.
      wa_fieldcat1-ref_tabname = 'SPFLI'.
      wa_fieldcat1-key = 'X'.
      wa_fieldcat1-seltext_s = 'FLIGHT CODE'.
      append wa_fieldcat1 to it_fieldcat1.
      clear wa_fieldcat1.

      wa_fieldcat1-row_pos = 1.
      wa_fieldcat1-col_pos = 2.
      wa_fieldcat1-fieldname = 'CONNID'.
      wa_fieldcat1-tabname = 'IT_SPFLI'.
      wa_fieldcat1-ref_tabname = 'SPFLI'.
      wa_fieldcat1-key = 'X'.
      wa_fieldcat1-seltext_s = 'FLIGHT CONN'.
      append wa_fieldcat1 to it_fieldcat1.
      clear wa_fieldcat1.

      wa_fieldcat1-row_pos = 1.
      wa_fieldcat1-col_pos = 3.
      wa_fieldcat1-fieldname = 'COUNTRYFR'.
      wa_fieldcat1-tabname = 'IT_SPFLI'.
      wa_fieldcat1-ref_tabname = 'SPFLI'.
      wa_fieldcat1-seltext_s = 'COUNTRY FROM'.
      append wa_fieldcat1 to it_fieldcat1.
      clear wa_fieldcat1.

      wa_fieldcat1-row_pos = 1.
      wa_fieldcat1-col_pos = 4.
      wa_fieldcat1-fieldname = 'COUNTRYTO'.
      wa_fieldcat1-tabname = 'IT_SPFLI'.
      wa_fieldcat1-ref_tabname = 'SPFLI'.
      wa_fieldcat1-seltext_s = 'COUNTRY TO'.
      append wa_fieldcat1 to it_fieldcat1.
      clear wa_fieldcat1.

      wa_fieldcat1-row_pos = 1.
      wa_fieldcat1-col_pos = 5.
      wa_fieldcat1-fieldname = 'AIRPFROM'.
      wa_fieldcat1-tabname = 'IT_SPFLI'.
      wa_fieldcat1-ref_tabname = 'SPFLI'.
      wa_fieldcat1-seltext_s = 'AIRPORT FROM'.
      append wa_fieldcat1 to it_fieldcat1.
      clear wa_fieldcat1.

      wa_fieldcat1-row_pos = 1.
      wa_fieldcat1-col_pos = 6.
      wa_fieldcat1-fieldname = 'AIRPTO'.
      wa_fieldcat1-tabname = 'IT_SPFLI'.
      wa_fieldcat1-ref_tabname = 'SPFLI'.
      wa_fieldcat1-seltext_s = 'AIRPORT TO'.
      append wa_fieldcat1 to it_fieldcat1.
      clear wa_fieldcat1.

      wa_fieldcat1-row_pos = 1.
      wa_fieldcat1-col_pos = 7.
      wa_fieldcat1-fieldname = 'CITYFROM'.
      wa_fieldcat1-tabname = 'IT_SPFLI'.
      wa_fieldcat1-ref_tabname = 'SPFLI'.
      wa_fieldcat1-seltext_s = 'CITY FROM'.
      append wa_fieldcat1 to it_fieldcat1.
      clear wa_fieldcat1.

      wa_fieldcat1-row_pos = 1.
      wa_fieldcat1-col_pos = 8.
      wa_fieldcat1-fieldname = 'CITYTO'.
      wa_fieldcat1-tabname = 'IT_SPFLI'.
      wa_fieldcat1-ref_tabname = 'SPFLI'.
      wa_fieldcat1-seltext_s = 'CITY TO'.
      append wa_fieldcat1 to it_fieldcat1.
      clear wa_fieldcat1.

      wa_layout1-zebra = 'X'.
      wa_layout1-colwidth_optimize = 'X'.

      call function 'REUSE_ALV_GRID_DISPLAY'

       exporting
         i_callback_program        = sy-cprog
     I_CALLBACK_TOP_OF_PAGE        = 'PAGE_HEAD1'
         is_layout                 = wa_layout1
         it_fieldcat               = it_fieldcat1
        tables
          t_outtab                 = it_spfli.
  endcase.
endform.                    "DISPLAY_SECOND_ALV


FORM PAGE_HEAD1.
  wa_header1-typ = 'H'.
  wa_header1-info  = 'JET AIRLINES'.
  append wa_header1 to it_header1.
  clear wa_header1.

  call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
      it_list_commentary       = it_header1
     i_logo                   = 'AEROPLANE'.
  REFRESH IT_HEADER1.
  ENDFORM.

*********** (8) BLOCKED ALV REPORT ************************

TYPE-POOLS : SLIS.
DATA : IT_SPFLI TYPE TABLE OF SPFLI,
       IT_SFLIGHT TYPE TABLE OF SFLIGHT,
       IT_SBOOK  TYPE TABLE OF SBOOK.

DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA : IT_EVENT TYPE SLIS_T_EVENT.
START-OF-SELECTION.

PERFORM FETCH_DATA.

END-OF-SELECTION.
PERFORM BLOCKED_ALV_INITIALIZATION.

PERFORM FIELD_CAT USING 'IT_SPFLI' 'SPFLI'.
PERFORM BLOCKED_ALV_APPEND USING 'IT_SPFLI' IT_SPFLI.
REFRESH IT_FIELDCAT[].

PERFORM FIELD_CAT USING 'IT_SFLIGHT' 'SFLIGHT'.
PERFORM BLOCKED_ALV_APPEND USING 'IT_SFLIGHT' IT_SFLIGHT.
REFRESH IT_FIELDCAT[].


PERFORM FIELD_CAT USING 'IT_SBOOK' 'SBOOK'.
PERFORM BLOCKED_ALV_APPEND USING 'IT_SBOOK' IT_SBOOK.
REFRESH IT_FIELDCAT[].
PERFORM BLOCKED_ALV_DISPLAY.
*----------------------------------------------------------------------*
form FETCH_DATA .
SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
SELECT * FROM SFLIGHT INTO TABLE IT_SFLIGHT UP TO 10 ROWS.
SELECT * FROM SBOOK INTO TABLE IT_SBOOK UP TO 10 ROWS.
endform.                    " FETCH_DATA
*----------------------------------------------------------------------*
form BLOCKED_ALV_INITIALIZATION .
call function 'REUSE_ALV_BLOCK_LIST_INIT'
  exporting
    i_callback_program             = SY-CPROG.
endform.                    " BLOCKED_ALV_INITIALIZATION
*----------------------------------------------------------------------*
form FIELD_CAT  using  ITAB TYPE C
                       TAB_STRUC TYPE C.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
   I_PROGRAM_NAME               = SY-CPROG
   I_INTERNAL_TABNAME           = ITAB
   I_STRUCTURE_NAME             = TAB_STRUC
  changing
    ct_fieldcat                  = IT_FIELDCAT.

endform.                    " FIELD_CAT


*----------------------------------------------------------------------*
form BLOCKED_ALV_APPEND  using   ITAB1 TYPE C
                                 ITAB2 TYPE STANDARD TABLE.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'
  exporting
    is_layout                        = WA_LAYOUT
    it_fieldcat                      = IT_FIELDCAT
    i_tabname                        = ITAB1
    it_events                        = IT_EVENT
  tables
    t_outtab                         = ITAB2.

endform.                    " BLOCKED_ALV_APPEND
*----------------------------------------------------------------------*
form BLOCKED_ALV_DISPLAY .
call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

endform.                    " BLOCKED_ALV_DISPLAY

Output-






















*********** (9) SIMPLE TREE ALV REPORT ************************

type-pools : slis.
types : begin of ty_scarr,
          carrid type scarr-carrid,
        end of ty_scarr.
types : begin of ty_spfli,
        carrid type spfli-carrid,
        connid type spfli-connid,
       end of ty_spfli.

types : begin of ty_sflight,
        carrid type sflight-carrid,
        connid type sflight-connid,
        fldate type sflight-fldate,
       end of ty_sflight.

data : it_scarr type table of ty_scarr ,
       wa_scarr type ty_scarr,
       it_spfli type table of ty_spfli,
        wa_spfli type ty_spfli,
        it_sflight type table of ty_sflight ,
         wa_sflight type ty_sflight,
         it_node type table of snodetext,
          wa_node type snodetext .

start-of-selection.
  perform data-fetch.
  perform build_tree.
  perform display_tree.
*----------------------------------------------------------------------*
form data-fetch .
  select carrid from scarr into table it_scarr.

  if it_scarr is not initial.
    select carrid connid from spfli into table it_spfli for all entries in it_scarr where carrid  = it_scarr-carrid.
    if it_spfli is not initial.
      select carrid
             connid
             fldate from sflight into table it_sflight for all entries in it_spfli where carrid = it_spfli-carrid and connid = it_spfli-connid.
    endif.
  endif.


  sort : it_scarr by carrid,
          it_spfli by carrid connid,
          it_sflight by carrid connid fldate.
endform.                    " DATA-FETCH

*----------------------------------------------------------------------*

form build_tree .
  clear : wa_node, it_node.

  wa_node-type = 'T'.
  wa_node-name = 'Airline'.
  wa_node-tlevel = '01'.
  wa_node-nlength = '08'.
  wa_node-color = '05'.
  wa_node-text = 'CODE'.
  wa_node-tlength = '04'.
  wa_node-tcolor = '05'.
  append wa_node to it_node.
  clear wa_node.

  loop at it_scarr into wa_scarr.
    wa_node-type = 'P'.
    wa_node-name = 'CARRID'.
    wa_node-tlevel = '02'.
    wa_node-nlength = '08'.
    wa_node-color = '06'.
    wa_node-text = wa_scarr-carrid.
    wa_node-tlength = '04'.
    wa_node-tcolor = '06'.
    append wa_node to it_node.
    clear wa_node.

    loop at it_spfli into wa_spfli.
      wa_node-type = 'P'.
      wa_node-name = 'CONNID'.
      wa_node-tlevel = '03'.
      wa_node-nlength = '08'.
      wa_node-color = '04'.
      wa_node-text = wa_spfli-connid.
      wa_node-tlength = '04'.
      wa_node-tcolor = '04'.
      append wa_node to it_node.
      clear wa_node.

      LOOP AT IT_SFLIGHT INTO WA_SFLIGHT.
      wa_node-type = 'P'.
      wa_node-name = 'fldate'.
      wa_node-tlevel = '04'.
      wa_node-nlength = '06'.
      wa_node-color = '04'.
      wa_node-text = wa_sflight-fldate.
      wa_node-tlength = '10'.
      wa_node-tcolor = '04'.
      append wa_node to it_node.
      clear wa_node.

        ENDLOOP.
    endloop.
  endloop.
endform.                    " BUILD_TREE
*----------------------------------------------------------------------*
form display_tree .
  call function 'RS_TREE_CONSTRUCT'
* EXPORTING
*   INSERT_ID                = '000000'
*   RELATIONSHIP             = ' '
*   LOG                      =
    tables
      nodetab                  = it_node.
  call function 'RS_TREE_LIST_DISPLAY'
   exporting
     callback_program                = sy-cprog.
            .
endform.                    " DISPLAY_TREE

Output-





























*********** (10) INTERACTIVE TREE ALV REPORT ************************

type-pools : slis.
types : begin of ty_scarr,
        carrid type scarr-carrid,
        end of ty_scarr.
types : begin of ty_spfli,
          carrid type spfli-carrid,
          connid type spfli-connid,
       end of ty_spfli.

types : begin of ty_sflight,
          carrid type sflight-carrid,
          connid type sflight-connid,
          fldate type sflight-fldate,
       end of ty_sflight.

data : it_scarr type table of ty_scarr ,
         wa_scarr type ty_scarr,
         it_spfli type table of ty_spfli,
         wa_spfli type ty_spfli,
         it_sflight type table of ty_sflight ,
         wa_sflight type ty_sflight,
         it_node type table of snodetext,
         wa_node type snodetext .
data : it_fcat type slis_t_fieldcat_alv,
       wa_fcat type slis_fieldcat_alv.

start-of-selection.
  perform data-fetch.
  perform build_tree.
  perform display_tree.
*----------------------------------------------------------------------*
form data-fetch .
  select carrid from scarr into table it_scarr.

  if it_scarr is not initial.
    select carrid connid from spfli into table it_spfli for all        entries in it_scarr where carrid  = it_scarr-carrid.
  endif.

  sort : it_scarr by carrid,
          it_spfli by carrid connid.

endform.                    " DATA-FETCH
*----------------------------------------------------------------------*
form build_tree .
  clear : wa_node, it_node.

  wa_node-type = 'T'.
  wa_node-name = 'Airline'.
  wa_node-tlevel = '01'.
  wa_node-nlength = '08'.
  wa_node-color = '05'.
  wa_node-text = 'CODE'.
  wa_node-tlength = '04'.
  wa_node-tcolor = '05'.
  append wa_node to it_node.
  clear wa_node.

  loop at it_scarr into wa_scarr.
    wa_node-type = 'P'.
    wa_node-name = 'CARRID'.
    wa_node-tlevel = '02'.
    wa_node-nlength = '08'.
    wa_node-color = '06'.
    wa_node-text = wa_scarr-carrid.
    wa_node-tlength = '04'.
    wa_node-tcolor = '06'.
    append wa_node to it_node.
    clear wa_node.

    loop at it_spfli into wa_spfli.
      wa_node-type = 'P'.
        wa_node-name = 'CONNID'.
      wa_node-tlevel = '03'.
      wa_node-nlength = '08'.
      wa_node-color = '04'.
      wa_node-text = wa_spfli-connid.
      wa_node-tlength = '04'.
      wa_node-tcolor = '04'.
      append wa_node to it_node.
      clear wa_node.

    endloop.
  endloop.
endform.                    " BUILD_TREE
*----------------------------------------------------------------------*
form display_tree .
  call function 'RS_TREE_CONSTRUCT'
* EXPORTING
*   INSERT_ID                = '000000'
*   RELATIONSHIP             = ' '
*   LOG                      =
    tables
      nodetab                  = it_node.
  call function 'RS_TREE_LIST_DISPLAY'
   exporting
     callback_program                = sy-cprog
   callback_user_command           = 'INTERACTIVE_LIST'
   CALLBACK_GUI_STATUS             = 'SET_GUI_STATUS'.
endform.                    " DISPLAY_TREE
*----------------------------------------------------------------------*
form interactive_list tables node structure seucomm
                       using command " DOUBLE CLICK F2 -FCODE-TRSL
                       changing exit
                                list_refresh.

  list_refresh = 'M'.

  if node-tlevel = '03'.
    select carrid connid fldate from sflight into table it_sflight                                    where connid = node-text.

    wa_fcat-row_pos = '1'.
    wa_fcat-col_pos = '1'.
    wa_fcat-fieldname = 'CARRID'.
    wa_fcat-key = 'X'.
    wa_fcat-seltext_m = 'airline carrier'.
    wa_fcat-hotspot = 'X'.
    append wa_fcat to it_fcat.
    clear wa_fcat.

    wa_fcat-row_pos = '1'.
    wa_fcat-col_pos = '2'.
    wa_fcat-fieldname = 'CONNID'.
    wa_fcat-key = 'X'.
    wa_fcat-seltext_m = 'airline cONNECTION'.
    wa_fcat-hotspot = 'X'.
    append wa_fcat to it_fcat.
    clear wa_fcat.

    wa_fcat-row_pos = '1'.
    wa_fcat-col_pos = '3'.
    wa_fcat-fieldname = 'FLDATE'.
    wa_fcat-key = 'X'.
    wa_fcat-seltext_m = 'airline DAT'.
    wa_fcat-hotspot = 'X'.
    append wa_fcat to it_fcat.
    clear wa_fcat.


    call function 'REUSE_ALV_GRID_DISPLAY'
     exporting
       i_callback_program   = sy-cprog
       it_fieldcat          = it_fcat
      tables
        t_outtab            = it_sflight.
    REFRESH : IT_SFLIGHT[],
              IT_FCAT[].

  endif.
endform.                    "INTERACTIVE_LIST

FORM SET_GUI_STATUS.
  SET PF-STATUS 'STST'.
ENDFORM.

******** (11) HEIRARCHICAL SQUENTIAL ALV REPORT*********

type-pools : slis , icon.

types : begin of ty_dd02l,
        icon type icon_d,
        tabname type tabname,
        tabclass type tabclass,
        contflag type contflag,
        actflag type actflag,
        mainflag type maintflag,
        buffered type buffered,
        as4user type as4user,
        as4date type as4date,
        as4time type as4time,
        expand,
        end of ty_dd02l.

types : begin of ty_dd03l,
        tabname type tabname,
        fieldname type fieldname,
        keyflag type keyflag,
        mandatory type mandatory,
        checktable type checktable,
        rollname type rollname,
        end of ty_dd03l.


data : it_dd02l type standard table of ty_dd02l,
       wa_dd02l type ty_dd02l,
       it_dd03l type standard table of ty_dd03l,
       wa_dd03l type ty_dd03l.

data : it_fieldcat type slis_t_fieldcat_alv,
       wa_fieldcat type slis_fieldcat_alv,
       wa_layout type slis_layout_alv,
       key type slis_keyinfo_alv.
select-options : s_table for wa_dd02l-tabname no intervals.

start-of-selection.
  perform fetch_data.
  perform build_catalog.
  perform build_layout.
  perform build_key.
  perform dispaly_hier_alv.
*----------------------------------------------------------------------*
form fetch_data .
  select * from dd02l into corresponding fields of table it_dd02l                                            where tabname in s_table.
  if it_dd02l is not initial.
  select * from dd03l into corresponding fields of table it_dd03l     for all entries in it_dd02l where tabname = it_dd02l-tabname.
  endif.


  LOOP AT IT_DD02L INTO WA_DD02L.
    AT NEW TABNAME.
      WA_DD02L-ICON = '@3M@'.
      MODIFY IT_DD02L FROM WA_DD02L TRANSPORTING ICON WHERE TABNAME                                                = WA_DD02L-TABNAME.
      CLEAR WA_DD02L.
      ENDAT.
    ENDLOOP.
endform.                    " FETCH_DATA
*----------------------------------------------------------------------*
form build_catalog .
  clear wa_fieldcat.
  wa_fieldcat-col_pos = 1.
  wa_fieldcat-fieldname = 'TABNAME'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'Tablename'.
  wa_fieldcat-key = 'X'.
  wa_fieldcat-emphasize = 'C610'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.


  wa_fieldcat-col_pos = 2.
  wa_fieldcat-fieldname = 'TABCLASS'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'Tablecategory'.
  wa_fieldcat-emphasize = 'C600'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-col_pos = 3.
  wa_fieldcat-fieldname = 'CONTFLAG'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'DeliveryClass'.
  wa_fieldcat-emphasize = 'C510'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.


  wa_fieldcat-col_pos = 4.
  wa_fieldcat-fieldname = 'ACTFLAG'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'Activationstatus'.
  wa_fieldcat-emphasize = 'C500'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-col_pos = 5.

  wa_fieldcat-fieldname = 'MAINFLAG'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'MaintainenceFlag'.
  wa_fieldcat-emphasize = 'C410'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-col_pos = 6.
  wa_fieldcat-fieldname = 'BUFFERED'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'BufferFlag'.
  wa_fieldcat-emphasize = 'C400'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.
 
  wa_fieldcat-col_pos = 7.
  wa_fieldcat-fieldname = 'AS4USER'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'User'.
  wa_fieldcat-emphasize = 'C310'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.


  wa_fieldcat-col_pos = 8.
  wa_fieldcat-fieldname = 'AS4DATE'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'Date'.
  wa_fieldcat-emphasize = 'C300'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-col_pos = 9.
  wa_fieldcat-fieldname = 'AS4TIME'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'Time'.
  wa_fieldcat-emphasize = 'C210'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.


  wa_fieldcat-col_pos = 10.
  wa_fieldcat-fieldname = 'ICON'.
  wa_fieldcat-tabname = 'IT_DD02L'.
  wa_fieldcat-seltext_m = 'ICON'.
  wa_fieldcat-icon = 'X'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-col_pos = 11.
  wa_fieldcat-fieldname = 'FIELDNAME'.
  wa_fieldcat-tabname = 'IT_DD03L'.
  wa_fieldcat-key = 'X'.
  wa_fieldcat-seltext_m = 'Field'.
  wa_fieldcat-emphasize = 'C600'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat

  wa_fieldcat-col_pos = 12.

  wa_fieldcat-fieldname = 'KEYFLAG'.
  wa_fieldcat-tabname = 'IT_DD03L'.
  wa_fieldcat-seltext_m = 'Key'.
  wa_fieldcat-emphasize = 'C500'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.


  wa_fieldcat-col_pos = 13.
  wa_fieldcat-fieldname = 'CHECKTABLE'.
  wa_fieldcat-tabname = 'IT_DD03L'.
  wa_fieldcat-seltext_m = 'Checktable'.
  wa_fieldcat-emphasize = 'C400'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.


  wa_fieldcat-col_pos = 14.
  wa_fieldcat-fieldname = 'MANDATORY'.
  wa_fieldcat-tabname = 'IT_DD03L'.
  wa_fieldcat-seltext_m = 'Mandatory'.
  wa_fieldcat-emphasize = 'C300'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.

  wa_fieldcat-col_pos = 15.
  wa_fieldcat-fieldname = 'ROLLNAME'.
  wa_fieldcat-tabname = 'IT_DD03L'.
  wa_fieldcat-seltext_m = 'Dataelement'.
  wa_fieldcat-emphasize = 'C200'.
  append wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.
endform.                    " BUILD_CATALOG
*----------------------------------------------------------------------*
form build_layout .
  wa_layout-expand_fieldname = 'EXPAND'.
  wa_layout-window_titlebar = 'Hierarchical ALV list display'.
  wa_layout-lights_tabname = 'IT_DD03L'.
  wa_layout-colwidth_optimize = 'X'.
endform.                    " BUILD_LAYOUT


*----------------------------------------------------------------------*
form BUILD_KEY .
  key-header01 = 'TABNAME'.
  key-item01 = 'TABNAME'.
endform.                    " BUILD_KEY
*----------------------------------------------------------------------*
form DISPALY_HIER_ALV .
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
  exporting
   I_CALLBACK_PROGRAM             = sy-cprog
   IS_LAYOUT                      = wa_layout
   IT_FIELDCAT                    = it_fieldcat
    i_tabname_header               =  'IT_DD02L'
    i_tabname_item                 = 'IT_DD03L'
    is_keyinfo                     = key
  tables
    t_outtab_header                = it_dd02l
    t_outtab_item                  = it_dd03l.

endform.                    " DISPALY_HIER_ALV

Output-























--------------------------------------------------------------------------------------------------------------------

3 comments:

rebel said...

Big fan of yours sir. U are doing a great job...I din't find any sites as helpful as ur blog, thank you so much.

David said...
This comment has been removed by the author.
My Knowledge said...

Nice guidance :)

Comments system

Disqus Shortname