Google Search - Blog...........

ABAP - Top Of Page Center Using OOPS In ALV Report.

REPORT zalvtest.



*------------------------------------------------------------------------------

* tables

*------------------------------------------------------------------------------

TABLES vbak.



*------------------------------------------------------------------------------

* type pools

*------------------------------------------------------------------------------



TYPE-POOLS slis.



*------------------------------------------------------------------------------

* types and internal tables

*------------------------------------------------------------------------------



*Data Declaration

TYPES: BEGIN OF t_vbak,

vbeln TYPE vbak-vbeln,

erdat TYPE vbak-erdat,

ernam TYPE vbak-ernam,

audat TYPE vbak-audat,

vbtyp TYPE vbak-vbtyp,

netwr TYPE vbak-netwr,

vkorg TYPE vbak-vkorg,

vkgrp TYPE vbak-vkgrp,

END OF t_vbak.



DATA it_vbak TYPE STANDARD TABLE OF t_vbak INITIAL SIZE 0.



*ALV Data Declaration

DATA: fldcat TYPE slis_t_fieldcat_alv,



w_fldcat TYPE slis_fieldcat_alv,



gd_layout TYPE slis_layout_alv,



gd_repid TYPE sy-repid.



DATA: date1(10).



*------------------------------------------------------------------------------

* selection screen design

*------------------------------------------------------------------------------



SELECT-OPTIONS: vbeln FOR vbak-vbeln.



*------------------------------------------------------------------------------

* start of selection

*------------------------------------------------------------------------------



START-OF-SELECTION.



PERFORM data_retrieval.



PERFORM bld_fldcat.



PERFORM bld_layout.



PERFORM display_alv_report.



*------------------------------------------------------------------------------

* build catalog

*------------------------------------------------------------------------------

*Build Field Catalog for ALV Report

FORM bld_fldcat.



w_fldcat-fieldname = 'VBELN'.

w_fldcat-seltext_m = 'Sales_Document'.

w_fldcat-col_pos = 0.

w_fldcat-outputlen = 15.

w_fldcat-key = 'X'.

w_fldcat-icon = 'X'.

APPEND w_fldcat TO fldcat.

CLEAR w_fldcat.



w_fldcat-fieldname = 'ERDAT'.

w_fldcat-seltext_l = 'Record_Date_created'.

w_fldcat-col_pos = 1.

w_fldcat-key = 'X'.

APPEND w_fldcat TO fldcat.

CLEAR w_fldcat.



w_fldcat-fieldname = 'ERNAM'.

w_fldcat-seltext_l = 'Cteated_Person_Name'.

w_fldcat-col_pos = 2.

w_fldcat-emphasize = 'C011'.

APPEND w_fldcat TO fldcat.

CLEAR w_fldcat.



w_fldcat-fieldname = 'AUDAT'.

w_fldcat-seltext_m = 'Document_Date'.

w_fldcat-col_pos = 3.

w_fldcat-emphasize = 'C110'.

APPEND w_fldcat TO fldcat.

CLEAR w_fldcat.



w_fldcat-fieldname = 'VBTYP'.

w_fldcat-seltext_l = 'SDDocument_category'.

w_fldcat-col_pos = 4.

APPEND w_fldcat TO fldcat.

CLEAR w_fldcat.



w_fldcat-fieldname = 'NETWR'.

w_fldcat-seltext_l = 'Net_Value'.

w_fldcat-col_pos = 5.

w_fldcat-outputlen = 10.

w_fldcat-do_sum = 'X'.

w_fldcat-datatype = 'CURR'.

APPEND w_fldcat TO fldcat.

CLEAR w_fldcat.



w_fldcat-fieldname = 'VKORG'.

w_fldcat-seltext_l = 'Sales_Organization'.

w_fldcat-col_pos = 6.

APPEND w_fldcat TO fldcat.

CLEAR w_fldcat.



w_fldcat-fieldname = 'VKGRP'.

w_fldcat-seltext_m = 'Sales_Group'.

w_fldcat-col_pos = 7.

w_fldcat-emphasize = 'C801'.

APPEND w_fldcat TO fldcat.

CLEAR w_fldcat.



ENDFORM. "BLD_FLDCAT

*------------------------------------------------------------------------------

* display fatalog

*------------------------------------------------------------------------------

*Build Layout for ALV Grid Report



FORM bld_layout.

gd_layout-no_input = 'X'.

gd_layout-box_fieldname = 'VBELN'.

ENDFORM. "BLD_LAYOUT





*Display report using ALV grid



FORM display_alv_report.

gd_repid = sy-repid.



CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = gd_repid

is_layout = gd_layout

i_callback_html_top_of_page = 'TOP_OF_PAGE_SPLIT'

it_fieldcat = fldcat[]

TABLES

t_outtab = it_vbak.



ENDFORM. "DISPLAY_ALV_REPORT

*------------------------------------------------------------------------------

* get data

*------------------------------------------------------------------------------

*Retrieve data from VBAK table and populate itab IT_VBAK

FORM data_retrieval.



SELECT vbeln

erdat

ernam

audat

vbtyp

netwr

vkorg

FROM vbak

INTO TABLE it_vbak

WHERE vbeln IN vbeln.

ENDFORM. "DATA_RETRIEVAL

*------------------------------------------------------------------------------

* build header for alv

*------------------------------------------------------------------------------



FORM top_of_page_split USING r_top TYPE REF TO cl_dd_document.



DATA: s_tab TYPE sdydo_text_table,



c_area TYPE REF TO cl_dd_area,



text TYPE sdydo_text_element.



TYPES: BEGIN OF tab_text,

text TYPE sdydo_text_element,

END OF tab_text.



DATA: i_text TYPE TABLE OF tab_text.

DATA: w_text TYPE tab_text.



CALL METHOD r_top->initialize_document.



CALL METHOD r_top->vertical_split

EXPORTING

split_area = r_top

split_width = '70%'

IMPORTING

right_area = c_area.



CONCATENATE sy-datum+4(2)

' / '

sy-datum+6(2)

' / '

sy-datum(4)

INTO date1.



CONCATENATE 'DATE'

date1

INTO w_text-text

SEPARATED BY ':'.

APPEND w_text TO i_text.



CONCATENATE 'time:' sy-uzeit INTO w_text .

APPEND w_text TO i_text.



CONCATENATE 'uesr:' sy-uname INTO w_text .

APPEND w_text TO i_text.



CONCATENATE 'local date:' sy-datlo INTO w_text .

APPEND w_text TO i_text.



CONCATENATE 'time zone:' sy-zonlo INTO w_text .

APPEND w_text TO i_text.





s_tab[] = i_text[].



CALL METHOD c_area->add_text

EXPORTING

text_table = s_tab

fix_lines = 'X'

sap_fontsize = cl_dd_document=>medium

sap_emphasis = cl_dd_document=>strong.



CALL METHOD r_top->add_gap

EXPORTING

width = 60.



text = 'THIS IS REPORT HEADING'.

CALL METHOD r_top->add_text

EXPORTING

text = text

sap_emphasis = 'STRONG'.



CALL METHOD r_top->new_line.



CALL METHOD r_top->add_gap

EXPORTING

width = 70.



text = 'THIS IS REPORT HEADING1'.

CALL METHOD r_top->add_text

EXPORTING

text = text

sap_emphasis = 'STRONG'.



CALL METHOD r_top->new_line.



CALL METHOD r_top->add_gap

EXPORTING

width = 80.



text = 'THIS IS REPORT HEADING2'.

CALL METHOD r_top->add_text

EXPORTING

text = text

sap_emphasis = 'STRONG'.





CALL METHOD r_top->new_line.



text = 'Report Subheading1'.

CALL METHOD r_top->add_text

EXPORTING

text = text

sap_emphasis = 'NORMAL'.



CALL METHOD r_top->new_line.



text = 'Report Subheading2'.

CALL METHOD r_top->add_text

EXPORTING

text = text

sap_emphasis = 'NORMAL'.



CALL METHOD r_top->new_line.



text = 'Report Subheading3'.

CALL METHOD r_top->add_text
EXPORTING
text = text
sap_emphasis = 'NORMAL'.
CALL METHOD r_top->new_line.
ENDFORM. "TOP_OF_PAGE_SPLIT




No comments:

Post a Comment