Application Development 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: 

ALV GRID FUNCTIONS

Former Member
0 Kudos
1,139

Hi Everyone,

I have 4-5 grids on my screen and a common custom toolbar for all of the grids. The toolbar has buttons like print, find, details, export etc. Based on the focus on which grid I will have to implement the above toolbar functionality.

After figuring out on which grid the focus was present, when the user clicked on the toolbar button. I would like to know how to implement print, find, details, export functions. Are there any grid related function modules which I can call to implement these functions.

Sample codes will be highly appreciated.

Thanks in advance,

Prabhakar.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
351

Hi Prabhakaran,

Standard SAP toolbar has the Print/Find buttons that will work for you.

Print, Find are functions that are handled by the standard SAP, if you dont handle it yourself.

Did u try giving it a func code and letting SAP handle it ?

Rgds,

Prashanth.

10 REPLIES 10

Former Member
0 Kudos
352

Hi Prabhakaran,

Standard SAP toolbar has the Print/Find buttons that will work for you.

Print, Find are functions that are handled by the standard SAP, if you dont handle it yourself.

Did u try giving it a func code and letting SAP handle it ?

Rgds,

Prashanth.

0 Kudos
351

Hi Prashanth,

I tried giving a function code but it doesn't work. It gives an error saying "this function is not possible". Since the focus is on a ALV grid, SAP doesn't know how to print it. Do u have any sample code.

Thanks,

Prabhakar.

Former Member
0 Kudos
351

Hi,

Here is a Sample Code,

DATA: G_REPID LIKE SY-REPID,

GS_PRINT TYPE SLIS_PRINT_ALV.

  • Print Parameters

PARAMETERS:

P_PRINT AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE

P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO

P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE

P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE

P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO

P_RESERV TYPE I. "NO OF FOOTER LINE

INITIALIZATION.

G_REPID = SY-REPID.

PERFORM PRINT_BUILD USING GS_PRINT. "Print PARAMETERS

  • ABAP List Viewer

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = G_REPID

I_STRUCTURE_NAME = 'ITAB1'

IS_LAYOUT = GS_LAYOUT

IT_FIELDCAT = GT_FIELDCAT[]

IT_SORT = GT_SORT[]

IT_EVENTS = GT_EVENTS[]

  • IT_EVENT_EXIT =

IS_PRINT = GS_PRINT.

  • PRINT SETTINGS

FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.

LS_PRINT-PRINT = P_PRINT. "PRINT IMMEDIATE

LS_PRINT-NO_PRINT_SELINFOS = P_NOSINF. "NO SELECTION INFO

LS_PRINT-NO_COVERPAGE = P_NOCOVE. "NO COVER PAGE

LS_PRINT-NO_NEW_PAGE = P_NONEWP.

LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO

LS_PRINT-RESERVE_LINES = P_RESERV.

ENDFORM.

Also Check this link,

http://www.sap-basis-abap.com/sapalv.htm

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

Hope it helps u.

Thanks&Regards,

Ruthra.R

0 Kudos
351

you need to build a commn toolbar using class CL_GUI_TOOLBAR and from these button you can trigger the events of the grids.

Regards

Raja

0 Kudos
351

Hi All,

I'm using object oriented implementation for alv grid. I want to print the contents of the grid as a list. Are there any methods to call the implement the print function. Here is the sample of how my code looks like,

create object alv_container

exporting container_name = 'ALV_CONTAINER'.

  • create Event Receiver

create object event_receiver.

create object alv_grid

exporting i_parent = alv_container.

gs_layout-grid_title = 'Flights'.

  • gs_layout-keyhot = 'X'.

clear fieldcat. refresh: fieldcat.

clear: ls_fcat.

ls_fcat-reptext = 'Carriage Number'.

ls_fcat-coltext = 'Carriage Number'.

ls_fcat-fieldname = 'CARRID'.

ls_fcat-ref_table = 'IALV'.

ls_fcat-hotspot = 'X'.

ls_fcat-outputlen = '10'.

ls_fcat-col_pos = 1.

append ls_fcat to fieldcat.

clear: ls_fcat.

ls_fcat-reptext = 'Flight Description'.

ls_fcat-coltext = 'Flight Description'.

ls_fcat-fieldname = 'CONNID'.

ls_fcat-ref_table = 'IALV'.

ls_fcat-hotspot = 'X'.

ls_fcat-outputlen = '20'.

ls_fcat-col_pos = 2.

append ls_fcat to fieldcat.

call method alv_grid->set_table_for_first_display

exporting

is_layout = gs_layout

changing

it_outtab = ialv[]

it_fieldcatalog = fieldcat[].

  • handler for ALV grid

set handler event_receiver->handle_hotspot_click for alv_grid.

Thanks,

Prabhakar.

0 Kudos
351

check this program to find how you can manage the grid toolbar button click event from outside.

BCALV_TEST_GRID_TOOLBAR

Regards

Raja

Former Member
0 Kudos
351

Hi prabhakaran,

this might help you

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

regards,

venu

Former Member
0 Kudos
351

Hi,

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

REUSE_ALV_LIST_DISPLAY

REUSE_ALV_HIERARCHICAL_LIST_DISPLAY

REUSE_ALV_GRID_DISPLAY

TYPE SLIS_T_FIEDLCAT_ALV

These are the function modules are used

If you want code on alv grid functions then follow this site

http://sap.niraj.tripod.com/id66.html

it will helpful for you.

Clemenss
Active Contributor
0 Kudos
351

Hi Prabhakaran,

clicking on your common custom toolbar will set the focus on this toolbar. You will not know where it was before, at least I do not know such a thing as focus history.

By the way, how do you display the four grids and how do you display them without toolbar?

Regards,

Clemens

Former Member
0 Kudos
351

Once again, check the date of the OP.

Rob