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

object

Former Member
0 Likes
432

HI all

For Practice please help me step by step ALV Grids.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
417

hi,

We can use ABAP ALV LIST and GRID function modules to display Normal LIST and Hiearchical LISTS .

All the definitions TYPES and STRUCTURES and CONSTANTS are defined

in the TYPE-POOL 'SLIS' ,so it should be declared first.

TYPE-POOLS : 'SLIS' .

To display ALV LISTS the function module used are :

REUSE_ALV_LIST_DISPLAY "For Normal LIST

REUSE_ALV_HIERARCHICAL_LIST_DISPLAY "For Hierarchical LIST

To display ALV GRID the function module used are :

REUSE_ALV_GRID_DISPLAY . "For GRID display

The most important component of the ALV is the FIELDCATALOG which is of

TYPE SLIS_T_FIEDLCAT_ALV

or of

TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV .

The line items of the field catalog are of

TYPE SLIS_FIELDCAT_ALV .

FIELDCATALOG

To prepare field catalog certain fields are essential .There are various other fields allowing for vaarious possibilities and display options.

TABNAME

FIELDNAME

REF_TABNAME

SELTECT_M

e.g.

DATA: WS_FCAT TYPE SLIS_FIELDCAT_ALV . "LINE ITEM OF FCAT

DATA: IN_FCAT TYPE SLIS_T_FIELDCAT_ALV.

WS_FCAT-TABNAME = 'MARA'.

WS_FCAT-FIELDNAME = 'MATNR'.

WS_FCAT-SELTEXT_M = 'Material Number'.

APPEND WS_FCAT TO IN_FCAT .

CLEAR WS_FCAT.

WS_FCAT-TABNAME = 'MAKT'.

WS_FCAT-FIELDNAME = 'MAKTX'.

WS_FCAT-SELTEXT_M = 'Material Description'.

APPEND WS_FCAT TO IN_FCAT .

This will create fieldcatalog with two columns for displaying material and material description .

RESUSE_ALV_LIST_DISPLAY.

The following FM is used to display the data in the internal table in the form of ALV

LIST. The Event table is only required if event handling is being done.

CALL FUNCTION 'RESUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID "of TYPE SY-REPID and

" value SY-REPID

IS_LAYOUT = W_LAYOUT "of TYPE SLIS_LAYOUT_ALV

IT_FIELDCAT = IN_FCAT "of TYPE SLIS_T_FIELDCAT_ALV

I_SAVE = W_SAVE "of TYPE C ,values A ,U ,' '

IT_EVENTS = IN_EVENTS " of TYPE SLIS_T_EVENT

TABLES

T_OUTTAB = IN_DATA "internal table conatining data

"corresponding to IN_FCAT

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

IF SY-SUBRC NE 0.

MESSAGE ENNN .

ENDIF.

REUSE_ALV_EVENTS_GET.

This FM is used to get the default event table of the ALV LIST DISPLAY.

The IN_EVENTS internal table is of TYPE SLIS_T_EVENT. This table contains

all the events wrapped up in the ALV LIST or ALV GRID and consistsof two fields

NAME and FORM .The NAME corresponds to names of the events like TOP_OF_PAGE and END_OF_PAGE ,USER_COMMAND and FORM will contain the name of the FORM ROUTINE that will be called dynamically through callback mechanism when the particular event will fire and is initial for all events bt default and has to be filled for

events for which handling is required.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = IN_EVENTS[].

e.g.

DATA: W_EVENT TYPE SLSI_ALV_EVENT "LINE ITEM OF EVENT TABLE

DATA: IN_EVENTS TYPE SLSI_T_EVENT . "Internal table containing events

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = IN_EVENTS[].

RTEAD TABLE IN_EVENTS WITH KEY NAME = 'TOP_OG_PAGE'

INTO W_EVENT.

IF SY-SUBRC EQ 0.

MOVE 'F3000_TOP_OF_PAGE' TO W_EVENT -FORM.

MODIFY IN_EVENTS FROM W_EVENT INDEX SY-TABIX.

ENDIF.

Here the FORM ROUTINE 'F3000_TOP_OF_PAGE' is being set up for the

event TOP_OF_PAGE which will fire when the ALV LIST will be displayed ,This form

will be called dynamically by th ALV LIST display during top_of_page event and for this the modified Events internal table has to be passed to the FM 'REUSE_ALV_LIST_DISPLAY' in the exporting parameter IT_EVENTS. Failing this the form '3000_TOP_OF_PAGE' will not be called . This event is used for placing heading information like Current date and time and the name of the report.

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

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

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?

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

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

Link for OOPS alv.

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-7%2bsteps%2bto%2bcreate%2boops%2bal...

Hope this is helpful, Do reward.

2 REPLIES 2
Read only

Former Member
0 Likes
417

hi

i thing this will help u.

Using a selection screen, read the value of material type. (MARA-MTART)

Create an ALV on another screen in the same module pool program and display 100 records.

Display only the following fields:

Material number (MARA-MATNR)

Material Group (MARA-MATKL)

Material Description (MAKT-MAKTX)

Create GUI status for proper navigation.

ALV Grids:

The ALV Grid control is a flexible tool for displaying lists. The tool provides common list operations as generic functions and can be enhanced by self-defined options.

The ALV Grid control is used to build non-hierarchical, interactive, and modern-design lists. As a control, it is a component that is installed on the local PC.

Step 1: In Screen Painter: Create a screen with a custom control object on it and

Give the custom control a name (e.g. CC_ALV)

Step 2: In Screen logic: Create TYPE REF’s to cl_gui_custom_container and

cl_gui_alv_grid

DATA:

container TYPE REF TO cl_gui_custom_container,

grid TYPE REF TO cl_gui_alv_grid.

Step 3: In PBO of screen: create objects for the above 2 reference variables

IF container IS INITIAL.

CREATE OBJECT container

EXPORTING container_name = ' CC_ALV '.

ELSE .

CALL METHOD grid->refresh_table_display

ENDIF.

CREATE OBJECT grid

EXPORTING i_parent = container.

Step 4: In PBO of screen or start-of-selection:

-Create an internal table having structure same as what you want to display

-Populate internal table with data to be displayed

Step 5: In PBO of screen: Transfer data to the grid

CALL METHOD grid->set_table_for_first_display

EXPORTING

i_structure_name = '‘ “structure name

CHANGING

it_outtab = . “internal table name

Step 6: Before LEAVE PROGRAM: Free the container

call method custom_container1->free.

call method cl_gui_cfw=>flush.

*ITAB & W.A FOR FIELDCATLOG

DATA ITAB_FCAT TYPE LVC_T_FCAT.

DATA WA_FCAT LIKE LINE OF itab_fcat.

*POPULATE ITAB

WA_FCAT-FIELDNAME = ‘CTYPE'.

WA_FCAT-REF_FIELD = 'CUSTTYPE' . “Database field name

WA_FCAT-REF_TABLE = 'SBOOK'. “Database table name

WA_FCAT-COL_POS = 27.

APPEND WA_FCAT TO ITAB_FCAT.

*Call method “set_table_for_first_display”, passing the name of the field catalog

CALL METHOD grid->set_table_for_first_display

EXPORTING

I_STRUCTURE_NAME = 'SBOOK'

CHANGING

IT_OUTTAB = ITAB

IT_FIELDCATALOG = ITAB_FCAT.

Read only

Former Member
0 Likes
418

hi,

We can use ABAP ALV LIST and GRID function modules to display Normal LIST and Hiearchical LISTS .

All the definitions TYPES and STRUCTURES and CONSTANTS are defined

in the TYPE-POOL 'SLIS' ,so it should be declared first.

TYPE-POOLS : 'SLIS' .

To display ALV LISTS the function module used are :

REUSE_ALV_LIST_DISPLAY "For Normal LIST

REUSE_ALV_HIERARCHICAL_LIST_DISPLAY "For Hierarchical LIST

To display ALV GRID the function module used are :

REUSE_ALV_GRID_DISPLAY . "For GRID display

The most important component of the ALV is the FIELDCATALOG which is of

TYPE SLIS_T_FIEDLCAT_ALV

or of

TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV .

The line items of the field catalog are of

TYPE SLIS_FIELDCAT_ALV .

FIELDCATALOG

To prepare field catalog certain fields are essential .There are various other fields allowing for vaarious possibilities and display options.

TABNAME

FIELDNAME

REF_TABNAME

SELTECT_M

e.g.

DATA: WS_FCAT TYPE SLIS_FIELDCAT_ALV . "LINE ITEM OF FCAT

DATA: IN_FCAT TYPE SLIS_T_FIELDCAT_ALV.

WS_FCAT-TABNAME = 'MARA'.

WS_FCAT-FIELDNAME = 'MATNR'.

WS_FCAT-SELTEXT_M = 'Material Number'.

APPEND WS_FCAT TO IN_FCAT .

CLEAR WS_FCAT.

WS_FCAT-TABNAME = 'MAKT'.

WS_FCAT-FIELDNAME = 'MAKTX'.

WS_FCAT-SELTEXT_M = 'Material Description'.

APPEND WS_FCAT TO IN_FCAT .

This will create fieldcatalog with two columns for displaying material and material description .

RESUSE_ALV_LIST_DISPLAY.

The following FM is used to display the data in the internal table in the form of ALV

LIST. The Event table is only required if event handling is being done.

CALL FUNCTION 'RESUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID "of TYPE SY-REPID and

" value SY-REPID

IS_LAYOUT = W_LAYOUT "of TYPE SLIS_LAYOUT_ALV

IT_FIELDCAT = IN_FCAT "of TYPE SLIS_T_FIELDCAT_ALV

I_SAVE = W_SAVE "of TYPE C ,values A ,U ,' '

IT_EVENTS = IN_EVENTS " of TYPE SLIS_T_EVENT

TABLES

T_OUTTAB = IN_DATA "internal table conatining data

"corresponding to IN_FCAT

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

IF SY-SUBRC NE 0.

MESSAGE ENNN .

ENDIF.

REUSE_ALV_EVENTS_GET.

This FM is used to get the default event table of the ALV LIST DISPLAY.

The IN_EVENTS internal table is of TYPE SLIS_T_EVENT. This table contains

all the events wrapped up in the ALV LIST or ALV GRID and consistsof two fields

NAME and FORM .The NAME corresponds to names of the events like TOP_OF_PAGE and END_OF_PAGE ,USER_COMMAND and FORM will contain the name of the FORM ROUTINE that will be called dynamically through callback mechanism when the particular event will fire and is initial for all events bt default and has to be filled for

events for which handling is required.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = IN_EVENTS[].

e.g.

DATA: W_EVENT TYPE SLSI_ALV_EVENT "LINE ITEM OF EVENT TABLE

DATA: IN_EVENTS TYPE SLSI_T_EVENT . "Internal table containing events

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = IN_EVENTS[].

RTEAD TABLE IN_EVENTS WITH KEY NAME = 'TOP_OG_PAGE'

INTO W_EVENT.

IF SY-SUBRC EQ 0.

MOVE 'F3000_TOP_OF_PAGE' TO W_EVENT -FORM.

MODIFY IN_EVENTS FROM W_EVENT INDEX SY-TABIX.

ENDIF.

Here the FORM ROUTINE 'F3000_TOP_OF_PAGE' is being set up for the

event TOP_OF_PAGE which will fire when the ALV LIST will be displayed ,This form

will be called dynamically by th ALV LIST display during top_of_page event and for this the modified Events internal table has to be passed to the FM 'REUSE_ALV_LIST_DISPLAY' in the exporting parameter IT_EVENTS. Failing this the form '3000_TOP_OF_PAGE' will not be called . This event is used for placing heading information like Current date and time and the name of the report.

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

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

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?

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

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

Link for OOPS alv.

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-7%2bsteps%2bto%2bcreate%2boops%2bal...

Hope this is helpful, Do reward.