Tuesday, May 7, 2013

All about ABAP List Viewer ( List Display, Grid Display, Using OOP)



ALV programming

Content:

Ø  Introduction
Ø  ALV List Display
Ø  ALV Grid Display
Ø  ALV Hierarchical Display
Ø  ALV using OOPs
Ø  Editing and coloring
Ø  Code snippets

Introduction:

ALV stands for ABAP List Viewer. The ABAP List Viewer standardizes and simplifies the use of lists and reports in the R/3 System. ALV provides a lot of inbuilt functions (like searching, sorting, printing filtering, totaling) to our reports that’s why it substantially decreases the report development time. ALV takes care of rendering the list and we can concentrate only on the data retrieval part.

Common Steps:
         - Data declarations
         - Fetch the required data form the tables
         - Prepare field catalog
         - Build up the event table if required
         - Display ALV output by Calling FM

All the definitions TYPES and STRUCTURES and CONSTANTS are defined in the TYPE-POOL ‘SLIS’, so it should be declared first.

ALV List Display:

      - Field catalog can be prepared manually (should contain at least TABNAME, FIELDNAME,    REF_TABNAME, SELTECT_M) or by using REUSE_ALV_FIELDCATALOG_MERGE.
    - To get all possible events REUSE_ALV_EVENTS_GET can be used.
    - To write proper comments use REUSE_ALV_COMMENTARY_WRITE.
    - To print the data REUSE_ALV_LIST_DISPLAY can be used.

ALV Grid Display:

    - The first 3 function modules mentioned above can be used and to print the data REUSE_ALV_GRID_DISPLAY is used.

Hierarchical ALV:

  -  Hierarchical display is used for displaying data that are related. Like sales order and item details.
  - REUSE_ALV_HIERSEQ_LIST_DISPLAY is used to print the data.

ALV Using OOPs:

- Create Docking/custom container.
- Create a grid inside container.
- Call function LVC_FIELDCATALOG_MERGE to get the field catalog.
- Call method SET_TABLE_FOR_FIRST_DISPLAY for o/p.


Editing and Coloring:


- Coloring an entire column

 To make an entire column be painted with the color you want, you can use  the "emphasize" option of the field catalog. Simply assign a color code to this field of the row added for your column. Color codes are constructed as follows:

Cxyz: - x: 1-7 (1 for example is gray-blue, 6 is red), y: intensified on/off, z: inverse on/off.

- Coloring an entire row

Coloring a row is a bit more complicated. To enable row coloring, you should add an additional field to your list data table. It should be of character type and at least 4 bit long. This field will contain the color code for the row. So for example:

DATA: BEGIN OF gt_list occurs 0.
INCLUDE STRUCTURE .
DATA rowcolor(4) TYPE c.
DATA: END OF gt_list.

As you guess, you should fill the color code to this field. Its format is as explained before. For second you must pass the name of the field to the layout structure:
E.g. ps_layout-info_fname = 'ROWCOLOR'.
- Coloring an individual cell: 
Likely coloring rows, you must append an internal table to each line of gt_list containing the color information:
DATA: BEGIN OF gt_list occurs 0.
INCLUDE STRUCTURE .
DATA cellcolors TYPE lvc_t_scol.
DATA: END OF gt_list.

If you want to modify the cell in the 5 row and the 2 column, you have to set:

DATA: cellcolor type line of lvc_t_scol.
READ TABLE gt_list INDEX 2.
cellcolor-fname = '.
cellcolor-color-col = '6'.
cellcolor-color-int = '0'.
APPEND cellcolor TO gt_list-cellcolors.
Modify GT_LIST INDEX 5. 
As like coloring rows, you have to pass the info for coloring cell to the layout-structure:
ps_layout-info_ctab_fname = 'CELLCOLOR'.

- Editing an entire column:

When you want to do edit only for particular column and not for the entire grid then you need to perform fieldcat in that particular column only. Loop the field catalog and for that column make the EDIT field of catalog as ‘X’ and then modify catalog.

- Editing a single cell:
Add a table to your list data table.

Data begin of gt_grid occurs 0.
data cellstyles type lvc_t_styl.
Data end of gt_grid.
Form make_field_edit using pt_grid like gt_grid[].
data: ls_grid like line of pt_grid,
ls_style type lvc_s_styl,
lt_style type lvc_t_styl.Loop at pt_grid into ls_grid.
If ls_grid-curr = xyz. 'your condition for the row
ls_style-fieldname = 'CURR'.
ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
append ls_style to lt_style.
endif.


Insert lines of lt_style into ls_grid-celltyles.
modify pt_grid from ls_grid.

Endloop.
Endform.

Code Snippet for ALV List Display, Grid Display and Using OOP.

Link : http://www.scribd.com/doc/139934961/ABAP-ALV-Programming

ABAP ALV Programming by Debesh Swain


14 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
    Informatica Training In Chennai
    Hadoop Training In Chennai
    Oracle Training In Chennai
    SAS Training In Chennai

    ReplyDelete
  5. Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
    angularjs interview questions and answers

    angularjs Training in bangalore

    angularjs Training in bangalore

    angularjs Training in chennai

    automation anywhere online Training

    ReplyDelete
  6. Well researched article and I appreciate this. The blog is subscribed and will see new topics soon.
    online Python training
    python training in chennai

    ReplyDelete
  7. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information.

    rpa training in chennai
    rpa training in bangalore
    rpa course in bangalore
    best rpa training in bangalore
    rpa online training

    ReplyDelete
  8. wonderful opportunity is created by you

    BEST ANGULAR JS TRAINING IN CHENNAI WITH PLACEMENT

    https://www.acte.in/angular-js-training-in-chennai
    https://www.acte.in/angular-js-training-in-annanagar
    https://www.acte.in/angular-js-training-in-omr
    https://www.acte.in/angular-js-training-in-porur
    https://www.acte.in/angular-js-training-in-tambaram
    https://www.acte.in/angular-js-training-in-velachery

    ReplyDelete
  9. Thanks for the great post on your blog, it really gives me an insight on this topic.I must thank you for this informative ideas. I hope you will post again soon.
    Angular js Training in Chennai

    Angular js Training in Velachery

    Angular js Training in Tambaram

    Angular js Training in Porur

    Angular js Training in Omr

    Angular js Training in Annanagar

    ReplyDelete
  10. Thanks for the great post on your blog, it really gives me an insight on this topic.I must thank you for this informative ideas. I hope you will post again soon.
    IELTS Coaching in chennai

    German Classes in Chennai

    GRE Coaching Classes in Chennai

    TOEFL Coaching in Chennai

    Spoken english classes in chennai | Communication training

    ReplyDelete