Smartforms to PDF file

hi experts,
How can I convert smartforms into PDF?
Regards,
Marc

Here is the sample code..
CALL FUNCTION fm_name        " '/1BCDWB/SF00000035' - FM Generated by Smartform
  EXPORTING
    control_parameters = control_parameters
    output_options     = output_options
    s_header           = st_header
  IMPORTING
    job_output_info = output_data
  TABLES
    it_overdue = ITAB[]
  EXCEPTIONS
    formatting_error = 1
    internal_error   = 2
    send_error       = 3
    user_canceled    = 4
    OTHERS           = 5.
* now convert the final document (OTF format) into PDF
format
CALL FUNCTION 'CONVERT_OTF'
  EXPORTING
    format = 'DOC'
  IMPORTING
    bin_filesize = v_pdf_len
  TABLES
    otf   = output_data-otfdata
    lines = pdf_table
  EXCEPTIONS
    err_max_linewidth     = 1
    err_format            = 2
    err_conv_not_possible = 3
    err_bad_otf           = 4
    OTHERS                = 5.
** Downloading the PDF file to the local Server
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME = L_FILENAME
    FILETYPE = C_BIN_FILETYPE
  TABLES
    DATA_TAB = lt_pdf_nuc_data
  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.
Regards,
Raja T

Similar Messages

  • Problem in downloading smartform as pdf file...

    Hi SDNs.,
    while downloading the invoice layout as .PDF file.. i am getting following error...
    <b>OTF end command // missing in OTF data</b>
    and the file is downloading as empty size... ( xyz.pdf with 0kb )
    It is working fine in sandbox... i am getting this error in production...
    what could be the probelm? when this type of error occurs?

    hi raghu.,
    CALL FUNCTION LF_FM_NAME
            EXPORTING
              ARCHIVE_INDEX      = TOA_DARA
              ARCHIVE_PARAMETERS = ARC_PARAMS
              CONTROL_PARAMETERS = W_CTRLOP
              MAIL_RECIPIENT     = LS_RECIPIENT
              MAIL_SENDER        = LS_SENDER
              OUTPUT_OPTIONS     = LS_COMPOSER_PARAM
              USER_SETTINGS      = 'X'
              IS_BIL_INVOICE     = LS_BIL_INVOICE
              IS_NAST            = NAST
              IS_REPEAT          = REPEAT
              OUT_TYPE           = V_OUTPUT
              TEMP_LST           = TEMP_LST
              TEMP_CST           = TEMP_CST
              TEMP_TELF1         = TEMP_TELF1
              TEMP_TELFX         = TEMP_TELFX
              TEMP_NAME1         = TEMP_NAME1
              TEMP_STRAS         = TEMP_STRAS
              TEMP_ADRNR         = TEMP_ADRNR
              TMP_VAT            = TMP_LST
              TMP_CST            = TMP_CST
              TEMP_WERKS         = TEMP_WERKS
              VAT_DATE           = VAT_DATE
              CST_DATE           = CST_DATE
              VAT                = VAT
              I_ADDRESS          = I_ADDRESS
              FLAG_HDR           = FLAG_HDR
              I_ADDR             = I_ADDR
              TMP_CST_DATE       = TMP_CST_DATE                 " mod-004
              TMP_LST_DATE       = TMP_LST_DATE                 " mod-004
            IMPORTING
              JOB_OUTPUT_INFO    = W_RETURN
            TABLES
              IT_KONV            = TEMP_KONV
              IT_VBRP            = IT_VBRP_FORM
            EXCEPTIONS
              FORMATTING_ERROR   = 1
              INTERNAL_ERROR     = 2
              SEND_ERROR         = 3
              USER_CANCELED      = 4
              OTHERS             = 5.
          IF SY-SUBRC <> 0.
      error handling
            CF_RETCODE = SY-SUBRC.
            PERFORM PROTOCOL_UPDATE.
    get SmartForm protocoll and store it in the NAST protocoll
            PERFORM ADD_SMFRM_PROT.
          ENDIF.
        ENDDO.
        LS_COMPOSER_PARAM-TDCOPIES = NAST_ANZAL.
        IF NOT NAST_TDARMOD IS INITIAL.
          NAST-TDARMOD = NAST_TDARMOD.
          CLEAR NAST_TDARMOD.
        ENDIF.
      ENDIF.
    ************************add for pdf**********************************
      I_OTF[] = W_RETURN-OTFDATA[].
      DATA : ITAB2 LIKE DOCS OCCURS 0,
              SIZE TYPE I.
      BIL_NUM = LS_BIL_INVOICE-HD_GEN-BIL_NUMBER.
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
       EXPORTING
         USE_OTF_MC_CMD               = 'X'
      ARCHIVE_INDEX                =
       IMPORTING
         BIN_FILESIZE                  = SIZE
        TABLES
          OTF                          = I_OTF
          DOCTAB_ARCHIVE               = ITAB2
          LINES                        = I_TLINE
       EXCEPTIONS
         ERR_CONV_NOT_POSSIBLE        = 1
         ERR_OTF_MC_NOENDMARKER       = 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.
    ****************download************************
      CONCATENATE 'C:\' BIL_NUM '.PDF' INTO FILENAME.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
      BIN_FILESIZE                    =
          FILENAME                        = FILENAME
          FILETYPE                        = 'BIN'
    IMPORTING
      FILELENGTH                      =
        TABLES
          DATA_TAB                        = I_TLINE
      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.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      IF SY-SUBRC = 0.
      message  i000.
      ENDIF.
    is this enough????
    Thanking you..,

  • Smartform sending pdf file as a mail

    i have done a mailing a pdf as mail i am able to down load a file in to the systam which is perfect but i am not able to send the mail can any one tell me whats the problem in this and guide me if there is any problem.
    CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
    EXPORTING
       WINDOW_TITLE            = 'Save as'
       DEFAULT_EXTENSION       = 'PDF'
       DEFAULT_FILE_NAME       = W_FNAME
      WITH_ENCODING           =
      FILE_FILTER             =
      INITIAL_DIRECTORY       =
      DEFAULT_ENCODING        =
    IMPORTING
       FILENAME                = W_FNAME
      PATH                    =
      FULLPATH                =
       USER_ACTION             = v_action
      FILE_ENCODING           =
    if v_action = '9'.
      exit.
    endif.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = W_BIN_SIZE
    FILENAME = W_FNAME
    FILETYPE = 'BIN' "'ASC'
    IMPORTING
    FILELENGTH = V_FILESIZE
    TABLES
    DATA_TAB = T_PDF_TAB
    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 'File not downloaded succesfully' TYPE 'E'.
    ELSE.
    CONCATENATE 'File : ' W_FNAME 'downloaded succesfully ' INTO MSG1.
    MESSAGE MSG1 TYPE 'I'.
    ENDIF.
    data : GD_DOC_DATA type SODOCCHGI1.
    data : LT_MAILPACK type standard table of SOPCKLSTI1.
    data : LA_MAILPACK type SOPCKLSTI1.
    data : LT_OBJTXT   type STANDARD TABLE OF SOMLRECI1 WITH HEADER LINE.
    DATA:LF_LINES TYPE I.
    DATA LV_OUTPUT TYPE SDOKCNTBINS WITH HEADER LINE.
    *DATA LV_OUTPUT TYPE standard table of SOLISTI1 .
    data pdf_file type XSTRING.
    DATA: IT_RECEIVERS TYPE STANDARD TABLE OF SOMLRECI1 WITH HEADER
    LINE.
    data iv_mailid type AD_SMTPADR.
    move W_FNAME to pdf_file.
    Data : w_buffer TYPE string.
    *data : i_record LIKE solisti1 OCCURS 0
    *WITH HEADER LINE.
    data : i_record LIKE solisti1 OCCURS 0
    WITH HEADER LINE.
    data : s_record LIKE solisti1 OCCURS 0
    WITH HEADER LINE.
         CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
           EXPORTING
             BUFFER     = pdf_file "PDF file from function module
           TABLES
             BINARY_TAB = LV_OUTPUT.
         DESCRIBE TABLE LV_OUTPUT LINES LF_LINES.
    loop at T_PDF_TAB.
    *TRANSLATE T_PDF_TAB USING '~'.
    CONCATENATE w_buffer T_PDF_TAB INTO w_buffer.
      endloop.
    *TRANSLATE w_buffer USING '~ '.
    DO.
    i_record = w_buffer.
    APPEND i_record.
    SHIFT w_buffer LEFT BY 255 PLACES.
    IF w_buffer IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    s_record[] = i_record[].
    *DESCRIBE TABLE T_PDF_TAB LINES LF_LINES.
    select single SMTP_ADDR from ADR6 into iv_mailid where ADDRNUMBER =
    IV_ADDNR_VENDOR.
         DATA:LT_OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
          MOVE 'Email sent to you from SAP' TO LT_OBJTXT.
          APPEND LT_OBJTXT.
          GD_DOC_DATA-OBJ_DESCR = 'PDF'.
          GD_DOC_DATA-OBJ_NAME  = 'PDFMail'.
          GD_DOC_DATA-OBJ_DESCR = 'PDF'.
          GD_DOC_DATA-SENSITIVTY = 'O'.
       GD_DOC_DATA-EXPIRY_DAT = SY-DATUM + 15.
          GD_DOC_DATA-DOC_SIZE = STRLEN( LT_OBJTXT ).
          CLEAR  LA_MAILPACK.
          LA_MAILPACK-HEAD_START = 1.
          LA_MAILPACK-HEAD_NUM = 0.
          LA_MAILPACK-BODY_START = 1.
          LA_MAILPACK-BODY_NUM = 1.
       LA_MAILPACK-DOC_TYPE = 'RAW'.
          LA_MAILPACK-DOC_SIZE = STRLEN( LT_OBJTXT ).
          APPEND  LA_MAILPACK TO  LT_MAILPACK.
          CLEAR LA_MAILPACK.
          LA_MAILPACK-TRANSF_BIN = ''.
          LA_MAILPACK-HEAD_START = 1.
          LA_MAILPACK-HEAD_NUM = 1.
          LA_MAILPACK-BODY_START = 1.
          LA_MAILPACK-DOC_TYPE = 'PDF'.
          LA_MAILPACK-BODY_NUM = LF_LINES.
          LA_MAILPACK-DOC_SIZE = LF_LINES * 255.
          LA_MAILPACK-OBJ_DESCR = 'Open'.
          LA_MAILPACK-OBJ_NAME = 'MAIL'.
          APPEND LA_MAILPACK TO LT_MAILPACK.
          IT_RECEIVERS-RECEIVER = iv_mailid.
          IT_RECEIVERS-REC_TYPE = 'U'.
          APPEND IT_RECEIVERS.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA                    = GD_DOC_DATA
       PUT_IN_OUTBOX                    = 'X'
       COMMIT_WORK                      = 'X'
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
      TABLES
        PACKING_LIST                     = LT_MAILPACK
      OBJECT_HEADER                    =
       CONTENTS_BIN                     = s_record
       CONTENTS_TXT                     = LT_OBJTXT
      CONTENTS_HEX                     = LV_OUTPUT
      CONTENTS_HEX                     = s_record
      OBJECT_PARA                      =
      OBJECT_PARB                      =
        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.
    MESSAGE 'Mail was not sent' type 'E'.
    else.
      MESSAGE 'Mail was sent Succesfully' type 'S'.
    ENDIF.
    thanks and regards ,
    venkat.

    refer below program
    c_par-preview = space.
        c_par-getotf = 'X'.
        out_opt-tddest = 'EPSON-COMMON'.
        CALL FUNCTION fm_name
          EXPORTING
            control_parameters = c_par
            output_options     = out_opt
            user_settings      = space
            vbeln              = it_vbeln-vbeln
            pdf                = r2
            rbiclear           = c3
          IMPORTING
            job_output_info    = opt
            einv               = einv.
        i_otf = opt-otfdata.
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format        = 'PDF'
            max_linewidth = 132
          IMPORTING
            bin_filesize  = v_len_in
          TABLES
            otf           = i_otf
            lines         = i_tline.
       IF lv_check EQ 1.
         CALL METHOD cl_gui_frontend_services=>file_save_dialog
           CHANGING
             filename = file_name
             path     = file_path
             fullpath = full_path.
       ENDIF.
        CLEAR full_path.
        move wa_exnum to lv_exnum.
        shift lv_exnum left deleting leading '0'.
        move 'C:\SAPWORKDIR\' to file_path.
        CONCATENATE file_path 'Invoice_E' lv_exnum '.PDF' INTO full_path.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            bin_filesize = v_len_in
            filename     = full_path
            filetype     = 'BIN'
          IMPORTING
            filelength   = file_size
          TABLES
            data_tab     = i_tline.
    For mailing
        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.
    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.

  • Urgent: Error while uploading into pdf file

    Hi ,
    I got a requirement that converting smartform into pdf file and sending into application server, And uploading the that pdf file into presentation server once a day am geting error when uploading into pdf format from application server .
    Error : There was an  error while tryinging to parse an image.
    Please help me out its urgent.
    Thanks in advance
    Regards
    krishna
    Edited by: krishna rao on Feb 13, 2008 12:05 PM

    U can use this code
    Reward if useful
    REPORT  ZMN_PDF_UPLOAD.
    data: begin of itab occurs 0,
    field(256),
    end of itab.
    data: dsn(100) value '\usr\sap\DEV\DVEBMGS00\work\testpdf',
    length like sy-tabix,
    lengthn like sy-tabix.
    call function 'GUI_UPLOAD'
    exporting
    filename = 'c:\temp\test.pdf'
    filetype = 'BIN'
    importing
    filelength = length
    tables
    data_tab = itab.
    open dataset dsn for output in binary mode.
    loop at itab.
    transfer itab-field to dsn.
    endloop.
    close dataset dsn.
    clear itab.
    refresh itab.
    *To crosscheck if it went well
    open dataset dsn for input in binary mode.
    do.
    read dataset dsn into itab-field.
    if sy-subrc = 0.
    append itab.
    else.
    exit.
    endif.
    enddo.
    call function 'GUI_DOWNLOAD'
    exporting
    filename = 'c:\temp\testn.pdf'
    filetype = 'BIN'
    bin_filesize = length
    importing
    filelength = lengthn
    tables
    data_tab = itab.
    *Or
    *Use the TCode
    *CG3Z or CG3Y
    *for downloading to Application Server.

  • Regarding the uploading the pdf file to the application server

    hi,
    iam getting this error while uploading the pdf file to the applicatioin server.
    "There was an error while trying to parse an image"
    to convert smartform into PDF file we ll use convert_otf FM.
    If see that FM data ll be stored in it_tline structure ok.
    For sending to application server we ll use
    OPEN DATASET p_arch for OUTPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.
      LOOP AT it_tline.
      TRANSFER it_tline to p_arch.
      ENDLOOP.
      CLOSE DATASET p_arch.
    Ok
    For getting data from internal table we ll use
    OPEN DATASET p_arch FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS
    do.
      READ DATASET p_arch INTO it_tline.
      if sy-subrc = 0.
        APPEND it_tline.
        ELSE .
          exit.
          endif.
      enddo.
    CLOSE DATASET p_arch.
          LOOP AT it_tline.
        TRANSLATE it_tline USING '~'.
        CONCATENATE wa_buffer it_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 = 'COMMERCIAL INVOICE'.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
      READ TABLE i_objtxt INDEX v_lines_txt.
      wa_doc_chng-obj_name   = 'COMMERCIAL INVOICE'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr  = 'COMMERCIAL INVOICE'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size   = v_lines_txt * 255.
      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.
      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  = 'COMMERCIAL INVOICE'.
      i_objpack-obj_descr = 'COMMERCIAL INVOICE'.
      APPEND i_objpack.
    BREAK-POINT.
      IF it_adr6[] IS NOT INITIAL.
        LOOP AT it_adr6 INTO wa_adr6.
          CLEAR i_reclist.
          i_reclist-receiver = wa_adr6-smtp_addr.
          i_reclist-rec_type = 'U'.
          i_reclist-com_type = 'INT'.
          APPEND i_reclist.
        ENDLOOP.
        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.
      ENDIF.
    The above error I am getting.
    Please give your suggestions
    Thanks in advance

    U can use this code
    Reward if useful
    REPORT  ZMN_PDF_UPLOAD.
    data: begin of itab occurs 0,
    field(256),
    end of itab.
    data: dsn(100) value '\usr\sap\DEV\DVEBMGS00\work\testpdf',
    length like sy-tabix,
    lengthn like sy-tabix.
    call function 'GUI_UPLOAD'
    exporting
    filename = 'c:\temp\test.pdf'
    filetype = 'BIN'
    importing
    filelength = length
    tables
    data_tab = itab.
    open dataset dsn for output in binary mode.
    loop at itab.
    transfer itab-field to dsn.
    endloop.
    close dataset dsn.
    clear itab.
    refresh itab.
    *To crosscheck if it went well
    open dataset dsn for input in binary mode.
    do.
    read dataset dsn into itab-field.
    if sy-subrc = 0.
    append itab.
    else.
    exit.
    endif.
    enddo.
    call function 'GUI_DOWNLOAD'
    exporting
    filename = 'c:\temp\testn.pdf'
    filetype = 'BIN'
    bin_filesize = length
    importing
    filelength = lengthn
    tables
    data_tab = itab.
    *Or
    *Use the TCode
    *CG3Z or CG3Y
    *for downloading to Application Server.

  • Download smartform to pdf

    in script it is possible to download in pdf format without new spool
    request.is it possible in smartforms if possible please help..

    Go through the link given below :
    SMARTFORM to PDF File format
    Smartform to PDF format

  • PDF File Format

    hi,
         When i tried to export a smartform into PDF file format,it successfully works.But the customer wants that PDF document Digitally signed.Is it possible to do in SAP itself.
    With Regards,
    Kumaresh

    Hi,
    Please go through these documents :
    http://www.adobe.com/enterprise/pdfs/sap_adobe_whitepaper.pdf
    http://help.sap.com/saphelp_nw04s/helpdata/en/37/504b8cbc2848a494facfdc09a359b1/frameset.htm
    Regards,
    Narayani

  • PDF file format error - Smartform to e-mail attachment

    Hi All,
    I am trying to convert smartform output to PDF and send as an e-mail/fax attachment. Every thing works fine except when I try to open attachment in e-mail it says ‘Not supported file type or File Damage –> May be not correctly decoded’. I have attached my code for reference, any hints much appreciated. Thanks in advance.
    Regards,
    Tim
    data: t_otf    type  table of itcoo,
            t_tline  type  table of tline,
            g_filesize  TYPE I.
    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_objbin LIKE SOLIX OCCURS 0 WITH HEADER LINE,
      i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
      w_objhead TYPE soli_tab,
      w_ctrlop TYPE ssfctrlop,
      w_compop TYPE ssfcompop,
      w_return TYPE ssfcrescl,
      w_doc_chng typE sodocchgi1,
      w_data TYPE sodocchgi1,
      w_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.
    <b> CALL FUNCTION FM_NAME</b>. .......
      t_otf[] = wa_outinfo-otfdata[].
      CALL FUNCTION <b>'CONVERT_OTF'</b>
                    EXPORTING
                      FORMAT                      = 'PDF'
                     MAX_LINEWIDTH               = 132
                  ARCHIVE_INDEX               = ' '
                  COPYNUMBER                  = 0
                  ASCII_BIDI_VIS2LOG          = ' '
                  PDF_DELETE_OTFTAB           = ' '
                    IMPORTING
                      BIN_FILESIZE                = g_filesize
                  BIN_FILE                    = g_binfile
                    TABLES
                      OTF                         = t_otf
                      LINES                       = i_tline
                    EXCEPTIONS
                      ERR_MAX_LINEWIDTH           = 1
                      ERR_FORMAT                  = 2
                      ERR_CONV_NOT_POSSIBLE       = 3
                      ERR_BAD_OTF                 = 4
                      OTHERS                      = 5.
    convert PDF 132 to 255
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Convert PDF from 132 to 255.
      LOOP AT i_tline.
    Replacing space by ~
        TRANSLATE i_tline USING ' ~'.
        CONCATENATE w_buffer i_tline INTO w_buffer.
      ENDLOOP.
    Replacing ~ by space
      TRANSLATE w_buffer USING '~ '.
      DO.
        i_record = w_buffer.
    Appending 255 characters as a record
        APPEND i_record.
        SHIFT w_buffer LEFT BY 255 PLACES.
        IF w_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
      Refresh: i_reclist,
      i_objtxt,
      i_objbin,
      i_objpack.
      clear w_objhead.
    Object with PDF.
      loop at i_record.
       i_objbin-line = i_record-line.
       append i_objbin.
      endloop.
    i_objbin[] = i_record[].
      DESCRIBE TABLE i_objbin LINES v_lines_bin.
    Object with main text of the mail.
      i_objtxt = 'Find attached the output of the smart form.'.
      APPEND i_objtxt.
      i_objtxt = 'Regards,'.
      APPEND i_objtxt.
      i_objtxt = 'test'.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    Document information.
      w_doc_chng-obj_name = 'Smartform'.
      w_doc_chng-expiry_dat = sy-datum + 10.
      w_doc_chng-obj_descr = 'Smart form output'.
      w_doc_chng-sensitivty = 'F'. "Functional object
      w_doc_chng-doc_size = v_lines_txt * 255.
    Pack to main body as RAW.
    Obj. to be transported not in binary form
      CLEAR i_objpack-transf_bin.
    *Start line of object header in transport packet
      i_objpack-head_start = 1.
    Number of lines of an object header in object packet
      i_objpack-head_num = 0.
    Start line of object contents in an object packet
      i_objpack-body_start = 1.
    Number of lines of the object contents in an object packet
      i_objpack-body_num = v_lines_txt.
    Code for document class
      i_objpack-doc_type = 'RAW'.
      APPEND i_objpack.
    Packing as PDF.
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'Smartform'.
      CONCATENATE 'Smartform_output' '.pdf'
      INTO i_objpack-obj_descr.
      i_objpack-doc_size = v_lines_bin * 255.
      APPEND i_objpack.
    Document information.
      CLEAR i_reclist.
    e-mail receivers.
      i_reclist-receiver = '[email protected]'.
      i_reclist-express = 'X'.
      i_reclist-rec_type = 'U'. "Internet address
      APPEND i_reclist.
    Sending mail.
      CALL FUNCTION <b>'SO_NEW_DOCUMENT_ATT_SEND_API1'</b>
        EXPORTING
          document_data              = w_doc_chng
          put_in_outbox              = 'X'
          COMMIT_WORK                = 'X'
        TABLES
          packing_list               = i_objpack
          object_header              = w_objhead
          contents_hex               = 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.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

    Hi Tim,
    I used this to send a smartform in pdf format by email.
    Hope it helps
    Cristian
    REPORT  y_cb_test_051                           .
    DATA DECLARATION
    TYPE-POOLS: meein.
    TABLES: toa_dara,
            nast,
            tnapr,
            arc_params.
    DATA: ent_retco  TYPE sy-subrc,
          ent_screen TYPE c,
          l_xkomk LIKE TABLE OF komk WITH HEADER LINE,
          xscreen.                         "Kz. Probeausgabe
    DATA: i_texto_cuerpo LIKE  solisti1 OCCURS 0 WITH HEADER LINE.
    SELECT OPTIONS / PARAMETERS
    PARAMETERS:
    p_kappl  LIKE nast-kappl OBLIGATORY DEFAULT 'EF',
    p_objky  LIKE nast-objky OBLIGATORY DEFAULT '0010001125',
    p_kschl  LIKE nast-kschl OBLIGATORY DEFAULT 'NEU',
    p_spras  LIKE nast-spras OBLIGATORY DEFAULT  'EN',
    p_parnr  LIKE nast-parnr OBLIGATORY DEFAULT  '50009123',
    p_parvw  LIKE nast-parvw OBLIGATORY DEFAULT  'BA',
    p_erdat  LIKE nast-erdat OBLIGATORY DEFAULT '20050908',
    p_eruhr  LIKE nast-eruhr OBLIGATORY DEFAULT '130105',
    p_aende  LIKE nast-aende DEFAULT 'X',
    p_nacha  LIKE nast-nacha DEFAULT '1',
    p_ndialo TYPE tdsfflag   DEFAULT ' ',
    p_telfx  LIKE nast-telfx DEFAULT '1-720-220-4274',
    p_tland   LIKE nast-tland DEFAULT 'US',
    p_sform TYPE tdsfname DEFAULT 'ZMMNABPR3PFMMPO_L3' OBLIGATORY.
    *PDF TABLES
    DATA: tb_pdf LIKE tline OCCURS 0.
    DATA: tb_pdf255 TYPE so_text255 OCCURS 0.
    MAIN PROCESSING SECTION
    START-OF-SELECTION.
    SELECT SINGLE *
    INTO nast
    FROM nast
    WHERE kappl = p_kappl
    AND   objky = p_objky
    AND   kschl = p_kschl
    AND   spras = p_spras
    AND   parnr = p_parnr
    AND   parvw = p_parvw
    AND   erdat = p_erdat
    AND   eruhr = p_eruhr.
    IF sy-subrc <> 0.
      MESSAGE s000(00) WITH 'Record in NAST not found.'.
      nast-kappl = p_kappl.
      nast-objky = p_objky.
      nast-kschl = p_kschl.
      nast-spras = p_spras.
      nast-parnr = p_parnr.
      nast-parvw = p_parvw.
      nast-erdat = p_erdat.
      nast-eruhr = p_eruhr.
      nast-nacha = p_nacha.
      nast-telfx = p_telfx.
      nast-tland = p_tland.
    ENDIF.
      nast-aende  = p_aende.
      tnapr-sform = p_sform.
      PERFORM entry_neu
                      USING
                                ent_retco
                                ent_screen.
    FORMS
    *&      Form  entry_neu
          text
         -->ENT_RETCO  text
         -->ENT_SCREEN text
    FORM entry_neu
                    USING
                              ent_retco
                              ent_screen.
      DATA: l_druvo LIKE t166k-druvo,
            l_nast  LIKE nast,
            l_from_memory,
            l_doc   TYPE meein_purchase_doc_print.
      DATA: ls_print_data_to_read TYPE lbbil_print_data_to_read.
      DATA: ls_bil_invoice TYPE lbbil_invoice.
      DATA: lf_fm_name            TYPE rs38l_fnam.
      DATA: ls_control_param      TYPE ssfctrlop.
      DATA: ls_composer_param     TYPE ssfcompop.
      DATA: ls_recipient          TYPE swotobjid.
      DATA: ls_sender             TYPE swotobjid.
      DATA: lf_formname           TYPE tdsfname.
      DATA: ls_addr_key           LIKE addr_key.
    xscreen = ent_screen.
    clear ent_retco.
      IF nast-aende EQ space.
        l_druvo = '1'.
      ELSE.
        l_druvo = '2'.
      ENDIF.
      CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
        EXPORTING
          ix_nast        = nast
          ix_screen      = ent_screen
        IMPORTING
          ex_retco       = ent_retco
          ex_nast        = l_nast
          doc            = l_doc
        CHANGING
          cx_druvo       = l_druvo
          cx_from_memory = l_from_memory.
      CHECK ent_retco EQ 0.
      IF nast-adrnr IS INITIAL.
        PERFORM get_addr_key
                             CHANGING ls_addr_key.
      ELSE.
        ls_addr_key = nast-adrnr.
      ENDIF.
    *Set the print Parameters
      PERFORM set_print_param USING      ls_addr_key
                                CHANGING ls_control_param
                                         ls_composer_param
                                         ls_recipient
                                         ls_sender
                                         ent_retco.
    *Get the Smart Form name.
      IF NOT tnapr-sform IS INITIAL.
        lf_formname = tnapr-sform.
      ELSE.
        lf_formname = tnapr-fonam.
      ENDIF.
    determine smartform function module for invoice
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = lf_formname
        IMPORTING
          fm_name            = lf_fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
    error handling
        ent_retco = sy-subrc.
      perform protocol_update_i.
      ENDIF.
      ls_control_param-getotf = 'X'.
      DATA: l_document_output_info TYPE  ssfcrespd,
            l_job_output_info      TYPE  ssfcrescl,
            l_job_output_options   TYPE  ssfcresop.
      CALL FUNCTION lf_fm_name
           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      = ' '
                zxekko             = l_doc-xekko
                zxpekko            = l_doc-xpekko
               zxaend             = l_doc-xaend
          IMPORTING
                document_output_info = l_document_output_info
                job_output_info      = l_job_output_info
                job_output_options   = l_job_output_options
          TABLES
                l_xekpo            = l_doc-xekpo[]
                l_xekpa            = l_doc-xekpa[]
                l_xpekpo           = l_doc-xpekpo[]
                l_xeket            = l_doc-xeket[]
                l_xtkomv           = l_doc-xtkomv[]
                l_xekkn            = l_doc-xekkn[]
                l_xekek            = l_doc-xekek[]
                l_xaend            = l_doc-xaend[]
                l_xkomk            = l_xkomk
           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.
        BREAK-POINT.
      ENDIF.
    Converts OTF to PDF
      DATA: v_len_in TYPE i.
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          bin_filesize          = v_len_in
        TABLES
          otf                   = l_job_output_info-otfdata
          lines                 = tb_pdf
        EXCEPTIONS
          err_max_linewidth     = 0
          err_format            = 1
          err_conv_not_possible = 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.
    Change the PDF format from 132 to 255.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
       EXPORTING
       line_width_src                    =
       line_width_dst                    =
         transfer_bin                      = 'X'
        TABLES
          content_in                        = tb_pdf
          content_out                       = tb_pdf255
       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.
      DATA: lw_subject TYPE so_obj_des.
      DATA: lwa_body  TYPE solisti1.
      DATA: ltb_body  TYPE TABLE OF solisti1.
      DATA: lw_filename TYPE char100.
      DATA: ltb_recipients TYPE TABLE OF somlreci1.
      DATA: lwa_recipients TYPE somlreci1.
      lw_subject = 'This is the email subject'.
      lwa_body-line = 'This is the email body - Line1'.
      APPEND lwa_body TO ltb_body.
      lwa_body-line = 'This is the email body - Line2'.
      APPEND lwa_body TO ltb_body.
      lwa_body-line = 'This is the email body - Line3'.
      APPEND lwa_body TO ltb_body.
      lwa_body-line = 'This is the email body - Line4'.
      APPEND lwa_body TO ltb_body.
      lw_filename = 'Contract'.
    *RECIPIENTS
      lwa_recipients-rec_type = 'U'.
      lwa_recipients-express  = 'X'.
      lwa_recipients-receiver = sy-uname.
      lwa_recipients-copy     = ''.
      APPEND lwa_recipients TO ltb_recipients.
    RECIPIENTS
      lwa_recipients-rec_type = 'U'.
      lwa_recipients-express  = 'X'.
      lwa_recipients-receiver = '[email protected]'.
      lwa_recipients-copy     = ''.
      APPEND lwa_recipients TO ltb_recipients.
    RECIPIENTS
      lwa_recipients-rec_type = 'U'.
      lwa_recipients-express  = 'X'.
      lwa_recipients-receiver = '[email protected]'.
      lwa_recipients-copy     = ''.
      APPEND lwa_recipients TO ltb_recipients.
    Sends the PDF by email.
      PERFORM f_send_pdf_by_email
                          TABLES
                                 tb_pdf255
                                 ltb_body
                                 ltb_recipients
                          USING
                                 lw_subject
                                 lw_filename.
    ENDFORM.                    "entry_neu
    *&      Form  ZCA_MAIL_BIN
          text
    FORM f_send_pdf_by_email
                        TABLES
                                ptb_pdf255      STRUCTURE solisti1
                                ptb_body        STRUCTURE solisti1
                                ptb_recipients  STRUCTURE somlreci1
                        USING
                                pw_subject TYPE so_obj_des
                                pw_filename TYPE char100.
    *-DATA DECLARATION----
    Variables y tablas internas.
      DATA: BEGIN OF ltb_objbin OCCURS 0.
              INCLUDE STRUCTURE solisti1.
      DATA: END OF ltb_objbin.
      DATA:  lwa_doc_chng LIKE sodocchgi1,
             lw_tab_lines LIKE sy-tabix,
             ltb_objtxt  LIKE solisti1 OCCURS 10 WITH HEADER LINE,
             ltb_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    *-MAIN PROCESSING SECTION----
      clear:   ltb_objbin, ltb_objtxt, ltb_objpack, lwa_doc_chng.
      refresh: ltb_objbin, ltb_objtxt, ltb_objpack.
    Control Data
      lwa_doc_chng-obj_name   = 'URGENT'.
      lwa_doc_chng-sensitivty = 'P'.
      lwa_doc_chng-no_change  = 'X'.
      lwa_doc_chng-priority   = '1'.
      lwa_doc_chng-obj_prio   = '1'.
      lwa_doc_chng-obj_langu  = sy-langu.
      lwa_doc_chng-no_change  = 'X'.
    Email Subject
      lwa_doc_chng-obj_descr = pw_subject.
    Email Body
      ltb_objtxt[] = ptb_body[].
      CLEAR ltb_objtxt.
      DESCRIBE TABLE ltb_objtxt LINES lw_tab_lines.
      IF lw_tab_lines GT 0.
        READ TABLE ltb_objtxt INDEX lw_tab_lines.
        lwa_doc_chng-doc_size =
            ( lw_tab_lines - 1 ) * 255 + STRLEN( ltb_objtxt ).
        CLEAR ltb_objpack-transf_bin.
        ltb_objpack-body_start = 1.
        ltb_objpack-body_num   = lw_tab_lines.
        ltb_objpack-doc_type   = 'RAW'.
        APPEND ltb_objpack.
      ENDIF.
    Attachment
    Move the binary attachment to other internal table.
      ltb_objbin[] = ptb_pdf255[].
      ltb_objpack-transf_bin = 'X'.
      ltb_objpack-body_start = 1.
    Get the number of lines in the Attachment (PDF FILE)
      DESCRIBE TABLE ltb_objbin LINES lw_tab_lines.
      ltb_objpack-body_num  = lw_tab_lines.
      ltb_objpack-doc_type  = 'PDF'.
      ltb_objpack-obj_descr = pw_filename.
      ltb_objpack-obj_name  = pw_filename.
      ltb_objpack-doc_size  = lw_tab_lines * 255.
      APPEND ltb_objpack.
    Call the function to send the PDF file by email
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = lwa_doc_chng
          put_in_outbox              = 'X'
        TABLES
          packing_list               = ltb_objpack
          contents_bin               = ltb_objbin
          contents_txt               = ltb_objtxt
          receivers                  = ptb_recipients
        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.
    ENDFORM.                    "ZCA_MAIL_BIN
    *&      Form  get_addr_key
          text
         -->P_CS_BIL_INVOICE_HD_ADR  text
         <--P_CS_ADDR_KEY  text
    FORM get_addr_key
                      CHANGING l_addr_key LIKE addr_key.
      DATA: l_lfa1 LIKE lfa1.
      SELECT SINGLE * FROM lfa1 INTO l_lfa1
      WHERE lifnr = nast-parnr.
      IF sy-subrc = 0.
        MOVE l_lfa1-adrnr TO l_addr_key.
      ENDIF.
    ENDFORM.                               " get_addr_key
    *&      Form  set_print_param
          text
         -->P_LS_ADDR_KEY  text
         <--P_LS_CONTROL_PARAM  text
         <--P_LS_COMPOSER_PARAM  text
         <--P_LS_RECIPIENT  text
         <--P_LS_SENDER  text
         <--P_CF_RETCODE  text
    FORM set_print_param USING    is_addr_key LIKE addr_key
                         CHANGING cs_control_param TYPE ssfctrlop
                                  cs_composer_param TYPE ssfcompop
                                  cs_recipient TYPE  swotobjid
                                  cs_sender TYPE  swotobjid
                                  cf_retcode TYPE sy-subrc.
      DATA: ls_itcpo     TYPE itcpo.
      DATA: lf_repid     TYPE sy-repid.
      DATA: lf_device    TYPE tddevice.
      DATA: ls_recipient TYPE swotobjid.
      DATA: ls_sender    TYPE swotobjid.
      lf_repid = sy-repid.
    CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
      CALL FUNCTION 'Z_MMNA_WFMC_PREPARE_SMART_FORM'
        EXPORTING
          pi_nast       = nast
          pi_addr_key   = is_addr_key
          pi_repid      = lf_repid
        IMPORTING
          pe_returncode = cf_retcode
          pe_itcpo      = ls_itcpo
          pe_device     = lf_device
          pe_recipient  = cs_recipient
          pe_sender     = cs_sender.
      IF cf_retcode = 0.
        MOVE-CORRESPONDING ls_itcpo TO cs_composer_param.
        cs_composer_param-tdimmed = ' '.
        cs_control_param-device      = lf_device.
        cs_control_param-no_dialog   = 'X'.
      cs_control_param-no_dialog   = p_ndialo.
        cs_control_param-preview     = xscreen.
        cs_control_param-getotf      = ls_itcpo-tdgetotf.
        cs_control_param-langu       = nast-spras.
      ENDIF.
    ENDFORM.                    "set_print_param
    Message was edited by: Cristian Berri

  • Need help in conversion of pdf file to itab and d details abt SMARTFORMS

    hello all
    how can i retrieve data from  pdf  file (instead of a txt format) to an internal table for an BDC application .
    anyone of you please help me in SMARTFORMS .

    Hi,
    If you want to conver report data in pdf format then you have to made some changes in programe and some setting done by abaper in the programe.
    Regards,
    Anil

  • In smartform word document convert into pdf file

    Hi Experts,
    I have issue on smartform, i have done two page smartform in preview its coming properly but
    when i give to print its not coming properly...output is not coming properly...so please sugest me
    even how to covert smartform word document into PDF file...im waiting for your replay. Thanks in
    Advance....
    Regards
    Ashwini

    Hi,
       I hope its printer problem check with u r basis, and for Smartform to PDF bewlow is my coding in which by using OTF data from Smartform it ill veiw in PDF.
    *& Report  ZSAP_PDF_VIEWER_DEMO_2
    REPORT  ZSAP_PDF_VIEWER.
    DATA: LT_PDF TYPE TABLE OF TLINE,
          LS_PDF LIKE LINE OF LT_PDF,
          LV_URL TYPE CHAR255,
          PDF_FSIZE TYPE  I,
          LV_CONTENT  TYPE XSTRING,
          LT_DATA TYPE STANDARD TABLE OF X255.
    DATA : L_JOB_OUTPUT_INFO TYPE SSFCRESCL.
    DATA : LS_CONTROL_PARAM  TYPE SSFCTRLOP.
    DATA : G_HTML_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
           G_HTML_CONTROL   TYPE REF TO CL_GUI_HTML_VIEWER.
    DATA: LO_DIALOG_CONTAINER TYPE REF TO CL_GUI_DIALOGBOX_CONTAINER.
    DATA: LO_DOCKING_CONTAINER TYPE REF TO CL_GUI_DOCKING_CONTAINER.
    DATA : P_VBELN TYPE  VBELN_VL.
    FIELD-SYMBOLS <FS_X> TYPE X.
    INITIALIZATION.
    LS_CONTROL_PARAM-GETOTF = 'X'.
    LS_CONTROL_PARAM-NO_DIALOG = 'X'.
    START-OF-SELECTION.
      CALL FUNCTION '/1BCDWB/SF00000034'
    EXPORTING
       ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
         CONTROL_PARAMETERS         = LS_CONTROL_PARAM
         P_VBELN                    = P_VBELN
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      OUTPUT_OPTIONS             =
      USER_SETTINGS              = 'X'
    IMPORTING
         DOCUMENT_OUTPUT_INFO  = L_DOCUMENT_OUTPUT_INFO
           JOB_OUTPUT_INFO       = L_JOB_OUTPUT_INFO
         JOB_OUTPUT_OPTIONS    = L_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.
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          FORMAT                = 'PDF'
        IMPORTING
          BIN_FILESIZE          = PDF_FSIZE
        TABLES
          OTF                   = L_JOB_OUTPUT_INFO-OTFDATA
          LINES                 = LT_PDF
        EXCEPTIONS
          ERR_MAX_LINEWIDTH     = 1
          ERR_FORMAT            = 2
          ERR_CONV_NOT_POSSIBLE = 3
          OTHERS                = 4.
    convert pdf to xstring string
      LOOP AT LT_PDF INTO LS_PDF.
        ASSIGN LS_PDF TO <FS_X> CASTING.
        CONCATENATE LV_CONTENT <FS_X> INTO LV_CONTENT IN BYTE MODE.
      ENDLOOP.
       CALL SCREEN 100.
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS '100'.
    **CREATE OBJECT LO_DOCKING_CONTAINER
    EXPORTING
       REPID     = SY-REPID
       DYNNR     = '100'"SY-DYNNR
       SIDE      = LO_DOCKING_CONTAINER->DOCK_AT_LEFT
       EXTENSION = 1200.
    CREATE OBJECT g_html_container
       EXPORTING
         container_name = 'HTML'.
    *CREATE OBJECT G_HTML_CONTROL
    EXPORTING
       PARENT = LO_DOCKING_CONTAINER.
      CREATE OBJECT G_HTML_CONTAINER
          EXPORTING
            CONTAINER_NAME = 'HTML'.
        CREATE OBJECT G_HTML_CONTROL
          EXPORTING
            PARENT = G_HTML_CONTAINER.
    Convert xstring to binary table to pass to the LOAD_DATA method
      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          BUFFER     = LV_CONTENT
        TABLES
          BINARY_TAB = LT_DATA.
    *application/
    Load the HTML
      CALL METHOD G_HTML_CONTROL->LOAD_DATA(
         EXPORTING
           TYPE         =  'application'
           SUBTYPE      =   'pdf' "
         IMPORTING
           ASSIGNED_URL         = LV_URL
         CHANGING
           DATA_TABLE           = LT_DATA
         EXCEPTIONS
           DP_INVALID_PARAMETER = 1
           DP_ERROR_GENERAL     = 2
           CNTL_ERROR           = 3
           OTHERS               = 4 ).
    CALL METHOD G_HTML_CONTROL->show_url
         EXPORTING  url        = lv_url
                   in_place    = 'X'
         EXCEPTIONS cntl_error = 1.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    MODULE user_command_0100 INPUT.
      DATA ok_code LIKE sy-ucomm.
      MOVE sy-ucomm TO ok_code.
      CASE ok_code.
        WHEN 'BACK' OR 'EXIT'.
         CALL METHOD LO_DOCKING_CONTAINER->free.
          CALL METHOD g_html_control->free.
          LEAVE TO SCREEN 0.
        WHEN OTHERS.
      ENDCASE.
    ENDMODULE.                 " USE

  • PDF-File in Smartform Window

    Hi Experts,
    is there any chance to include a pdf-file in a smartforms window? We don't want to attach a pdf-file as second page but need to show the content of a pdf-document in a window.
    Regards
    Nicola

    IMO, You have the option not to display the Smartform, but out of Smartform's OTF, you can convert it to PDF and display it in the custom screen...
    Hope this gives you an alternative.
    Thanks & regards,
    Hadiman

  • Problem with opening of PDF file, generated through smartform

    Recently, I have developed a new program where, the output of smartform will generate a PDF file, and then that PDF file will be mailed to concern persons,
    I have sucessuly done this in development server, and further testing I have transported this to Quality, in Quality i am able to generated a pdf file and able to send it to mail box of concern person, but when concern person tries to open the PDF file, it gives the error stating 'There was an error in opening the document, The file is damaged and could not be repaired'
    But same, I can able to read from development server.
    When I asked the Basis person, they are not aware about it, and , I have make it sure that, I have transported all request to Quality and nothing is pending in development.
    Can you please give me some idea to sort out this issue.
    Thanks in advance
    Rani

    Hi,
    I have same requirement.
    I need to cnvert smartform->pdf->send mail.
    The mail is send but the attachment is corrupted.
    Can you tell me what code you have written so its working in developement?

  • Smartform output to a PDF file, using it as an attachment to send the mail.

    Hi,
    I have a smartform output, which needs to be converted to PDF file and it should be mailed to a user as an attachment.
    Could anyone please tell me how this can be done.
    Thanks & Regards,
    Goutham.

    Hi ,
    Find the code below:
    Reward if helpful
    *&      Form  smart_form_process
          Make calls to required functions exporting GT_INTERFACE
    FORM smart_form_process CHANGING cf_retcode TYPE sy-subrc.
    Smart form data
    DATA:
      w_ssfname         TYPE tdsfname,             "Smart form name
      lf_fm_name        TYPE rs38l_fnam.           "Function module name
    Local data:
      DATA:
        ls_control_param  TYPE ssfctrlop,           "Control paramters
        ls_output_options TYPE ssfcompop.           "Output options
    Data for email smart form:
      DATA:
        lv_ip_mailaddr  TYPE so_name,               "Address of a Mail Recipient
        lv_ip_type_id   TYPE so_escape,             "Recipient type
        ls_recipient_id TYPE swotobjid,             "Structure for recvr obj ID
        ls_sender_id    TYPE swotobjid.             "Structure for sender obj id
    Constants:
      CONSTANTS:
        lc_ip_type_id TYPE so_escape VALUE 'U',               "For internet address.
        lc_smartform  TYPE tdsfname VALUE 'ZVSF_ASN_DELNOTE', "Smart form name
        lc_mail       TYPE tddevice VALUE 'MAIL'.             "Mail device
    Assign recipient
      lv_ip_mailaddr = gv_smtp_addr.                "CSAM email id
      lv_ip_type_id  = lc_ip_type_id.               "External address
    Create Mail title
      CONCATENATE text-001
                  nast-objky
             INTO ls_output_options-tdtitle.
    Create recipient object
      CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
        EXPORTING
          ip_mailaddr       = lv_ip_mailaddr
          ip_type_id        = lv_ip_type_id
        IMPORTING
          ep_recipient_id   = ls_recipient_id
        EXCEPTIONS
          invalid_recipient = 1
          OTHERS            = 2.
      IF sy-subrc <> 0.
      error handling
        cf_retcode = sy-subrc.
        PERFORM protocol_update.
      ENDIF.
    Get sender object id.
      CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
        EXPORTING
          ip_sender      = sy-uname
        IMPORTING
          ep_sender_id   = ls_sender_id
        EXCEPTIONS
          invalid_sender = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
      error handling
        cf_retcode = sy-subrc.
        PERFORM protocol_update.
      ENDIF.
    Assign the smart form name
      w_ssfname = lc_smartform.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = w_ssfname
        IMPORTING
          fm_name            = lf_fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
      error handling
        cf_retcode = sy-subrc.
        PERFORM protocol_update.
      ENDIF.
    For email output.
    Output options
      ls_output_options-BCS_COMMIT = 'X'.
        ls_control_param-device  = lc_mail.
      ENDIF.
    dynamically call Fm behind the Smart form
      CALL FUNCTION lf_fm_name
        EXPORTING
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient_id
          mail_sender        = ls_sender_id
          output_options     = ls_output_options
          user_settings      = ' '
        TABLES
          delivery           = gt_delivery
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      IF sy-subrc <> 0.
    Error handling
        cf_retcode = sy-subrc.
        PERFORM protocol_update.
      ENDIF.
    ENDFORM.                                        " smart_form_process

  • Create PDF Files with assigned a Password in SmartForm

    Hi,
    can i assign a password to pdf files that created with smartform?
    Thanks.

    Hi Chenna,
    Thank you very much first of all.
    i examined RSTXPDFT4 program but the FM that CONVERT_OTFSPOOLJOB_2_PDF has no parameter to assign a password to pdf.
    is there another program or FM to set a password to pdf files?
    thanks  again.

  • Tamper proof or noneditable PDF file creation from smartforms.

    Experts,
    We have requirement to create PDF file from smartforms that should be tamper proof.
    As we know there any many PDF to word convertors tools are in market.
    So PDF file should not be copied and not converted in word (should be tamper proof and non-editable).
    So do we have solution with in SAP only to achieve above requirement ?
    Please take your time answering, I'm not the kind of person that demands an answer really quickly, because that would be a bit rude.
    Message was edited by: Matthew Billingham - "hurry up" text replaced.

    Dear Jelena,
    True PDF is non-editable, but we can copy PDF content or even we can use tool to convert into word/docx format. for basically we are using information.
    Orignal source will never change.
    Let me explain you example.
    Let say i have converted invoice (smartform) into PDF and send to X person.
    Now X person can convert PDF into word format.
    X person did some changes in word and converted back to PDF (miss use of orignal data/PDF file).
    So requirement is that X person should not copy PDF content (Ctrl + C) and X person should be restrcited from converting to word.
    Acrobat/Adobe has this feature but this is external (need to use some third pary tool)
    Can this requirement accomplished within SAP only or include some Adobe package (class & method in SAP ).

Maybe you are looking for

  • HT1657 If you don't watch a rented movie do you get your money back

    If you don't watch a rented movie do you get your money back

  • Iphoto will not open after upgrade to Iphoto 11

    "In order to open iPhoto.app, you need to update to the latest version." What gives here? Anyone have a solution for this?

  • Iphoto library upgrade to work with iphoto?

    Iphoto won't launch. I tried upgrading it to the newest iphoto, but it still doest not work. I followed some advice where I click the control-alt key to rebuild but when I do that it gives me a dialogue saying "the photo library needs to be upgraded

  • ECDSA KEY PAIR

    Hi, does this output look ok? a lot of sequences, prefix and in the middle of the sequence repeat every generation. thanks (output and partial code below) pub: 3049301306072a8648ce3d020106082a8648ce3d030101033200046b4c88bb2a2b05ab1de3e91780a00849f2e2

  • DRG-50857 and ORA-12838 error while INDEXTYPE IS CTXSYS.CONTEXT

    Hi Experts, I've been encountering an issue while creating INDEX. If I execute the below script from SQLDEVELOPER line by line, then the index gets created but the weirdest thing is, if I executed the same as one sql file from SQLPLUS or SQLDEVELOPER