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

Reg:ALV OUTPUT

Former Member
0 Likes
483

Dear Experts,

i thank this community for helping me so far.I need your help on these issues.

1.Am displaying a list on ALV Grid. i have a header and a footer...

Header

Dia1

__________________________

list a b c d

e f g h

__________________________

footer

both header and footer are being displayed on top-of-page and end-of-page....i have passed the end-of -page event for footer at end-of-list form name....

but i need the footer to get displayed on the Grid Container itself..

Header

Dia

__________________________

list a b c d

e f g h

footer

_______________________

can it be possible.?..i mean to say that at the end of the last record ..i have to display the footer and not at the end of the page...i have checked so many threads..followd the same concept and code..but it shows only the end -of-page and not the footer at end-of-list...

2. if so the output is displayed as in dia1....i need to download to excel..when i click on excel on ALV grid...it shows me the excel sheet with header and list sheets..but the footer is not being carried onto the excel sheet..any option to be checked?

Helpful Answers higly appreciated,

regards,

sampath

Dear Experts,

i thank this community for helping me so far.I need your help on these issues.

1.Am displaying a list on ALV Grid. i have a header and a footer...

Header

Dia1

__________________________

list a b c d

e f g h

__________________________

footer

both header and footer are being displayed on top-of-page and end-of-page....i have passed the end-of -page event for footer at end-of-list form name....

but i need the footer to get displayed on the Grid Container itself..

Header

Dia

__________________________

list a b c d

e f g h

footer

_______________________

can it be possible.?..i mean to say that at the end of the last record ..i have to display the footer and not at the end of the page...i have checked so many threads..followd the same concept and code..but it shows only the end -of-page and not the footer at end-of-list...

2. if so the output is displayed as in dia1....i need to download to excel..when i click on excel on ALV grid...it shows me the excel sheet with header and list sheets..but the footer is not being carried onto the excel sheet..any option to be checked?

Helpful Answers higly appreciated,

regards,

sampath

3 REPLIES 3
Read only

Former Member
0 Likes
454

there are different options in the parameter I_GRID_SETTINGS of function module

REUSE_ALV_GRID_DISPLAY....

try for Print end of list only.....

I hope it will work..

Read only

0 Likes
454

Thanks sumeet,

i passed the same for gs_grid and still doesnt work..

my issue:

header

_________________

grid display

-


-


-


at last record....i shud print a statement...

_____________________________

footer....

i tried using end-of-list for this..but it doesnt work...can we write some statements after the last line of alv grid?

Read only

0 Likes
454

try using following examples::

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

code

DATA: gr_table TYPE REF TO cl_salv_table,

gr_functions TYPE REF TO cl_salv_functions, "#EC *

gr_columns TYPE REF TO cl_salv_columns_table,

gr_column TYPE REF TO cl_salv_column_table,

alv_exc TYPE REF TO cx_salv_msg,

gr_events TYPE REF TO cl_salv_events,

lr_events TYPE REF TO lcl_handler,

gr_display TYPE REF TO cl_salv_display_settings,

gr_content TYPE REF TO cl_salv_form_element.

DATA: lr_header TYPE REF TO cl_salv_form_header_info,

l_text TYPE string.

// Build ALV:

TRY.

cl_salv_table=>factory( IMPORTING r_salv_table = gr_table

CHANGING t_table = outtab[] ).

CATCH cx_salv_msg INTO alv_exc.

err_txt = alv_exc->get_text( ).

MESSAGE e398(00) WITH err_txt. "#EC *

ENDTRY.

// Set Status

gr_table->set_screen_status(

report = sy-repid

pfstatus = 'SALV_STANDARD'

set_functions = gr_table->c_functions_all ).

// Get Layout

gr_display = gr_table->get_display_settings( ).

gr_display->set_striped_pattern( cl_salv_display_settings=>true ).

IF test IS INITIAL.

gr_display->set_list_header( text-m01 ).

ELSE.

gr_display->set_list_header( text-m02 ).

ENDIF.

// Get Columns

gr_columns = gr_table->get_columns( ).

gr_columns->set_optimize( abap_true ).

TRY.

gr_column ?= gr_columns->get_column( 'JOBNOTES' ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

// Set columns text

gr_column->set_medium_text( 'Note Job' ). "#EC NOTEXT

gr_column->set_long_text( 'Note Job' ). "#EC NOTEXT

gr_column->set_short_text( 'Note Job' ). "#EC NOTEXT

ENDTRY.

color-col = 5.

color-inv = 0.

color-int = 0.

gr_column->set_color( color ).

// Try to build a nice header:

PERFORM build_header CHANGING gr_content.

gr_table->set_top_of_list( gr_content ).

// Build Footer

l_text = text-i98.

lines_read = LINES( outtab ).

WRITE lines_read TO lines_n NO-ZERO.

REPLACE '&1' WITH lines_n INTO l_text.

// Number of CID

lines_read = LINES( pernr_tab ).

WRITE lines_read TO lines_n NO-ZERO.

REPLACE '&2' WITH lines_n INTO l_text.

CREATE OBJECT lr_header

EXPORTING

text = l_text

tooltip = l_text.

gr_content = lr_header.

gr_table->set_end_of_list( gr_content ).

// Display Grid

gr_table->display( ).

// Here's the code for the header:

&----


*& Form build_header

&----


text

-


FORM build_header CHANGING pr_content TYPE REF TO cl_salv_form_element.

DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid,

lr_grid_1 TYPE REF TO cl_salv_form_layout_grid,

lr_label TYPE REF TO cl_salv_form_label,

lr_text TYPE REF TO cl_salv_form_text,

l_text TYPE string.

// Creates the main grid

CREATE OBJECT lr_grid.

// Create the main header

l_text = text-i99.

lr_grid->create_header_information( row = 1

column = 1

text = l_text

tooltip = l_text ).

lr_grid->add_row( ).

lr_grid->add_row( ).

// Into this, build an another little grid:

lr_grid_1 = lr_grid->create_grid( row = 3

column = 1 ).

// On the left of the grid, create a label

l_text = text-f00. "File di backup PTEXDIR creato

lr_label = lr_grid_1->create_label( row = 1

column = 1

text = l_text

tooltip = l_text ).

// Then create a text

IF test IS INITIAL.

l_text = dir_backup_filename.

ELSE.

l_text = text-f02.

ENDIF.

lr_text =

lr_grid_1->create_text( row = 1

column = 2

text = l_text

tooltip = 'Backup file' ). "#EC NOTEXT

// Bind label and text togheter

lr_label->set_label_for( lr_text ).

// Do it again!

l_text = text-f01. "File di backup PTEX2000 creato

lr_label = lr_grid_1->create_label( row = 2

column = 1

text = l_text

tooltip = l_text ).

IF test IS INITIAL.

l_text = 2k_backup_filename.

ELSE.

l_text = text-f02.

ENDIF.

lr_text =

lr_grid_1->create_text( row = 2

column = 2

text = l_text

tooltip = 'Backup file' ). "#EC NOTEXT

lr_label->set_label_for( lr_text ).

// The content is the top grid

pr_content = lr_grid.

ENDFORM. " build_header

[/code]

This works in printing, because the screen is not divided into different sections.

Hope this helps,

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

secondly there is a sample code in SAP wiki...

try following link..

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abapObjects-ALVModel-UsingHeaderand+Footer&