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

REGARDING ALV GRID

Former Member
0 Likes
833

i need to display contents which are upto 3 lines in the title of a ALV-GRID display..

the contents of the grid are a combination from various tables...

the result should be like this..

Title - 'COMPANY NAME'

'PERSON INCHARGE'

'TELEPHONE NUMBER'.

BODY- ALV GRID DISPLAY..

HOW CAN I BRING THIS OUTPUT...

THE CONTENTS OF THE TITLE SHOULD NOT BE HARD CODED.

1 ACCEPTED SOLUTION
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
806

Hi,

You can print these details using this code, its working:-


*FOR TOP OF THE PAGE
DATA : it_top TYPE slis_t_listheader,
       wa_top TYPE slis_listheader.
 
*&---------------------------------------------------------------------*
*          DISPLAY RECORDS IN ALV GRID
*&---------------------------------------------------------------------*
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program                = sy-repid "report id
      i_callback_top_of_page            = 'TOP' "for top of page
      is_layout                         = wa_layout "layout
      it_fieldcat                       = it_field "field catalogs
      it_sort                           = it_sort "sort records
      i_save                            = 'A' "variant for all users
      is_variant                        = wa_variant "variant selected
    TABLES
      t_outtab                          = itab "internal table with data
    EXCEPTIONS
      program_error                     = 1
      OTHERS                            = 2.
 
  IF sy-subrc  0.
  ENDIF.
 
*&---------------------------------------------------------------------*
*&      Form  top
*&---------------------------------------------------------------------*
*       TO WRITE THE HEADER
*----------------------------------------------------------------------*
FORM top.
 
  REFRESH it_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Company Name'.
  wa_top-info = v_cname. "variable holding value of company name
  APPEND wa_top TO it_top.
  CLEAR wa_top.
 
  wa_top-typ = 'S'.
  wa_top-key = 'Incharge'.
  wa_top-info = v_pinch. "variable holding value of person's name
  APPEND wa_top TO it_top.
  CLEAR wa_top.
 
  wa_top-typ = 'S'.
  wa_top-key = 'Contact No'.
  wa_top-info = v_telno. "variable holding value of contact number
  APPEND wa_top TO it_top.
  CLEAR wa_top.
 
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_top
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .
 
ENDFORM.                    "top

This will print the header information as per your requirement.

Hope this helps you out.

Thanks & Regards,

Tarun Gambhir

i need to display contents which are upto 3 lines in the title of a ALV-GRID display..

the contents of the grid are a combination from various tables...

the result should be like this..

Title - 'COMPANY NAME'

'PERSON INCHARGE'

'TELEPHONE NUMBER'.

BODY- ALV GRID DISPLAY..

HOW CAN I BRING THIS OUTPUT...

THE CONTENTS OF THE TITLE SHOULD NOT BE HARD CODED.

6 REPLIES 6
Read only

Former Member
0 Likes
806

SUGGESTIONS PLEASE

Read only

Former Member
0 Likes
806

Hi...instead of diplaying the information in titlebar..u can put it in top-of-page using...

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE. "the 3 lines needed

WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.

ENDFORM.

Titlebar is only for showing the info of the table...

Read only

Former Member
0 Likes
806

a detailed example:

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 = 'GANESH_LOGO'.

endform. " top-of-page

Read only

Sandra_Rossi
Active Contributor
0 Likes
806

Please conform [forum rules|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] :

- "Use a good subject line" (Step 2)

- As this question is very common, it appears clear that you didn't "check SAP's online help \[...\] SAP Notes \[...\] the forums, the articles, the blog posts and the Frequently Asked Questions (FAQ) in the Wiki"

Keep in mind that your thread may be locked (see [this thread|; for example) if you don't conform.

Read only

0 Likes
806

Thanks for the information and your care... i'll avoid such mistakes hereafter...

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
807

Hi,

You can print these details using this code, its working:-


*FOR TOP OF THE PAGE
DATA : it_top TYPE slis_t_listheader,
       wa_top TYPE slis_listheader.
 
*&---------------------------------------------------------------------*
*          DISPLAY RECORDS IN ALV GRID
*&---------------------------------------------------------------------*
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program                = sy-repid "report id
      i_callback_top_of_page            = 'TOP' "for top of page
      is_layout                         = wa_layout "layout
      it_fieldcat                       = it_field "field catalogs
      it_sort                           = it_sort "sort records
      i_save                            = 'A' "variant for all users
      is_variant                        = wa_variant "variant selected
    TABLES
      t_outtab                          = itab "internal table with data
    EXCEPTIONS
      program_error                     = 1
      OTHERS                            = 2.
 
  IF sy-subrc  0.
  ENDIF.
 
*&---------------------------------------------------------------------*
*&      Form  top
*&---------------------------------------------------------------------*
*       TO WRITE THE HEADER
*----------------------------------------------------------------------*
FORM top.
 
  REFRESH it_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Company Name'.
  wa_top-info = v_cname. "variable holding value of company name
  APPEND wa_top TO it_top.
  CLEAR wa_top.
 
  wa_top-typ = 'S'.
  wa_top-key = 'Incharge'.
  wa_top-info = v_pinch. "variable holding value of person's name
  APPEND wa_top TO it_top.
  CLEAR wa_top.
 
  wa_top-typ = 'S'.
  wa_top-key = 'Contact No'.
  wa_top-info = v_telno. "variable holding value of contact number
  APPEND wa_top TO it_top.
  CLEAR wa_top.
 
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_top
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
            .
 
ENDFORM.                    "top

This will print the header information as per your requirement.

Hope this helps you out.

Thanks & Regards,

Tarun Gambhir