Zip binary data and save zip file to disk at bsp
Hi,
I try to compress (zip) binary data (for example a picture) and then give it to a html page. I use the cl_abap_gzip=>compress_binary method and it seems to work. But when I save the zip-file to harddisk over the popup at the html - page, the file could not be opened. WinZip says that it is an unvalid archive.
Can anybody help me?
Here my example coding at the OnInitialization Event of the business server page:
* event handler for data retrieval
* local variables
DATA: xsourcefile TYPE xstring.
DATA: xzippedfile TYPE xstring.
DATA: source_file_mime_type TYPE string.
DATA: xzippedcontentlength TYPE i, xzippedcontentlengthstring TYPE
string.
* References
DATA: o_mime_api TYPE REF TO if_mr_api.
* processing
* +++ Read File from MIME-Repository (binary) +++
CALL METHOD cl_mime_repository_api=>if_mr_api~get_api
RECEIVING
r_mr_api = o_mime_api.
CALL METHOD o_mime_api->get
EXPORTING
i_url = 'SAP/ZGSD_SD_ADIS/test.gif'
* I_CHECK_AUTHORITY = 'X'
IMPORTING
* E_IS_FOLDER =
e_content = xsourcefile
e_mime_type = source_file_mime_type
* E_LOIO =
* CHANGING
* C_LANGUAGE =
EXCEPTIONS
parameter_missing = 1
error_occured = 2
not_found = 3
permission_failure = 4
OTHERS = 5
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* +++ create ZIP-File +++
TRY.
CALL METHOD cl_abap_gzip=>compress_binary
EXPORTING
raw_in = xsourcefile
* RAW_IN_LEN = -1
* COMPRESS_LEVEL = 6
IMPORTING
gzip_out = xzippedfile
gzip_out_len = xzippedcontentlength.
* ... Länge Casten !
xzippedcontentlengthstring = xzippedcontentlength.
* ... Errorhandling
CATCH cx_parameter_invalid_range . " Error-Handling
CATCH cx_sy_buffer_overflow . " Error-Handling
CATCH cx_sy_compression_error . " Error-Handling
ENDTRY.
* +++ Put ZIP-File in Response +++
response->set_data( xzippedfile ).
response->set_header_field( name = if_http_header_fields=>content_type
value = 'application/octet-stream' ).
response->set_header_field( name =
if_http_header_fields=>content_length
value = xzippedcontentlengthstring ).
response->set_header_field( name = 'Content-Disposition'
value = 'inline;filename=test.zip' ).
navigation->response_complete( ).
Thanks Timo
PS: I posted this question also at ABAP Forum.
Hi,
First you need to define your ext prog in SM69.
It is simple though, specify:
Command name: ZZIPBIN
OS: (your os)
System command: /yourpath/zzipbin
Extra params allowed: checked
Then you need to code this:
data: table TYPE zeu_t_btcxpm.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = 'ZZIPBIN'
additional_parameters = param
operatingsystem = sy-opsys
terminationwait = 'X'
TABLES
exec_protocol = table
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry = 13
jobcount_generation_error = 14
OTHERS = 15.
See also http://help.sap.com/saphelp_nw2004s/helpdata/en/c4/3a8023505211d189550000e829fbbd/frameset.htm
Eddy
PS.
Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.
Spread the wor(l)d!
Similar Messages
-
Zip the data and send as an email attachment
Hi,
I have a requirement where I want to send the log as an email attachment. The log size is very huge about 20MB. When I try to send this log as an excel attachment through FM SO_DOCUMENT_SEND_API1 its throwing an error related to the attachment size. Is there any way to zip the data and send the zipped attachment?
Any help is really appreciated.
Thnaks,
Rajinikanth Gwhich might help you getting the file from the pc or you can change the source path and then send it to the following reciptant
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 3
OTHERS = 4
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'Manohar testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'Manohar testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
FOLMEM_DATA =
RECEIVE_DATA =
File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
this code might help you -
DAQ vi to perform digital write and read measurements using 32 bits binary data saved in a file
Hi
DAQ vi to perform digital write and read measurements using 32 bits binary data saved in a file
Two main
sections:
1)
Perform
write and read operations to and fro different spread sheet files, such that
each file have a single row of 32bits different binary data (analogous to 1D
array) where the left most bit is the MSB. I don’t want to manually enter the
32 bits binary data, I want the data written or read just by opening a file
name saves with the intended data.
2)
And
by using test patterns implemented using the digital pattern generator or build digital data functions or otherwise, I need to
ensure that the
binary data written to a spreadsheet file or any supported file type
then through the NI-USB 6509 is same as the data read.
I’m aware I can’t use the simulated
device to read data written to any port but if the write part of the vi works I
‘m sure the read part will work on the physical device which I’ll buy later.
My Plan
of action
I’ve
created a basic write/read file task and a write/read DAQ task for NI USB 6509
and both combine in a while loop to form a progress VI which I’m confuse of how
to proceed with the implementation.
My
greatest problem is to link both together with the correct functions or operators
such that there are no syntax/execution errors and thus achieve my intended
result.
This
project is one of my many assignments for my master thesis, so please i’ll
appreciate every help as I’m not really efficient with LabVIEW programming but
I prefer it because is fun and interesting if I get to know it.
Currently I’m
practicing with LabVIEW 8.6/NI DAQmx 8.8 Demo versions and NI USB 6509
simulated device.
Please see
the attached file for my novice progress, thanks in
advance for the support
Rgds
Paul
Attachments:
DIO_write_read DAQ from file.vi 17 KBWhat does your file look like? The DAQmx write is expecting a single U32 value, not an array of I64.
Message Edited by vt92 on 09-16-2009 02:42 PM
"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal -
How to read csv Data and save it with no format changes
Hi,
At first I am not used to Diadem.
I want to read in a csv file do some calculation with the data and save the changed data in the same csv file. A file as an example is attached (496888_edit.csv).
Therefore I wrote this lines:
Dim i
Dim Delimiter
Dim FilePath
Dim FileParameters
Delimiter = ";"
Call DataFileLoad(FilePath,"CSV","Load")
' Do some calculations
FileParameters = "<filename>"&FilePath&"</filename>"&"<delimiter>"&Delimiter&"</delimiter>"
Call DataFileSave(FileParameters,"CSV")
After running that lines the csv file is looking like the other attached file (496888_after.csv)
Because of some reasons which I could not explain Diadem is rounding the numbers. I want that both files look the same.
What can I do?
There might be another extension. Just to read in some columns, doing some calculations and after the calculation saving that columns in the file instead of the originals. (The csv files are much bigger like the two examples)
Thanks,
Jens
Attachments:
496888_edit.csv 1 KB
496888_after.csv 1 KBThe only thing that can be changed in writing float64 values using the CSV plugin is the decimal point ('.' or ',').
The format of the doubles is not rounded but the CSV writer only writes the relevant digits.
It is using up to 15 digits which is the resolution of float 64. It would also switch to scintific writing if necessary.
So there is no way to force only 6 digits and filling 0s are left out. So if you just fear that you loose precision that will not happen.
(only the typical problems of epressing a 2 system binary value in a 10 system text string)
If you are interested to have a fix float format the only solution is to write with VBS directly to a file doing formatting on your own, which is slow. -
How to capture a .gif file from a spectrum analyzer and save the file in PC
I want to capture a .gif file from a spectrum analyzer and save the file in PC, but I've got a problem when read data from the instrument. I'm not sure how to format the string got from the instrument , When I use "%s" or "%t" as the read string format the data got from the instrument is truncated.
my code are as follows, could anyone tell me where i am wrong?
char resultsArray[5000];
viPrintf(hSpectrumInstr, ":MMEMTORCR 'CICTURE.GIF'\n");
viQueryf(hSpectrumInstr, ":MMEMATA? 'CICTURE.GIF'\n", "%t", resultsArray);
printf("%s", resultsArray);
getchar();
Solved!
Go to Solution.
Attachments:
readResult.docx 50 KBchar resultsArray[5000];
viPrintf(hSpectrumInstr, ":MMEMTORCR 'CICTURE.GIF'\n");
viQueryf(hSpectrumInstr, ":MMEMATA? 'CICTURE.GIF'\n", "%b", resultsArray); -
Confusion regarding Binary data and byte arrays
HI guys,
I have a question...i am going to send some binary data...the format of that data is that first two bytes is the lenght of the data and then follows that data. Here i have one confusion. e.g. i want to say that the lenght of my data is 1000 bytes. How do i do it.
coz if i do something like this.
int k = 1000;//the length of my data
String binaryString = Integer.toBinaryString(k);
byte[] binaryData = binaryString.getBytes();
and then if i say binaryData.lenght, i see a lenght of 10, as the binary string which
is generated is -> 1111101000. i guess its obivious as this byte array is nothing but perhaps a character array with each character occupying one thread...so what exactly is the difference between byte array and binary data. and in the above said condition how do i send the binary data?
Also adding to my confusion is the fact that i have a file which contains binary data, but that data is not 10010101 type of data...its just some absurd characters. How do we explain this.
i would be highly grateful if you could explain me the solution to this problem.
I am not getting as to how to go about it.
its urgent..pls help...one sec..actually i dont want to 'read' the two bytes. That i know how to do? but The thing is that i want to write a binary stream. right? so in that the first two bytes should be the size of the data, followed by the data itself. So i want to write the first two bytes, which should contain the size of data (as a matter of fact i have that binary data in a byte array). But my question is , that if i say the size of data is 1000 (bytes , since, as i said i am gettting the data as a byte array), how do i write this in my binary stream as 1000 in this case would be an int. right? which is four bytes. So essentially that byte array (which contains binary data) i have to forward to somewhere, say X , but X reads binary data in the following way...it expects the first two bytes to give him info regarding the size of the data to follow and then it starts reading the data from the third byte onwards till the size of the data (which it got by reading first two bytes)...i hope i could communicate my confusion better this time
-
i recently updated my macbook, i don't know if that has any effect to my recent problem, but when i try to download and save .mp3 files from the internet, like i have done in the past, it downloads but not as an mp3 file, its "blank" and when i try to open it, i can't? I NEED HELP !
Here is the download page
-
Hi All,
I need code of How to open and save excel file in local system in Oracle forms.
With Regards,
Chandra ShekharHello Chandra,
Webutil can be used to achieve this functionality.
STEPS TO FOLLOW
================
1. Install and configure Webutil following instructions in the webutil manual
and the readme file.
2. Create a form with a block Eg. DEPT
3. Create a button, and in that button put the following code -
DECLARE
application Client_OLE2.Obj_Type;
workbooks Client_OLE2.Obj_Type;
workbook Client_OLE2.Obj_Type;
worksheets Client_OLE2.Obj_Type;
worksheet Client_OLE2.Obj_Type;
args Client_OLE2.List_Type;
cell ole2.Obj_Type;
j INTEGER;
k INTEGER;
BEGIN
application := Client_OLE2.create_obj('Excel.Application');
workbooks := Client_OLE2.Get_Obj_Property(application, 'Workbooks');
workbook := Client_OLE2.Invoke_Obj(workbooks, 'Add');
worksheets := Client_OLE2.Get_Obj_Property(workbook, 'Worksheets');
worksheet := Client_OLE2.Invoke_Obj(worksheets, 'Add');
go_block('dept');
first_record;
j:=1;
k:=1;
while :system.last_record = 'FALSE'
loop
for k in 1..3 /* DEPT has 3 columns */
loop
If not name_in(:system.cursor_item) is NULL Then
args:=Client_OLE2.create_arglist;
Client_OLE2.add_arg(args, j);
Client_OLE2.add_arg(args, k);
cell:=Client_OLE2.get_obj_property(worksheet, 'Cells', args);
Client_OLE2.destroy_arglist(args);
Client_OLE2.set_property(cell, 'Value', name_in(:system.cursor_item));
Client_OLE2.release_obj(cell);
End If;
next_item;
end loop;
j:=j+1;
next_record;
end loop;
/* For the last record */
for k in 1..3
loop
If not name_in(:system.cursor_item) is NULL Then
args:=Client_OLE2.create_arglist;
Client_OLE2.add_arg(args, j);
Client_OLE2.add_arg(args, k);
cell:=Client_OLE2.get_obj_property(worksheet, 'Cells', args);
Client_OLE2.destroy_arglist(args);
Client_OLE2.set_property(cell, 'Value', name_in(:system.cursor_item));
Client_OLE2.release_obj(cell);
End If;
next_item;
end loop;
Client_OLE2.Release_Obj(worksheet);
Client_OLE2.Release_Obj(worksheets);
/* Save the Excel file created */
args := Client_OLE2.Create_Arglist;
Client_OLE2.Add_Arg(args,'d:\test.xls');
Client_OLE2.Invoke(workbook, 'SaveAs', args);
Client_OLE2.Destroy_Arglist(args);
/* release workbook */
Client_OLE2.Release_Obj(workbook);
Client_OLE2.Release_Obj(workbooks);
/* Release application */
Client_OLE2.Invoke(application, 'Quit');
Client_OLE2.Release_Obj(application);
END;
4. Save the form and compile it.
5. Run the form.
6. Execute the query in the block.
7. Click on the button.
8. An excel file will be created in the d:\ directory by the name test.xls.
Kind regards,
Alex
If someone's answer is helpful or correct please mark it accordingly. -
How to create and save a file in flex web application ?
Hi,
I want to create and save a file form flex web application. Is it possible ?
I have done some googling and found that its only possible through file referece, which needs some serverside implementation be called.
Is it not possible with file reference to create and save file directly ?
Can any one suggest how to over come this.
Thanks in advance.Alex,
code written with the Flex Builder 3 libraries will certainly run in Flash Player 10. However, what you need is not so much the capabilities of FP10 but the library functionalities of the Flex 4 package. And I think that Flex 4 code will only run in FP10 and not 9 (but haven't tested this as at work we have not yet been permitted to upgrade, so there is not a lot of point going for Flex 4!).
Richard -
I had some problems with ITunes and had to uninstall but now when I reinstall iTunes after I click on download iTunes and save the File, I get this message"Thank you for downloading iTunes" and nothing else happens. I don't see any thing else. Now not sure what else I have to do.
Thanks,
RanjitSee the further information area of Troubleshooting issues with iTunes for Windows updates.
tt2 -
As per adobe agent chat representative, the following question is posted on the fórum to obtain an answe from adobe.
What is the location for the swatches file in the illustrator product part of Adobe Creative Suite 3 Design Premium for windows (date and lenght)? File that manges its funcionallity.
Thanks
<moved from downloading,installing,setting up - kglad>Illustrator is not working as it should...
I want them to compare the original size and date of creation with what I have installed on my computer... I have installed several times with my original CD and I tried once downloading the files from the adobe site (using my own license). I suspect the files has been modified or renamed on my laptop by an external unauthorized user causing the malfunction of the application.
Customer services does not support CS3 anymore and the updates / patches in the adobe site does not solve the problem... They redirect me to the forums for support...
Presently, my problem is that after creating a swatch and drag it to the swatch panel, it does not fill as it should a new form... Now, after deactivating and activating my license the swatch seems to fill the new form but when the filter that the swatch has is persistence in the next filling object created even though a different color is being used as a fill (X)... Help in the creation of a swatch over the internet just complicate the issue.
That's why I would like to know whether updates on my product are being received or files are being replaced without my knowledge...
Thanks...
PS Do you know how to contact a staff adobe employer on the forums? -
Flash Player update 10.3 unable to download and save flv files
Hello,
Since the Flash Player update to 10.3.183.10 it is no longer possible for me to download and save *.flv files. A file of only 2320 kb is saved along with a meta file of 1 kb. The 2320 kb file has a flv extension but the file will not play in any of my media players. Files of mp4 type still download and play fine. The problem only occurred following the last upgrade and even though I uninstalled then reinstalled Adobe Flash Player I cannot overcome the problem. My PC runs MS Windows Vista Home Premium Version: 6.0.6002 Service Pack 2 Build 6002. Browser Internet Explorer 9.0.8112.16421.
Your assistance would be much appreciated.
DiblocThank you.
The problem only occurs when downloading flv files from YouTube. For all video downloads I have been using RealPlayer and experience no problems when downloading flv files from sites other than YouTube.
Have been able to download these files now using the site http://www.savevid.com/
Perhaps YouTube are blocking the use of RealPlayer from downloading flv files? -
How do I download and saves html files off my website to store and save using Dreamweaver CS3?
How do I download and saves html files off my website to store and save using Dreamweaver CS3?
I need to save all files from web and store onto a drive to reupload to a new domain name. I use Dreamweaver CS3.First define your Local Site folder in Dreamweaver. DW will use this folder to store your site files.
Go to Manage Sites > New or Edit site. See screenshots.
Servers: Enter your remote server's log-in details. When complete, hit TEST to see if the connection is working. If all is well, hit SAVE.
From the Files Panel (F8), click on Remote Server to show the files that are currently there. Click the green Down Arrow to GET files from remote server to your local site folder.
Nancy O. -
When I try and save a file Photoshop crashes "McAfee blocked suspicious activity-Buffer overflow"
I never had this problem before. When i try and save a file Photoshop just fails instantly crashes and I get this error message from McAfee software:
Well, you could just make your firewall behave and create an exception rule as the warning suggests... It's unlikely that this is PS itself, anyway. Eitehr it's a flakey driver or a cracked plug-in you may be using (not implying anything here, so keep cool) may produce a wrong hash value/ signature and trigger the alarm.
Mylenium -
my ibook keeps shutting down completely with the date to reverting back to 1969. i restart only after i plug in charger it lets me, then change date and save. the next time i use same thing happens, safari, iphoto, email are the only ones i have used.
please help! i am at a loss here.
thank you, movie lady
ibook g4The iBook does not have a backup (PRAM) battery. It only has the main battery and a small capacitor which maintains the settings long enough to do a battery swap. If the battery is dead, what you are seeing can happen.
If the battery is not a problem (or even if it is), you could try resetting the PMU and see if that helps.
Maybe you are looking for
-
How to include an ASP page from JSP?
I had a working ASP page to be repeated on each page of the web site as an navigation bar updated from a single SiteMap.xml. Anyone knew how to include the ASP page from the JSP app? Thanks
-
Difference between the Function Module with remote execution option and the Function module used in BAPI. Thankyou for your time in giving the answers. Bhaskar.
-
TS3297 How do I regain my security password questions. Thank you.
I am unable to answer security questions. I am being informed I have to do this as it is the first time I have used this computer for itunes, but I have used it for quite some time. I do not even recognize the questions. Than You.
-
Target node/queue unavailable after clone
Target node/queue unavailable error after clone. All nodes are updated (accordingly to the structure) in fnd_nodes Please help EBS 11.5.10.2 DB 9.2.0.8.0
-
I've had this issue since first buying my MBA mid-2013. Instead of going to standby, which works 98% of the time, every now and again it appears to go into standby with the screen black, but no amount of key pressing or mouse moving will wake it up.