Skip to Content
0
Former Member
Jun 30, 2009 at 02:43 PM

Problem in emailing PDF attachment of a smartform.

260 Views

Hi all,

I am trying to email a smartform output as pdf attachment. But though the mail is being sent to the recipient, the attachment gets corrupted. The funny thing is that, when i write the pdf output (after converting it's line from 132 to 255) to the presentation server using GUI_DOWNLOAD, the pdf file shows the smartform output without any problem. What changes i need to incorporate in my code to avoid the corruption of the attachment?

Below is the sample of my code :

FORM PREPARE_AND_SEND_MAIL USING P_JOB_INFO TYPE SSFCRESCL.
  DATA:

        IT_OTFDATA TYPE TABLE OF ITCOO,
        L_BIN_FILESIZE TYPE I,
        L_BUFFER TYPE STRING. "To convert 132 characters to 255 characters.

  IT_OTFDATA[] = P_JOB_INFO-OTFDATA[].
  REFRESH IT_PDFDATA[].
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      FORMAT                = 'PDF'
    IMPORTING
      BIN_FILESIZE          = L_BIN_FILESIZE
    TABLES
      OTF                   = IT_OTFDATA[]
      LINES                 = IT_PDFDATA[]
    EXCEPTIONS
      ERR_MAX_LINEWIDTH     = 1
      ERR_FORMAT            = 2
      ERR_CONV_NOT_POSSIBLE = 3
      ERR_BAD_OTF           = 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.
  ELSE.
    REFRESH IT_ATTACHMENT[].

*Convert 132 to 255.
    CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
      EXPORTING
        LINE_WIDTH_DST              = '255'
      TABLES
        CONTENT_IN                  = IT_PDFDATA
        CONTENT_OUT                 = IT_ATTACHMENT
      EXCEPTIONS
        ERR_LINE_WIDTH_SRC_TOO_LONG = 1
        ERR_LINE_WIDTH_DST_TOO_LONG = 2
        ERR_CONV_FAILED             = 3
        OTHERS                      = 4.

Continued in the next thread....