on 2006 Mar 16 6:09 AM
Hello people,
A few hours ago I asked a couple of guys how to download a file to html. For that I am most thankful, and as mentioned this is a two part question, my other question is about how to proccess downloading the html in background and to automatically send it to a folder or other path. Without any user intervention.
Example, I run a long report to be downloaded in background. The lets say the next day, I can get the file in a folder. Thanks guys take care!
Hi,
Here is the sample code.
data: ifields type table of w3fields with header line.
data: ihtml type table of w3html with header line.
data itab type standard table of pa0001.
select * into corresponding fields of table itab
from pa0001 up to 100 rows.
call function 'WWW_ITAB_TO_HTML'
EXPORTING
TABLE_ATTRIBUTES = 'BORDER=1'
TABLE_HEADER =
ALL_FIELDS = 'X'
tables
html = ihtml
fields = ifields
ROW_HEADER =
itable = itab
.
Local variable Declaration
DATA l_msg(60) TYPE c.
Opening the file for output in text mode
OPEN DATASET '/sapio/outbound/html.txt' FOR OUTPUT
IN TEXT MODE ENCODING DEFAULT MESSAGE l_msg.
IF sy-subrc NE 0.
MESSAGE s000 WITH 'Error in opening file for output'.
LEAVE LIST-PROCESSING.
ENDIF.
LOOP AT ihtml .
TRANSFER ihtml TO '/sapio/outbound/html.txt'.
ENDLOOP.
Closing the file
CLOSE DATASET '/sapio/outbound/html.txt'.
IF sy-subrc NE 0.
MESSAGE s000 with 'Error in closing file'.
LEAVE LIST-PROCESSING.
ENDIF.
Since you want to download in background,you cannot download in presentation server.SO you have to download in application server.
Kindly reward points if it helps.
Message was edited by: Jayanthi Jayaraman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Use
OPEN DATASET FOR OUPUT
&CLOSE DATASET
OPEN DATASET P_PATH FOR OUTPUT IN TEXT MODE.
LOOP AT PR_TBL.
ENDLOOP.
CLOSE DATASET P_PATH.
Regards,
Santosh
Message was edited by: Santosh Kumar Patha
Hello guys thanks for your help so far. I have been off again on again with this task because its more for future purposes than anything.
So far I have searched the net and stuff and decided that I will use WWW_LIST_TO_HTML since I want to download it the way it is. I am also going to use open/close dataset as many of you have mentioned.
SO far Im just trying it out with a simple report program to see its funcitonalities. My code goes like this.
_______________________________________
<b>REPORT ZCCYT_COOL2 NO STANDARD PAGE HEADING LINE-COUNT 100 .
DATA: IFIELDS TYPE TABLE OF W3FIELDS WITH HEADER LINE.
*DATA: ihtml TYPE TABLE OF w3html WITH HEADER LINE.
DATA: IHTML TYPE TABLE OF W3_HTML WITH HEADER LINE.
DATA: BEGIN OF I_TAB OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF I_TAB.
SELECT-OPTIONS: SO_MATNR FOR I_TAB-MATNR.
SELECT MATNR MAKTX
FROM MAKT
INTO TABLE I_TAB
WHERE MATNR IN SO_MATNR..
LOOP AT I_TAB.
WRITE: / I_TAB-MATNR,
I_TAB-MAKTX.
ENDLOOP.
.
CALL FUNCTION 'WWW_LIST_TO_HTML'
EXPORTING
list_index = sy-lsind
TABLES
HTML = IHTML.
DATA: FILE TYPE LOCALFILE.
FILE = '/usr/test.html'.
OPEN DATASET FILE FOR OUTPUT IN BINARY MODE.
LOOP AT IHTML.
TRANSFER IHTML TO FILE.
ENDLOOP.
CLOSE DATASET FILE.</b>
_____________________________________________
NOw the problem now though is that the file isnt downloading or saving at all. I cant seem to get what is wrong since the path does exist and the this seems the universal way to implement the program. Im guessing the problem lies in the file name, because everything seems to work fine. Hope to hear again soon sorry for not visiting this place sooner cuz I was buzy elsewhere.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Use below statement
*--- open file
open dataset nfile for output in text mode message w_msg.
if sy-subrc ne 0.
write: / 'Cannot open for writing:', nfile, w_msg.
exit.
endif.
*--- write file
loop at it_file.
transfer it_file to nfile.
endloop.
*--- close file
close dataset nfile.
regards
vinod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In background mode, files can only be downloaded in application server (not on presentation server).
For this use open dataset & close dataset statements
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.