Skip to Content
0
Former Member
May 31, 2007 at 08:36 PM

Report output in background -download in Excel format to virtual dir

25 Views

Hi,

I got this piece of code from forum.this works fine in frontend but I need this functionality in background.Any ideas?

REPORT C.

TABLES: BKPF.

*

DATA: BEGIN OF ITAB OCCURS 0,

BUKRS LIKE BKPF-BUKRS,

GJAHR LIKE BKPF-GJAHR,

END OF ITAB.

*

DATA: BEGIN OF ITAB_FIELD OCCURS 0,

TXT(10),

TXT1(10),

END OF ITAB_FIELD.

PARAMETERS:

P_FILE TYPE RLGRAP-FILENAME DEFAULT '
xyz\xyxxx\test'.

START-OF-SELECTION.

*

SELECT BUKRS GJAHR FROM BKPF INTO TABLE ITAB UP TO 100 ROWS.

*

ITAB_FIELD-TXT = 'Bukrs'. APPEND ITAB_FIELD.

ITAB_FIELD-TXT = 'Gjahr'. APPEND ITAB_FIELD.

*

CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = P_FILE

TABLES

DATA_TAB = ITAB

FIELDNAMES = ITAB_FIELD

EXCEPTIONS

FILE_NOT_EXIST = 1

FILENAME_EXPECTED = 2

COMMUNICATION_ERROR = 3

OLE_OBJECT_METHOD_ERROR = 4

OLE_OBJECT_PROPERTY_ERROR = 5

INVALID_PIVOT_FIELDS = 6

DOWNLOAD_PROBLEM = 7

OTHERS = 8.

*

IF SY-SUBRC <> 0.

WRITE: / SY-SUBRC.

ENDIF.

*

regards

Praveen