Dwonloading internal table into Pivot table using function moudle XXL_SIMPLE_API



Hi Friends,

Now we are discussing on how to download the data from internal table Excel in tabular format or Pivot table Format by using Function Moule "XXL_SIMPLE_API".



Here i am sharing you the example program:

EPORT ZDOWNLOAD_PIVOT.
data : begin of it_data occurs 0,
vbeln type vbeln_va,
posnr type posnr_va,
matnr type matnr,
NETPR type NETPR,
end of it_data.

DATA : " XXL_SIMPLE_API parameters and tables
y_filename LIKE gxxlt_f-file, " File name on the workstation
y_header LIKE gxxlt_p-text, " XXL interface: texts for printing a list
y_wa_col_text TYPE gxxlt_v,
y_it_col_text TYPE TABLE OF gxxlt_v, " Headings for DATA columns
y_wa_online_text TYPE gxxlt_o,
y_it_online_text TYPE TABLE OF gxxlt_o, " Table with online texts
y_wa_print_text TYPE gxxlt_p,
y_it_print_text TYPE TABLE OF gxxlt_p. " Table with print texts

*Selction Screen Options

SELECT-OPTIONS s_vbeln FOR it_data-vbeln.

*Retriving data

SELECT * from vbap INTO CORRESPONDING FIELDS OF TABLE it_data where vbeln IN s_vbeln.

IF sy-subrc NE 0.

MESSAGE 'No Data' TYPE 'I'.

ENDIF.


y_filename = 'download.xls'.
y_header = text-001. " Header Information "

* Column Headings

y_wa_col_text-col_no = '1'.
y_wa_col_text-col_name = 'Sales Order Number'.

APPEND y_wa_col_text TO y_it_col_text.

y_wa_col_text-col_no = '2'.
y_wa_col_text-col_name = 'Item Number'.
APPEND y_wa_col_text TO y_it_col_text.

y_wa_col_text-col_no = '3'.
y_wa_col_text-col_name = 'Material'.
APPEND y_wa_col_text TO y_it_col_text.

y_wa_col_text-col_no = '4'.
y_wa_col_text-col_name = 'Net Price'.
APPEND y_wa_col_text TO y_it_col_text.

* Calling a function module to down load the data

CALL FUNCTION 'XXL_SIMPLE_API'
EXPORTING
filename = y_filename
header = y_header " Heading
n_key_cols = 1 " Number of (hierarchical) key columns
TABLES
col_text = y_it_col_text
data = it_data
online_text = y_it_online_text
print_text = y_it_print_text
EXCEPTIONS
dim_mismatch_data = 1 " Non-present DATA column is referenced
file_open_error = 2 " File FILENAME cannot be opened
file_write_error = 3 " File FILENAME cannot be written to
inv_winsys = 4 " Wrong window system, DOS windows required
inv_xxl = 5 " Installation at the frontend incorrect
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*******************************************************************


After that you need to save and activate it.


No comments: