How to ZIP a PDF file email attachment
Hi,
We have an ABAP report requirement to send an email to a user. This program will send an email with PDF attachement. However, the PDF attachment is quite big (9MB) and our email server couldn't handle it (5MB only). Is there any way to ZIP this PDF file attachment?
I am using a SAP release 4.6C with OS WinNT. And the ABAP program should be able to run in Foreground/Background.
Thanks for your help in advance...
Kind regards,
Herson
Read Notes:
616958
644640
You can create a class method:
CALL METHOD zca_tools=>zip_table
EXPORTING
i_data_table = <data_struc>
i_filename = 'aa'
IMPORTING
e_bin_table = t_zipped
e_bin_length = lines.
METHOD zip_table.
DATA: lv_original_length(10) TYPE n,
lv_data_ref TYPE REF TO data,
lv_struc_ref TYPE REF TO data.
DATA: lv_zip TYPE REF TO cl_abap_zip,
lv_lines TYPE i,
lv_length TYPE i,
lv_data_to_zip TYPE xstring,
lv_zip_file TYPE xstring,
lv_catch TYPE REF TO cx_root,
lv_message TYPE string.
FIELD-SYMBOLS: <data_struc> TYPE ANY,
<final_data> TYPE ANY,
<final_data_table> TYPE STANDARD TABLE,
<aux> TYPE x.
LOOP AT i_data_table ASSIGNING <data_struc>.
DESCRIBE FIELD <data_struc> LENGTH lv_original_length IN CHARACTER MODE.
EXIT.
ENDLOOP.
TRY.
CREATE DATA lv_data_ref TYPE c LENGTH lv_original_length.
ASSIGN lv_data_ref->* TO <final_data>.
CREATE DATA lv_data_ref LIKE STANDARD TABLE OF <final_data>.
ASSIGN lv_data_ref->* TO <final_data_table>.
APPEND LINES OF i_data_table TO <final_data_table>.
DESCRIBE TABLE <final_data_table> LINES lv_lines.
ASSIGN COMPONENT 1 OF STRUCTURE <final_data> TO <aux> CASTING.
IF sy-subrc NE 0 OR NOT <aux> IS ASSIGNED.
ASSIGN COMPONENT 0 OF STRUCTURE <final_data> TO <aux> CASTING.
ENDIF.
DESCRIBE FIELD <aux> LENGTH lv_length IN BYTE MODE.
MULTIPLY lv_length BY lv_lines.
CATCH cx_root INTO lv_catch. "#EC CATCH_ALL
lv_message = lv_catch->get_text( ).
MESSAGE lv_message TYPE 'E' RAISING error.
ENDTRY.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_length
first_line = 1
last_line = lv_lines
IMPORTING
buffer = lv_data_to_zip
TABLES
binary_tab = <final_data_table>
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF sy-msgty IS INITIAL.
sy-msgty = 'S'.
ENDIF.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 RAISING error.
ENDIF.
CREATE OBJECT lv_zip.
CALL METHOD lv_zip->add
EXPORTING
name = i_filename
content = lv_data_to_zip.
CALL METHOD lv_zip->save
RECEIVING
zip = lv_zip_file.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_zip_file
TABLES
binary_tab = e_bin_table.
TRY.
DESCRIBE TABLE e_bin_table LINES lv_lines.
e_bin_length = lv_lines * 255. "255 is the length of each line of e_bin_table
CATCH cx_root INTO lv_catch. "#EC CATCH_ALL
lv_message = lv_catch->get_text( ).
MESSAGE lv_message TYPE 'E' RAISING error.
ENDTRY.
ENDMETHOD.
I hope it helps!
Regards,
Frinee
Similar Messages
-
How to ZIP a PDF File with a Password Protection
Hi,
i've a pdf file with created smartforms and i want to assign a password to that pdf file but the SAP doesn't let doing that protection. So i want to create a zip file with a password protection for PDF file.
How can i create a zip file with a password protection? Can somebody help me please?
Thanks.Hello,
Check this links
Take a look to the class CL_ABAP_GZIP
open (top-)zip-archive
CALL METHOD lo_zip->load
EXPORTING
zip = lv_zip_file_head
EXCEPTIONS
zip_parse_error = 1
OTHERS = 2.
create sub-zip-archives which contain the files you would assign to a folder
add sub-zip-archive to top-zip-archive
CALL METHOD lo_zip->add
EXPORTING
name = lv_zip_filename
content = lv_zip_file.
save zip-archive
CALL METHOD lo_zip->save
RECEIVING
zip = ev_zip_file.
ABAP Development
How to ZIP a PDF file email attachment
Re: How to ZIP a PDF file email attachment -
Problem with pdf as email attachment
Hi All,
when i am opening the pdf file(email attachment), getting the error "file type not support or content conversion....."
the peice of code is as followed...
IF p_email = 'X'.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = mi_rqident (spool number)
TABLES
buffer = l_contents.
IF l_contents IS NOT INITIAL.
CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
EXPORTING
ip_solitab = l_contents
IMPORTING
ep_solixtab = contents_hex.
Create the send request
TRY.
l_send_request = cl_bcs=>create_persistent( ).
Create the main document
l_doc = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = l_text
i_subject = p_sub ).
Add attachment to document
l_doc->add_attachment( i_attachment_type = 'PDF'
i_attachment_subject = p_doc
i_att_content_text = contents_text ).
i_att_content_hex = contents_hex ).
Add document to send request
l_send_request->set_document( l_doc ).
Add recipients to send request
l_recipient = cl_cam_address_bcs=>create_internet_address(
p_email1-low ).
l_send_request->add_recipient( i_recipient = l_recipient ).
Send email
l_sent_all = l_send_request->send( ).
and other way also i tried, please let me know the solution.
thanks in advancetry this code ..
For mailing(converting data to char 255)
IF ch2 EQ 'X'.
DATA sub TYPE string.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = i_tline
t_target_tab = so_ali[]
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
Mail Contents
refresh objtxt[].
objtxt = space.
APPEND objtxt.
objtxt = 'Dear Sir/Madam,'.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
CLEAR : sub.
CONCATENATE 'Sub: Dispatch Details - Invoice Number :' invno '.' INTO sub SEPARATED BY space.
objtxt = sub.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
objtxt = 'We have dispatched the subject consignment from our factory, and'.
APPEND objtxt.
objtxt = 'enclose the Invoice(pdf file) for your kind reference.'.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
objtxt = 'Note: Please cover insurance on all risks in case INCO TERMS as "EXW, FCA, FOB, CFR"'.
APPEND objtxt.
objtxt = 'in the subject consignment.'.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
objtxt = 'For Delivery Management - International,'.
APPEND objtxt.
objtxt = 'Pricol Limited,'.
APPEND objtxt.
objtxt = 'Coimbatore. India.'.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
Determining the Email Ids of Mail Receivers
PERFORM fetch_mailids.
objtxt = 'Copy to :'.
APPEND objtxt.
LOOP AT reclist.
objtxt = reclist-receiver.
APPEND objtxt.
ENDLOOP.
objtxt = space.
APPEND objtxt.
objtxt = '<This is system generated message>.'.
APPEND objtxt.
objtxt = space.
APPEND objtxt.
Mail Body of message over.
DESCRIBE TABLE objtxt[] LINES v_lines_txt.
CONCATENATE 'Inv.' invno INTO sub SEPARATED BY space.
doc_chng-obj_name = sub.
doc_chng-expiry_dat = sy-datum + 10.
Mail Subject
refresh objpack[].
CONCATENATE 'Pricol Dispatch - Invoice' invno '- Reg.' INTO sub SEPARATED BY space.
doc_chng-obj_descr = sub.
doc_chng-sensitivty = 'F'.
doc_chng-doc_size = v_lines_txt * 255.
objpack-transf_bin = ' '.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = v_lines_txt.
objpack-doc_type = 'RAW'.
APPEND objpack.
*PDF Attachment
DESCRIBE TABLE so_ali[] LINES lineno.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-doc_size = lineno * 255 .
objpack-body_num = lineno.
objpack-doc_type = 'PDF'.
objpack-obj_name = 'INVOICE'.
objpack-obj_descr = 'Invoice'.
objpack-obj_langu = 'E'.
APPEND objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
contents_txt = objtxt[]
contents_bin = so_ali[]
*contents_hex = so_ali[]
receivers = reclist[]
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc = 0.
PERFORM mail.
MESSAGE 'Mail sent successfully' TYPE 'S'.
*SUBMIT RSCONN01 WITH MODE = MODE.
ENDIF.
ENDIF.
ENDLOOP. -
I have 6 pdf files to attach to an email. I don't want them all to open in the body of the email. How do I just attach the pdf file?
Never mind. Found the solution here: Re: How to mail PDF file as an icon
-
How to zip a text file and send as email attachment in SAP version 4.6c?
Hi Guru,
How to zip a text file in SAP version 4.6c which doesn't have class CL_ABAP_ZIP?
Please help.
Thanks & Regards,
AriHi,
Try this link
[http://sap.ittoolbox.com/groups/technical-functional/sap-dev/sapr3dev-zip-file-from-sap-1707099?cv=expanded]
Cheers,
Surinder -
How to insert a pdf file in an outgoing email
Looking for assistance, on how do you insert a pdf file in an outgoing email on iphone5, I have adobe and dropbox I can open a pdf file and send it from their respective apps but when I create a new email or reply or forward I want to be able to go get the pdf file and attach it to the email. Have not been able to find how to do this.
Regards,
FrankThanks for responding. For my work I have manuals, certifications or other regulatory docs that I have uploaded either to dropbox or adobe reader apps on my phone because I travel I find more often that I get request for these documents on an email chain and need to add a pdf to it. It seems I have to start a new email from the app the pdf is in as you stated. This defeats the purpose of responding or forwarding. very frustrating and not very professional. Is their an app out there that may help with this situation.
-
Can anyone tell me how to send a PDF file so that it opens up in the body of the email itself? Thanks
That is a function of the recipient's e-mail software understanding what your software sent. If it doesn't it will always show as an icon or attachment. It is also a function of both your internet provider and their internet provider accepting messages of that size, and a function of their download attachment settings in their e-mail program. There is no way to guarantee it will appear inline in the attachment. The best you can do is attach with Windows Friendly format. To do that, use the attach toolbar icon that looks like a paperclip, (View menu -> Customize toolbar if invisible) on Mac OS X Mail when composing the message. A checkbox appears in the file dialog box's bottom to make it Windows friendly when you navigate to pick the PDF file. That makes it as universally compatible as possible. It still may not appear inline, but at least you are less likely to be incompatible.
-
IPAD3/IPAD2 :PDF files/ attachments sent in an email displayed inline ( embedded within the main email) in the message text on both my Ipad2 and Ipad three, however the same email displayed the PDF File icons/ attachment on both my Iphone and a friend’s PC. How do i get both my IPAD devices to display the PDF icons/attachments? Bearing in mind if i open the same email over the internet the PDF Icons/attachments display OK!
Has anyone come across this? Your advice/help would be most appreciatedThis happens to me all the time.
If is a one page PDF it seems as though it comes over already open and inline in the body of the email. Multiple page PDF files show as the PDF icon.
I can't find any official documentation of this - other than based on my own experience with PDF attachments in my various email accounts.
Message was edited by: Demo -
How to Sender PDF file as attachment in Payload?
Hi Experts,
After I done some of PI scenarios, I'm stuck with one of my requirement... In requirement, "Web service" will send request to "SAP ECC 6" in order to get PO document print out in PDF file by call smartform or any form printing as usual.
In my understand, I'm using SOAP adapter as sender and RFC adapter in receiver side, in RFC function, I will call form and generate PDF file by using normal ABAP function, but here, how can I send PDF file as response message of SYNC call from web service.
I try to search and read some of document and blog, some said I can attach file as Payload attachment, but no clear solution or guide to do so.
Here is example blog that I found, I really useful
/people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments
Please suggest me in my case,
Thanks in advance...
Cheers,
TerryHi,
>>In my understand, I'm using SOAP adapter as sender and RFC adapter in receiver side, in RFC function, I will call form and generate PDF file by using normal ABAP function, but here, how can I send PDF file as response message of SYNC call from web service.
as per my blog you can attach PDF to a message only if you use abap proxy on ECC and not RFC
the code is just copy and paste from my blog:
/people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments
so there is nothing spectacular there
Regards,
Michal Krawczyk -
How to open a pdf file and then attach it with images
I am new to Indesign Server.
I'm currently working on a pdf.
I have a white blank pdf template.
that I want to attach/glue it with images.
How to open a pdf file and then attach it with images.
Please, help me.
Thanks.First step would be to make yourself familiar with InDesign desktop version.
Whatever you intend to achieve, do it there manually. (see regular app docs or forums)
Then try to automate your steps with scripting (see scripting docs or forum)
If you can do it with a script in the desktop version, that script will likely also run in ID Server. (see server forum).
If you can specify missing features not achievable thru scripting or manual use, reconsider to write a plugin (this forum).
A seasoned C++ programmer will need a few months to learn the basics, wade thru tons of documentation etc. Alternatively consider to hire a consultant to do the development work for you.
Dirk -
I have iphone6 and I cant open PDF files which attached to my email
Dear All
I have iPhone and I cant open PDF files which attached to my email
Regardsthanks for the suggestions weather15 - the firefox help site you directed me to explains what ought to happen but i cant make it work. I shut my firefox browser on my new machine and attach the hard drive from my old machine. I can explore the contents of that drive but when i search it for the suggested folder " %APPDATA%\Mozilla\Firefox\Profiles\" nothing is found. when i try and open firefox from the old drive, the browser opens that is the new version that i have on my new computer with no saved bookmarks! Am I doing everything right?
-
How do i get PDF files from email to open with 6.0.1?
How do I open PDF files from email in 6.0.1?
Just tap the PDF icon and will open in the viewer.
-
Hi i cANT OPEN PDF FILE FROM ATTACHMENT CAN U TELL ME HOW
HOW CAN I OPEN PDF FILE FROM ATTACHMENT
Attachment to what?
Have you tried saving the attachment to your computer then launching Adobe Reader and using File>Open to open it? -
Not able to send pdf file as attachment in my apple mail.
Hi, I was easily able to attach pdf files to my apple mail. infact I could just open a pdf file and then send it as attachment in the email earlier. but after downloading and upgrading to os X Mountain lion, I am neither being able to attach and send pdf files in my apple mail, nor can I send PDF file as an attachment.
Is there any issue with OS X Mountain Lion.
Issue 1. I compose Email , then click attach > Browse > select pdf file > click attach > it shows in my Email body either as an icon or as first page of the pdf document > I send it. >>> But when the receipient opens the Email, that pdf attachment is missing. In fact When I put a cc to my self and I open the Email, the attachment is mssing in the incoming E amil.
Issue 2. I open the PDF document > Click on File > send as attachment in E-Mail > on right, a menu appears where I select the File and click attach> I get a message
The SendMail doesnot know how to talk to your default mail client. Please select a different mail application to use. Attaching a screen shot.
I never had these issues earlier with my Lion OS . but since the time I have upgraded to mountain Lion OS, I am having these issues.
Are these the Mountain Lion issues, how to fix these please.I believe, the software team forgot to put a button for send or share as an attachment to preview.
-
How do I save PDF from email to iBooks
How do I save PDF from email to iBooks like I do on iPhone.
touch and hold the attachment in mail. a box will open that says 'open in' and i books, along with any other apps you have that read pdf files will be offered. select i books, or the one you want. once it is associated with an app, it will be stored within the app.
Maybe you are looking for
-
Need to limit number of rows returned by a query
Hi. Is there a way to limit the rowsets returned to me in a query? I need to get the first 100, then the next hundred, etc until there are no more rows left to retrieve. Someone told me that I should use a cursor to do this. Does anyone have a specif
-
Change decimal places in PO quantity
Hi, How can I set the number of decimal places in PO quantity? Thanks so much! Regards, Paula
-
I have a button that executes TS_ExecutionAbort. When I press that button in debug, it seems to work find but when I exit the program, I get the following error: Global type list not empty! Error Code: -17001 Where raised: function: TypeUsageList:ele
-
I was recently married and need to change my last name on my icloud profile. How do I do so?
-
Some CS6 could not be installed successfully
When installing Adobe CS6 Web Premium Suite, everything installs except InDesign, Flash, Photoshop, and Illustrator. Any idea why? Error Summary: Exit Code: 6 Please see specific errors below for troubleshooting. For example, ERROR: DF024, DF037 ...