Google Search - Blog...........

ABAP - Download Data Without File Using FM WS_DOWNLOAD.

REPORT ZC1DOWNLOAD MESSAGE-ID ZC1DWNMSG.


TABLES: MAKT.

DATA: INTAB TYPE TABLE OF MAKT,
WA_INTAB LIKE LINE OF INTAB,
NO_OF_REC TYPE I,
COUNT TYPE I.

DATA: BEGIN OF F_INTAB,
STR(255) TYPE C,
END OF F_INTAB.

DATA: T_INTAB LIKE TABLE OF F_INTAB,
W_INTAB LIKE LINE OF T_INTAB,
TEMP(255) TYPE C.

FIELD-SYMBOLS: TYPE ANY.

* Selection ScreenSection for the file download

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: FILE TYPE RLGRAP-FILENAME MEMORY ID FILE,
TAB RADIOBUTTON GROUP RAD1 DEFAULT 'X',
OTHERS RADIOBUTTON GROUP RAD1,
DELIMIT TYPE C.
SELECTION-SCREEN END OF BLOCK B1.

START-OF-SELECTION.

IF FILE IS INITIAL.
MESSAGE I001.
EXIT.
ENDIF.
IF OTHERS = 'X'.
IF DELIMIT = ' '.
MESSAGE I002.
EXIT.
ENDIF.
ENDIF.
* data selection into table
SELECT * FROM MAKT UP TO 100 ROWS INTO TABLE INTAB.

IF TAB = 'X'.

CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'DAT'
MODE = 'A'
TABLES
DATA_TAB = INTAB.

ELSE.
* Counts the number of fields *
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE WA_INTAB TO .
IF SY-SUBRC <> 0.
EXIT.
ELSE.
COUNT = COUNT + 1.
ENDIF.
ENDDO.

LOOP AT INTAB INTO WA_INTAB.
DO COUNT TIMES. " Adding the delimiter in required places
ASSIGN COMPONENT SY-INDEX OF STRUCTURE WA_INTAB TO .
CONCATENATE TEMP DELIMIT INTO TEMP.
ENDDO.
SHIFT TEMP.
APPEND TEMP TO T_INTAB.
CLEAR TEMP.
ENDLOOP.


CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'ASC'
MODE = 'A'
TABLES
DATA_TAB = T_INTAB.
ENDIF.
WRITE:/ 'The Data has been tranfered to :', FILE.



ALSO READ:



RETURN TO MAIN INDEX:

- Sample Programs On Uploading & Downloading Files.

- Sample Programs On HR ABAP.

- Sample Report Programs On ALV List/ Grid Display.

- Sample Programs On Selection Screen.

- Sample Programs On BDC.

.....Back To MAIN INDEX.

No comments:

Post a Comment