Embed SAP View in an ABAP Program

0
406

We can also embed View of a Table in a program. SAP have provided a set of standard function modules for achieving the goal and by passing the initial values required to do this, we can accomplish that.

In this example, we will use the function module SE16N_INTERFACE to call the new standard table display.

Embed View in Program

Program code:

*&———————————————————————*
*& Call the SE16n with the Selection from report                             *
*&                                                                                                                   *
*&———————————————————————*

REPORT ztest_tmp.

START-OF-SELECTION.

* data declaration for the FM
DATA: l_tab TYPE se16n_tab,
t_sel TYPE se16n_or_t,
la_sel LIKE LINE OF t_sel,
t_sel_tab TYPE se16n_or_seltab_t,
la_sel_tab LIKE LINE OF t_sel_tab.

* Table name
l_tab = ‘VBAK’.

* Selection for VBELN
la_sel_tab-field = ‘VBELN’.
la_sel_tab-sign = ‘I’.
la_sel_tab-option = ‘BT’.
la_sel_tab-low = ‘0000001000’.
la_sel_tab-high = ‘0000002000 ‘.
APPEND la_sel_tab TO t_sel_tab.

* Selection for ERDAT
la_sel_tab-field = ‘ERDAT’.
la_sel_tab-sign = ‘I’.
la_sel_tab-option = ‘BT’.
la_sel_tab-low = ‘20081001’.
la_sel_tab-high = sy-datum.
APPEND la_sel_tab TO t_sel_tab.

* Fill the main selection table
la_sel-pos = 1.
la_sel-seltab = t_sel_tab.
APPEND la_sel TO t_sel.

* Function module for the SE16N

CALL FUNCTION ‘SE16N_INTERFACE’

EXPORTING
i_tab = l_tab
i_clnt_dep = ‘X’

TABLES
* IT_OUTPUT_FIELDS =
it_or_selfields = t_sel

EXCEPTIONS
no_values = 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.

LEAVE A REPLY