Skip to Content
avatar image
Former Member

to down load the print format to pdf and sent the data thru the mail

i have a report to which a smartform is attached to it.when executed that program the selection screen will contain customer codes within the range.

on giving the range of customers the screen displays some text for each and every customer given.

now we take a printout manually for each and every customer.

in order to avoid this, is there a way to download the printed text for each customer and send the mail automatically to each and every customer , so that paper printing can be stopped.

can anybody help me in this out.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 15, 2009 at 05:06 AM

    hi

    Try to use Function module -


    > 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    surya reddy

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 15, 2009 at 05:25 AM

    Hi,

    whatever u get the data from SMARTFORM is OTF data, so first u need to convert the OTF data to PDF using FM 'CONVERT_OTF'.

    Now, u ill get the PDF data in '132' line size format, now u need to convert it into '255' line size format using FM 'QCE1_CONVERT'.

    once u get the PDF data in 255 line size, use the FM 'SO_NEW_DOCUMENT_SEND_API1' to send it through e mail..

    try to use where used list for all the above FM to understand what parameters needs to be passed to FM's.

    Hope it helps!!

    Rgds,

    Pavan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 15, 2009 at 05:31 AM

    Hi Amalrose,

    I have developed one test program to do the way you requested. Its absolutely working. Please try to replicate this in your program.

    REPORT  ztest_smartform.
    DATA:it_nfal      TYPE nfal OCCURS 0 WITH HEADER LINE.
    DATA:fm_name      TYPE rs38l_fnam.
    DATA:ssfctrlop    TYPE ssfctrlop.
    DATA:ssfcompop    TYPE ssfcompop.
    DATA:it_otf_data  TYPE ssfcrescl.
    DATA:it_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE.
    DATA:bin_filesize TYPE i.
    DATA:it_pdfdata   TYPE TABLE OF tline.
    DATA:it_pdf       TYPE TABLE OF solisti1.
    *--------------------------------------------------------*
    "  Mail related declarations
    *--------------------------------------------------------*
    "Variables
    DATA :
         g_sent_to_all   TYPE sonv-flag,
         g_tab_lines     TYPE i.
    "Types
    TYPES:
         t_document_data  TYPE  sodocchgi1,
         t_packing_list   TYPE  sopcklsti1,
         t_attachment     TYPE  solisti1,
         t_body_msg       TYPE  solisti1,
         t_receivers      TYPE  somlreci1,
         t_pdf            TYPE  tline.
    "Workareas
    DATA :
         w_document_data  TYPE  t_document_data,
         w_packing_list   TYPE  t_packing_list,
         w_attachment     TYPE  t_attachment,
         w_body_msg       TYPE  t_body_msg,
         w_receivers      TYPE  t_receivers,
         w_pdf            TYPE  t_pdf.
    "Internal Tables
    DATA :
         i_document_data  TYPE STANDARD TABLE OF t_document_data,
         i_packing_list   TYPE STANDARD TABLE OF t_packing_list,
         i_attachment     TYPE STANDARD TABLE OF t_attachment,
         i_body_msg       TYPE STANDARD TABLE OF t_body_msg,
         i_receivers      TYPE STANDARD TABLE OF t_receivers,
         i_pdf            TYPE STANDARD TABLE OF t_pdf.
    PARAMETERS p_mail type char120.
    *START-OF-SELECTION.
    START-OF-SELECTION.
      "select data
      SELECT * FROM nfal INTO TABLE it_nfal UP TO 10 ROWS.
    
      ssfctrlop-no_dialog = 'X'.
      ssfctrlop-preview   = 'X'.
      ssfctrlop-getotf    = 'X'.
    
      ssfcompop-tddest = 'LP01'.
    

    <li>Continued

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      yes i will try definetly

      but will it work for all customers within the range

      that is , will the data be sent to all customers given in the range

  • avatar image
    Former Member
    Jul 15, 2009 at 05:31 AM

    <li>from above

    
      "Get Function module name for given smartform
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname = 'ZTEST_SMARTFORM'
        IMPORTING
          fm_name  = fm_name.
      "Call Smartform function module.
      CALL FUNCTION fm_name
        EXPORTING
          control_parameters = ssfctrlop
          output_options     = ssfcompop
        IMPORTING
          job_output_info    = it_otf_data
        TABLES
          it_nfal            = it_nfal.
    
    ************appending the otf data into the final table**********************
      it_otf_final[] = it_otf_data-otfdata[].
    
    ************ converting OTF data into pdf data**************************
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
        IMPORTING
          bin_filesize          = bin_filesize
    *     bin_file              =
        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.
    * To send data as email attachment, we need to have a table of SOLISTI1.
    * This table contains line size of 255 characters. Below function module
    * does the trick of changing the table from X character sized lines into
    * any given Y character sized lines.
      REFRESH it_pdf[].
    
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_dst              = '255'
        TABLES
          content_in                  = it_pdfdata[]
          content_out                 = it_pdf[]
        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.
      ELSE.
    

    <li>Continued

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 15, 2009 at 05:32 AM

    <li><strong>from above</strong>

    <pre>

    "Subject of the mail.

    w_document_data-obj_name = 'MAIL_TO_HEAD'.

    w_document_data-obj_descr = 'Regarding Mail Program by SAP ABAP'.

    "Body of the mail

    w_body_msg = 'This is body of mail msg.'.

    APPEND w_body_msg TO i_body_msg.

    CLEAR w_body_msg.

    "Write Packing List for Body

    DESCRIBE TABLE i_body_msg LINES g_tab_lines.

    w_packing_list-head_start = 1.

    w_packing_list-head_num = 0.

    w_packing_list-body_start = 1.

    w_packing_list-body_num = g_tab_lines.

    w_packing_list-doc_type = 'RAW'.

    APPEND w_packing_list TO i_packing_list.

    CLEAR w_packing_list.

    "Write Packing List for Attachment

    w_packing_list-transf_bin = 'X'.

    w_packing_list-head_start = 1.

    w_packing_list-head_num = 1.

    w_packing_list-body_start = 1.

    DESCRIBE TABLE it_pdf LINES w_packing_list-body_num.

    w_packing_list-doc_type = 'PDF'.

    w_packing_list-obj_descr = 'PDF Attachment'.

    w_packing_list-obj_name = 'PDF_ATTACHMENT'.

    w_packing_list-doc_size = w_packing_list-body_num * 255.

    APPEND w_packing_list TO i_packing_list.

    CLEAR w_packing_list.

    "Fill the document data and get size of attachment

    w_document_data-obj_langu = sy-langu.

    READ TABLE it_pdf INTO w_pdf INDEX g_tab_lines.

    w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_attachment ).

    "Receivers List.

    w_receivers-rec_type = 'U'."Internet address

    w_receivers-receiver = p_mail.

    w_receivers-com_type = 'INT'.

    w_receivers-notif_del = 'X'.

    w_receivers-notif_ndel = 'X'.

    APPEND w_receivers TO i_receivers .

    CLEAR:w_receivers.

    "Function module to send mail to Recipients

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    document_data = w_document_data

    put_in_outbox = 'X'

    commit_work = 'X'

    IMPORTING

    sent_to_all = g_sent_to_all

    TABLES

    packing_list = i_packing_list

    contents_bin = it_pdf

    contents_txt = i_body_msg

    receivers = i_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 i303(me) WITH 'Mail has been Successfully Sent.'.

    ENDIF.

    ENDIF.

    </pre>

    Thanks

    Venkat.O

    Add comment
    10|10000 characters needed characters exceeded