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 REPORT

Former Member
0 Likes
913

Hi,

Can any one say simple example program to display TOP-OF-PAGE in ALV report

7 REPLIES 7
Read only

Former Member
0 Likes
881

alv.

Message was edited by:

Karthikeyan Pandurangan

Read only

Former Member
Read only

Former Member
0 Likes
881

*& Form top-of-page

&----


  • text

----


FORM top_of_page.

*ALV Header declarations

DATA:int_header TYPE slis_t_listheader,

fs_header TYPE slis_listheader,

t_line LIKE fs_header-info.

  • Date

fs_header-typ = 'S'.

fs_header-key = text-027.

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

sy-datum+4(2) '.'

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

APPEND fs_header TO int_header.

CLEAR: fs_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = int_header.

ENDFORM. "top-of-page

hi try to use this

regrads'

karthik

Read only

former_member386202
Active Contributor
0 Likes
881

Hi,

Refer this code

data : it_events TYPE slis_t_event,

it_event1 TYPE slis_t_event,

it_event2 TYPE slis_t_event,

it_header TYPE slis_t_listheader.

&----


*& Form sub_create_events *

&----


  • This form will display the ALV Events *

----


FORM sub_create_events .

*--Local Work Area

DATA: lwa_event TYPE slis_alv_event. "Work area for Events

*--Call Function to display the events for the ALV

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 1

IMPORTING

et_events = it_events.

*--Sort by Name

SORT it_events BY name.

*--Clear

CLEAR lwa_event.

READ TABLE it_events INTO lwa_event WITH KEY name =

slis_ev_top_of_page

BINARY SEARCH.

IF sy-subrc = 0.

MOVE c_top_of_page TO lwa_event-form.

MODIFY it_events FROM lwa_event TRANSPORTING form WHERE

name = slis_ev_top_of_page.

ENDIF.

*--Clear

CLEAR : lwa_event.

ENDFORM. "sub_create_events

&----


*& Form sub_top_of_page *

&----


  • This form is to build the Page Header *

----


FORM sub_top_of_page .

*--Local Variable

DATA : lv_title(120) TYPE c, " Title

lv_month(30) TYPE c,

lv_mont(30) TYPE c,

lv_bud(16) TYPE c.

*--Local Work Area

DATA : lwa_line TYPE slis_listheader. " Hold list header

  • CONCATENATE p_month 'to' s_hmonth INTO lv_month SEPARATED BY space.

  • IF NOT s_hmonth IS INITIAL.

  • lv_mont = lv_month.

  • ELSE.

lv_mont = p_month.

  • ENDIF.

*--Title Display

lwa_line-typ = 'H'. " header

lv_title = sy-title.

lwa_line-info = lv_title.

APPEND lwa_line TO it_header.

CLEAR lwa_line.

*--Month Display

lwa_line-typ = 'S'. " Item

WRITE: lv_mont TO lv_month.

lwa_line-key = text-024.

lwa_line-info = lv_month.

APPEND lwa_line TO it_header.

*--Budget Display

lwa_line-typ = 'S'. " Item

WRITE: p_bud TO lv_bud.

lwa_line-key = text-025.

lwa_line-info = lv_bud.

APPEND lwa_line TO it_header.

CLEAR: lwa_line,

lv_mont.

*--This funcation module will display the top of the page

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_header.

*--Free

FREE : it_header.

ENDFORM. "sub_top_of_page

Reward Points.....

Regards,

Prashant

Read only

Former Member
0 Likes
881

Hi,

Check this link for sample program.

http://www.sap-img.com/abap/test-alv-display-with-header-footer.htm

Regards,

Maha

Read only

Former Member
0 Likes
881

HI

sample program for top-of-page where you can see also LOGO in top-of-page

*&---------------------------------------------------------------------*
*& Report  ZTEST_ALV_LOGO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ztest_alv_logo.

TYPE-POOLS : slis.

*ALV Formatting tables /structures
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: gt_events   TYPE slis_t_event.
DATA: gs_layout   TYPE slis_layout_alv.
DATA: gt_page     TYPE slis_t_listheader.
DATA: gs_page     TYPE slis_listheader.
DATA: v_repid     LIKE sy-repid.

*ALV Formatting work area
DATA: w_fieldcat TYPE slis_fieldcat_alv.
DATA: w_events   TYPE slis_alv_event.

DATA: gt_bsid TYPE TABLE OF bsid WITH HEADER LINE.

INITIALIZATION.

  PERFORM build_events.
  PERFORM build_page_header.

START-OF-SELECTION.
*perform build_comment.     "top_of_page - in initialization at present

  SELECT * FROM bsid INTO TABLE gt_bsid UP TO 10 ROWS.

*perform populate_for_fm using '1' '3' 'BUKRS' '8' 'GT_BSID' 'Whee'.
*USING = Row, Column, Field name, display length, table name, heading

*OR
  PERFORM build_fieldcat.
  gs_layout-zebra = 'X'.


*top of page event does not work without I_callback_program
  v_repid = sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program                = v_repid
      i_structure_name                  = 'BSID'
*    i_background_id                   = 'ALV_BACKGROUND'
      i_grid_title                      = 'This is the grid title'
*   I_GRID_SETTINGS                   =
      is_layout                         = gs_layout
      it_fieldcat                       = gt_fieldcat[]
      it_events                         = gt_events[]
    TABLES
      t_outtab                          = gt_bsid.

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

* Form..............:  populate_for_fm
* Description.......:  Populates fields for function module used in ALV
************************************************************************

FORM populate_for_fm USING p_row
                           p_col
                           p_fieldname
                           p_len
                           p_table
                           p_desc.

  w_fieldcat-row_pos      = p_row.          "Row Position
  w_fieldcat-col_pos      = p_col.          "Column Position
  w_fieldcat-fieldname    = p_fieldname.    "Field name
  w_fieldcat-outputlen    = p_len.          "Column Lenth
  w_fieldcat-tabname      = p_table.        "Table name
  w_fieldcat-reptext_ddic = p_desc.         "Field Description
  w_fieldcat-input        = '1'.
  APPEND w_fieldcat TO gt_fieldcat.
  CLEAR w_fieldcat.

ENDFORM.                    " populate_for_fm
*&---------------------------------------------------------------------*

*&      Form  build_events
*&---------------------------------------------------------------------*

FORM build_events.
  DATA: ls_event TYPE slis_alv_event.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type = 0
    IMPORTING
      et_events   = gt_events.

  READ TABLE gt_events
             WITH KEY name =  slis_ev_user_command
             INTO ls_event.
  IF sy-subrc = 0.
    MOVE slis_ev_user_command TO ls_event-form.
    APPEND ls_event TO gt_events.
  ENDIF.
  READ TABLE gt_events
             WITH KEY name =  slis_ev_top_of_page
             INTO ls_event.
  IF sy-subrc = 0.
    MOVE slis_ev_top_of_page TO ls_event-form.
    APPEND ls_event TO gt_events.
  ENDIF.

ENDFORM.                    " build_events
*&---------------------------------------------------------------------*

*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*

* When user command is called it uses 2 parameters. The itab
* passed to the ALV is in whatever order it currently is on screen.
* Therefore, you can read table itab index rs_selfield-tabindex to get
* all data from the table. You can also check r_ucomm and code
* accordingly.
*&---------------------------------------------------------------------*

FORM user_command USING  r_ucomm     LIKE sy-ucomm
                         rs_selfield TYPE slis_selfield.

  READ TABLE gt_bsid INDEX rs_selfield-tabindex.
* error checking etc.
  SET PARAMETER ID 'KUN' FIELD gt_bsid-kunnr.
  CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDFORM.                    "user_command
*&---------------------------------------------------------------------*

*&      Form  top_of_page
*&---------------------------------------------------------------------*

* Your own company logo can go here if it has been saved (OAOR)
* If the logo is larger than the size of the headings in gt_page,
* the window will not show full logo and will have a scroll bar. Thus,
* it is a good idea to have a standard ALV header if you are going to
* use logos in your top of page.
*&---------------------------------------------------------------------*

FORM top_of_page.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = gt_page
      i_logo             = 'ENJOYSAP_LOGO'.
ENDFORM.                    "top_of_page
*&---------------------------------------------------------------------*

*&      Form  build_fieldcat
*&---------------------------------------------------------------------*

*Many and varied fields are available here. Have a look at documentation

*for FM REUSE_ALV_LIST_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE
*----------------------------------------------------------------------*

FORM build_fieldcat.
  w_fieldcat-fieldname  = 'BUDAT'.
  w_fieldcat-seltext_m  = 'Dte pst'.
  w_fieldcat-ddictxt(1) = 'M'.
  w_fieldcat-edit = 'x'.
* Can change the position of fields if you do not want them in order
* of the DDIC or itab

*  w_fieldcat-row_pos = '1'.
*  w_fieldcat-col_pos = '10'.
  APPEND w_fieldcat TO gt_fieldcat.
  CLEAR w_fieldcat.

ENDFORM.                    " build_fieldcat
*&---------------------------------------------------------------------*

*&      Form  build_page_header
*&---------------------------------------------------------------------*

*       gt_page is used in top of page (ALV subroutine - NOT event)
*       *H = Header, S = Selection, A = Action
*----------------------------------------------------------------------*

FORM build_page_header.
* For Headers, Key is not printed and is irrelevant. Will not cause
* a syntax error, but is not used.
  gs_page-typ  = 'H'.
  gs_page-info = 'Header 1'.
  APPEND gs_page TO gt_page.

  gs_page-typ  = 'H'.
  gs_page-info = 'Header 2'.
  APPEND gs_page TO gt_page.

* For Selections, the Key is printed (bold). It can be anything up to 20

* bytes. It gets printed in order of code here, not by key value.
  gs_page-typ  = 'S'.
  gs_page-key  = 'And the winner is:'.
  gs_page-info = 'Selection 1'.
  APPEND gs_page TO gt_page.

  gs_page-typ  = 'S'.
  gs_page-key  = 'Runner up:'.
  gs_page-info = 'Selection 2'.
  APPEND gs_page TO gt_page.

* For Action, Key is also irrelevant.
  gs_page-typ  = 'A'.
  gs_page-info = 'Action goes here'.
  APPEND gs_page TO gt_page.

ENDFORM.                    " build_page_header

<b>Reward if usefull</b>

Read only

Former Member
0 Likes
881

HI.

report zmjud001 no standard page heading line-size 85 line-count 50.

  • DATA /TABLES DECLARATION*

tables: eban.

data: prog_nam(8).

data: begin of pur_req occurs 100,

ekgrp like eban-ekgrp,

werks like eban-werks,

banfn like eban-banfn,

bnfpo like eban-bnfpo,

bsart like eban-bsart,

estkz like eban-estkz,

matnr like eban-matnr,

menge like eban-menge,

meins like eban-meins,

numb(3) type n.

data: end of pur_req.

  • THE REPORT HEADER

prog_nam = sy-repid.

top-of-page.

perform header_write.

  • SELECTION

start-of-selection.

pur_req-numb = 1.

  • SELECT ONLY THOSE FIELDS THAT WILL BE USED FROM THE TABLE EBAN, AND ONLY

*THE FIRST100 RECORDS OF THE THE PLANT 'PL01'

select banfn bnfpo bsart ekgrp matnr werks menge meins frgdt estkz

into corresponding fields of eban from eban up to 100 rows

where bsart = 'NB' "document type 'NB' = purchase requisition

and werks = 'PL01'

and statu = 'N' "processing status

and loekz = ' '. "deletion indicator

  • THE SELECTED RECORDS SHOULD BE APPENDED TO INTERNAL TABLE 'PUR_REQ'

pur_req-banfn = eban-banfn.

pur_req-matnr = eban-matnr.

pur_req-werks = eban-werks.

pur_req-ekgrp = eban-ekgrp.

pur_req-bnfpo = eban-bnfpo.

pur_req-bsart = eban-bsart.

pur_req-menge = eban-menge.

pur_req-meins = eban-meins.

pur_req-estkz = eban-estkz.

append pur_req.

pur_req-numb = pur_req-numb + 1.

endselect.

  • CHECK WHETHER THE TABLE EBAN CONTAINS ANY PURCHASE REQUISITIONS

if sy-subrc ne 0.

write: / 'No Purchase Requisition found.'.

endif.

  • PROCESS THE INTERNAL TABLE; WRITE OUT THE REQUIRED FIELDS AND HIDE THE

*FIELDS YOU ARE GOING TO USE LATER

loop at pur_req.

write: /1 pur_req-numb, 9 pur_req-banfn, 21 pur_req-bnfpo, 31 pur_req-bsart, 41 pur_req-matnr,

61 pur_req-menge unit pur_req-meins, 82 pur_req-meins.

hide: pur_req-matnr, pur_req-werks, pur_req-banfn.

endloop.

clear pur_req-banfn. clear pur_req-matnr. clear pur_req-werks.

  • IN THE MENU PAINTER (SE41) CREATE A STATUS TO YOUR PROGRAM. HERE YOU CAN

*DEFINE THE PUSH-BUTTON

set pf-status 'basic'.

  • CHOOSE A REQUISITION (WITH DOUBLE CLICKING OR PUSH-BUTTON) IN THE LIST! THE

*PURCHASE REQUISITION IS GOING TO COME UP

at line-selection.

if pur_req-banfn <> space.

set parameter id 'BAN' field pur_req-banfn. " parameter id for pruchase req. number

call transaction 'ME52' and skip first screen. "trans. code 'ME52': Change Purchase Requis.

clear pur_req-banfn. clear pur_req-matnr.

clear pur_req-werks.

endif.

  • FORM THE HEADER

form header_write.

write: / prog_nam, 32 'FUN-FACTORY',

/ 'Purch.Gr.:', pur_req-ekgrp, 26 'Purchase Requisition List',

61 'As Of Date:', 75 sy-datum,

/ 'Plant:', pur_req-werks, 61 'Page:', 75 sy-pagno.

uline.

write: / text-001,

/ text-002.

uline.

endform.

To be reward all helpfull answers.

Regards,

Jay