Skip to Content
0
Former Member
Jun 07, 2006 at 03:07 PM

How to Change PDF file name in the email

236 Views

Hi,

I am sending a Smartform data as a PDF attachment to an internet email ID.

Everything looks fine except the PDF file name.

Somehow it gets a name 'Filename.PDF', eventhough I have set the parameter obj_name = 'TESTFILE'.

For further clarification I am attaching the code snippet.

  gt_objpack-head_start = 1.

*-Create Message Body
*-  Title and Description
  gw_docdata-obj_name  = 'TESTOBJ'.
  gw_docdata-obj_descr = 'Testing Object '.

* Email Body must represent the OTF Data
* Email body
  gt_objtxt = 'SAP Document Attached'.
  APPEND gt_objtxt. CLEAR gt_objtxt.

*-Write Packing List (Main Body)
  DESCRIBE TABLE gt_objtxt LINES gw_tab_lines.
  READ     TABLE gt_objtxt INDEX gw_tab_lines.

  gw_docdata-doc_size = ( gw_tab_lines - 1 ) * 255 +
                        STRLEN( gt_objtxt ).

  CLEAR gt_objpack-transf_bin.
  gt_objpack-head_start = 1.
  gt_objpack-head_num   = 0.
  gt_objpack-body_start = 1.
  gt_objpack-body_num   = gw_tab_lines.
  gt_objpack-doc_type   = 'RAW'.
  APPEND gt_objpack. CLEAR gt_objpack.

*Create Message Attachment
*   Write Packing List (Attachment)
  gw_att_type = 'OTF'.
  gt_objbin[] = gw_job_output_info-otfdata[].
  DESCRIBE TABLE gt_objbin LINES gw_tab_lines.
  READ     TABLE gt_objbin INDEX gw_tab_lines.

  gt_objpack-doc_size = ( gw_tab_lines - 1 ) * 255 +
                        STRLEN( gt_objbin ).
  gt_objpack-transf_bin = 'X'.
  gt_objpack-head_start = 1.
  gt_objpack-head_num   = 0.
  gt_objpack-body_start = 1.
  gt_objpack-body_num   = gw_tab_lines.
  gt_objpack-doc_type   = gw_att_type.
 <u> gt_objpack-obj_name   = 'TESTFILE'.</u>
  gt_objpack-obj_descr  = lw_ob_desc.
  APPEND gt_objpack. CLEAR gt_objpack.

  gt_reclist-receiver = p_email.
  gt_reclist-rec_type = 'U'.
  APPEND gt_reclist. CLEAR gt_reclist.

* Send Message
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = gw_docdata
      put_in_outbox              = 'X'
      commit_work                = 'X'
    TABLES
      packing_list               = gt_objpack
      contents_bin               = gt_objbin
      contents_txt               = gt_objtxt
      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.

Have I missed something ?

Can you experts guide me on how to change my PDF filename.

Regards

RK