Skip to end of metadata
Go to start of metadata

Author: Manish Shankar
Submitted: 22/09/2012

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT  zmalv02 .

TABLES : sflight .
TYPE-POOLS : slis .

TYPES : BEGIN OF ty_sflight ,                 " Structure
  carrid    TYPE sflight-carrid    ,
  connid    TYPE sflight-connid    ,
  fldate    TYPE sflight-fldate    ,
  price     TYPE sflight-price     ,
  currency  TYPE sflight-currency  ,
  planetype TYPE sflight-planetype ,
  cell TYPE slis_t_specialcol_alv  ,
  END OF ty_sflight .

DATA : it_sflight TYPE TABLE OF ty_sflight ,  " Internal Table
       wa_sflight TYPE ty_sflight    .

DATA : it_fcat TYPE slis_t_fieldcat_alv ,      " Field Cat
       wa_fcat TYPE slis_fieldcat_alv .

DATA : wa_layout TYPE slis_layout_alv .        " Layout

DATA : wa_grid TYPE lvc_s_glay .               " Grid Setting
DATA : variant TYPE disvariant .               " Layout

START-OF-SELECTION .

  SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight .

  PERFORM color_field .                " Color field
  PERFORM fieldcat .                           " Field catalog

  wa_layout-colwidth_optimize = 'X' .                 " Optimize the Field Name
  wa_layout-zebra = 'X' .                             " Zebra
  wa_layout-coltab_fieldname = 'CELL'.                " To color one particular cell

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = sy-repid
      i_callback_user_command = 'USRCMD'               " Create FORM for this
      i_callback_top_of_page  = 'TOPOFPAGE'            " Create FORM for this
      i_background_id         = 'SKY'                  " Background, OAER
      i_grid_title            = 'Sflight Table'        " ALV Title
      i_grid_settings         = wa_grid                " Grid Settings
      is_layout               = wa_layout              " Layout
      it_fieldcat             = it_fcat                " Field Cat
      i_save                  = 'X'                    " Save
      is_variant              = variant                " Variant
    TABLES
      t_outtab                = it_sflight.

*&---------------------------------------------------------------------*
*&      Form  FIELDCAT
*&---------------------------------------------------------------------*
FORM fieldcat .
  CLEAR it_fcat.
  CLEAR wa_fcat.
  wa_fcat-fieldname = 'CARRID'.
  wa_fcat-tabname = 'IT_SFLIGHT'.
  wa_fcat-seltext_m = 'Airline Code'.
  wa_fcat-no_zero = 'X'.
  wa_fcat-key = 'X'.
  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.

  wa_fcat-fieldname = 'CONNID'.
  wa_fcat-tabname = 'IT_SFLIGHT'.
  wa_fcat-seltext_l = 'Flight Connection Number'.
  wa_fcat-key = 'X'.
  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.

  wa_fcat-fieldname = 'FLDATE'.
  wa_fcat-tabname = 'IT_SFLIGHT'.
  wa_fcat-seltext_m = 'Flight date'.
  wa_fcat-key = 'X'.
  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.

  wa_fcat-fieldname = 'PRICE'.
  wa_fcat-tabname = 'IT_SFLIGHT'.
  wa_fcat-seltext_m = 'Airfare'.
  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.

  wa_fcat-fieldname = 'CURRENCY'.
  wa_fcat-tabname = 'IT_SFLIGHT'.
  wa_fcat-edit = 'X'.
  wa_fcat-seltext_m = 'Local currency'.
  wa_fcat-emphasize = 'C410' .
*    WA_FCAT-KEY = 'X'.
  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.

  wa_fcat-fieldname = 'PLANETYPE'.
  wa_fcat-tabname = 'IT_SFLIGHT'.
  wa_fcat-seltext_m = 'Aircraft Type'.
  APPEND wa_fcat TO it_fcat.
  CLEAR wa_fcat.

ENDFORM .                    "FIELDCAT

*&---------------------------------------------------------------------*
*&      Form  USRCMD
*&---------------------------------------------------------------------*
FORM usrcmd USING ucomm TYPE sy-ucomm                  " For Double Click
                  selfield TYPE slis_selfield .
  DATA : it_sflight1 LIKE it_sflight .
  DATA : it_sflight2 TYPE TABLE OF sflight ,
         wa_sflight2 TYPE sflight .
  CASE ucomm  .
    WHEN '&IC1' .
      READ TABLE it_sflight INTO wa_sflight INDEX selfield-tabindex .
      APPEND wa_sflight TO it_sflight1 .

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'           " To Display Second ALV
       EXPORTING
         it_fieldcat                       = it_fcat
        TABLES
          t_outtab                          = it_sflight1.

    WHEN '&DATA_SAVE' .                             " To Save the changes
      LOOP AT it_sflight INTO wa_sflight .
        MOVE-CORRESPONDING wa_sflight TO wa_sflight2.
        APPEND wa_sflight2 TO it_sflight2.
      ENDLOOP.
      UPDATE sflight FROM TABLE it_sflight2.

  ENDCASE .
ENDFORM .                    "USRCMD

*&---------------------------------------------------------------------*
*&      Form  TOPOFPAGE
*&---------------------------------------------------------------------*
FORM topofpage .                                                            " Header
  DATA: it_header TYPE TABLE OF slis_listheader ,
        wa_header TYPE slis_listheader .

  wa_header-typ = 'H'.                                              " H: Header, S: Sub header, A: Italic
  wa_header-info = 'ALV Report'.
  APPEND wa_header TO it_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 it_header.
  CLEAR wa_header.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = it_header
      i_logo             = 'LUFTHANSA'.                              " Upload the logo through T Code: OAER

ENDFORM .                    "TOPOFPAGE

*&---------------------------------------------------------------------*
*&      Form  COLOR_FIELD
*&---------------------------------------------------------------------*
FORM color_field .
  DATA : it_color TYPE slis_t_specialcol_alv ,
         wa_color TYPE slis_specialcol_alv   .

  LOOP AT it_sflight INTO wa_sflight.
    IF  wa_sflight-connid  = '0087' .                            " Check in Table for the format
      wa_color-fieldname = 'CONNID'.
      wa_color-color-col = '6'.
      wa_color-color-int = '1'.
      wa_color-color-inv = '1'.
      APPEND wa_color TO wa_sflight-cell.
      MODIFY it_sflight FROM wa_sflight.
    ENDIF .
  ENDLOOP .
ENDFORM .                    "COLOR_FIELD