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

Similar Messages

  • 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

  • Sending SAP Script output as a PDF attachment through mail

    Dear Guru,
    I am using SAP 4.0B version, DATABASE Oracle 8i, OS is sun solaris 7.5.
    I want to send SAP script output as a
    PDF attachement through mail.Please suggest a solution.
    Regards,
    Rajesh

    Hi Rajesh,
    In your print program, while calling OPEN_FORM, pass options-TDGETOTF = 'X'. This is used for returning print output in OTF format.
    Then in CLOSE_FORM, get the table OTFDATA returned from the function module. for example
    DATA: OTF_DATA LIKE ITCOO OCCURS 0 WITH HEADER LINE.
        CALL FUNCTION 'CLOSE_FORM'
          IMPORTING
            RESULT  = RESULT
          TABLES
            OTFDATA = OTF_DATA.
    now you can convert this OTF data to PDF using function module CONVERT_OTF
    Then send this data as attachment to a mail using function module SO_NEW_DOCUMENT_ATT_SEND_API1
    Regards,
    Komal.

  • How to Send mail woth pdf attachment through workflow

    Hi SDNer's,
           I have a problem with pdf attachment through workflow. Please anybody help me to get solve my issue.

    Hi Suresh,
    I just tried this thing in my systtem and it is working... BADI is trigerred everytime there is a change in the PO... even when you release there is a change in the PO so this BADI will be triggerred....
    I suggest you should implement BADI in your dev system and place a break point in the POST method...
    After that create a PO and release it using ME29N... thereafter when you save the PO... this method will trigger and you will have access to PO details...
    PS: Remember this BADI wont work for transaction ME29...
    Regards
    Gautam

  • 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...

  • Send Invoice email with pdf attachement through DI?

    Hi all,
    is it possible to send an Invoice email with pdf attachement through DI as it can be done through UI?
    Best Regards,
    Vangelis

    Hi Vangelis,
    I Don't think that the DI API has that functionality (but I am not sure).
    However with .Net's System.Net.Mail it should be quite easy to build.
    Good luck,
    Johan

  • 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

  • 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.

  • 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

  • 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

  • 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.

  • 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

  • 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 .. !

  • Purchase Order Smartform as attachment in step mail through workflow

    Whenever user create a PO, mail should trigger in Microsoft Outlook, with the purchase order form as attachment.
    I am able to send mail to Microsoft Outlook whenever PO is created.
    But kindly advice how to attach PO smartform in th mail.
    Regards,
    Rahul.

    Hello,
    Please find below link. There is lot of stuff in google regarding this.
    smartform as work item attachment
    Re: PDF attachment in mail
    Regards.
    Edited by: vikram singh on Jan 30, 2012 2:00 PM

Maybe you are looking for