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

how to use this function call function 'REUSE_ALV_COMMENTARY_WRITE' in alv

Former Member
0 Likes
871

hi all

thanks in advance

how to use this function in alv programming

call function 'REUSE_ALV_COMMENTARY_WRITE'

why use and what purpose use this function plz tell me details

plz guide me

thanks

hi all

thanks in advance

how to use this function in alv programming

call function 'REUSE_ALV_COMMENTARY_WRITE'

why use and what purpose use this function plz tell me details

plz guide me

thanks

5 REPLIES 5
Read only

Former Member
0 Likes
777

Hi,

For those who wish to upload and use a picture in ALV abap reports.

Ex.

You want to upload a picture in ALV, do the following way:

1. Goto the transaction OAER

2. Enter the class name as 'PICTURES'

3. Enter the class type as 'OT'

4. Enter the object key as the name of the logo you wish to give

5. Execute

6. Then in the new screen select Standard doc. types in bottom window

Click on the Screen icon

Now, it will ask for the file path where you have to upload the logo

7. Now you can use this logo in REUSE_ALV_COMMENTARY_WRITE

Regards,

Bhaskar

Read only

Former Member
0 Likes
777

Hi

see this exmaple code where i had inserted a LOGO by useing this FM

&----


*& 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

Read only

dhruv_shah3
Active Contributor
0 Likes
777

Hi,

This FM is used to simply put the some Logo in the Header of the ALV report.

At that time this FM is used.

E.g

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = gt_List

I_LOGO = 'ENJOYSAP_LOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM = .

HTH

Regards,

Dhruv Shah

Read only

Former Member
0 Likes
777

REUSE_ALV_COMMENTARY_WRITEList body comment block output

List header information is output according to its type. The output information is put in an internal table. Output attributes are assigned to each line via the TYP field.

This module outputs formatted simple header information at TOP-OF-PAGE.

Example

List <-- Type 'H'

Currency DEM Controlling area currency <-- Type 'S'

Material FGS_TEST Test material <-- Type 'S'

Action info <-- Type 'A'

-


Column headers -


-


List -


Read only

Former Member
0 Likes
777

Hi,

DATA: gt_events TYPE slis_t_event.

*---Build the event table for ALV display

PERFORM build_eventtab CHANGING gt_events[].

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_background_id = 'SIWB_WALLPAPER'

i_callback_program = sy-repid

i_default = 'X'

i_save = 'A'

is_layout = gs_layout

it_fieldcat = gt_fieldcat_alv

it_events = gt_events

it_sort = i_sort

TABLES

t_outtab = gt_payroll_exct.

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

FORM build_eventtab CHANGING p_events TYPE slis_t_event.

DATA: ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = p_events.

READ TABLE p_events

WITH KEY name = slis_ev_top_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE 'TOP_OF_PAGE' TO ls_event-form.

APPEND ls_event TO p_events.

ENDIF.

ENDFORM. " BUILD_EVENTTAB

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

FORM top_of_page. "#EC *

PERFORM build_comment USING gt_heading.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_heading[].

CLEAR gt_heading.

ENDFORM. "TOP_OF_PAGE

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

FORM build_comment USING p_heading TYPE slis_t_listheader.

DATA: ls_hline TYPE slis_listheader,

lv_text(120) TYPE c,

lv_text1(60) TYPE c,

lv_lines_char(10) TYPE c.

*-Display report title

ls_hline-typ = 'H'. " H = Header, S = Selection, A = Action

WRITE text-006 TO lv_text.

ls_hline-info = text.

APPEND ls_hline TO p_heading.

CLEAR ls_hline.

*-Display totals for the Employees & Records Processed

IF p_mode IS INITIAL.

ls_hline-typ = 'S'.

CONCATENATE text-007 lv_lines_char INTO lv_text SEPARATED BY space.

ls_hline-info = lv_text.

APPEND ls_hline TO p_heading.

CLEAR ls_hline.

ELSE.

*---Display totals - Success records Processed

CONCATENATE text-008 lv_lines_char INTO lv_text SEPARATED BY space.

ls_hline-info = lv_text.

ls_hline-typ = 'S'.

APPEND ls_hline TO p_heading.

CLEAR ls_hline.

ENDIF.

*-Display file name, user has selected

IF p_ot_pc IS NOT INITIAL AND p_mode IS INITIAL.

CONCATENATE text-009 p_ot_pc INTO lv_text SEPARATED BY space.

IF STRLEN( lv_text ) > 60.

lv_text115(45) = lv_text60(45).

ENDIF.

ls_hline-typ = 'S'.

ls_hline-info = lv_text.

APPEND ls_hline TO p_heading.

ls_hline-info = lv_text1.

APPEND ls_hline TO p_heading.

CLEAR ls_hline.

ENDIF.

ENDFORM. "BUILD_COMMENT

Cheers!!

Lokesh