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
771

hi to all experts.

i have alv report.

in this how can i giving grant total , top of page , end of page.

and page no.

thanks in advance and reward also.

regard :deep.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
740

Hi,

This example shows the use of the method GET_SUBTOTALS.

report zkiran_0006.

tables: mara.

type-pools: slis, icon.

  • Internal Tables

data: begin of ialv occurs 0,

matnr type mara-matnr,

maktx type makt-maktx,

brgew type mara-brgew,

end of ialv .

data: alv_container type ref to cl_gui_custom_container,

alv_grid type ref to cl_gui_alv_grid,

ok_code like sy-ucomm,

layout type lvc_s_layo,

fieldcat type lvc_t_fcat.

select-options: s_matnr for mara-matnr.

start-of-selection.

perform get_data.

call screen 100.

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

  • Module status_0100 OUTPUT

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

module status_0100 output.

set pf-status '0100'.

set titlebar '0100'.

data: variant type disvariant.

variant-report = sy-repid.

variant-username = sy-uname.

  • Create Controls

create object alv_container

exporting container_name = 'ALV_CONTAINER'.

create object alv_grid

exporting i_parent = alv_container.

  • Populate Field Catalog

perform get_fieldcatalog.

call method alv_grid->set_table_for_first_display

exporting

is_layout = layout

is_variant = variant

i_save = 'U'

i_structure_name = 'IALV'

changing

it_outtab = ialv[]

it_fieldcatalog = fieldcat[].

endmodule.

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

  • Module USER_COMMAND_0100 INPUT

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

module user_command_0100 input.

case sy-ucomm.

when 'BACK' or 'CANC'.

perform free_containers.

if sy-subrc = 0.

set screen 0.

leave screen.

else.

leave program.

endif.

when 'EXIT'.

perform free_containers.

leave program.

when 'ENTER'.

data: grandtots type ref to data.

call method alv_grid->get_subtotals

importing

ep_collect00 = grandtots

  • EP_COLLECT01 =

  • EP_COLLECT02 =

  • EP_COLLECT03 =

  • EP_COLLECT04 =

  • EP_COLLECT05 =

  • EP_COLLECT06 =

  • EP_COLLECT07 =

  • EP_COLLECT08 =

  • EP_COLLECT09 =

  • ET_GROUPLEVELS =

.

check sy-subrc = 0.

endcase.

endmodule.

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

  • FORM GET_DATA.

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

form get_data.

select maramatnr marabrgew makt~maktx

into corresponding fields of table ialv

from mara

inner join makt

on maramatnr = maktmatnr

where mara~matnr in s_matnr

and makt~spras = sy-langu.

sort ialv ascending by matnr.

endform.

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

  • Form FREE_CONTAINERS

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

form free_containers.

if not alv_container is initial.

call method alv_container->free.

clear: alv_container.

free : alv_container.

endif.

endform.

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

  • Form Get_Fieldcatalog - Set Up Columns/Headers

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

form get_fieldcatalog.

data: ls_fcat type lvc_s_fcat.

data: columnno(3) type n value '0'.

refresh: fieldcat.

clear: ls_fcat.

ls_fcat-reptext = 'Material Number'.

ls_fcat-coltext = 'Material Number'.

ls_fcat-fieldname = 'MATNR'.

ls_fcat-ref_table = 'IALV'.

ls_fcat-outputlen = '18'.

ls_fcat-col_pos = 1.

append ls_fcat to fieldcat.

clear: ls_fcat.

ls_fcat-reptext = 'Material Description'.

ls_fcat-coltext = 'Material Description'.

ls_fcat-fieldname = 'MAKTX'.

ls_fcat-ref_table = 'IALV'.

ls_fcat-outputlen = '40'.

ls_fcat-col_pos = 2.

append ls_fcat to fieldcat.

clear: ls_fcat.

ls_fcat-reptext = 'Material Description'.

ls_fcat-coltext = 'Material Description'.

ls_fcat-fieldname = 'BRGEW'.

ls_fcat-ref_table = 'IALV'.

ls_fcat-do_sum = 'X'.

ls_fcat-just = 'R'.

ls_fcat-datatype = 'QUAN'.

ls_fcat-outputlen = '15'.

ls_fcat-col_pos = 2.

append ls_fcat to fieldcat.

endform.

Regards

hi to all experts.

i have alv report.

in this how can i giving grant total , top of page , end of page.

and page no.

thanks in advance and reward also.

regard :deep.

5 REPLIES 5
Read only

Former Member
0 Likes
741

Hi,

This example shows the use of the method GET_SUBTOTALS.

report zkiran_0006.

tables: mara.

type-pools: slis, icon.

  • Internal Tables

data: begin of ialv occurs 0,

matnr type mara-matnr,

maktx type makt-maktx,

brgew type mara-brgew,

end of ialv .

data: alv_container type ref to cl_gui_custom_container,

alv_grid type ref to cl_gui_alv_grid,

ok_code like sy-ucomm,

layout type lvc_s_layo,

fieldcat type lvc_t_fcat.

select-options: s_matnr for mara-matnr.

start-of-selection.

perform get_data.

call screen 100.

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

  • Module status_0100 OUTPUT

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

module status_0100 output.

set pf-status '0100'.

set titlebar '0100'.

data: variant type disvariant.

variant-report = sy-repid.

variant-username = sy-uname.

  • Create Controls

create object alv_container

exporting container_name = 'ALV_CONTAINER'.

create object alv_grid

exporting i_parent = alv_container.

  • Populate Field Catalog

perform get_fieldcatalog.

call method alv_grid->set_table_for_first_display

exporting

is_layout = layout

is_variant = variant

i_save = 'U'

i_structure_name = 'IALV'

changing

it_outtab = ialv[]

it_fieldcatalog = fieldcat[].

endmodule.

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

  • Module USER_COMMAND_0100 INPUT

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

module user_command_0100 input.

case sy-ucomm.

when 'BACK' or 'CANC'.

perform free_containers.

if sy-subrc = 0.

set screen 0.

leave screen.

else.

leave program.

endif.

when 'EXIT'.

perform free_containers.

leave program.

when 'ENTER'.

data: grandtots type ref to data.

call method alv_grid->get_subtotals

importing

ep_collect00 = grandtots

  • EP_COLLECT01 =

  • EP_COLLECT02 =

  • EP_COLLECT03 =

  • EP_COLLECT04 =

  • EP_COLLECT05 =

  • EP_COLLECT06 =

  • EP_COLLECT07 =

  • EP_COLLECT08 =

  • EP_COLLECT09 =

  • ET_GROUPLEVELS =

.

check sy-subrc = 0.

endcase.

endmodule.

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

  • FORM GET_DATA.

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

form get_data.

select maramatnr marabrgew makt~maktx

into corresponding fields of table ialv

from mara

inner join makt

on maramatnr = maktmatnr

where mara~matnr in s_matnr

and makt~spras = sy-langu.

sort ialv ascending by matnr.

endform.

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

  • Form FREE_CONTAINERS

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

form free_containers.

if not alv_container is initial.

call method alv_container->free.

clear: alv_container.

free : alv_container.

endif.

endform.

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

  • Form Get_Fieldcatalog - Set Up Columns/Headers

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

form get_fieldcatalog.

data: ls_fcat type lvc_s_fcat.

data: columnno(3) type n value '0'.

refresh: fieldcat.

clear: ls_fcat.

ls_fcat-reptext = 'Material Number'.

ls_fcat-coltext = 'Material Number'.

ls_fcat-fieldname = 'MATNR'.

ls_fcat-ref_table = 'IALV'.

ls_fcat-outputlen = '18'.

ls_fcat-col_pos = 1.

append ls_fcat to fieldcat.

clear: ls_fcat.

ls_fcat-reptext = 'Material Description'.

ls_fcat-coltext = 'Material Description'.

ls_fcat-fieldname = 'MAKTX'.

ls_fcat-ref_table = 'IALV'.

ls_fcat-outputlen = '40'.

ls_fcat-col_pos = 2.

append ls_fcat to fieldcat.

clear: ls_fcat.

ls_fcat-reptext = 'Material Description'.

ls_fcat-coltext = 'Material Description'.

ls_fcat-fieldname = 'BRGEW'.

ls_fcat-ref_table = 'IALV'.

ls_fcat-do_sum = 'X'.

ls_fcat-just = 'R'.

ls_fcat-datatype = 'QUAN'.

ls_fcat-outputlen = '15'.

ls_fcat-col_pos = 2.

append ls_fcat to fieldcat.

endform.

Regards

Read only

Former Member
0 Likes
740

Hi,

Simple ALV report

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

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

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

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

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

Reward points for useful Answers

Regards

Sudheer

Read only

Former Member
0 Likes
740

Hi

Check Tx SE38 and search all programs with BCALV*

Reward points for useful Answers

Regards

Gregory

Read only

Former Member
0 Likes
740

HI,

see this example.it will have top-of-page and end-of-page.

REPORT ZBHALV_LIST_GRID2.

TABLES:MARA.

DATA:BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

ERNAM LIKE MARA-ERNAM,

MBRSH LIKE MARA-MBRSH,

END OF ITAB.

TYPE-POOLS:SLIS.

DATA:AFIELD TYPE SLIS_FIELDCAT_ALV.

DATA:FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.

DATA:FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.

DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.

DATA:HEAD TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'ITAB'

  • I_STRUCTURE_NAME = 'ITAB'

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = SY-REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FIELDCAT1.

CLEAR AFIELD.

AFIELD-Col_pos = 1.

AFIELD-fieldname = 'MATNR'.

AFIELD-KEY = 'X'.

APPEND AFIELD TO FIELDCAT.

CLEAR FIELDCAT.

CLEAR AFIELD.

AFIELD-Col_pos = 2.

AFIELD-fieldname = 'ERSDA'.

AFIELD-KEY = 'X'.

APPEND AFIELD TO FIELDCAT.

CLEAR FIELDCAT.

CLEAR AFIELD.

AFIELD-Col_pos = 3.

AFIELD-fieldname = 'ERNAM'.

APPEND AFIELD TO FIELDCAT.

CLEAR FIELDCAT.

CLEAR AFIELD.

AFIELD-Col_pos = 4.

AFIELD-fieldname = 'MBRSH'.

APPEND AFIELD TO FIELDCAT.

CLEAR FIELDCAT.

EVE-NAME = 'TOP_OF_PAGE'.

EVE-FORM = 'HEADER'.

APPEND EVE.

CLEAR EVE.

EVE-NAME = 'END_OF_LIST'.

EVE-FORM = 'LISTEND'.

APPEND EVE.

CLEAR EVE.

EVE-NAME = 'TOP_OF_LIST'.

EVE-FORM = 'LISTTOP'.

APPEND EVE.

CLEAR EVE.

SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB UP TO 20 ROWS

.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

  • I_STRUCTURE_NAME = 'ITAB'

IT_FIELDCAT = FIELDCAT1

I_DEFAULT = 'X'

I_SAVE = 'A'

IT_EVENTS = EVE[]

TABLES

T_OUTTAB = ITAB.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

  • I_STRUCTURE_NAME = 'ITAB'

IT_FIELDCAT = FIELDCAT[]

I_DEFAULT = 'X'

I_SAVE = 'A'

IT_EVENTS = EVE[]

TABLES

T_OUTTAB = ITAB.

FORM HEADER.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'GENERAL MATERIAL DATA'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[].

ENDFORM.

FORM LISTEND.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'END OF THE LIST'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[].

ENDFORM.

FORM LISTTOP.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'TOP OF THE LIST'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[].

ENDFORM.

rgds,

bharat.

Read only

Former Member
0 Likes
740

Hi,

Refer to my code as follows:

wf_event-name = 'TOP_OF_PAGE'.

wf_event-form = 'F_REPORT_HEADER'.

APPEND wf_event TO int_event.

CLEAR wf_event.

FORM f_report_header .

DATA: WC_RIGHT type i,

WC_RIGHT2 type i.

WC_RIGHT = ( SY-LINSZ - 18 ).

WC_RIGHT2 = ( WC_RIGHT + 8 ).

WRITE AT WC_RIGHT 'Pagina: '.

WRITE AT WC_RIGHT2 sy-pagno.

WRITE: /4 'Period from: ',s_year-low, 'Period to: ', s_period-low.

ENDFORM. " f_report_header

Hope this helps.

reward if helpful.

Regards,

Sipra