Wednesday, June 4, 2008

SAP ABAP Programs

1. Top-of-page and End-of-Page in ALV using OOPS

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_background_id = 'ALV_BACKGROUND'
i_callback_html_top_of_page = 'TOP_OF_PAGE'
i_callback_html_end_of_list = 'END_OF_LIST_HTML'
is_layout = wa_layout
it_fieldcat = it_fieldcat
i_default = 'X'
i_save = 'A'
is_print = wa_print
TABLES
t_outtab = it_result
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.

**********************************************************************************
*& Form TOP-OF-PAGE
**********************************************************************************
FORM top_of_page USING cl_dd TYPE REF TO cl_dd_document.
DATA: lv_per(255).
* for space
CALL METHOD cl_dd->add_gap
EXPORTING
width = 7.

* to add text in heading
CALL METHOD cl_dd->add_text
EXPORTING
text = text-001
sap_style = cl_dd_document=>heading
sap_fontsize = cl_dd_document=>medium
sap_emphasis = cl_dd_document=>strong.

* for gap between two text
CALL METHOD cl_dd->add_gap
EXPORTING
width = 23.

* for new text
CALL METHOD cl_dd->add_text
EXPORTING
text = text-001
sap_style = cl_dd_document=>key
sap_color = cl_dd_document=>list_background
sap_fontsize = cl_dd_document=>large
sap_emphasis = cl_dd_document=>emphasis.

* for new line
CALL METHOD cl_dd->new_line
EXPORTING
repeat = 0.

CALL METHOD cl_dd->add_gap
EXPORTING
width = 7.

CALL METHOD cl_dd->add_text
EXPORTING
text = text-001
sap_emphasis = cl_dd_document=>strong
style_class = space.

CALL METHOD cl_dd->add_gap
EXPORTING
width = 25.

CALL METHOD cl_dd->add_text
EXPORTING
text = text-001
sap_emphasis = cl_dd_document=>strong
style_class = space.

ENDFORM. "top_of_page

********************************************************************************
*& Form END-OF-PAGE
********************************************************************************
FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
DATA: ls_text TYPE sdydo_text_element,
l_grid TYPE REF TO cl_gui_alv_grid,
f(14) TYPE c VALUE 'SET_ROW_HEIGHT'.

ls_text = 'Footer title'.

* adds and icon (red triangle)
CALL METHOD end->add_icon
EXPORTING
sap_icon = 'ICON_MESSAGE_ERROR_SMALL'.

* adds test (via variable)
CALL METHOD end->add_text
EXPORTING
text = ls_text
sap_emphasis = 'strong'.

* adds new line (start new line)
CALL METHOD end->new_line.

* display text(bold)
CALL METHOD end->add_text
EXPORTING
text = 'Bold text'
sap_emphasis = 'strong'.

*set height of this section
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.

CALL METHOD l_grid->parent->parent->(f)
EXPORTING
id = 3
height = 10.

ENDFORM. "end_of_list_html.

2.To display Total Text in ALV List Display

Perform fieldcat.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat
it_events = it_events
is_layout = i_layout
it_sort = it_sort
i_default = 'X'
TABLES
t_outtab = it_final.

Perform build_layout.
Perform bulid_sort.


form build_layout.
data i_layout type slis_layout_alv.
i_layout-no_input = 'X'.
i_layout-colwidth_optimize = 'X'.
i_layout-totals_text = 'Total'.
i_layout-subtotals_text = 'SubTotal'.
I_layout-totals_only = 'X'.
i_layout-zebra = 'X'. “For stripped pattern
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT



FORM bulid_sort.

data it_sort type slis_t_sortinfo_alv .
data wa_sort type slis_sortinfo_alv.
CLEAR wa_sort.
wa_sort-spos = '1'.
wa_sort-fieldname = 'CITY1'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-group = '*'. “For Page Break
wa_sort-obligatory = 'X'.
APPEND wa_sort TO it_sort.

ENDFORM. " bulid_sort

3.To download Internal Table data’s to Particular path in Local PC

REPORT zkk.
TABLES tjj15.

PARAMETERS: filename(10).
PARAMETERS: path(30) TYPE c DEFAULT 'C:\'.

DATA path_name type string.
DATA itab LIKE TABLE OF tjj15 WITH HEADER LINE.

SELECT * FROM tjj15 INTO TABLE itab.

CONCATENATE path filename '.' 'XLS' INTO path_name.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = path_name “this variable must be a string
FILETYPE = 'DAT'
tables
data_tab = itab
.

1 comment:

Anonymous said...

Is the casino game of chance better than a
The games of chance worrione in the casino are not very 제왕 카지노 high quality and the game 온카지노 may have no live dealer tables. However, this may be due to the fact that the casino has