Friday, September 7, 2018

ADDING STANDARD TOOLBAR IN OOALV

                                       ADDING STANDARD TOOLBAR IN OOALV

Normally ,when we output the alv in old abap , we have multiple feature like downloading , sorting, sending into excel file and many more.To use the same functionality in OOALV we need to use some classes. CL_SALV_FUNCTIONS_LIST.
 and create a reference object for this and get 2 methods:
                                                       GET_FUNCTIONS).
                           
                           SET_ALLABAP_TRUE ).

Factory pattern is used when we have a super class with multiple sub-classes and, based on input, we need to return one of the sub-classes. This pattern removes the responsibility of instantiation of a class from the client program to the factory class.



*&---------------------------------------------------------------------*
*& Report  ZALVWITHTTOOLBAR
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZALVWITHTTOOLBAR.
TYPES:BEGIN OF  TY_MARA,
      MATNR TYPE MARA-MATNR,
      ERNAM TYPE MARA-ERNAM,
      END OF TY_MARA.

DATAIT_MARA TYPE TABLE OF TY_MARA.
SELECT MATNR
       ERNAM
       FROM MARA INTO TABLE IT_MARA UP TO 20 ROWS.

DATAOO_ALV TYPE REF TO CL_SALV_TABLE.

*TRY.
CALL METHOD CL_SALV_TABLE=>FACTORY
*  EXPORTING
*    LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
*    R_CONTAINER    =
*    CONTAINER_NAME =
  IMPORTING
    R_SALV_TABLE   OO_ALV
 CHANGING
    T_TABLE        IT_MARA
    .
* CATCH CX_SALV_MSG .
*ENDTRY.

DATALO_FUNCTION TYPE REF TO CL_SALV_FUNCTIONS_LIST.
LO_FUNCTION  OO_ALV->GET_FUNCTIONS).
LO_FUNCTION->SET_ALLABAP_TRUE ).
OO_ALV->DISPLAY).