2007 Nov 13 3:38 PM
Hi all,
My requirement is to downlaod data from App Server to Pres server in CSV format.
In function module i can use in order to acheive this.I tried with GUI_DOWNLAOD but i couldn't get it.
Please help.
Points will be rewarded...
Hi all,
My requirement is to downlaod data from App Server to Pres server in CSV format.
In function module i can use in order to acheive this.I tried with GUI_DOWNLAOD but i couldn't get it.
Please help.
Points will be rewarded...
2007 Nov 13 3:41 PM
Dear Divya,
first read it fro application server into your internal table using open dataset, read dataset and then close dataset. i hope you know theese commands i.e to read into internal table from application server.
once you have it in your internal table its easy to download to presentation server using GUI_DOWNLOAD.
CHEERS
2007 Nov 13 3:46 PM
Hi,
I need to download it from ABAP Program.Say itab_final.I tried using with GUI_DOWNLOAD but couldn't.Could please send me the code if possible?
Thanks,
2007 Nov 13 3:50 PM
Ok..
You need to first read the data into internal table and then you can download it into CSV file using the gui_download...
To read the file into internal table from Application server
OPEN DATASET OUTFILE FOR OUTPUT IN TEXT MODE encoding default.
IF sy-subrc <> 0.
message e001(z_error).
endif.
transfter outfile to itab
if sy-subrc = 0.
append itab.
endif.
CLOSE DATASET OUTFILE.Now, once you have data into the itab, you can download it into CSV.
data: begin of it_down occurs 0,
str type string,
end of it_down.
Loop at itab.
concatenate itab-field1 itab-field2 itab-field3 into it_down-str separated by ','.
append itab.
endloop.Then download thi it_down to presentation server with GUI_DOWNLOAD
Regards,
Naimesh Patel
2007 Nov 13 3:53 PM
if its not working then have a break point in your program and check if you are able to get data in to internal table or not..
if its not so , then go thru the code given by some of our friends to split the data being read from application server and then appending it to internal table.
if not could you be more precise on your porblem
CHEERS
Message was edited by:
trivenn mudiavrthi
2007 Nov 13 3:57 PM
Hi Divya,
If the File is in application server, then you need to read it first, then move the contents to an internal table and then transfer it using GUI_DOWNLOAD.
Use the following code to read the file from Application server.
OPEN DATASET <filepath> FOR INPUT.
CHECK sy-subrc = 0.
DO.
READ DATASET <filepath> INTO wa_string.
IF sy-subrc <> 0.
EXIT.
ENDIF.
SPLIT wa_string AT '#' INTO wa-<field1> wa-<field2>.... wa-<fieldn>
append wa to itab.
ENDDO.
CLOSE DATASET '/tmp/test.xls'.
Once the internal table id populated call FM GUI_DOWNLOAD to download the contents into a csv or xls. file
Use the following code for download.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = <Filepath>
TABLES
data_tab = itab.
Hope it helps.
Lokesh
Message was edited by:
Lokesh Aggarwal
2007 Nov 13 3:50 PM
hi
good
go through this code hope this would give you some idea to solve your problem
parameters: p_file(512).
DATA : BEGIN OF ITAB OCCURS 0,
COL1(1024) TYPE C,
END OF ITAB,
WA_ITAB LIKE LINE OF ITAB.
DATA: BEGIN OF ITAB_2 OCCURS 0,
FIELD01(256),
FIELD02(256),
FIELD03(256),
FIELD04(256),
FIELD05(256),
FIELD06(256),
FIELD07(256),
FIELD08(256),
FIELD09(256),
FIELD10(256),
FIELD11(256),
FIELD12(256),
FIELD13(256),
FIELD14(256),
FIELD15(256),
FIELD16(256),
END OF ITAB_2.
DATA: WA_2 LIKE LINE OF ITAB_2.
OPEN DATASET p_FILE FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.
IF SY-SUBRC = 8.
WRITE:/ 'File' , p_FILE , 'cannot be opened'.
LV_LEAVEPGM = 'X'.
EXIT.
ENDIF.
WHILE SY-SUBRC <> 4.
READ DATASET p_FILE INTO WA_ITAB.
APPEND WA_ITAB TO ITAB.
ENDWHILE.
CLOSE DATASET p_FILE.
LOOP AT ITAB INTO WA_ITAB.
SPLIT WA_ITAB-COL1 AT ',' " where comma is ur demiliter
INTO WA_2-FIELD01 WA_2-FIELD02 WA_2-FIELD03 WA_2-FIELD04
WA_2-FIELD05 WA_2-FIELD06 WA_2-FIELD07 WA_2-FIELD08 WA_2-FIELD09
WA_2-FIELD10 WA_2-FIELD11 WA_2-FIELD12 WA_2-FIELD13 WA_2-FIELD14
WA_2-FIELD15 WA_2-FIELD16.
APPEND WA_2 TO ITAB_2.
CLEAR WA_2.
ENDLOOP.
thanks
mrutyun^
2007 Nov 14 11:17 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |