Tuesday, May 6, 2008

Sample ABAP Program to Download file to Presentation Server

DATA: BEGIN OF I_VEND OCCURS 0,

NAME1 LIKE LFA1-NAME1,

LIFNR LIKE MSEG-LIFNR,

MATKL LIKE MARA-MATKL,

MATNR LIKE MSEG-MATNR,

MAKTX LIKE MAKT-MAKTX,

WERKS LIKE MSEG-WERKS,

SOBKZ LIKE MSEG-SOBKZ,

MENGE LIKE MSEG-MENGE,

MEINS LIKE MSEG-MEINS,

DMBTR LIKE MSEG-DMBTR,

COUNT TYPE I,

END OF I_VEND.





DATA: BEGIN OF FIELDNAMES OCCURS 1,

NAME(60),

END OF FIELDNAMES.

" CHECK_UNITS

*&---------------------------------------------------------------------*

*& Form DOWNLOAD_VENDOR

*&---------------------------------------------------------------------*

FORM DOWNLOAD_VENDOR.



PERFORM VEND_FIELDNAMES.



CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

* BIN_FILESIZE = ' '

* CODEPAGE = ' '

FILENAME = FILENAME

FILETYPE = 'DAT'

* MODE = ' '

* WK1_N_FORMAT = ' '

* WK1_N_SIZE = ' '

* WK1_T_FORMAT = ' '

* WK1_T_SIZE = ' '

* COL_SELECT = ' '

* COL_SELECTMASK = ' '

* importing

* filelength =

TABLES

DATA_TAB = I_VEND

FIELDNAMES = FIELDNAMES

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_WRITE_ERROR = 2

INVALID_FILESIZE = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

OTHERS = 8.



IF SY-SUBRC NE 0.

MESSAGE I004(YM) WITH FILENAME SY-SUBRC.

ENDIF.

ENDFORM. " DOWNLOAD_VENDOR



*&---------------------------------------------------------------------*

*& Form FIELDNAMES

*&---------------------------------------------------------------------*

FORM VEND_FIELDNAMES.



FIELDNAMES-NAME = 'Vendor name'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'Vendor No'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'Mat. Group'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'Material No'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'Material Desc.'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'Plant'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'SSI'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'Total Qty'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'UOM'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'Total value received'.

APPEND FIELDNAMES.

FIELDNAMES-NAME = 'Number'.

APPEND FIELDNAMES.

ENDFORM.

*

No comments:

Blog Archive