Sample ALV report with Hotspot

TYPE-POOLS : slis.
TABLES : mara.
TYPES :ty_mara TYPE STANDARD TABLE OF mara.
DATA : int_tbl TYPE STANDARD TABLE OF mara,
      wa_tbl TYPE mara ,
      it_final type TABLE OF mara,
      fld_cat TYPE slis_t_fieldcat_alv,
      wa_fld TYPE slis_fieldcat_alv,
      wa_fld_cat TYPE slis_fieldcat_alv.
DATA : et_event TYPE slis_t_event,
      we_event TYPE slis_alv_event.

START-OF-SELECTION.
  perform event_call.
  SELECT * FROM mara INTO TABLE int_tbl.
  perform field_catalog_merge.
  PERFORM call_alv_grid using 'SUB1'
        'USER_COMMAND'
        fld_cat
         et_event
         CHANGING
           int_tbl.
FORM sub1 USING extab TYPE slis_t_extab.
  SET PF-STATUS 'PF_STATUS'." EXCLUDING extab.
ENDFORM .
FORM user_command USING l_ucomm LIKE sy-ucomm l_sel TYPE slis_selfield.
    CASE l_ucomm.
    WHEN '&IC1'.
      IF l_sel-FIELDNAME = 'MATNR'.
        READ TABLE int_tbl INTO wa_tbl INDEX  l_sel-TABINDEX.
        append wa_tbl to it_final.
      ENDIF.
    perform field_catalog_merge.
    perform DISPLAY_OUTPUT2.
  ENDCASE.
ENDFORM.
form EVENT_CALL .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
   EXPORTING
     I_LIST_TYPE           = 0
   IMPORTING
     ET_EVENTS             = et_event
            .
  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.

FORM POPULATE_EVENT.
  READ TABLE et_event INTO We_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
  IF SY-SUBRC EQ 0.
    We_EVENT-FORM = 'TOP_OF_PAGE'.
    MODIFY et_event FROM We_EVENT TRANSPORTING FORM WHERE NAME =
We_EVENT-FORM.
  ENDIF.

  READ TABLE  et_event INTO We_EVENT WITH KEY NAME = 'USER_COMMAND'.
  IF SY-SUBRC EQ 0.
    We_EVENT-FORM = 'USER_COMMAND'.
    MODIFY et_event FROM We_EVENT TRANSPORTING FORM WHERE NAME =
We_EVENT-NAME.
  ENDIF.
ENDFORM.

form FIELD_CATALOG_MERGE .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
      i_program_name               = sy-repid
     i_internal_tabname           = 'int_tbl'
     i_structure_name             = 'MARA'
    CHANGING
      ct_fieldcat                  = fld_cat
            .
  IF sy-subrc &lt;&gt; 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE .
    READ TABLE fld_cat INTO wa_fld WITH KEY fieldname = 'MATNR' .
    wa_fld-hotspot = 'X' .
    MODIFY fld_cat INDEX sy-tabix FROM wa_fld TRANSPORTING hotspot .
  ENDIF.
endform.
form DISPLAY_OUTPUT2 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
   I_CALLBACK_PROGRAM                = sy-repid
   IT_FIELDCAT                       = fld_cat
  TABLES
    t_outtab                          = it_final
 EXCEPTIONS
   PROGRAM_ERROR                     = 1
   OTHERS                            = 2
          .
IF sy-subrc &lt;&gt; 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

endform.

*&---------------------------------------------------------------------*
*&      Form  CALL_ALV_GRID
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0059   text
*      -->P_0060   text
*      -->P_FLD_CAT  text
*      -->P_ET_EVENT  text
*      <--P_INT_TBL  text
*----------------------------------------------------------------------*
form CALL_ALV_GRID  using    value(p_0059)
                             value(p_0060)
                             p_fld_cat
                             p_et_event
                    changing p_int_tbl TYPE ty_mara.
 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program                = sy-repid
     i_callback_pf_status_set          = p_0059 "'SUB1'
     i_callback_user_command           = p_0060 "'USER_COMMAND'
     it_fieldcat                       = p_fld_cat
     it_events                         = p_et_event
    TABLES
      t_outtab                          = p_int_tbl
   EXCEPTIONS
     program_error                     = 1
     OTHERS                            = 2
            .
  IF sy-subrc &lt;&gt; 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

endform.                    " CALL_ALV_GRID


OuOutput









  • click on the material 5






2 comments:

  1. Hi,
    I wrote the program , but I received an error.
    "relational operator <> is not supported "
    Can you help me?

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

/*Newer Post*/ Older Post Home