Thursday, July 2, 2015

SAP ABAP ALV

There are total four types of views, based on the way in which the view is implemented and the methods that are permitted for accessing the view data. They are - Database Views, Projection Views, Maintenance Views, and Helps Views,.


Among these four types of database views, only 'Database Views' implements INNER JOIN, rest all implements an OUTER JOIN. The detail description of each views has been discussed further below.

- Database View (SE11)

Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.

- Help View ( SE54)

Help views are used to output additional information when the online help system is called.

When the F4 button is pressed for a screen field, a check is first made on whether a matchcode is defined for this field. If this is not the case, the help view is displayed in which the check table of the field is the primary table. Thus, for each table no more than one help view can be created, that is, a table can only be primary table in at most one help view.

 - Projection View

Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed.

A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.

- Maintenance View ( SE54 )

Maintenance views enable a business-oriented approach to looking at data, while at the same time, making it possible to maintain the data involved. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is, the data is entered via the view and then distributed to the underlying tables by the system.
========================================================================
ABAP Reports:
classical and interactive:
- SY-LSIND - list number from 0 to 21.
- SY-lisel - contains data of selcted line.
- Interactive report events:

  1. At line selection
  2. AT user command 
  3. AT PFn
  4. TOP-OF-PAGE during line selection

ABAP Report Types
ABAP report types are those ones available in some report's attributes screen, i.e. :
Executable program
Function group (containing function modules)
Include
Interface pool
Class pool
Module pool
Subroutine pool
=======================================================================

========================================================================

ABAP List Viewer :
Also ALV means ABAP List Viewer. Most convenient way to use it is through reuse library (cf. transaction se83) available from release 4.6 of SAP R/3.
ALV is available in two modes: list and grid. List mode is good old list processing with standard functionnalities, and grid mode is using a new OCX object displaying grids 

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM       = 'Prog.name'
            I_STRUCTURE_NAME         = 'I_ITAB'
            I_DEFAULT                = 'X'
            I_SAVE                   = 'A'
       TABLES
            T_OUTTAB                 = I_ITAB.
  IF SY-SUBRC <> 0.
    WRITE: 'SY-SUBRC: ', SY-SUBRC .
  ENDIF.

- FM REUSE_ALV_COMMENTRY_WRITE to add logo in your report output.
- you can first upload image in tcode OAER.

- REFRESH_TABLE_DISPLAY to refresh the alv grid.
- I_SOFT_REFRESH , used to display only Icons.
========================================================================

SALV:

        CALL METHOD CL_SALV_TABLE=>FACTORY
          IMPORTING
            R_SALV_TABLE = O_ALV
          CHANGING
            T_TABLE      = T_MARA.
      CATCH CX_SALV_MSG INTO LC_MSG .
    
* Calling Set PF status method
    CALL METHOD SET_PF_STATUS
      CHANGING
        CO_ALV = O_ALV.       "set_end_of_page
* Calling the top of page method
    CALL METHOD SET_TOP_OF_PAGE
      CHANGING
        CO_ALV = O_ALV.
* Calling the End of page method
    CALL METHOD SET_END_OF_PAGE
      CHANGING
        CO_ALV = O_ALV.
************************************************************************
* Displaying the ALV
* Here we will call the DISPLAY method to get the output on the screen
************************************************************************
    O_ALV->DISPLAY( ).

 METHOD SET_TOP_OF_PAGE.
    DATA: LO_HEADER TYPE REF TO CL_SALV_FORM_LAYOUT_GRID,
          LO_H_LABEL TYPE REF TO CL_SALV_FORM_LABEL,
          LO_H_FLOW  TYPE REF TO CL_SALV_FORM_LAYOUT_FLOW.

========================================================================
Reuse_ALV_GRID:
ALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program          = sy-repid
        i_callback_top_of_page      = 'TOP-OF-PAGE' "see FORM
        i_callback_html_end_of_list = 'END_OF_LIST_HTML' "see FORM

*       is_layout                   = gd_layout
        it_fieldcat                 = li_fcat[]
        i_save                      = 'X'
      TABLES
        t_outtab                    = li_mara
      EXCEPTIONS
        program_error               = 1
        OTHERS                      2.
========================================================================
SPILIT Container :

  1. Create a custom container for  cl_gui_custom_container.
  2. Create O_DD_DOC for CL_DD_DOCUMENT.
  3. Create split container for CL_GUI_SPLITTER_CONTAINER for 2 rows and 1 column.
  4. create 2 containers for CL_GUI_CONTAINER.
  5. Assign first part of ( row 1 ) to container 1.
  6. Assign part 2 to container 2.
  7. Create a grid for container 2 for CL_GUI_ALV_GRID.
  8. Then create a local class and method for TOP_OF_PAGE event of grid.
  9. do set handler and rise event,
  10. ADD_TEXTADD_PICTUREADD_GAP, etc. ADD_TEXT is used to add the text and also you can specify the color,font size,font type.