Saturday, December 18, 2010
We use HTML_TOP_OF_PAGE event to display TOP OF PAGE for ALV GRID Display.
REPORT ztest_alv_grid. TABLES:t001. "Types TYPES: BEGIN OF t_1001, bukrs TYPE t001-bukrs, butxt TYPE t001-butxt, ort01 TYPE t001-ort01, land1 TYPE t001-land1, END OF t_1001. "Work area DATA: w_t001 TYPE t_1001. "Internal table DATA: i_t001 TYPE STANDARD TABLE OF t_1001. *&---------------------------------------------------------------------* " ALV Declarations *----------------------------------------------------------------------* * Types Pools TYPE-POOLS: slis. * Types TYPES: t_fieldcat TYPE slis_fieldcat_alv, t_events TYPE slis_alv_event, t_layout TYPE slis_layout_alv. * Workareas DATA: w_fieldcat TYPE t_fieldcat, w_events TYPE t_events, w_layout TYPE t_layout. * Internal Tables DATA: i_fieldcat TYPE STANDARD TABLE OF t_fieldcat, i_events TYPE STANDARD TABLE OF t_events. *&---------------------------------------------------------------------* *& start of selection *&---------------------------------------------------------------------* START-OF-SELECTION. PERFORM get_data. *&---------------------------------------------------------------------* *& end-of-selection. *&---------------------------------------------------------------------* END-OF-SELECTION. PERFORM build_fieldcatlog. PERFORM build_layout. PERFORM list_display. *&---------------------------------------------------------------------* *& Form get_data *&---------------------------------------------------------------------* FORM get_data . SELECT bukrs butxt ort01 land1 FROM t001 INTO TABLE i_t001 UP TO 30 ROWS. ENDFORM. " get_data *&---------------------------------------------------------------------* *& Form build_fieldcatlog *&---------------------------------------------------------------------* FORM build_fieldcatlog . CLEAR:w_fieldcat,i_fieldcat[]. PERFORM build_fcatalog USING: 'BUKRS' 'I_T001' 'BUKRS', 'BUTXT' 'I_T001' 'BUTXT', 'ORT01' 'I_T001' 'ORT01', 'LAND1' 'I_T001' 'LAND1'. ENDFORM. "BUILD_FIELDCATLOG *&---------------------------------------------------------------------* *& Form BUILD_FCATALOG *&---------------------------------------------------------------------* FORM build_fcatalog USING l_field l_tab l_text. w_fieldcat-fieldname = l_field. w_fieldcat-tabname = l_tab. w_fieldcat-seltext_m = l_text. APPEND w_fieldcat TO i_fieldcat. CLEAR w_fieldcat. ENDFORM. " build_fieldcatlog *&---------------------------------------------------------------------* *& Form build_layout *&---------------------------------------------------------------------* FORM build_layout . w_layout-colwidth_optimize = 'X'. w_layout-zebra = 'X'. ENDFORM. " build_layout *&---------------------------------------------------------------------* *& Form list_display *&---------------------------------------------------------------------* FORM list_display . DATA: l_program TYPE sy-repid. l_program = sy-repid. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = l_program i_callback_html_top_of_page = 'HTML_TOP_OF_PAGE' is_layout = w_layout it_fieldcat = i_fieldcat TABLES t_outtab = i_t001 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. ENDFORM. " list_display *&---------------------------------------------------------------------* *& Form top_of_page *&---------------------------------------------------------------------* FORM top_of_page. DATA : li_header TYPE slis_t_listheader, w_header LIKE LINE OF li_header. DATA: l_date TYPE char10. WRITE sy-datum TO l_date. w_header-typ = 'H'. CONCATENATE sy-repid ':' 'From Date' l_date INTO w_header-info SEPARATED BY space. APPEND w_header TO li_header. CLEAR w_header. w_header-typ = 'S'. w_header-info = sy-title. APPEND w_header TO li_header. CLEAR w_header. w_header-typ = 'A'. w_header-info = sy-uname. APPEND w_header TO li_header. CLEAR w_header. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = li_header. ENDFORM. "top_of_page *-----------------------------------------------------------------* * FORM html_top_of_page * *-----------------------------------------------------------------* FORM html_top_of_page USING top TYPE REF TO cl_dd_document. DATA: l_text(255) TYPE c. DO 180 TIMES. l_text+sy-index(1) = '*'. ENDDO. CALL METHOD top->add_text EXPORTING text = 'Here you can write long text.but when use TOP_OF_PAGE its length only 60 Chars.' sap_style = 'heading'. CALL METHOD top->add_gap EXPORTING width = 200. CALL METHOD top->add_picture EXPORTING picture_id = 'ENJOYSAP_LOGO'. CALL METHOD top->new_line( ). CALL METHOD top->add_text EXPORTING text = l_text. ENDFORM. "html_top_of_page
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
0 comments:
Post a Comment
Your useful comments, suggestions are appreciated.Your comments are moderated.