Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to ZIP, PDF file attachment

Former Member
0 Kudos

Hi,

I 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 ECC 6.0with OS WinNT. And the ABAP program should be able to run in Foreground/Background.

Thanks for your help in advance...

4 REPLIES 4

OttoGold
Active Contributor
0 Kudos

You´d better install, configure ADS (Adoe document services) and start using Adobe forms for this purpose.

To create a simple form (like same content as ALV for example) takes me like 20 minutes and the size of the form is like 100kb in average and rise very slowly, nothing like this "old" conversion routine. Visit Adobe forms forum under NetWeaver.

Regards Otto

OttoGold
Active Contributor
0 Kudos

Or check this thread:

Otto

Former Member
0 Kudos

Hi,

Try this code:

data ca_attach_zip(22)     TYPE c VALUE 'Attch.',
OPEN DATASET va_filename_zip  FOR INPUT  IN BINARY MODE.
   DO.
     READ DATASET va_filename_zip INTO objbin.
     IF sy-subrc NE 0. EXIT. ENDIF.
     APPEND objbin.
   ENDDO.
    APPEND objbin.
  DESCRIBE TABLE objbin LINES tab_lines.
   CLOSE  DATASET va_filename_zip.
    DELETE DATASET va_filename.
    DELETE DATASET va_filename_zip.
 
    DESCRIBE TABLE objbin LINES tab_lines.
 
    objhead = ca_attach_zip.
    APPEND objhead.
 
***Creation of the entry for the compressed attachment
   objpack-transf_bin = 'X'.
    objpack-head_start = 1.
  objpack-head_num = 1.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
   objpack-doc_type = ca_zip.
   objpack-obj_name  = ca_attach_zip.
  objpack-obj_descr = ca_attach_zip.
   objpack-doc_size = tab_lines * ca_255.
    APPEND objpack.
 
*** Completing the recipient list
 
    reclist-receiver = va_mail_address.
    reclist-express  = 'X'.
    reclist-rec_type = 'U'.
    APPEND reclist.
 
 
*** Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
       document_data              = doc_chng
       put_in_outbox              = ca_x
        commit_work                = 'X'
      TABLES
       packing_list               = objpack
        object_header              = objhead
        contents_bin               = objbin
        contents_txt               = objtxt
        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.

You have to load your file in the contents_bin table of FM.

You can load the file by OPEN DATASET and the READ DATASET command.

In the object_header you can put some description.

For your info:

1.

2.

3.

May it helps you.

Regards.

Deepak Sharma.

JerryWang
Advisor
Advisor
0 Kudos

Hello friend,

You can use CL_ABAP_ZIP to zip content.

please refer to following links:

http://wiki.sdn.sap.com/wiki/display/ABAP/CL_ABAP_ZIPusage-ZippingABAPreportoutput

DATA: IZIP       TYPE REF TO CL_ABAP_ZIP,
      CONT       TYPE XSTRING ,
      XZIP_FILE  TYPE XSTRING,
      BINARY_TAB TYPE STANDARD TABLE OF X255 ,
      BIN_LEN TYPE I .

DATA: ITAB TYPE STANDARD TABLE OF SDOKCNTASC .
 
START-OF-SELECTION.
  DO 20 TIMES.
    APPEND 'ABAP?a·uFFE0' TO ITAB.
  ENDDO.
  CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
    EXPORTING
      MIMETYPE = 'text/html;charset=gb2312'
    IMPORTING
      BUFFER   = CONT
    TABLES
      TEXT_TAB = ITAB
    EXCEPTIONS
      FAILED   = 1
      OTHERS   = 2.
 
  CREATE OBJECT IZIP.
  CALL METHOD IZIP->ADD
    EXPORTING
      NAME    = 'ITAB.TXT'
      CONTENT = CONT.
  CALL METHOD IZIP->SAVE
    RECEIVING
      ZIP = XZIP_FILE.
 
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      BUFFER        = XZIP_FILE
    IMPORTING
      OUTPUT_LENGTH = BIN_LEN
    TABLES
      BINARY_TAB    = BINARY_TAB.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE = BIN_LEN
      FILENAME     = 'C:sf.zip'
      FILETYPE     = 'BIN'
    TABLES
      DATA_TAB     = BINARY_TAB.

Edited by: Jerry Wang on Jun 29, 2010 3:05 PM