Smartform as PDF attachment to a mail.

Hi,
Can anyonce briefly explain me how the output of a smartform can be attached as a PDF file to a mail.
Ques 1: Do we need to pass any explicit value to the smart form generated function module.  If so, what is the value and to which parameter do we need to pass.
Ques 2: As far as i know OTF is converted to PDF. If this is so please explain how this is  done.
Ques 3: How can a PDF document be made as an attachment, to a mail.
If anyone can provide me an example it would be very great.
Thanks & Regards,
Goutham.

Hi,
Go through the following code:
REPORT  z_smtf_pdf_and_email_aks01.
DATA: x_ctrl_p       TYPE ssfctrlop,
      x_output_data  TYPE ssfcrescl.
DATA: it_docs    LIKE docs       OCCURS 0 WITH HEADER LINE,
      it_lines   LIKE tline      OCCURS 0 WITH HEADER LINE,
      it_packing LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
*-----Initialisation
x_ctrl_p-no_dialog = 'X'.
x_ctrl_p-getotf    = 'X'.
x_ctrl_p-langu     = sy-langu.
          Internal Tables  Declaration                              *
DATA: it_record    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
      it_pcklist   LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
      it_mess      LIKE solisti1   OCCURS 0 WITH HEADER LINE,
      it_objbin    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
      it_receivers LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
      it_table     LIKE solix      OCCURS 0 WITH HEADER LINE.
DATA: it_soli      LIKE soli OCCURS 0 WITH HEADER LINE.
*-----Work area declaration
DATA: wa_doc_data  TYPE  sodocchgi1.
          Variable  Declaration                                     *
DATA: v_lines_txt  TYPE  i,
      v_lines_bin  TYPE  i,
      v_lines      TYPE  i,
      v_fname TYPE rs38l_fnam,
      v_size TYPE i,
      v_filename TYPE rlgrap-filename.
          Start of selection event                                  *
START-OF-SELECTION.
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname = 'Z_SMTF_TEST_AKS01'
    IMPORTING
      fm_name  = v_fname.
  CALL FUNCTION v_fname
    EXPORTING
      control_parameters = x_ctrl_p
    IMPORTING
      job_output_info    = x_output_data.
*-----Calling fumction module to convert output to pdf.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
   IMPORTING
     bin_filesize   = v_size
   TABLES
     otf            = x_output_data-otfdata
     doctab_archive = it_docs
     lines          = it_lines.
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
      max_linewidth         = 134
    IMPORTING
      bin_filesize          = v_size
    TABLES
      otf                   = x_output_data-otfdata
      lines                 = it_lines
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      OTHERS                = 4.
  CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
    EXPORTING
      line_width_dst              = 255
    TABLES
      content_in                  = it_lines
      content_out                 = it_soli
    EXCEPTIONS
      err_line_width_src_too_long = 1
      err_line_width_dst_too_long = 2
      err_conv_failed             = 3
      OTHERS                      = 4.
  CALL FUNCTION 'ZFUNC_CONVERT_DATA_ODC01'
   EXPORTING
     iv_byte_mode       = 'X'
   TABLES
     it_data            = it_lines
     et_data            = it_table.
*-----To caluculate total number of lines of internal table
  DESCRIBE TABLE it_table LINES v_lines.
*-----Function module to download the output file.
  CALL FUNCTION 'DOWNLOAD'
    EXPORTING
      bin_filesize = v_size
      filename     = ' '
      filetype     = 'BIN'
    IMPORTING
      act_filename = v_filename
    TABLES
      data_tab     = it_lines.
*-----Create Message Body and Title and Description
  it_mess =
'i have successfully converted smartform from otf format to pdf' .
  " and i have attached that in mail'.
  APPEND it_mess.
  wa_doc_data-obj_name   = 'smartform'.
  wa_doc_data-expiry_dat = sy-datum + 10.
  wa_doc_data-obj_descr  = 'smartform'.
  wa_doc_data-sensitivty = 'F'.
  wa_doc_data-doc_size   = v_lines * 255.
  APPEND it_pcklist.
*-----PDF Attachment
  it_pcklist-transf_bin = 'X'.
  it_pcklist-head_start = 1.
  it_pcklist-head_num = 0.
  it_pcklist-body_start = 1.
  it_pcklist-doc_size =  v_lines_bin * 255 .
  it_pcklist-body_num = v_lines.
  it_pcklist-doc_type = 'PDF'.
  it_pcklist-obj_name = 'smartform'.
  it_pcklist-obj_descr = 'smart_desc'.
  it_pcklist-obj_langu  = 'E'.
  it_pcklist-doc_size   = v_lines * 255.
  APPEND it_pcklist.
*-----Giving the receiver email-id
  CLEAR it_receivers.
  it_receivers-receiver = '[email protected]'
  it_receivers-rec_type = 'U'.
  APPEND it_receivers.
  CLEAR it_receivers.
  it_receivers-receiver = '[email protected]'.
  it_receivers-rec_type = 'U'.
  APPEND it_receivers.
  CLEAR it_receivers.
  it_receivers-receiver = '[email protected]'.
  it_receivers-rec_type = 'U'.
  APPEND it_receivers.
*-----Calling the function module to sending email
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = wa_doc_data
      put_in_outbox              = 'X'
      commit_work                = 'X'
    TABLES
      packing_list               = it_pcklist
      contents_txt               = it_mess
      contents_hex               = it_table
      receivers                  = it_receivers
    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.
    SUBMIT rsconn01   WITH mode       = 'INT'
                      WITH output     = 'X'
                      WITH rfcgroup   = 'iwdf7ytc_YD3_94'
                      AND RETURN.
    REFRESH: it_receivers,
             it_mess,
             it_pcklist.
  ENDIF.
Reward points if helpful answer.
Ashvender

Similar Messages

  • Sending smartforms as PDF attachement via e mail

    Hello all:
    I have configured PPF actions to send smartforms as PDF attchment via e mail it works fine in one client.
    But when I copied the transport to another client, the entries in field 'Recipient' in the configuration step 'Define Conditions and Output Parameters for Comm. of Cust.Shipm. & Cust.Dcl'  are not copied to the new client. I had maintained the name of the inbox folder that has e mail addresses in this field. Any one has a similar issue ? Or is this similar to the number ranges and not transportable and we have to maintain them in every client. Any insight into this very much appreciated.

    Hello:
    If you want to send the smartform as a PDF attachment, configure your PPF action as described below:
    Step 1: Define Techn. Medium for Msgs (PPF Actions) f. Cust. Shipm. and Cust. Decl.
                In the action definition, choose processing type as 'External Communication'
                                                             form type:  'Smart Forms'
                                                             format: /SAPSLL/FORM_PROC
                                                             personalization type: 2 object specific....
                Make this action definition partner function dependent and create a Z partner function. Maintain that  
                partner function in this definition.
    Step 2: Define Conditions and Output Parameters for Comm. of Cust.Shipm. & Cust.Dcl
                Select Communication Method: Internet Mail
                          Mail Settings: send status: 3
    Configure the reamaining PFF actions as usual.
    This will work if that configured partner function is maintained in the customs declaration. And for that business partner, maintain the e mail address in the address dependent section via txn BP.

  • Want to Send smartform as pdf attachment with a Email to some mail id

    Hi ,
    I want to send a smartform as a PDF attachment with a mail to a mail id. And I can send a mail with the PDF attachment.
    But I am not able to open the PDF. It is throwing some error (Adobe reader could not open u2018fileu2019 because it is either not a supported file type or because the file has been damaged (for example , it was sent as an email attachment and was not correctly decoded)).
    By debugging I come to know that the file which is generating is in some encoding format.
    Please help me regard this. This is very urgent.
    here is the code,
    Main Program :
    REPORT Ztest_report.
    *--Top Include for Global Data Declarations.
    INCLUDE ztest_report_top.
    *--Form Include for Form Routines.
    INCLUDE ztest_report_form.
    START-OF-SELECTION.
    START-OF-SELECTION.
    *--Display data
      Perform display_data.
    END-OF-SELECTION.
    Top declaration :
    Internal table
    DATA :  i_otfdata TYPE tsfotf,          " Smart Forms: Table OTF
            i_tline TYPE TABLE OF tline WITH HEADER LINE,
            i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
            i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
            i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
            w_mailaddr TYPE ppfdmailad,
            w_mailtype TYPE so_escape,
            w_mailrecipient TYPE swotobjid,
            w_control TYPE ssfctrlop,
            w_compop TYPE ssfcompop,
            w_return TYPE ssfcrescl,
            wa_doc_chng TYPE sodocchgi1,
            w_data TYPE sodocchgi1,
            wa_buffer TYPE string, "To convert from 132 to 255
            wa_objhead TYPE soli_tab,
    Variables declarations
            v_form_name TYPE rs38l_fnam,
            v_len_in LIKE sood-objlen,
            v_len_out LIKE sood-objlen,
            v_len_outn TYPE i,
            v_lines_txt TYPE i,
            v_lines_bin TYPE i.
    Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-009.
    PARAMETER:      p_bukrs TYPE bukrs OBLIGATORY,            "Company Code
                    p_belnr TYPE belnr_d OBLIGATORY,          "Document No
                    p_gjahr TYPE gjahr OBLIGATORY,            "document type
                    p_mailid(50) TYPE c OBLIGATORY.
    "Mail Id
    SELECTION-SCREEN END OF BLOCK blk1.
    Form Logic :
    FORM display_data.
    *Local Variable declaration
      DATA: lc_fm TYPE rs38l_fnam,       "local variable to store the
            l_i_document_output_info TYPE ssfcrespd,
            l_i_struc_job_output_info TYPE ssfcrescl,
            l_i_struc_job_output_options TYPE ssfcrescl,
            i_lines TYPE TABLE OF tline WITH HEADER LINE,
            lv_job_output_info      TYPE ssfcrescl,
            lv_document_output_info TYPE ssfcrespd,
            lv_job_output_options   TYPE ssfcresop,
            lv_bin_filesize         LIKE sood-objlen.
    Determine the smartform name
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
           EXPORTING
                formname           = 'ZTEST_SMARTFORM'
           IMPORTING
                fm_name            = lc_fm
           EXCEPTIONS
                no_form            = 1
                no_function_module = 2
                OTHERS             = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      w_control-getotf = 'X'.
      w_control-no_dialog = 'X'.
      w_control-preview = space.
    w_control-device = 'MAIL'.
    Call the smartform and pass the selection screen parameter
      CALL FUNCTION lc_fm
           EXPORTING
                control_parameters = w_control
                output_options     = w_compop
                user_settings      = 'X'
                t_bukrs            = p_bukrs
                t_belnr            = p_belnr
                t_gjahr            = p_gjahr
           IMPORTING
                job_output_info    = l_i_struc_job_output_info
           EXCEPTIONS
                formatting_error   = 1
                internal_error     = 2
                send_error         = 3
                user_canceled      = 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.
    Moving the Smart Forms: Table OTF into an internal table
      i_otfdata[] = l_i_struc_job_output_info-otfdata[].
    CONVERT TO OTF TO PDF.
      CALL FUNCTION 'CONVERT_OTF'
           EXPORTING
                format                = 'PDF'
                max_linewidth         = 132
           IMPORTING
                bin_filesize          = lv_bin_filesize
           TABLES
                otf                   = i_otfdata
                lines                 = i_lines
           EXCEPTIONS
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                err_bad_otf           = 4
                OTHERS                = 5.
    IF sy-batch EQ l_c_no.
    To directly view the print-preview in PDF format
      CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
           EXPORTING
                i_otf                    = i_otfdata
           EXCEPTIONS
                convert_otf_to_pdf_error = 1
                cntl_error               = 2
                OTHERS                   = 3.
    For Sending the PDF file to a Mail ID.
    LOOP AT i_lines.
       TRANSLATE i_lines USING '~'.
       CONCATENATE wa_buffer i_lines INTO wa_buffer.
    ENDLOOP.
    TRANSLATE wa_buffer USING '~'.
    DO.
       i_record = wa_buffer.
       APPEND i_record.
       SHIFT wa_buffer LEFT BY 255 PLACES.
       IF wa_buffer IS INITIAL.
         EXIT.
       ENDIF.
    ENDDO.
      DATA: BEGIN OF zlines OCCURS 0,
      tline TYPE char255,
      END OF zlines.
    *Change the PDF format from 132 to 255.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
           EXPORTING
                transfer_bin                = 'X'
           TABLES
                content_in                  = i_lines
                content_out                 = zlines
           EXCEPTIONS
                err_line_width_src_too_long = 1
                err_line_width_dst_too_long = 2
                err_conv_failed             = 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.
    Attachment
      REFRESH: i_reclist,
      i_objtxt,
      i_objbin,
      i_objpack.
      CLEAR wa_objhead.
      i_objbin[] = zlines[].
    Create Message Body Title and Description
      i_objtxt = 'test with pdf-Attachment!'.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
      READ TABLE i_objtxt INDEX v_lines_txt.
      wa_doc_chng-obj_name = 'smartform'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'smartform'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
    Main Text
      CLEAR i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 2.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      APPEND i_objpack.
    Attachment (pdf-Attachment)
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 2.
    I_OBJPACK-DOC_TYPE = 'RAW'.
      DESCRIBE TABLE i_objbin LINES v_lines_bin.
      READ TABLE i_objbin INDEX v_lines_bin.
      i_objpack-doc_size = v_lines_bin * 255 .
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'smart'.
      i_objpack-obj_descr = 'test'.
      APPEND i_objpack.
      CLEAR i_reclist.
      i_reclist-receiver = p_mailid.
      i_reclist-rec_type = 'U'.
      APPEND i_reclist.
    Send new document with attachments via RFC
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                document_data              = wa_doc_chng
                put_in_outbox              = 'X'
                commit_work                = 'X'
           TABLES
                packing_list               = i_objpack
                object_header              = wa_objhead
                contents_bin               = i_objbin
                contents_txt               = i_objtxt
                receivers                  = i_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.
        WRITE:/ 'Error When Sending the File', sy-subrc.
      ELSE.
        WRITE:/ 'Mail sent'.
      ENDIF.
    ENDFORM.                    " display_data

    hi,
    i wrote a programm.for me it is working.i think it will help for u.
    DATA: t_otfdata TYPE ssfcrescl,
          t_lines LIKE tline OCCURS 0 WITH HEADER LINE,
          t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
          t_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    Objects to send mail.
    DATA:T_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
         T_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
         T_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
         T_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
    DATA: w_filesize TYPE i,
          w_bin_filesize TYPE i,
          wa_ctrlop TYPE ssfctrlop,
          wa_outopt TYPE ssfcompop,
          WA_BUFFER TYPE STRING,          "To convert from 132 to 255
          WA_OBJHEAD TYPE SOLI_TAB,
          WA_DOC_CHNG TYPE SODOCCHGI1,
          W_DATA TYPE SODOCCHGI1.
    DATA: form_name TYPE rs38l_fnam,
          V_LINES_TXT TYPE I,
          V_LINES_BIN TYPE I,
          nast-spras type sy-langu value 'DE'.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZSR_DEMO1'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
       FM_NAME                  = form_name
    EXCEPTIONS
       NO_FORM                  = 1
       NO_FUNCTION_MODULE       = 2
       OTHERS                   = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    wa_ctrlop-LANGU = nast-spras.
    wa_ctrlop-getotf = 'X'.
    wa_ctrlop-no_dialog = 'X'.
    wa_outopt-tdnoprev = 'X'.
    CALL FUNCTION form_name
      EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
       CONTROL_PARAMETERS         = wa_ctrlop
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
       OUTPUT_OPTIONS             = wa_outopt
       USER_SETTINGS              = 'X'
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
       JOB_OUTPUT_INFO            = t_otfdata
      JOB_OUTPUT_OPTIONS         =
    EXCEPTIONS
       FORMATTING_ERROR           = 1
       INTERNAL_ERROR             = 2
       SEND_ERROR                 = 3
       USER_CANCELED              = 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.
    t_otf[] = t_otfdata-otfdata[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       FORMAT                      = 'PDF'
       MAX_LINEWIDTH               = 132
      ARCHIVE_INDEX               = ' '
      COPYNUMBER                  = 0
      ASCII_BIDI_VIS2LOG          = ' '
      PDF_DELETE_OTFTAB           = ' '
    IMPORTING
       BIN_FILESIZE                = w_bin_filesize
      BIN_FILE                    =
      TABLES
        OTF                         = t_otf
        LINES                       = t_lines
    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.
    ENDIF.
    loop at t_lines.
    TRANSLATE t_lines USING '~'.
      CONCATENATE WA_BUFFER T_LINES INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
      t_RECORD = WA_BUFFER.
      APPEND t_RECORD.
      SHIFT WA_BUFFER LEFT BY 255 PLACES.
      IF WA_BUFFER IS INITIAL.
        EXIT.
      ENDIF.
    ENDDO.
    Attachment
    REFRESH: T_RECLIST,
    T_OBJTXT,
    T_OBJBIN,
    T_OBJPACK.
    CLEAR WA_OBJHEAD.
    T_OBJBIN[] = T_RECORD[].
    Create Message Body Title and Description
    T_OBJTXT = 'test with pdf-Attachment!'.
    APPEND T_OBJTXT.
    DESCRIBE TABLE T_OBJTXT LINES V_LINES_TXT.
    READ TABLE T_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR T_OBJPACK-TRANSF_BIN.
    T_OBJPACK-HEAD_START = 1.
    T_OBJPACK-HEAD_NUM = 0.
    T_OBJPACK-BODY_START = 1.
    T_OBJPACK-BODY_NUM = V_LINES_TXT.
    T_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND T_OBJPACK.
    Attachment (pdf-Attachment)
    T_OBJPACK-TRANSF_BIN = 'X'.
    T_OBJPACK-HEAD_START = 1.
    T_OBJPACK-HEAD_NUM = 0.
    T_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE T_OBJBIN LINES V_LINES_BIN.
    READ TABLE T_OBJBIN INDEX V_LINES_BIN.
    T_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    T_OBJPACK-BODY_NUM = V_LINES_BIN.
    T_OBJPACK-DOC_TYPE = 'PDF'.
    T_OBJPACK-OBJ_NAME = 'smart'.
    T_OBJPACK-OBJ_DESCR = 'test'.
    APPEND T_OBJPACK.
    CLEAR T_RECLIST.
    T_RECLIST-RECEIVER = 'mail id'.
    T_RECLIST-REC_TYPE = 'U'.
    APPEND T_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA              = WA_DOC_CHNG
        PUT_IN_OUTBOX              = 'X'
        COMMIT_WORK                = 'X'
      TABLES
        PACKING_LIST               = T_OBJPACK
        OBJECT_HEADER              = WA_OBJHEAD
        CONTENTS_BIN               = T_OBJBIN
        CONTENTS_TXT               = T_OBJTXT
        RECEIVERS                  = T_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.
      WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
      WRITE:/ 'Mail sent'.
    ENDIF.
    please reward me if helpful.

  • Smartform - PDF attachment through E-mail issue

    Hi,
    A custom form and custom program was created to print the Purchase order information through ME21N, 22n and 23n.
    It also has E-mail option. when output medium 5(Simple mail) and 7(External send), email will be send to respective mail-id's with the PDF attachment.
    I have issue at the time of saving PO which processed with medium 5. when i save A popup appears "Express document update was terminated received from author". Brief message about it is
    "Error Info... 00 671: ABAP/4 processor: COMMIT_IN_POSTING"
    In Smartform driver program i am using below function modules to convert OTF into PDF and send through e-mail.
    Function Module: CONVERT_OTF.
    Function Module: SO_DOCUMENT_SEND_API1.
    I am not sure, what i missed out. Can you guys tell is this the correct way to send PDF attachment through E-mail or i missed out any function module for commit.
    Regards,
    Hemanth.
    Edited by: keerthipati hemanth on Jul 31, 2008 1:15 PM
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Jul 31, 2008 3:14 PM

    Hi Hemant,
    Below is the code for the  downloading of the smartform into the PDF Format.
    * Program Name : ZPPREP_SHOPFLOOR_VIEWER_ZOOM
    REPORT zppeerep_shorepfloor_viewer_zoom.
    * T A B L E S    D E C L A R A T I O N
    *---Tables Used.
    TABLES: afpo,
            mara,
            marc,
            aufk,
            afko,
            itcoo,
            nast,                          "Messages
            *nast,                         "Messages
            tnapr,                         "Programs & Forms
            addr_key,
            arc_params,                    "Archive parameters
            toa_dara.                      "Archive parameters
    * I N T E R N A L    T A B L E S     D E C L A R A T I O N
    *--Internal Tables Used.
    * D A T A     D E C L A R A T I O N
    *--Global Variables Used.
    DATA: ws_matnr LIKE afpo-matnr,
          ws_werks LIKE aufk-werks,
          ws_mtart LIKE mara-mtart,
          ws_wrkst LIKE mara-wrkst,
          ws_fname TYPE rs38l_fnam,
          ws_ctrlp TYPE ssfctrlop,
          ws_optns TYPE ssfcompop,
          w_padest LIKE tsp03l-padest.                          "BMC01+
    DATA: da_message_printed(1) TYPE c,
          da_preview_processed(1) TYPE c,
          repeat(1) TYPE c,
          da_subrc LIKE sy-subrc.
    DATA: w_otfdata  TYPE ssfcrescl.
    DATA: BEGIN OF it_itcoo OCCURS 0.
            INCLUDE STRUCTURE itcoo.
    DATA: END OF it_itcoo.
    DATA: w_otf  TYPE itcoo.
    *--Data Declaration for Printing Layout
    DATA: ls_itcpo     TYPE itcpo.
    DATA: lf_repid     TYPE sy-repid.
    DATA: lf_device    TYPE tddevice.
    DATA: cf_retcode   TYPE sy-subrc.
    DATA: ls_recipient TYPE swotobjid.
    DATA: ls_sender    TYPE swotobjid.
    DATA: ls_control_param   TYPE ssfctrlop.
    DATA: ls_composer_param  TYPE ssfcompop.
    DATA: ls_addr_key        LIKE addr_key.
    DATA: w_screen(1) TYPE c.
    DATA: xscreen(1) TYPE c.
    DATA: da_mess LIKE vbfs OCCURS 0 WITH HEADER LINE.
    * C O N S T A N T S
    CONSTANTS: c_fas1(8)  TYPE c VALUE 'PRINTFAS',
               c_fas2(15) TYPE c VALUE 'PRINTFASDRAWING',
               c_wip1(8)  TYPE c VALUE 'PRINTWIP',
               c_wip2(15) TYPE c VALUE 'PRINTWIPDRAWING'.
    * S E L E C T I O N - S C R E E N.
    SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1.
    * Production order
    PARAMETERS: p_aufnr LIKE afpo-aufnr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK bl1.
    START-OF-SELECTION.
    *--Begin of Commenting                   "
    *--Get Partially processed orders
      MOVE: sy-mandt         TO nast-mandt,
            'V1'             TO nast-kappl,
            p_aufnr          TO nast-objky,
            p_aufnr          TO nast-parnr,
            sy-langu         TO nast-spras,
            sy-datum         TO nast-erdat,
            '1'              TO nast-nacha,
            '3'              TO nast-vsztp,
            'X'              TO nast-manue,
            sy-uname         TO nast-usnam,
            'DFLT'           TO nast-ldest,
            sy-langu         TO nast-tdspras,
            'Shop Floor Papers' TO nast-tdcovtitle,
            '1'              TO nast-tdarmod,
            'BUS2032'        TO nast-objtype.
    *--Printer settings
      CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
        EXPORTING
          pi_nast       = nast
          pi_repid      = sy-repid
        IMPORTING
          pe_returncode = cf_retcode
          pe_itcpo      = ls_itcpo
          pe_device     = lf_device
          pe_recipient  = ls_recipient
          pe_sender     = ls_sender.
      MOVE-CORRESPONDING ls_itcpo TO ls_composer_param.
      ls_control_param-device      = 'PRINTER'.
      ls_control_param-no_dialog   = 'X'.
      ls_control_param-preview     = 'X'.
      ls_control_param-getotf      = ls_itcpo-tdgetotf.
      ls_control_param-langu       = sy-langu.
    *--End   of Commenting                   "
    *--Start of Addition                     "
      CLEAR:   ws_werks.
      SELECT   SINGLE werks
               INTO   ws_werks
               FROM   aufk
               WHERE  aufnr = p_aufnr.
      CLEAR:   ws_matnr.
      SELECT   SINGLE plnbez
               INTO   ws_matnr
               FROM   afko
               WHERE  aufnr = p_aufnr.
      CLEAR:   marc.
      SELECT   SINGLE matgr
               INTO   marc-matgr
               FROM   marc
               WHERE  matnr = ws_matnr
               AND    werks = ws_werks.
    *--End   of Addition                     "
    *  CHECK NOT ws_matnr IS INITIAL.       
      IF NOT ws_matnr IS INITIAL.          
    *--Start of Addition                    
        SELECT   SINGLE matgr
                 INTO   marc-matgr
                 FROM   marc
                 WHERE  matnr = ws_matnr
                 AND    werks = ws_werks.
    *--Start of Addition BY Rapidigm01_01+
      ELSE.
        marc-matgr = c_wip1.
      ENDIF.
    *--End Of Addition BY Rapidigm01_01+
    *--End   of Addition                     "
    END-OF-SELECTION.
      PERFORM call_smartform.
    * F O R M    R O U T I N E S
    *&      Form  call_smartform
    *       text
    FORM call_smartform.
      CLEAR: ws_ctrlp, ws_optns, ws_fname.
    *--Start of Addition                                 "
      TRANSLATE marc-matgr TO UPPER CASE.
      IF marc-matgr = c_fas1 OR
         marc-matgr = c_fas2.
        PERFORM call_paper_a.
      ELSEIF marc-matgr = c_wip1 OR
             marc-matgr = c_wip2.
        PERFORM call_paper_b.
      ENDIF.
    *--End   of Addition                                 "
    ENDFORM.                    "call_smartform
    *&      Form  call_paper_a
    *       text
    FORM call_paper_a.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
    *>>BC SPARTA03    DATE: 19/05/2008
    *      formname           = 'ZPPSF_SHOP_FLOOR_PAPER_A'  "Rapidigm03_01-
          formname           = 'ZPPSF_SHOP_FLOOR_PAPER_C'  "Rapidigm03_01-
    *<<EC SPARTA03    DATE: 19/05/2008
    *       formname  = 'ZPPSF_SHOP_FLOOR_PAPER_A_2893'   "Rapidigm03_01+
        IMPORTING
          fm_name            = ws_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      CHECK NOT ws_fname IS INITIAL.
      CLEAR w_otfdata.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION ws_fname
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient
          mail_sender        = ls_sender
          output_options     = ls_composer_param
          user_settings      = ' '
          is_nast            = nast
          aufnr              = p_aufnr
          flag_orig          = 'X'
        IMPORTING
          job_output_info    = w_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      LOOP AT w_otfdata-otfdata INTO w_otf.
        APPEND w_otf TO it_itcoo.
      ENDLOOP.
      CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
        TABLES
          otf_table = it_itcoo.
    ENDFORM.                    "call_paper_a
    *&      Form  call_paper_b
    *       text
    FORM call_paper_b.
      DATA: ws_doknr TYPE draw-doknr,
            ws_dokvr TYPE draw-dokvr.
      CLEAR: ws_doknr, ws_dokvr.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZPPSF_SHOP_FLOOR_PAPER_B'
        IMPORTING
          fm_name            = ws_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      CHECK NOT ws_fname IS INITIAL.
      CLEAR w_otfdata.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION ws_fname
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient
          mail_sender        = ls_sender
          output_options     = ls_composer_param
          user_settings      = ' '
          is_nast            = nast
          aufnr              = p_aufnr
          doknr              = ws_doknr
          dokvr              = ws_dokvr
          flag_orig          = 'X'
        IMPORTING
          job_output_info    = w_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      LOOP AT w_otfdata-otfdata INTO w_otf.
        APPEND w_otf TO it_itcoo.
      ENDLOOP.
      CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
        TABLES
          otf_table = it_itcoo.
    ENDFORM.                    "call_paper_b

  • Facing problem with logo in the PDF attachment when sending mail...

    hi friends,
    i'm facing problem with logo in the PDF attachment to the mail.
    my requirement:
    1. enter spool number and mail id in the selection screen.
    process:
    1. now the program will fetch the spool data and converts it to PDF.
    2. but when i'm trying to send mail with this PDF as attachment.
    when i open the PDF file from the mail, logo is not coming properly (looks disturbed).
    can anyone help me how to resolve this issue...
    thanks in advance, murashali.

    hi dinakar, thanks for your mail...
    logo looks good in spool/script/smartform.
    even it look good when i download this spool to pdf and to the presentation server as pdf file.
    i'm using CONVERT_OTFSPOOLJOB_2_PDF.
    when i used CONVERT_ABAPSPOOLJOB_2_PDF, is gives a msg - 'spool number not found'.
    here i'm using folloing code to pass pdf to the function module: SO_NEW_DOCUMENT_ATT_SEND_API1.
    code:
    Transfer the 132-long strings to 255-long strings
      lt_mtab_pdf[] = pdf[].
      LOOP AT lt_mtab_pdf INTO lwa_mtab_pdf.
        TRANSLATE lwa_mtab_pdf USING ' ~'.
        CONCATENATE lv_gd_buffer lwa_mtab_pdf INTO lv_gd_buffer.
        CLEAR lwa_mtab_pdf.
      ENDLOOP.
      TRANSLATE lv_gd_buffer USING '~ '.
      DO.
        lwa_mess_att = lv_gd_buffer.
        APPEND lwa_mess_att TO lt_mess_att.
        CLEAR lwa_mess_att.
        SHIFT lv_gd_buffer LEFT BY 255 PLACES.
        IF lv_gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    NOTE: problem i believe is with ''.  i'm getting this tilt symbol () in my pdf internal table.  here in the above code the line   TRANSLATE lv_gd_buffer USING '~ ' is changing the existing tilt to space.  so my logo is getting disturbed.
    even i tried with REPLACE this tilt with other char, but it doent work.
    can you give any idea...

  • Sending smartform as PDF attachment through email

    Hi,
    I have used the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send the smartform as PDF attachment through email.In SOST transaction I can see that the mail has been sent to the reciepient,but the mail is not going to the mail box.What would be the reason for this?
    Regards,
    Hema

    That should be the basis issue. They needs to do some settings. Please ask them to do so.
    Pranav

  • How to open a pdf attachment in imac mail

    I am unable to open a PDF attachment in Mac Mail. There is not a PDF Icon in the email message. Is there a setting that should be checked?
    I have a new iMac (less than a month old) with Mountain Lion.
    Help would be greatly appreciated. Thanks

    It is an actual PDF that is an attachment to an email. There is not a link to click on to open the attachment.
    The attachment is a statement that I normally open, then print..
    What I am seeing on the monitor is the heading portion of the email with the statement image, all on one page..It prints exactly as seen on the screen.
    I have checked my Mail>Preferences>Viewing Tab."Display remote images in HTML" messages is checked..
    Thanks for the help.

  • Reading an PDF Attachment  From Sender Mail Adapter

    Hi All,
                   i am able to get a mail  from my Mail Server, But my aim is need to Read an PDF attachment from the mail, in SXMB Moni i am getting the Payload with attachment, I have a created a module to convert that PDF to XML(Module is working fine in file to file sceneraio) .
    In adapter should i need to use Payload Swap Bean Module also , because in sap help said that i need  Select Keep Attachments. I want to know how that how to Push the PDF attachment to My Custom Module which is used to convert the PDF To XML.
    If Payload Swap Bean Module needs to be Used , please tell me the Key Names and Key Values to be used.(swap.keyName,swap.keyValues)
    Thanks and Regards,
    Kamal
    Note: Points will be awarded

    Kamal...
    See if this helps
    [Module Name]
      AF_Modules/PayloadSwapBean
    [Module Parameters]
    The following parameters are used for this module
      swap.keyName          the name of a supported attribute.
      swap.keyValue         the value of a partial string that is required
                            to appear.
    The supported attributes (swap.keyName) include the payload attributes
    such as payload-name, payload-description and any content attributes
    such as content-type, content-disposition, content-description, etc.
    Regards
    Ravi Raman

  • How to send smartforms as pdf attachments with e mail

    hi experts,
    how to send smartforms as pdf attachments with e mail???
    nitin

    Hi
    In the FORM Interface put proper parameter. Hope this helps.

  • Send a remuneration statement (paystub) as a PDF attachment by e-mail

    Hi,
    Does anybody send to their employees remuneration statement (paystub) as a PDF attachment by e-mail?
    Could you please share the method that you using for it and advice why you choose this method?
    I need to analyse at least two options:
    u2022     Sending standard SAP Remuneration FORM
    u2022     Sending custom made Remuneration FORM (more relevant to my situation)
    Thank you in advance,
    Yutah

    Thank you Rohan,
    It may work for standard SAP payslip form but still need to find out how to send it out by e-mail automatically after pay-run is done to a bunch of employees.
    Is there any standard solution or I need to create custom program to do it?
    Any idea about custom made payslip form.
    Right now we create a text file which we send to third party for payslip printing and have a custom made report which reads this file if we need to display/print payslip in house.

  • Smartform to convert as pdf attachment and sending mail.

    Program to convert smartform as PDF and send PDF as an atachment to email id.
    ********Variable Declarations ****************************
    DATA: gv_form_name TYPE rs38l_fnam, " Used to store the function module generated by Smartform
    gv_bin_filesize TYPE i, " Store the file size
    gv_pos TYPE i,
    gv_len TYPE i,
    gv_tab_lines TYPE i.
    *******Constants ******************************************
    DATA : gc_text(11) TYPE c VALUE 'Form Output',
    gc_tst(3) TYPE c VALUE 'TST',
    gc_testing(7) TYPE c VALUE 'Testing'.
    CONSTANTS : c_formname           TYPE tdsfname VALUE 'ZSMART_T'.     "Zsmart_t is the smartform name.
    ********Work Area Declarations ****************************
    DATA: gs_docdata TYPE sodocchgi1, " Data of an object which can be changed
    gs_ctrlop TYPE ssfctrlop, " Smart Forms: Control structure
    gs_outopt TYPE ssfcompop, " SAP Smart Forms: Smart Composer (transfer) options
    gs_otfdata TYPE ssfcrescl, " Smart Forms: Return value at end of form printing
    gs_reclist TYPE somlreci1, " SAPoffice: Structure of the API Recipient List
    gs_pdf_tab TYPE tline, " Workarea for SAP Script Text Lines
    gs_objbin TYPE solisti1, " SAPoffice: Single List with Column Length 255
    gs_objpack TYPE sopcklsti1. " SAPoffice: Description of Imported Object Components
    ********Internal tables Declarations ****************************
    DATA: gt_reclist TYPE TABLE OF somlreci1, " SAPoffice: Structure of the API Recipient List
    gt_pdf_tab TYPE TABLE OF tline, " SAPscript: Text Lines
    gt_otf TYPE TABLE OF itcoo, " OTF Structure
    gt_objbin TYPE TABLE OF solisti1, " SAPoffice: Single List with Column Length 255
    gt_objpack TYPE TABLE OF sopcklsti1. " SAPoffice: Description of Imported Object Components
    DATA: customer TYPE scustom,
          bookings TYPE ty_bookings,
          connections TYPE ty_connections.
    CLEAR : gv_form_name,
    gs_ctrlop,
    gs_outopt,
    gs_otfdata,
    gv_bin_filesize,
    gv_pos,
    gv_len,
    gv_tab_lines.
    START-OF-SELECTION.
    Generate Function Module name
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = c_formname
        IMPORTING
          fm_name            = gv_form_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Assigning values to Form Control Structure and Form Composer
      gs_ctrlop-getotf = 'X'.
      gs_ctrlop-device = 'PRINTER'.
      gs_ctrlop-preview = ''.
      gs_ctrlop-no_dialog = 'X'.
      gs_outopt-tddest = 'LP01'.  "or  'LOCL'.
    Getting the OTFDATA
      CALL FUNCTION gv_form_name
        EXPORTING
          control_parameters = gs_ctrlop
          output_options     = gs_outopt
          user_settings      = ' '
          customer           = customer
          bookings           = bookings
          connections        = connections
        IMPORTING
          job_output_info    = gs_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 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.
    Assigning the OTFDATA to OTF Structure table
      CLEAR gt_otf.
      gt_otf[] = gs_otfdata-otfdata[].
    Convert the OTF DATA to SAP Script Text lines
      CLEAR gt_pdf_tab.
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          bin_filesize          = gv_bin_filesize
        TABLES
          otf                   = gt_otf
          lines                 = gt_pdf_tab
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 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.
    Assigning the Description of the object sent in the mail
      CLEAR gs_docdata.
      gs_docdata-obj_name = gc_tst.
      gs_docdata-obj_descr = gc_testing.
    Assigning the email id to Structure of the API Recipient List table
      CLEAR : gt_reclist, gs_reclist.
    IF internal mail id
    gs_reclist-receiver = sy-uname.
    GS_RECLIST-REC_TYPE = 'B'.
    if external mail id
      gs_reclist-receiver = mailid.com'.
      gs_reclist-rec_type = 'U'.
      APPEND gs_reclist TO gt_reclist.
    Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
      CLEAR : gs_objbin, gs_pdf_tab.
      LOOP AT gt_pdf_tab INTO gs_pdf_tab.
        gv_pos = 255 - gv_len.
        IF gv_pos > 134. "length of pdf_table
          gv_pos = 134.
        ENDIF.
        gs_objbin+gv_len = gs_pdf_tab(gv_pos).
        gv_len = gv_len + gv_pos.
        IF gv_len = 255. "length of out (contents_bin)
          APPEND gs_objbin TO gt_objbin.
          CLEAR: gs_objbin, gv_len.
          IF gv_pos < 134.
            gs_objbin = gs_pdf_tab+gv_pos.
            gv_len = 134 - gv_pos.
          ENDIF.
        ENDIF.
      ENDLOOP.
      IF gv_len > 0.
        APPEND gs_objbin TO gt_objbin.
      ENDIF.
    Filling the details in SAPoffice: Description of Imported Object Components table
      DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
      CLEAR gs_objbin.
      READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
      IF sy-subrc = 0.
        gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
        gs_objpack-transf_bin = 'X'.
        gs_objpack-head_start = 1.
        gs_objpack-head_num = 0.
        gs_objpack-body_start = 1.
        gs_objpack-body_num = gv_tab_lines.
        gs_objpack-doc_type = 'PDF'.
        gs_objpack-obj_name = 'ATTACHMENT'.
        gs_objpack-obj_descr = 'test'.
        APPEND gs_objpack TO gt_objpack.
      ENDIF.
    Sending the Form Output in the PDF format to email
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = gs_docdata
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = gt_objpack
          contents_bin               = gt_objbin
          receivers                  = gt_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.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        WRITE 'Sent Successfully'.
      ENDIF.
      SUBMIT rsconn01
      WITH mode EQ 'INT'
      AND RETURN.
    END-OF-SELECTION.

    Hi
    Use function modules
              CALL FUNCTION 'CONVERT_OTF'
    and  CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'  to convert as a pdf document
    for sending mail  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    Regards,
    Gopi

  • Sending smartform as pdf attachment through mail

    Dear All,
    Can anyone suggest me sample code of how an sap smartform output is sent as pdf attachment to a receipients email address?
    Thanks
    M A

    hi,
    chk this sample code.
    * Internal Table declarations
    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
          i_tline TYPE TABLE OF tline WITH HEADER LINE,
          i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
          i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    * Objects to send mail.
          i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
          i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    * Work Area declarations
          wa_objhead TYPE soli_tab,
          w_ctrlop TYPE ssfctrlop,
          w_compop TYPE ssfcompop,
          w_return TYPE ssfcrescl,
          wa_doc_chng typE sodocchgi1,
          w_data TYPE sodocchgi1,
          wa_buffer TYPE string,"To convert from 132 to 255
    * Variables declarations
          v_form_name TYPE rs38l_fnam,
          v_len_in LIKE sood-objlen,
          v_len_out LIKE sood-objlen,
          v_len_outn TYPE i,
          v_lines_txt TYPE i,
          v_lines_bin TYPE i.
    call function 'SSF_FUNCTION_MODULE_NAME'
         exporting
              formname           = 'ZZZ_TEST1'
         importing
              fm_name            = v_form_name
         exceptions
              no_form            = 1
              no_function_module = 2
              others             = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    w_ctrlop-getotf = 'X'.
    w_ctrlop-no_dialog = 'X'.
    w_compop-tdnoprev = 'X'.
    CALL FUNCTION v_form_name
         EXPORTING
              control_parameters = w_ctrlop
              output_options     = w_compop
              user_settings      = 'X'
         IMPORTING
              job_output_info    = w_return
         EXCEPTIONS
              formatting_error   = 1
              internal_error     = 2
              send_error         = 3
              user_canceled      = 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.
    i_otf[] = w_return-otfdata[].
    call function 'CONVERT_OTF'
           EXPORTING
                format                = 'PDF'
                max_linewidth         = 132
           IMPORTING
                bin_filesize          = v_len_in
           TABLES
                otf                   = i_otf
                lines                 = i_tline
           EXCEPTIONS
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                others                = 4.
    *   Fehlerhandling
      if sy-subrc <> 0.
      endif.
      loop at i_tline.
        translate i_tline using '~'.
        concatenate wa_buffer i_tline into wa_buffer.
      endloop.
      translate wa_buffer using '~'.
      do.
        i_record = wa_buffer.
        append i_record.
        shift wa_buffer left by 255 places.
        if wa_buffer is initial.
          exit.
        endif.
      enddo.
    * Attachment
      refresh:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
      clear wa_objhead.
      i_objbin[] = i_record[].
    ******* Create Message Body
    **** Title and Description
      i_objtxt = 'test with pdf-Attachment!'.
      append i_objtxt.
      describe table i_objtxt lines v_lines_txt.
      read table i_objtxt index v_lines_txt.
      wa_doc_chng-obj_name = 'smartform'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'smartform'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
    **** Main Text
    *  wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
      clear i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      append i_objpack.
    **** Attachment
    * (pdf-Attachment)
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
    * Länge des Attachment ermitteln
      describe table i_objbin lines v_lines_bin.
      read table i_objbin index v_lines_bin.
      i_objpack-doc_size =  v_lines_bin * 255 .
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'smart'.
      i_objpack-obj_descr = 'test'.
      append i_objpack.
      clear i_reclist.
      i_reclist-receiver = '[email protected]'.
      i_reclist-rec_type = 'U'.
      append i_reclist.
        call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
             EXPORTING
                  document_data              = wa_doc_chng
                  put_in_outbox              = 'X'
             TABLES
                  packing_list               = i_objpack
                  object_header              = wa_objhead
                  CONTENTS_BIN               = i_objbin
                  contents_txt               = i_objtxt
                  receivers                  = i_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.
    Regards
    Anver

  • Send smartform as pdf attachment through Email on ECC 5.0

    I have been trying hard to do this, but am not able to send attachment. Below are the problems -
    1. If sometimes the mail goes, the attachment is empty.
    2. if i use COMMIT_WORK = 'X' in FM SO_NEW_DOCUMENT_ATT_SEND_API1 , it throws a dump - ' Invalid COMMIT WORK in an update function module.'
    3. If i comment COMMIT_WORK = 'X', it gets executed successfully but, in the program i get a dump 'UC_OBJECTS_NOT_CHAR' exception.
    Can someone suggest, what settings are required in SAP to send smartforms as PDF attachments. Also, please suggest how can i remove the dump. If anyone can give me a working program, it will be very very helpful.
    here is the code,
    REPORT  zrsmfmail.
    TYPE-POOLS: addi.
    Tables defination.
    TABLES : vbpa,vbak,nast, stxl, stxh.
    Data Decleration .
    DATA: lf_fm_name  TYPE rs38l_fnam,
          l_lines TYPE i.
    DATA: output_options TYPE ssfcompop.
    DATA: fcodem TYPE sy-ucomm.
    DATA: i_id LIKE thead-tdid VALUE 'V002',
          i_object LIKE thead-tdobject VALUE 'VBBK' ,
          i_tdname LIKE thead-tdname ,
          i_lang LIKE thead-tdspras VALUE 'E' .
    Internal Table declration.
    DATA: int_vbak LIKE vbak OCCURS 0 WITH HEADER LINE,
          int_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.
    DATA : itline1 LIKE tline OCCURS 0 WITH HEADER LINE .
    DATA: retcode   LIKE sy-subrc.         "Returncode
    DATA: repeat(1) TYPE c.
    DATA: xscreen(1) TYPE c.               "Output on printer or screen
    Internal Table declarations
    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
    i_tline TYPE TABLE OF tline WITH HEADER LINE,
    i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
    i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    lt_att_content_hex LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    wa_objhead TYPE soli_tab,
    w_ctrlop TYPE ssfctrlop,
    w_compop TYPE ssfcompop,
    w_return TYPE ssfcrescl,
    wa_doc_chng TYPE sodocchgi1,
    w_data TYPE sodocchgi1,
    wa_buffer TYPE string,
    Variables declarations
    v_form_name TYPE rs38l_fnam,
    v_len_in LIKE sood-objlen,
    v_len_out LIKE sood-objlen,
    v_len_outn TYPE i,
    v_lines_txt TYPE i,
    v_lines_bin TYPE i.
    DATA: BEGIN OF zlines2 OCCURS 0,
    tline TYPE char255,
    END OF zlines2,
    size TYPE i,
    zdata TYPE sodocchgi1.
    *&      Form  entry
    FORM entry USING return_code TYPE i
                     us_screen TYPE c.
      CLEAR retcode.
      xscreen = us_screen.
      PERFORM processing.
      IF retcode NE 0.
        return_code = 1.
      ELSE.
        return_code = 0.
      ENDIF.
    ENDFORM.                    "ENTRY
    *&      Form  PROCESSING
          text
    FORM processing.
      SELECT *
      INTO   CORRESPONDING FIELDS OF TABLE int_vbak
      FROM   vbak
      WHERE  vbeln = nast-objky.
      LOOP AT int_vbak .
        i_tdname = int_vbak-vbeln .
        SELECT SINGLE * FROM stxh WHERE tdobject = i_object
                                    AND tdname = i_tdname
                                    AND tdid = i_id
                                    AND tdspras = i_lang.
        IF sy-subrc = 0 .
          CALL FUNCTION 'READ_TEXT'
            EXPORTING
              id       = i_id
              language = i_lang
              name     = i_tdname
              object   = i_object
            TABLES
              lines    = itline1.
          IF sy-subrc NE 0 .
            APPEND itline1 .
          ENDIF .
        ENDIF .
        DESCRIBE TABLE int_vbak LINES l_lines.
        l_lines = l_lines .
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname           = 'ZORDER_QUOTE'
          IMPORTING
            fm_name            = v_form_name
          EXCEPTIONS
            no_form            = 1
            no_function_module = 2
            OTHERS             = 3.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        w_ctrlop-getotf = 'X'.
        w_ctrlop-no_dialog = 'X'.
        w_compop-tdnoprev = 'X'.
        CALL FUNCTION v_form_name
          EXPORTING
            l_lines            = l_lines
            control_parameters = w_ctrlop
            output_options     = w_compop
            user_settings      = 'X'
          IMPORTING
            job_output_info    = w_return
          TABLES
            int_vbak           = int_vbak
            int_vbap           = int_vbap
            itline1            = itline1
          EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 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.
        i_otf[] = w_return-otfdata[].
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
            max_linewidth         = 132
          IMPORTING
            bin_filesize          = size
          TABLES
            otf                   = i_otf
            lines                 = i_tline
          EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 3
            OTHERS                = 4.
    Fehlerhandling
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Change the PDF format from 132 to 255.
        CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
          EXPORTING
            transfer_bin = 'X'
          TABLES
            content_in   = i_tline
            content_out  = zlines2
          EXCEPTIONS
            err_line_width_src_too_long = 1
            err_line_width_dst_too_long = 2
            err_conv_failed = 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.
    Attachment
        REFRESH:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
        CLEAR wa_objhead.
        i_objtxt = 'TEST PDF ATTACHMENT'.
        APPEND i_objtxt.
        DESCRIBE TABLE i_objtxt LINES v_lines_txt.
        READ TABLE i_objtxt INDEX v_lines_txt.
        wa_doc_chng-obj_name = 'SMARTFORM'.
        wa_doc_chng-expiry_dat = sy-datum + 10.
        wa_doc_chng-obj_descr = 'SMARTFORM'.
        wa_doc_chng-sensitivty = 'F'.
        wa_doc_chng-no_change = 'X'.
        wa_doc_chng-obj_langu = sy-langu.
        wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
        CLEAR i_objpack-transf_bin.
        i_objpack-head_start = 1.
        i_objpack-head_num = 0.
        i_objpack-body_start = 1.
        i_objpack-body_num = v_lines_txt.
        i_objpack-doc_type = 'RAW'.
        APPEND i_objpack.
    (pdf-Attachment)
        i_objbin[] = zlines2[].
        i_objpack-transf_bin = 'X'.
        i_objpack-head_start = 1.
        i_objpack-head_num = 1.
        i_objpack-body_start = 1.
    Länge des Attachment ermitteln
        DESCRIBE TABLE i_objbin LINES v_lines_bin.
        READ TABLE i_objbin INDEX v_lines_bin.
        i_objpack-doc_size = v_lines_bin * 255 .
        i_objpack-body_num = v_lines_bin.
        i_objpack-doc_type = 'PDF'.
        i_objpack-obj_name = 'SMARTFORM'.
        i_objpack-obj_descr = 'TEST'.
        APPEND i_objpack.
        CLEAR i_reclist.
        i_reclist-receiver = 'abc at aa.com'.
        i_reclist-rec_type = 'F'.
        i_reclist-express = 'X'.
        APPEND i_reclist.
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA = WA_DOC_CHNG
          PUT_IN_OUTBOX = 'X'
         commit_work = 'X'
        TABLES
          PACKING_LIST = I_OBJPACK
          CONTENTS_BIN = I_OBJBIN
          CONTENTS_TXT = I_OBJTXT
          RECEIVERS = I_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.
        CASE sy-subrc.
          WHEN 0.
          WHEN 1. RAISE too_many_receivers.
          WHEN 2. RAISE document_not_sent .
          WHEN 3. RAISE document_type_not_exist.
          WHEN 4. RAISE operation_no_authorization.
          WHEN 5. RAISE parameter_error.
          WHEN 7. RAISE enqueue_error .
          WHEN OTHERS. RAISE x_error.
        ENDCASE.
    COMMIT WORK.
      ENDLOOP.
    ENDFORM.                    "entry
    Please suggest ASAP, it has come to a critical stage now, a fruitful help will be a great saviour.
    Thanks !

    Hi Guys,
    You can even try this 'CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
          IMPORTING
            bin_filesize          = bin_filesize
            bin_file              = xstring
          TABLES
            otf                   = it_otf_final
            lines                 = it_pdfdata[]
          EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 3
            err_bad_otf           = 4
            OTHERS                = 5.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
          EXPORTING
            buffer                = xstring
          APPEND_TO_TABLE       = ' '
        IMPORTING
          OUTPUT_LENGTH         =
          TABLES
            binary_tab            = it_pdf
    Use Cl_BSC Class for easy way to send mail.
    Either u can Distribution list Tcode so23.
    This is the way i have implemted .. !

  • Change Font Size with PDF attachment  via e--mail

    Hi experts,
    I want to send mail with PDF attachment . Now the attachment is ok but only the font size in PDF is a little small.
    Is that possible to Change the font size of PDF
    Below is my code:
    first the data comes from an internal table, then changed to an ABAP Pool.
    * Create a new spool from the data in gt_data_pdf
      new-page print on
      destination c_local               "<<== my printer
      cover text text-027               "<<== Title or Spool req. name
      list name space
      list dataset space
      immediately space                 " X means print now
      keep in spool c_checked           " X means keep spool
      new list identification c_checked
      line-size 255
      line-count 65
      no dialog .
      loop at gt_data_pdf.
        write: / gt_data_pdf-line.
      endloop.
      new-page print off.
      lv_spoolid = lv_spdel-rqident = sy-spono.
      lv_spdel-sys = sy-sysid.
    *Convert ABAP Spool to PDF
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid   = lv_spoolid
          no_dialog     = c_checked
        importing
          pdf_bytecount = lv_pdf_fsize
        tables
          pdf           = lt_pdf_table
        exceptions
          others        = 0.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        exporting
          document_data              = lv_doc_chng
          put_in_outbox              = space
          commit_work                = c_checked
        tables
          packing_list               = lt_objpack
          object_header              = lt_objhead
          contents_bin               = lt_objbin
          contents_txt               = lt_objtxt
          receivers                  = lt_reclist
        exceptions
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          others                     = 99.
    Anyone could help me?
    Thanks a lot.
    Sincerely
    Julie

    Hi,
    we don´t have many options for setting the font type and size in an ABAP list. One option is that you print the output using either SmartForms or AdobeForms, where you can control font type as well as size. This one requires additional work.
    Another option is to use the instruction Print-Control:
    NEW-PAGE PRINT ON.
    PRINT-CONTROL FONT 1 SIZE 1 LPI 6 CPI 10.
    WRITE: /10   'FONT 1 size 1 LPI 6 cpi 10'.
    SKIP.
    PRINT-CONTROL FONT 1 SIZE 5 LPI 6 CPI 5.
    WRITE: /10   'FONT 1 size 5 LPI 6 cpi 5'.
    SKIP.
    PRINT-CONTROL FONT 2 SIZE 5 LPI 6 CPI 10.
    WRITE: /10   'FONT 2 size 5 LPI 6 cpi 10'.
    SKIP.
    NEW-PAGE PRINT OFF.

  • Smartform as PDF attachment

    Hi Friends,
    I have created a Smartform for PO driver program its working fine but my requirement is i want to mail this SF as PDF attachment and they have given me Partner function as "MP'
    for mail Partner and "MA" ,medium 7 ( Simple mail).  Can any one suggest me ,
    its urgent.
    Regards,
    DVNS

    hi,
    REPORT ztest.
    Variable declarations
    DATA:
    w_form_name TYPE tdsfname VALUE 'ZTEST',
    w_fmodule TYPE rs38l_fnam,
    w_cparam TYPE ssfctrlop,
    w_outoptions TYPE ssfcompop,
    W_bin_filesize TYPE i, " Binary File Size
    w_FILE_NAME type string,
    w_File_path type string,
    w_FULL_PATH type string.
    Internal tables declaration
    Internal table to hold the OTF data
    DATA:
    t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
    Internal table to hold OTF data recd from the SMARTFORM
    t_otf_from_fm TYPE ssfcrescl,
    Internal table to hold the data from the FM CONVERT_OTF
    T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
    This function module call is used to retrieve the name of the Function
    module generated when the SMARTFORM is activated
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = w_form_name
    VARIANT = ' '
    DIRECT_CALL = ' '
    IMPORTING
    fm_name = w_fmodule
    EXCEPTIONS
    no_form = 1
    no_function_module = 2
    OTHERS = 3
    IF sy-subrc 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Calling the SMARTFORM using the function module retrieved above
    GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
    format of the output
    w_cparam-no_dialog = 'X'.
    w_cparam-preview = space. " Suppressing the dialog box
    " for print preview
    w_cparam-getotf = 'X'.
    Printer name to be used is provided in the export parameter
    OUTPUT_OPTIONS
    w_outoptions-tddest = 'LP01'.
    CALL FUNCTION w_fmodule
    EXPORTING
    ARCHIVE_INDEX =
    ARCHIVE_INDEX_TAB =
    ARCHIVE_PARAMETERS =
    control_parameters = w_cparam
    MAIL_APPL_OBJ =
    MAIL_RECIPIENT =
    MAIL_SENDER =
    output_options = w_outoptions
    USER_SETTINGS = 'X'
    IMPORTING
    DOCUMENT_OUTPUT_INFO =
    job_output_info = t_otf_from_fm
    JOB_OUTPUT_OPTIONS =
    EXCEPTIONS
    formatting_error = 1
    internal_error = 2
    send_error = 3
    user_canceled = 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.
    t_otf] = t_otf_from_fm-otfdata[.
    Function Module CONVERT_OTF is used to convert the OTF format to PDF
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    MAX_LINEWIDTH = 132
    ARCHIVE_INDEX = ' '
    COPYNUMBER = 0
    ASCII_BIDI_VIS2LOG = ' '
    PDF_DELETE_OTFTAB = ' '
    IMPORTING
    BIN_FILESIZE = W_bin_filesize
    BIN_FILE =
    TABLES
    otf = T_OTF
    lines = T_pdf_tab
    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.
    ENDIF.
    To display File SAVE dialog window
    CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
    WINDOW_TITLE =
    DEFAULT_EXTENSION =
    DEFAULT_FILE_NAME =
    FILE_FILTER =
    INITIAL_DIRECTORY =
    WITH_ENCODING =
    PROMPT_ON_OVERWRITE = 'X'
    CHANGING
    filename = w_FILE_NAME
    path = w_FILE_PATH
    fullpath = w_FULL_PATH
    USER_ACTION =
    FILE_ENCODING =
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 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.
    Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
    presentation server
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = W_bin_filesize
    filename = w_FULL_PATH
    FILETYPE = 'BIN'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = ' '
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    CONFIRM_OVERWRITE = ' '
    NO_AUTH_CHECK = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    WRITE_BOM = ' '
    TRUNC_TRAILING_BLANKS_EOL = 'X'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
    tables
    data_tab = T_pdf_tab
    FIELDNAMES =
    EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH = 2
    GUI_REFUSE_FILETRANSFER = 3
    INVALID_TYPE = 4
    NO_AUTHORITY = 5
    UNKNOWN_ERROR = 6
    HEADER_NOT_ALLOWED = 7
    SEPARATOR_NOT_ALLOWED = 8
    FILESIZE_NOT_ALLOWED = 9
    HEADER_TOO_LONG = 10
    DP_ERROR_CREATE = 11
    DP_ERROR_SEND = 12
    DP_ERROR_WRITE = 13
    UNKNOWN_DP_ERROR = 14
    ACCESS_DENIED = 15
    DP_OUT_OF_MEMORY = 16
    DISK_FULL = 17
    DP_TIMEOUT = 18
    FILE_NOT_FOUND = 19
    DATAPROVIDER_EXCEPTION = 20
    CONTROL_FLUSH_ERROR = 21
    OTHERS = 22
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

Maybe you are looking for