cancel
Showing results for 
Search instead for 
Did you mean: 

multiple smartforms to be sent as PDF in a single mail

narendar_naidu
Active Participant
0 Kudos

hi all,

i have a custom programme that will print 2 smartforms , i have converted them to pdf ,now i have to send them as mail attachments.

i could attach only one, how to attach the other form in the same mail. my problem is im unable to split the data in the CONTENT_BIN table.

    FORM SEND_EMAIL .

    LV_NAME =  'naren@gmail.com'.
* ***----Send email
*----Contents bin
    CLEAR : W_CONTBIN.
    W_CONTXT = 'Smartform as PDF'.
    APPEND W_CONTXT TO T_CONTXT.
    DESCRIBE TABLE T_CONTXT LINES V_LINES.
    READ TABLE T_CONTXT INTO W_CONTXT INDEX  V_LINES.
*---Attributes of new document
    T_DOCDATA-OBJ_DESCR = 'Processing and Shipping Form' .
    T_DOCDATA-EXPIRY_DAT = SY-DATUM + 10.
    T_DOCDATA-SENSITIVTY = 'F'.
    T_DOCDATA-DOC_SIZE = V_LINES * 255.
*---Packing Data
    CLEAR W_PACKLIST-TRANSF_BIN.
    W_PACKLIST-TRANSF_BIN = 'X'.
    W_PACKLIST-HEAD_START = 1.
    W_PACKLIST-HEAD_NUM   = 0.
    W_PACKLIST-BODY_START = 1.
    DESCRIBE TABLE I_RECORD LINES V_BLINES.(here in this table i could get the data of the first form)
    READ TABLE I_RECORD INDEX V_BLINES.
    W_PACKLIST-BODY_NUM   = V_BLINES.
    W_PACKLIST-DOC_SIZE = V_BLINES * 255.
    CONDENSE W_PACKLIST-DOC_SIZE.
    W_PACKLIST-DOC_TYPE   = 'pdf'.
    W_PACKLIST-OBJ_NAME = 'ATTACHMENT'.
    APPEND W_PACKLIST TO T_PACKLIST.
*---Recievers data
    CLEAR : W_RECEIVERS.
    W_RECEIVERS-RECEIVER = LV_NAME.
    W_RECEIVERS-REC_TYPE = 'U'.
    APPEND W_RECEIVERS TO T_RECEIVERS.


******
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA                    = T_DOCDATA
       PUT_IN_OUTBOX                    = 'X'
       COMMIT_WORK                      = 'X'
      TABLES
        PACKING_LIST                     = T_PACKLIST
*       OBJECT_HEADER                    = T_OBJHEAD
       CONTENTS_BIN                     = I_RECORD
       CONTENTS_TXT                     = T_CONTXT
*       CONTENTS_HEX                     = CONTENTS_HEX
        RECEIVERS                        = T_RECEIVERS.

in the same way i can get the other form data also, how can i merge them in content bin table and send separately.

any help wud be greatfull.

regards,

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

To do this you have to use class CL_BCS. When you want to add an attachment to the email you use the method add_attachment:

CALL METHOD document->add_attachment

  EXPORTING

     i_attachment_type    = type

     i_attachment_subject = subject

     i_att_content_hex    = content_hex

     i_attachment_header  = attachment_header.

From the second attachment onwards (so is not needed for the first one):

CONCATENATE '&SO_FILENAME=' lv_attach_name INTO ls_attachment_header.

APPEND ls_attachment_header TO attachment_header.


The other values are

type = 'PDF'.

subject = file name.

content_hex = pdf_content.

You can retrive pdf_content (it's an xstring) like this:

CALL FUNCTION 'CONVERT_OTF'

  EXPORTING

      format                = 'PDF'

  IMPORTING

      bin_filesize          = bin_filesize

      bin_file              = bin_file

  TABLES

      otf                   = otfdata

      lines                 = lines

  EXCEPTIONS

      err_max_linewidth     = 1

      err_format            = 2

      err_conv_not_possible = 3

      err_bad_otf           = 4

      OTHERS                = 5.

REFRESH: pdf_content.

pdf_content = cl_document_bcs=>xstring_to_solix( bin_file ).



Former Member
0 Kudos

Hi,

Make use of BCS to convert to PDF and then send emails. Refer program BCS_EXAMPLE_6 in SE38.

Regards,

Danish.