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

HELP NEEDED

Former Member
0 Likes
522

This is my program i would like to add one logo at the top left corner of the

output(header) and some details at the bottom (footer). Can anybody do that,

and send me back.

&----


*& Report Y_BOM2_ALV

*&

&----


*&

*&

&----


REPORT y_bom2_alv LINE-SIZE 350 LINE-COUNT 350.

&----


*& Include YINCLUDE1

&----


TABLES : mast, stko, stpo.

TYPE-POOLS : slis.

DATA : BEGIN OF iall OCCURS 10,

matnr LIKE mast-matnr,

werks LIKE mast-werks,

stlan LIKE mast-stlan,

stlal LIKE mast-stlal,

stlst LIKE stko-stlst,

posnr LIKE stpo-posnr,

idnrk LIKE stpo-idnrk,

menge LIKE stpo-menge,

meins LIKE stpo-meins,

ausch LIKE stpo-ausch,

lgort LIKE stpo-lgort,

END OF iall.

DATA : i_repid LIKE sy-repid,

i_lines LIKE sy-tabix,

  • ls_events TYPE slis_alv_event,

eve TYPE slis_t_event WITH HEADER LINE,

head TYPE slis_t_listheader WITH HEADER LINE.

DATA : int_fcat TYPE slis_t_fieldcat_alv.

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE title1.

PARAMETER : p_werks LIKE mast-werks.

SELECT-OPTIONS : s_matnr FOR mast-matnr.

SELECTION-SCREEN END OF BLOCK a1.

INITIALIZATION.

title1(50) = ' Bill Of Material Input Screen '.

eve-name = 'TOP_OF_PAGE'.

eve-form = 'HEADER'.

APPEND eve.

CLEAR eve.

eve-name = 'END_OF_LIST'.

eve-form = 'LISTEND'.

APPEND eve.

CLEAR eve.

eve-name = 'TOP_OF_LIST'.

eve-form = 'LISTTOP'.

APPEND eve.

CLEAR eve.

top-of-page.

end-of-page.

write : sy-tabix.

&----


*& Include YINCLUDE2

&----


START-OF-SELECTION.

SELECT mastmatnr mastwerks maststlan maststlal stko~stlst

stpoposnr stpoidnrk stpomenge stpomeins stpo~ausch

stpo~lgort INTO TABLE iall FROM stpo INNER JOIN stko ON

stpostlnr = stkostlnr INNER JOIN mast ON

stpostlnr = maststlnr WHERE mast~werks EQ

p_werks AND mast~matnr IN s_matnr.

IF sy-subrc <> 0 OR p_werks EQ ' ' OR s_matnr EQ ' '.

CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'

EXPORTING

titel = 'ERROR MESSAGE ( INPUT ERROR / WRONG INPUT ) '

textline1 = ' PLANT / MATERIAL Invalid or Empty '

textline2 = ' Plese enter plant no / material no again '

start_column = 20

start_row = 5.

EXIT.

ENDIF.

CLEAR i_lines.

DESCRIBE TABLE iall LINES i_lines.

IF i_lines LT 1.

WRITE: /

'No materials found.'.

EXIT.

ENDIF.

END-OF-SELECTION.

i_repid = sy-repid.

&----


*& Include YINCLUDE3

&----


CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = i_repid

i_internal_tabname = 'IALL'

i_inclname = i_repid

CHANGING

ct_fieldcat = int_fcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE: /

'Returncode',

sy-subrc,

'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.

ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = i_repid

it_fieldcat = int_fcat

i_save = 'A'

it_events = eve[]

TABLES

t_outtab = iall

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE: /

'Returncode',

sy-subrc,

'from FUNCTION REUSE_ALV_LIST_DISPLAY'.

ENDIF.

&----


*& Form HEADER

&----


  • text

----


FORM header.

REFRESH head.

head-typ = 'H'.

head-info = 'REPORT FOR ALL ALTERNATIVE BOM AVAILABLE'.

APPEND head.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = head[]

i_logo = 'LOGO1'.

ENDFORM. "HEADER

&----


*& Form LISTEND

&----


  • text

----


FORM listend.

REFRESH head.

head-typ = 'H'.

head-info = 'TOTAL NO OF RECORDS ='.

APPEND head.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = head[]

i_logo = 'LOGO1'.

ENDFORM. "LISTEND

&----


*& Form LISTTOP

&----


  • text

----


FORM listtop.

REFRESH head.

head-typ = 'H'.

head-info = ' ALV REPORT'.

APPEND head.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = head[]

i_logo = 'LOGO1'.

ENDFORM. "LISTTOP

*CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

  • EXPORTING

  • it_list_commentary =

    • I_LOGO =

    • I_END_OF_LIST_GRID =

    • I_ALV_FORM =

  • .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
460

hi

SEE THIS PROGRAM SAME REQUIREMENT , YOU CAN SEE DOCUMENTATION ALSO AVAILABLE FOR THIS REPORT

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

REWARD IF USEFULL

2 REPLIES 2
Read only

Former Member
0 Likes
461

hi

SEE THIS PROGRAM SAME REQUIREMENT , YOU CAN SEE DOCUMENTATION ALSO AVAILABLE FOR THIS REPORT

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

REWARD IF USEFULL

Read only

Former Member
0 Likes
460

Hi

see this to put logo on ALV report

In the transaction OAOR, you should be able to insert your company Logo.

GOTO - OAOR (Business Document Navigator)

Give Class Name - PICTURES Class Type - OT..... then Execute

It will show you the list, then select ENJOYSAP_LOGO.

On that list, you will find one control with a "create" tab.

Click std. doc types.

Select SCREEN and double-click.

It will push FILE selection screen.

Select your company logo (.gif) and press OK.

It will ask for a description- for instance: "company logo".

It will let you know your doc has been stored successfully.

You can find your logo under ENJOYSAP_LOGO->Screen->company logo.

Just run your ALV program, you should find your company logo in place of the EnjoySAP logo.

FORM TOP-OF-PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEADING[]

I_LOGO = 'ENJOYSAP_LOGO'

I_END_OF_LIST_GRID ='GT_LIST_TOP_OF_PAGE'.

.

ENDFORM. "TOP-OF-PAGE

Here 'ENJOYSAP_LOGO' will replace by ur created logo.

Refer this link

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_enhanced.htm

http://www.sap-img.com/abap/alv-logo.htm

http://www.sap-img.com/fu002.htm

Regards

Anji