ABAP List Viewer(ALV) – 5

*ALV USING FM- REUSE_ALV_GRID_DISPLAY & 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

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

 ” Upload logo in OAER transaction

   ENDFORM.


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s