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 top of page , while print preview now output

Former Member
0 Kudos

HI Friends

I have tried below code, while printing I need the top of page and page no. but it is not printing while print preview.

My requirement is very simple I need to print list with page header which is defined my me. pls. help me with sample code.

Below code not working for me in this case

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

i_save = 'X'

tables

t_outtab = it_ekko

exceptions

program_error = 1

others = 2.

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


Form top-of-page.

*ALV Header declarations

data: t_header type slis_t_listheader,

wa_header type slis_listheader,

t_line like wa_header-info,

ld_lines type i,

ld_linesc(10) type c.

  • Title

wa_header-typ = 'H'.

wa_header-info = 'EKKO Table Report'.

append wa_header to t_header.

clear wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO wa_header-info. "todays date

append wa_header to t_header.

clear: wa_header.

  • Total No. of Records Selected

describe table it_ekko lines ld_lines.

ld_linesc = ld_lines.

concatenate 'Total No. of Records Selected: ' ld_linesc

into t_line separated by space.

wa_header-typ = 'A'.

wa_header-info = t_line.

append wa_header to t_header.

clear: wa_header, t_line.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_header.

  • i_logo = 'Z_LOGO'.

endform.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Usha,

Please note that TOP_OF_PAGE is an event for that you have to define events in your function call.

As Some one correctly mentione review program : BALVST03_GRID

Regards,

Lanka

15 REPLIES 15

Former Member
0 Kudos

<b>Use this code for reference:</b>

data: t_top type SLIS_T_LISTHEADER,

x_top like line of t_top.

data: v_title type lvc_title.

v_title = 'Report Header'.

clear x_top.

x_top-typ = 'H'.

x_top-info = v_title.

append x_top to t_top.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = t_top

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

0 Kudos

Sorry Also, do not assign the top-of-page form name to the parameter to whcih u r now assigning.

But, do like this

x_events-form = 'top_of_page'.

x_events-name = SLIS_EV_TOP_OF_PAGE.

append x_events to t_events.

Assign t_events to it_events parameters as t_events[].

Former Member
0 Kudos

Hi Usha,

You have to create EVENT for the TOP-OF-PAGE.

Check the code below..

FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.

CONSTANTS:

GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = LT_EVENTS.

READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO LT_EVENTS.

ENDIF.

ENDFORM. "EVENTTAB_BUILD

-


FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

DATA: GS_LINE TYPE SLIS_LISTHEADER.

CLEAR GS_LINE.

GS_LINE-TYP = 'H'.

GS_LINE-INFO = 'Purchasing Doc & Purchase Req Report'.

APPEND GS_LINE TO GT_TOP_OF_PAGE.

ENDFORM. " COMMENT_BUILD

-


FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

ENDFORM. "TOP_OF_PAGE

-


FORM CALL_ALV .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_CALLBACK_PF_STATUS_SET = 'FRM_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

is_layout = Gs_layout

it_fieldcat = Gt_fieldcat

it_sort = Gt_sort

IT_EVENTS = GT_EVENTS[]

TABLES

t_outtab = IT_EKPO.

ENDFORM. " CALL_ALV

Call all the PERFORMS at end os selection event,,

END-OF-SELECTION.

PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.

PERFORM COMMENT_BUILD CHANGING GT_LIST_TOP_OF_PAGE.

PERFORM CALL_ALV.

Former Member
0 Kudos

hi Usha

Check out this program "BALVST03_GRID"..

Hope it helps

Former Member
0 Kudos

Hi Usha,

Please note that TOP_OF_PAGE is an event for that you have to define events in your function call.

As Some one correctly mentione review program : BALVST03_GRID

Regards,

Lanka

0 Kudos

Thanks all of U.

I have passed that event to Reuse_Alv FM. while printing only I am facing problem.

0 Kudos

Hi Usha,

What is the issue related in printing.

Lanka

0 Kudos

Hi

Are you getting any error message?

Let us know....

Suresh B Mannem

0 Kudos

Hi Usha

Are you passing IS_PRINT = GS_PRINT parameter to the function module?

Suresh B Mannem

0 Kudos

Dear Friends

Thanks for useful answers.

New Problem: I need to put cursor in particular field after selection screen validation(in case some data required) . What Code I need to write

Still I have an issue My requirement is very clear.

when I am printing the the report I need provide 5 lines header.

1 line: xyz report (it should be in bold and sige is bit big)

2nd line onwards general line of text. I don't have problem printing 2nd line in page header.

In the case of 1st line how to format that. Is there any other ways to code it comfortably.

below pls. observe

only three types are there.

wa_header-typ = 'H'.

H , S and A. What is the use of these and how could I achive my objective.

Once again thanks all of U.

Usha

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


Form top-of-page.

*ALV Header declarations

data: t_header type slis_t_listheader,

wa_header type slis_listheader,

t_line like wa_header-info,

ld_lines type i,

ld_linesc(10) type c.

  • Title

wa_header-typ = 'H'.

wa_header-info = 'EKKO Table Report'.

append wa_header to t_header.

clear wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO wa_header-info. "todays date

append wa_header to t_header.

clear: wa_header.

  • Total No. of Records Selected

describe table it_ekko lines ld_lines.

ld_linesc = ld_lines.

concatenate 'Total No. of Records Selected: ' ld_linesc

into t_line separated by space.

wa_header-typ = 'A'.

wa_header-info = t_line.

append wa_header to t_header.

clear: wa_header, t_line.

0 Kudos
for ur first question

  u can place the cursor on the required field on selection screen like this 

  SET CURSOR FIELD 'P_FNAME'."P_FNAME is ur field

for ur second question

    type H will give u big font

  chk this code 

*&---------------------------------------------------------------------*
*& Report  Y_TOP_PAGE                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  y_top_page                              .

TABLES : mara.
TYPE-POOLS: slis.

DATA : w_repid LIKE sy-repid.
  w_repid = sy-repid.

DATA : BEGIN OF it_mara OCCURS 0,
       matnr LIKE mara-matnr,
       END OF it_mara.

*layout
DATA: wa_layout           TYPE SLIS_LAYOUT_ALV.
*field catalog
DATA: it_fieldcat_wrt_off TYPE slis_t_fieldcat_alv,
      wa_fieldcat_wrt_off TYPE slis_fieldcat_alv.

START-OF-SELECTION.

  SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara.

END-OF-SELECTION.


  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
     i_program_name               = w_repid
   I_INTERNAL_TABNAME           = 'IT_MARA'
*     i_structure_name             = 'IT_MARA'
*   I_CLIENT_NEVER_DISPLAY       = 'X'
   I_INCLNAME                   = w_repid
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
    CHANGING
      ct_fieldcat                  = it_fieldcat_wrt_off[]
   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.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program     = w_repid
      i_callback_top_of_page = 'TOP-OF-PAGE'
      is_layout              = wa_layout
      it_fieldcat            = it_fieldcat_wrt_off
    TABLES
      t_outtab               = it_mara
    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.



*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
FORM top-of-page.
*ALV Header declarations
  DATA: t_header TYPE slis_t_listheader,
        wa_header TYPE slis_listheader,
        t_line LIKE wa_header-info,
        ld_lines TYPE i,
        ld_linesc(10) TYPE c.

* Title
  wa_header-typ  = 'H'.
  wa_header-info = 'CHANDU REPORT'.
  APPEND wa_header TO t_header.
  CLEAR wa_header.

* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  CONCATENATE  sy-datum+6(2) '.'
               sy-datum+4(2) '.'
               sy-datum(4) INTO wa_header-info.   "todays date
  APPEND wa_header TO t_header.
  CLEAR: wa_header.

* Total No. of Records Selected
*  describe table it_ekko lines ld_lines.
*  ld_linesc = ld_lines.
*  concatenate 'Total No. of Records Selected: ' ld_linesc
*                    into t_line separated by space.
*  wa_header-typ  = 'A'.
*  wa_header-info = t_line.
*  append wa_header to t_header.
*  clear: wa_header, t_line.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = t_header.
*            i_logo             = 'Z_LOGO'.
ENDFORM.                    "top-of-page

still if u do not get big font with Type H , may be ur GUI problem

Pls rewars points if helpful and close thread if solved

0 Kudos

Hi All

Once again thanks for your help. I have achieved some of my objectives. still some or pending.

I have passed html top of page and I got display on screen heading and other lines. but while prinng those are not appearing in printing.

1. It need to be printed on first page what ever is appearing in top of list while display.

2. The 2nd page onward I need to print Report heading and page no like 1 of 10. The report heading should be in bold and page no. in normal I need to display.

I have used top of page and it is comming on printing

pls. advise me to proceed further.

Thanks & Reg.

Usha

hymavathi_oruganti
Active Contributor
0 Kudos

for top_of_page and end_of_page etc... to appear in printing, u need to fill the printing parameters and pass to IS_PRINT of REUSE_ALV_GRID_DISPLAY.

U CAN FIND <b>SLS_ALV_PRINT</b> IN SLIS TYPE or <b>LVC_S_PRNT</b> in lvc type.

declare a variable of above type and fill parameters and pass to

<b>IS_PRINT</b>

0 Kudos

All My Friends

I tried lot but failed to display page heading in desired format.

pls. look below code.

I have applied 'H' but no bold font.

I want this report heading in the centre of the first line in top of page in bold size(bit bigger than other coloms) I tried in HTML_TOP_Of list and I got it in display. but in printing it is not comming. again I am doing in ToP_page even all that. But I failed.

one more problem is I need to display page not at right side of the page. How to set that. How to move blank line into that I am not getting to push that string to right most.

Pls. help me. in this regard. Pls. wirte simple code to achive this.

Thaks onece again to all of U.

Code:

  • Title

wa_header-typ = 'H'.

wa_header-info = 'EKKO Table Report'.

append wa_header to t_header.

clear wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO wa_header-info. "todays date

append wa_header to t_header.

clear: wa_header.

0 Kudos

Hi Usha,

Please check the below example codes for the simple ALV's.Hope it will be helpful to you.

<a href="http://www.sap-basis-abap.com/sapabap01.htm">ALV Examples</a>