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

ABAP report

Former Member
0 Likes
818

HI Group,

How to create report templet using ALV which should contain common header and footer for all the reports.

Also I need to show the same in every page of the report.

Please provide some sample.

HI Group,

How to create report templet using ALV which should contain common header and footer for all the reports.

Also I need to show the same in every page of the report.

Please provide some sample.

6 REPLIES 6
Read only

Former Member
0 Likes
782

Hi swabap sct,

Welcome to SDN.

Are you talking about displaying header and footer in every page of your single report.

You can do that using use the events TOP_OF_PAGE and END_OF_PAGE .

You can handle the Event

print_top_of_page to define output text to be printed at the beginning of each page

and

print_end_of_page to define output text to be printed at the end of each page.

Example:

First add a handler method in your handler class definition as: e.g.

METHOD handle_print_top_of_list FOR EVENT print_top_of_list OF cl_gui_alv_grid .

Then implement the method in the implementation part of your local class. e.g.

METHOD handle_print_top_of_list .

WRITE:/ 'Flights Made on ', sy-datum .

ENDMETHOD .

And register this method as the handler. e.g.

SET HANDLER gr_event_handler->handle_print_top_of_list FOR gr_alvgrid .

Regards,

Tanveer.

Please mark helpful answers.

Read only

0 Likes
782

Hi Tanveer,

I need to create ABAP report templet using ALV.Which I can be add to every report.Can you please send me some

sample code.

Read only

0 Likes
782

Hi,

The best option is to browse through the std ALV report programs from SLIS development package and then copy the most relevant which fits your requirement.

Cheers

VJ

Read only

Former Member
0 Likes
782

Hi,

I am not getting your requirement. You need to create a report template using ALV?

Is your requirement like you want to create a skeleton ALV template which you can use for very ABAP report which makes use of ALV, in order to avoid typing the same common syntax again n again.

Please clarify??

Regards,

Tanveer.

Read only

0 Likes
782

yah I want to create a skeleton ALV template which I can use for very ABAP report which makes use of ALV, in order to avoid typing the same common syntax again n again.

I need templet like this

Header

date (2 tab spaces) report des (2 tab spaces) time

in one line ,and in another line

Selection Criteria

<Selection criteria>

Footer

User(2 tab spaces)pagenumber.

Read only

Former Member
0 Likes
782

Hai Swabap Sct

try with the following Code

type-pools:slis.

tables: ekko,ekpo.

data:begin of it_ekko occurs 0,

ebeln like ekko-ebeln,

bukrs like ekko-bukrs,

lifnr like ekko-lifnr,

bedat like ekko-bedat,

end of it_ekko.

data: begin of it_ekpo occurs 0,

sno like ekpo-ebeln,

ebelp like ekpo-ebelp,

menge like ekpo-menge,

netwr like ekpo-netwr,

end of it_ekpo.

data v_repid like sy-repid.

data it_fieldcat type slis_fieldcat_alv occurs 0 with header line.

data x_keyinfo type slis_keyinfo_alv.

select-options:s_ebeln for ekko-ebeln.

initialization.

v_repid = sy-repid.

s_ebeln-low = '1000'.

s_ebeln-sign = 'I'.

s_ebeln-option = 'EQ'.

S_ebeln-high = '5000'.

append s_ebeln.

start-of-selection.

perform get_data.

perform get_field.

perform get_key.

perform key_modify.

perform display.

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data.

select ebeln

bukrs

lifnr

bedat

from ekko into table it_ekko." where ebeln in s_ebeln.

select ebeln

ebelp

menge

netwr from ekpo into table it_ekpo." where ebeln in s_ebeln.

endform. " get_data

&----


*& Form get_field

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_field.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'IT_EKKO'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

changing

ct_fieldcat = it_fieldcat[] .

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'IT_EKPO'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

changing

ct_fieldcat = it_fieldcat[]

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " get_field

&----


*& Form get_key

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_key.

x_keyinfo-header01 = 'EBELN'.

x_keyinfo-item01 = 'SNO'.

endform. " get_key

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display.

*loop at it_ekko where ebeln eq '4500005016'.

  • write it_ekko-ebeln.

  • endloop.

*

*loop at it_ekpo where sno eq '4500005016'.

  • write it_ekpo-sno.

  • endloop.

*

**

*loop at it_fieldcat where key eq space .

  • write : / it_fieldcat-fieldname,it_fieldcat-key.

*endloop.

*

*loop at it_ekko.

  • loop at it_ekpo where sno eq it_ekko-ebeln.

  • write : / it_ekpo-menge,it_ekpo-ebelp.

  • endloop.

  • endloop.

*

*

*

call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

it_fieldcat = it_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

i_tabname_header = 'IT_EKKO'

i_tabname_item = 'IT_EKPO'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = x_keyinfo

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab_header = it_ekko

t_outtab_item = it_ekpo

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " DISPLAY

&----


*& Form key_modify

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form key_modify.

loop at it_fieldcat. "Avoid Repitiotion of data.

case it_fieldcat-fieldname.

when 'SNO'.

if it_fieldcat-tabname = 'IT_EKPO'.

it_fieldcat-no_out = 'X'.

it_fieldcat-key = space.

endif.

endcase.

modify it_fieldcat index sy-tabix.

endloop.

endform. " key_modify

Thanks & Regards

Sreenivasulu P