Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

alv

Former Member
0 Likes
726

Hi,

Can anyone help me wid ALV with classes..

how to use it with some example??

Thanks in advance

Palak

1 ACCEPTED SOLUTION
Read only

ak_upadhyay
Contributor
0 Likes
675

Hi,

Here are a few classes used in ALV, just read through their documentation or look at how they've been implemented in your system and you'll get a good idea on how to use them:

CL_ALV_EVENT_DATA (Changing Data Container for Events)

CL_ALV_EVENT_TOOLBAR_SET (ALV Context menu)

CL_ALV_TABLE_CREATE (Dynamic Creation of ALV Data Table)

CL_ALV_TREE_BASE (Basis Class ALV Tree Control)

CL_CK_ALVTREE_NKEY_2_OBJECT (Converter Node Key Object)

CL_COST_COSTINGVERSION_ALV (Display Costing Versions)

CL_GUI_ALV_GRID (List Viewer)

CL_GUI_ALV_GRID_BASE (Basis Class for ALV grid)

CL_GUI_ALV_TREE (ALV Tree Control)

CL_GUI_ALV_TREE_SIMPLE (Simple ALV Tree)

Sample:


DATA: lcl_alv TYPE REF TO cl_gui_alv_grid,
      t_flights TYPE STANDARD TABLE OF FLIGHTS.

SELECT * FROM flights INTO TABLE t_flights.

CREATE OBJECT lcl_alv
    EXPORTING I_PARENT = cl_gui_container=>screen0.

CALL METHOD lcl_alv->set_table_for_first_display
    EXPORTING
       I_STRUCTURE_NAME = 'FLIGHTS'
    CHANGING
       IT_OUTTAB = t_flights.

CALL SCREEN 100.

Reward points if useful....

Regards

AK

5 REPLIES 5
Read only

Former Member
0 Likes
675

Hi,

Gothrough the sample programs starting with BCALV*.

Example program : BCALV_TABLE_CREATE

Read only

Former Member
0 Likes
675

Hi,

Class ALV Specification

Classes used:

CL_GUI_ALV_GRID

Example of ALV using Classes

DATA: lcl_alv TYPE REF TO cl_gui_alv_grid,

t_flights TYPE STANDARD TABLE OF FLIGHTS.

SELECT * FROM flights INTO TABLE t_flights.

CREATE OBJECT lcl_alv

EXPORTING I_PARENT = cl_gui_container=>screen0.

CALL METHOD lcl_alv->set_table_for_first_display

EXPORTING

I_STRUCTURE_NAME = 'FLIGHTS'

CHANGING

IT_OUTTAB = t_flights.

CALL SCREEN 100.

Example Details

This is a simple example of the class ALV, we do not need to create, in this case, a field catalog because we are using the whole table of FLIGHTS and we will show all the fields that this table contains, we do this at the I_STRUCTURE_NAME = 'FLIGHTS' statement.

The CL_GUI_ALV_GRID constructor needs the I_PARENT parameter to define where it will be show, in the example we set the entire screen to place the ALV.

regards,

sowjanyagosala

Read only

Former Member
0 Likes
675

Check these links out , if helpful award point

ALV OOPS Blog

/people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid

Simple ALV report

http://www.sapgenie.com/abap/controls/alvgrid.htm

http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox

ALV Interactive Reports

ALV Easy Reference Guide OOPS

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a41...

ALV

1. Please give me general info on ALV.

http://www.sapfans.com/forums/viewtopic.php?t=58286

http://www.sapfans.com/forums/viewtopic.php?t=76490

http://www.sapfans.com/forums/viewtopic.php?t=20591

http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.

2. How do I program double click in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=11601

http://www.sapfans.com/forums/viewtopic.php?t=23010

Check the program in the following link:

http://sap-img.com/abap/display-secondary-list-using-alv-grid.htm

3. How do I add subtotals (I have problem to add them)...

http://www.sapfans.com/forums/viewtopic.php?t=20386

http://www.sapfans.com/forums/viewtopic.php?t=85191

http://www.sapfans.com/forums/viewtopic.php?t=88401

http://www.sapfans.com/forums/viewtopic.php?t=17335

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm

4. How to add list heading like top-of-page in ABAP lists?

http://www.sapfans.com/forums/viewtopic.php?t=58775

http://www.sapfans.com/forums/viewtopic.php?t=60550

http://www.sapfans.com/forums/viewtopic.php?t=16629

5. How to print page number / total number of pages X/XX in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)

6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.

http://www.sapfans.com/forums/viewtopic.php?t=64320

http://www.sapfans.com/forums/viewtopic.php?t=44477

7. How can I set the cell color in ALV?

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/coloring%2ba%2brow%2band%2bcolumn%2bin%2...

8. How do I print a logo/graphics in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=81149

http://www.sapfans.com/forums/viewtopic.php?t=35498

http://www.sapfans.com/forums/viewtopic.php?t=5013

9. How do I create and use input-enabled fields in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=84933

http://www.sapfans.com/forums/viewtopic.php?t=69878

10. How can I use ALV for reports that are going to be run in background?

http://www.sapfans.com/forums/viewtopic.php?t=83243

http://www.sapfans.com/forums/viewtopic.php?t=19224

11. How can I display an icon in ALV? (Common requirement is traffic light icon).

http://www.sapfans.com/forums/viewtopic.php?t=79424

http://www.sapfans.com/forums/viewtopic.php?t=24512

12. How can I display a checkbox in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=88376

http://www.sapfans.com/forums/viewtopic.php?t=40968

http://www.sapfans.com/forums/viewtopic.php?t=6919

13. Top-of-page in ALV

14. ALV Group Heading

http://www.sap-img.com/fu037.htm

How to add list heading like top-of-page in ABAP lists?

http://www.sapfans.com/forums/viewtopic.php?t=58775

http://www.sapfans.com/forums/viewtopic.php?t=60550

http://www.sapfans.com/forums/viewtopic.php?t=16629

15. ALV output to PDF conversion

It has an example code for PDF Conversion.

http://www.erpgenie.com/abap/code/abap51.htm

Go thru these programs they may help u to try on some hands on

ALV Demo program

BCALV_DEMO_HTML

BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode

BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode

BCALV_GRID_DEMO Simple ALV Control Call Demo Program

BCALV_TREE_DEMO Demo for ALV tree control

BCALV_TREE_SIMPLE_DEMO

BC_ALV_DEMO_HTML_D0100

REgards.

Read only

ak_upadhyay
Contributor
0 Likes
676

Hi,

Here are a few classes used in ALV, just read through their documentation or look at how they've been implemented in your system and you'll get a good idea on how to use them:

CL_ALV_EVENT_DATA (Changing Data Container for Events)

CL_ALV_EVENT_TOOLBAR_SET (ALV Context menu)

CL_ALV_TABLE_CREATE (Dynamic Creation of ALV Data Table)

CL_ALV_TREE_BASE (Basis Class ALV Tree Control)

CL_CK_ALVTREE_NKEY_2_OBJECT (Converter Node Key Object)

CL_COST_COSTINGVERSION_ALV (Display Costing Versions)

CL_GUI_ALV_GRID (List Viewer)

CL_GUI_ALV_GRID_BASE (Basis Class for ALV grid)

CL_GUI_ALV_TREE (ALV Tree Control)

CL_GUI_ALV_TREE_SIMPLE (Simple ALV Tree)

Sample:


DATA: lcl_alv TYPE REF TO cl_gui_alv_grid,
      t_flights TYPE STANDARD TABLE OF FLIGHTS.

SELECT * FROM flights INTO TABLE t_flights.

CREATE OBJECT lcl_alv
    EXPORTING I_PARENT = cl_gui_container=>screen0.

CALL METHOD lcl_alv->set_table_for_first_display
    EXPORTING
       I_STRUCTURE_NAME = 'FLIGHTS'
    CHANGING
       IT_OUTTAB = t_flights.

CALL SCREEN 100.

Reward points if useful....

Regards

AK

Read only

Former Member
0 Likes
675

Hi,

see the examples here.

example1:


DATA:t_mara TYPE TABLE OF mara.
DATA:FCAT TYPE LVC_T_FCAT.

DATA:G_CONTAINER TYPE SCRFNAME VALUE 'TABC',"TABC is *container in screen 101
     GRID  TYPE REF TO CL_GUI_ALV_GRID,
     G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

set screen 101.

MODULE STATUS_0101 output.
  IF G_CUSTOM_CONTAINER IS INITIAL.
    CREATE OBJECT G_CUSTOM_CONTAINER   "CREATING OBJECT FOR CUSTOM CONTAINER
           EXPORTING CONTAINER_NAME = G_CONTAINER.
    CREATE OBJECT GRID    "CREATING GRID IN WRKBNCH SCREEN
           EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
        I_STRUCTURE_NAME = 'MARA'
      CHANGING
        CT_FIELDCAT      = FCAT[].

    SELECT * from mara into table t_mara.

    CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
      CHANGING
        IT_FIELDCATALOG = FCAT[]
        IT_OUTTAB       = t_MARA.
  ENDIF.
ENDMODULE.

flow logic of screen 101:


PROCESS BEFORE OUTPUT.
 MODULE STATUS_0101.

PROCESS AFTER INPUT.

***************************************************************************

example2:


DATA:G_DOCKING_CONTAINER_1 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
     g_grid TYPE REF TO CL_GUI_ALV_GRID.

DATA:itab like sflight occurs 0 with header line,
      okcode like sy-ucomm.

select * from sflight into table itab.

set screen 101.

MODULE STATUS_0101 OUTPUT.
  SET PF-STATUS 'MENU'.
  SET TITLEBAR 'TIT'.
  perform create_and_init_controls.
ENDMODULE.                 " STATUS_0101  OUTPUT


FORM create_and_init_controls .
  CREATE OBJECT G_DOCKING_CONTAINER_1
    EXPORTING
      REPID       = sy-repid
      DYNNR       = '101'
      SIDE        = cl_gui_docking_container=>DOCK_AT_top
      EXTENSION   = 100.

  CREATE OBJECT G_GRID
    EXPORTING
      I_PARENT          = G_DOCKING_CONTAINER_1.

  CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      I_STRUCTURE_NAME              = 'SFLIGHT'
    CHANGING
    IT_OUTTAB                     = itab[].
ENDFORM.                    " create_and_init_controls


MODULE user_command_0101 INPUT.
  CASE okcode.
    WHEN 'BACK'.
      SET SCREEN 0.
  ENDCASE.
ENDMODULE.                 " user_command_0101  INPUT

flow logic of screen 101:


PROCESS BEFORE OUTPUT.
 MODULE STATUS_0101.

PROCESS AFTER INPUT.
 MODULE user_command_0101.

rgds,

bharat.