Download binary file (excelfile + makro)
Hi,
i searched in the forum for an answer but i didn´t find any...
So, here is my question:
I have an excelfile with makros and i want to download it from server.
Using gui_download creates a file which can not be read by excel.
DO.
READ DATASET makro_rag INTO downtab.
IF sy-subrc > 0. EXIT. ENDIF.
rec_len = STRLEN( downtab-tab ).
APPEND downtab.
ENDDO.
CLOSE DATASET makro_rag.
DESCRIBE TABLE downtab LINES rec_cnt.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = makro_rag_down
filetype = 'BIN'
IMPORTING
filelength = rec_len
TABLES
data_tab = downtab
EXCEPTIONS
file_open_error = 1
file_write_error = 2.
When using cl_gui_frontend_services=>gui_download I got errors because of incorrect assignments.
DO.
READ DATASET makro_rag INTO downtab.
IF sy-subrc > 0. EXIT. ENDIF.
rec_len = STRLEN( downtab-tab ).
wa_heading-line = downtab-tab.
APPEND wa_heading to g_heading.
ENDDO.
close dataset makro_rag.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
BIN_FILESIZE = rec_len
filename = 'c: empmakro_rag.xls'
FILETYPE = 'BIN'
changing
data_tab = g_heading
Has anybody an idea what goes wrong there?
Thanks in advance,
Sebastian
hi,
use TEXT_CONVERT_XLS_TO_SAP function module to fetch values directly from the EXCEL file to your internal table.
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
Also, check the following links:
http://www.sapdevelopment.co.uk/file/file_upexcel.htm
http://www.sapdevelopment.co.uk/file/file_upexcelalt1.htm
http://www.sapdevelopment.co.uk/file/file_upexcelalt2.htm
Regards
Anver
Similar Messages
-
Issue in downloading Binary File on Safari 5 (MAC OS)
Hi,
We are working on an application, which download binary file when clicks the button, when i am using Safari 6 the below code snippet download file successfully.
Image:
Safari 6: on clicking Export file downloaded:
code:
String userAgent = request.getHeader("user-agent");
if (userAgent.toLowerCase().indexOf("mac") >= 0) {
response.setContentType("application/octet-stream");
} else {
response.setContentType(TEXT_CSV);
// These Lines were added to make it work on the secure https
// connection
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");
response.setHeader("Content-Disposition", "filename=contacts.csv");
but when we use safari 5 on MAC its not downloading the file, it simply display the content on browser it self
Image:
and file is not downloaded in this case, can some one tell what should be the contentType(""); should be set to download the file in Safari 5, so that the file can be downloaded in case of Safari 5.
Thanks in advance:)You can set content type to:
response.setContentType("application/vnd.ms-excel");
file will download on safari 6 -
Itunes won't download, binary file won't save to computer.
Every time I click on the "Download Now" button, I am able to select what folder I want to download the binary file to.
Once I click save, nothing else happens. I am taken to the "Thank you for downloading itunes" screen, but there is no record of my download anywhere, and the file is simply not saving.So weird...I don't know why so many folks have this problem. Why won't the silly file download from Apple? When I click "save file" absolutely nothing happens. A dialogue box should pop up asking me where to save it.
My solution was to finally download it from one of the many file servers. I used one called "filehorse" and it downloaded right away.
How can one use their nifty iOS device if they can't install itunes on their computer?!
I tried the recommended "fixes", one of which included deleting the "temp" folder (which was not so easy to delete, required booting to safe mode command prompt) but made no difference. This was all using Firefox. IE is the only other browser on my computer, which seems to be permanently broken (most sites do not show properly even after using IE's "reset" feature).
I refuse to install Chrome, I tried it once and it sucked. Hopefully Apple will fix this silly issue so that next time I need to download iTunes, I can do it. Thank you! -
with firefox 3 I cannot open a program that downlaoded from the internet since they are binary files
Is there a phone number for tecj suppoprt with firefox sio that I van talk to a live person about thewias problenm
-
Binary file corrupted when downloading
Hi. I'm trying to download binary files using a JSP. This is my code:
<%
response.setContentType(report.getContent_type());
response.setHeader ("Content-Disposition", "attachment;filename=\""+report.getNombre()+"\"");
byte[] file = report.getFile();
ServletOutputStream sos = response.getOutputStream();
sos.write(file);
sos.close();
%>
It seems to work, but when i'm going to open the downloaded file, it's corrupted, and when I compare it with the original one, all bytes that follow the first '\0' character have been replaced by '\0'. The file size is the same, but not the content.
I'm using Websphere as application server. Maybe this problem is related with the server, or maybe I'm doing something wrong. Any ideas?
Thanks.I'm surprised that you didn't event get a IllegalStateException. Rather move all your logic to a servlet, jsps usually add whitespace where scriplets were and could corrupt your content.
-
Binary file, java, please fix these to just work when we try to download anything, Firefox 5 for example. I like to use Firefox desktop and mobile. It happens every time I download binary file, java script.
FileInputStream
-
Hi Experts,
i need to know how to transfer Binary files from application server to presentation server...
does it have any function module???
i hav use this Function Module 'DX_FILE_COPY'...
but it transfers only normal ".txt" files......
Thanks,
kassimHi,
I have searched the net and found something interesting that i think might solve your problem:
FM 'C13Z_APPL_TO_FRONT_END ' if present downloads binary files from the application server to the presentations server. It will show you a popup (which file to download and where to put it, including
the type of file) and when you click on the download button it will call function module C13Z_FILE_DOWNLOAD_BINARY, this will call (in the end) WS_DOWNLOAD.
FM 'C13Z_FILE_DOWNLOAD_BINARY' can show you how to write your own function, replacing WS_DOWNLOD with GUI_DOWNLOAD as WS_DOWNLOAD is obselete.
FM LIKE:
C13Z_FILE_DOWNLOAD_ASCII - Downloads a file in ASCII format
C13Z_FILE_DOWNLOAD_BINARY - Downloads a file in binary format
C13Z_FILE_UPLOAD_ASCII - Uploads a file in ASCII format
C13Z_FILE_UPLOAD_BINARY - Uploads a file in binary format \
I think above FM will definetly useful for you.
Pooja -
everytime i download a show or movie from the internet a pop up asks me:
"you have chosen to open xxxxxx which is a: Binary File from: httpxxxxx would you like to save this file - SAVE or CANCEL"
this never used to happen on the older versions of firefox. it is so annoying - is there any way to turn it off?
i am running mac os 10.5.8 and no, there is no option to click a 'don't ask me again' feature in the pop-up dialog.I'd first try downloading an installer from the Apple website using a different web browser:
http://www.apple.com/quicktime/download/
If you use Firefox instead of IE for the download (or vice versa), do you get a working installer? -
GUI_DOWNLOAD binary file download as XLS
All,
Using the following code i am generating a binary file and downloading as XLS using GUI_DOWNLOAD. But Everything working fine. But the problem is in the excel I am getting blank row and Blank column in the sheet.
ie First row and First column in the are coming as blank. I like to avoid this blank column and row
Any Info ?
data : lv_heading(50) type c.
data: lv_index(5) type c.
data: lv_string type string.
data: lv_string1 type string.
data: lv_xstring type xstring.
data: lt_textab type truxs_t_text_data.
data: ls_textab like line of lt_textab.
constants:
c_tab type c value cl_abap_char_utilities=>horizontal_tab,
c_cret type c value cl_abap_char_utilities=>cr_lf.
" Create Heading
do.
write sy-index to lv_index no-zero.
concatenate 'CTXT_' lv_index into lv_heading.
condense lv_heading no-gaps.
concatenate lv_string lv_heading c_tab into lv_string.
concatenate 'CVAL_' lv_index into lv_heading.
condense lv_heading no-gaps.
concatenate lv_string lv_heading c_tab into lv_string.
if sy-index eq gv_no_col.
concatenate c_cret c_tab lv_string into lv_string.
exit.
endif.
enddo.
call function 'SAP_CONVERT_TO_TEX_FORMAT'
exporting
i_field_seperator = c_tab
tables
i_tab_sap_data = <fs_table>
changing
i_tab_converted_data = lt_textab
exceptions
conversion_failed = 1
others = 2.
" Records for XLS
loop at lt_textab into ls_textab.
wa_out-text = ls_textab.
lv_string1 = wa_out-text.
concatenate lv_string c_cret c_tab lv_string1 into lv_string.
endloop.
clear: lv_xstring .
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = lv_string
importing
buffer = lv_xstring.
refresh it_binary_content .
call function 'SCMS_XSTRING_TO_BINARY'
exporting
buffer = lv_xstring
tables
binary_tab = it_binary_content.
endform. " F_generate_output_data.Resolved..
Issue is in the code
do.
write sy-index to lv_index no-zero.
concatenate 'CTXT_' lv_index into lv_heading.
condense lv_heading no-gaps.
concatenate lv_string lv_heading c_tab into lv_string.
concatenate 'CVAL_' lv_index into lv_heading.
condense lv_heading no-gaps.
concatenate lv_string lv_heading c_tab into lv_string.
if sy-index eq gv_no_col.
" concatenate c_cret c_tab lv_string into lv_string. "<< to be commented
exit.
endif.
enddo.
and
loop at lt_textab into ls_textab.
wa_out-text = ls_textab.
lv_string1 = wa_out-text.
concatenate lv_string c_cret lv_string1 into lv_string. " This line tab is removed
endloop. -
When trying to download it says binary file download and it starts but doesnt finish
as i try to download the little box pops up and says binary file save or cancel . So i save and it starts downloading the little line starts across and it gets to the end and disappears and leaves a empty box and nothing else happens
Which player? Do you mean Flash, or maybe the Windows Media Player plugin?
* http://www.adobe.com/products/flashplayer/distribution3.html
* https://support.mozilla.org/en-US/kb/play-windows-media-files-in-firefox
You have to run the installers with Firefox closed. -
When I try to download a software up date for another program in Binary File (eg. C Cleaner or a Microsoft file) in Firefox they all just come up in the download window as 'Canceled'? When I go to the destination folder the download file icon is there with 0 Kb's for size...Then when I click 'RETRY' the download it appears to download fully, but when I go into the destination folder the downloaded file is not there? I need to know if there is something in the Firefox options to resolve this problem or much more!!
If all .exe files are blocked, antivirus software is most likely configured to block them. See if you can download these with your antivirus and/or security software disabled.
-
Firefox crashed when I try to download a binary file
In this instance it is IE8 which I am trying to download (for business purposes I need Activex controls). When I currently open IE it runs as a process rather than an application. I have tried to download IE8 and google's Chrome but Firefox crashes as soon as I try to save the Binary files.
Sorry you are having problems. Can you give an example preferably of some small publicly available file and the site you are trying to download it from ?
As a simple example of a download (ok it is a .png image file not not a .exe file) but can you try to download a copy of your avtar/icon, as used on these forums. In Windows one method is that you right click & should get an option save. <br/> Mine alongside uses the link
* https://support.mozilla.com/media/uploads/avatars/avatar-257447.png
Are you able to download such an image, then see it in your download manager, and find it on your computer.
Once you have got Firefox to save your binary file you can use it. In the case of the .exe file you are trying to download that should be usable as intended with your Windows Operating System, the avatar also should be easily opened and viewed.
P.S.
You could try installing the add-on https://addons.mozilla.org/en-US/firefox/addon/opendownload-10902/ if you wished to adapt Firefox to run .exe files instead of just save them. -
using Windows 7 with i3 processor all the latest updates. Firefox is the ONLY browser that gives me this problem. I should not have to turn off my antivirus or go into my config files, write code or anything to have this simple task to work. If I buy a download for a program and get one shot at the download which is an executable file, I should not have it come up as a Binary file and can not use it to load the program that I just ordered.
Sorry you are having problems. Can you give an example preferably of some small publicly available file and the site you are trying to download it from ?
As a simple example of a download (ok it is a .png image file not not a .exe file) but can you try to download a copy of your avtar/icon, as used on these forums. In Windows one method is that you right click & should get an option save. <br/> Mine alongside uses the link
* https://support.mozilla.com/media/uploads/avatars/avatar-257447.png
Are you able to download such an image, then see it in your download manager, and find it on your computer.
Once you have got Firefox to save your binary file you can use it. In the case of the .exe file you are trying to download that should be usable as intended with your Windows Operating System, the avatar also should be easily opened and viewed.
P.S.
You could try installing the add-on https://addons.mozilla.org/en-US/firefox/addon/opendownload-10902/ if you wished to adapt Firefox to run .exe files instead of just save them. -
Read binary files that are wraped in the downloaded executable signed jar
Hello, there:
I have created a Swing application and created a signed jar file and uploaded it to my site. The signed jar includes class packages, and a folder of binary files which are the datasource for my application.
jws downloads this signed executable jar, it'll automatically run it, but it has problems reading the binary folders wrapped in itself (the app is supposed to read the folder's structure and use the info to create a JTree object, and read the file's content as well). Is it the file path conversion problem? Do we need to use URL instead? I tried it after reading some threads on this forum but didn't make it.
As an alternatives, I want JWS to unjar the jar file and expand it to exploded files. I manually unjar it and run the app from command line, it works fine.
Plus, the app is supposed to manipulate the binary files when it's in process, like saving new content back to the files, zip the files and upload them to the remote sql server. therefore, I think it's easy to have it run when it's expanded.
So here is the question: JWS by default is running the executable jar, is there a way to tell JWS to unzip the jar and find the main class in the exploded files and run it?
Thanks a lot for your suggestions,
SwayYou can get to any resource in a jar file in your classpath. The code below will return InputStream for resource.bin nested two packages down.
InputStream in = YourClass.class.getResourceAsStream("/com/mypackage/resouce.bin"); //use '/' instead of '.'You can open a FileOutputStream to write that file.
OutputStream out = new FileOutputStream("myTempResource.bin");
IOUtil.streamAndClose(in,out);If the resouce is a nested zip or nested jar then you can use the Java Zip utilities to unwrap the stream. -
Download ascii file procedure -problem as its getting binary after download
Hi ,
I have create a application that will download a file from a customised blob table by calling the procedure below which is as per oracle documentation:
CREATE OR REPLACE PROCEDURE download_my_file(p_file IN NUMBER) AS
v_mime VARCHAR2(48);
v_length NUMBER;
v_file_name VARCHAR2(400);
Lob_loc BLOB;
BEGIN
SELECT b.MIME_TYPE, a.file_content, a.file_name,A.file_size
INTO v_mime,lob_loc,v_file_name,v_length
FROM PCD_PROCESS_TBL a,PCD_CNTL_TBL b
WHERE a.seq_no =p_file AND ROWNUM<2;
-- set up HTTP header
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
owa_util.mime_header( NVL(v_mime,'text/plain'), FALSE,'ISO-8859-4' );
-- set the size so the browser knows how much to download
htp.p('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
htp.p('Content-Disposition: attachment; filename="'||SUBSTR(v_file_name,INSTR(v_file_name,'/')+1)|| '"');
-- close the headers
owa_util.http_header_close;
-- download the BLOB
wpg_docload.download_file( Lob_loc );
END download_my_file;
The problem is that when our process updating the blob table with .dat file from Unix the data getting inserted fine.The file is basically a ascii file. But after downloading this by mime 'text/plain' or 'application/octet' i can see its getting as a binary file and it is not carriage return by a new line.A space like character getting inserted inside each line .
can anybody please help out of that how can we get rid of this.
I even change the blob to clob but still the problem persists even for clob the procedure not getting called.
Thanks in advance,
DebaSounds like the problem you're having is the mismatch between the Unix text file format and the Windows text file format.
Specifically, Unix uses LF (line feed) to denote the end of a line, while Windows uses CRLF (two characters, carriage return and line feed).
If you open the file in Wordpad, you should see it ok.
Maybe you are looking for
-
How to get the file path in adf application
hii all, i have a txt file that i am using in my adf application, i am passing this txt file through a File Reader, for which i have to mention the file path. The file is in web-content and when i am hard coding the complete file path i.e C:/JDevelop
-
I know this has prob been covered a million times BUT I cant find the answer or solution. I am new to FCPX and I shoot video on canon xa10 using internal HD...When I go to import into FCPX the files are empty?? Why?? I can see the files on my HD but
-
Receive pdf reply, not xml
I've created a form using LiveCycle Designer ES. My reply by email button sends me the xml; I know how to repopulate the form, but would prefer a pdf. Can I modify my existing form?
-
New to apple- How to allow access to location?
I set up an apple id... but am unable to use "find my iPhone," mapquest, shopping apps.. The apps don't have access to "my location." I may have set as private somehow?? I am new to apple. Any help?
-
Deciding between iMac and Mac Pro
My current desktop computer (a PC) is basically dead. It is under extended warrenty but the custom build place I got it from tells me nothing is covered (because of their negligence but they won't admit that) And basically they want me to pay out of