cancel
Showing results for 
Search instead for 
Did you mean: 

Can email text be included in an Action sending a Smartform but not in the

Former Member
0 Kudos
194

We can generate a Smartform and mail it using CRM actions but the user receiving the email gets the Smartform as a PDF attachment, Sales would like to have some text with urls included in the text of the email with the PDF as the attachment not having the text in the actual Smartform.

I.E.

Email Title > Requested Qoute 12345

Here is your requested quote, for sales or technical information visit

http://www.acme.com

Your account information is viewable at

http://www.acme.com:50700/B2B/init.do

"PDF attachment"

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Glenn,

The answer to your question is yes. This is how I accomplished the task.

First of all, the FM that gets generated from the SMARTFORM, does the conversion and creates the email. That's where the problem really is, because you can't get in there to add text to the body, even though SO_OBJECT_SEND, which is ultimately called has a place for the text.

Here's the altered form of CRM_ORDER_EXEC_SMART_FORM in class

CL_DOC_PROCESSING_CRM_ORDER. Hope this helps.

Cathy

Here's the print parms I used

**--


language of smart form--


    • determin here the language of the smart form

    • control_parameters = is_control_parameters.

control_parameters-langu = lv_language.

control_parameters-no_open = ' '. "SAP SF: General flag

control_parameters-no_close = ' '. "SAP SF: General flag

control_parameters-device = ' '. "Output device

control_parameters-no_dialog = 'X'. "suppress printer dialog

control_parameters-preview = ' '. "Print preview

control_parameters-getotf = 'X'. "Return OTF tab, no print

control_parameters-replangu1 = ' '. "Language key

control_parameters-replangu2 = ' '. "Language key

control_parameters-replangu3 = ' '. "Language key

control_parameters-startpage = ' '. "SAP SF: Object name

IF NOT gr_action_badi IS INITIAL.

CALL METHOD gr_action_badi->change_language_for_printing

EXPORTING

iv_ref_guid = lv_object_guid

iv_ref_kind = lv_object_kind

io_partner = io_partner

CHANGING

cs_control_parameters = control_parameters

cs_language_texts = lv_language

EXCEPTIONS

error_occurred = 1

OTHERS = 2.

ENDIF.

*----


  • fill prepare sender

CALL FUNCTION 'GET_RECIPIENT_DATA_PPF'

EXPORTING

is_recipient = is_mail_sender

IMPORTING

ep_addressstring = lv_send_email.

ls_send_mail = lv_send_email.

  • begin of note 690147

lv_sender_name = lv_send_email.

CALL METHOD cl_pd_po_processing_bbp=>process_bbp_check_sender

EXPORTING

iv_po_guid = lv_guid

CHANGING

cv_po_sender = lv_sender_name.

ls_send_mail = lv_sender_name.

  • end of note 690147

  • call function to process smart form

CALL FUNCTION function_name

EXPORTING

............ Export parms

IMPORTING

.............. Import parms

EXCEPTIONS

output_canceled = 1

parameter_error = 2

OTHERS = 3.

IF is_output_options-tdarmod <> 2.

1

  • OSS NOTE 895550 - fill in subject line

IF ls_orderadm_h-process_type = 'TA'. *} INSERT

ls_output_options-tdtitle = 'Quote'.

endif.

*} INSERT

IF ls_output_options-tdtitle IS INITIAL.

SELECT SINGLE caption INTO ls_output_options-tdtitle

FROM stxfadmt WHERE

formname = ip_smart_form.

ENDIF.

REPLACE '&' WITH ls_orderadm_h-object_id

INTO ls_output_options-tdtitle.

concatenate 'Quote' ls_orderadm_h-object_id

into ls_doc_chng-obj_descr SEPARATED BY space.

ls_objtxt-line = 'To approve this quote to become an order '.

APPEND ls_objtxt TO lt_objtxt.

CONCATENATE

'select this link:' ' <a href="mailto:emailname@yahoo.com?subject=Approved' ls_orderadm_h-object_id'">'

into ls_objtxt-line.

APPEND ls_objtxt TO lt_objtxt.

ls_objtxt-line = ' To Reject this quote '.

APPEND ls_objtxt TO lt_objtxt.

CONCATENATE

'select this link: ' ' <a href="mailto:emailname@yahoo.com?subject=Rejected' ls_orderadm_h-object_id'">'

into ls_objtxt-line.

APPEND ls_objtxt TO lt_objtxt.

DESCRIBE TABLE lt_objtxt LINES lv_txtlines.

READ TABLE lt_objtxt INTO ls_objtxt INDEX lv_txtlines.

  • * ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT

CLEAR ls_objpack-transf_bin.

ls_objpack-head_start = 1.

ls_objpack-head_num = 0.

ls_objpack-body_start = 1.

ls_objpack-body_num = lv_txtlines.

ls_objpack-doc_type = 'RAW'.

APPEND ls_objpack TO lt_objpack.

LOOP AT es_job_output_info-otfdata INTO ls_otfdata.

ls_off_tab-line = ls_otfdata.

APPEND ls_off_tab TO lt_off_tab.

ENDLOOP.

CONCATENATE 'Quotation' 'PDF'

INTO ls_objhead SEPARATED BY '.'.

APPEND ls_objhead TO lt_objhead.

  • Erstellen des Eintrags zur komprimierten Anlage

CLEAR ls_objpack-transf_bin.

ls_objpack-head_start = 1.

ls_objpack-head_num = 1.

ls_objpack-body_start = lv_txtlines + 1.

DESCRIBE TABLE lt_off_tab LINES lv_txtlines.

ls_objpack-body_num = lv_txtlines.

ls_objpack-doc_type = 'OTF'.

lv_head_c = '1'.

ls_objpack-obj_name = ls_objname.

ls_objpack-obj_descr = lv_object_id.

ls_objpack-doc_size = lv_filelength.

APPEND ls_objpack TO lt_objpack.

lv_head_i = 2.

lv_bodystart_i = 1.

DESCRIBE TABLE lt_objtxt LINES lv_txtlines.

READ TABLE lt_objtxt INTO ls_objtxt INDEX lv_txtlines.

ls_doc_chng-doc_size =

( lv_txtlines - 1 ) * 255 + STRLEN( ls_objtxt ).

READ TABLE lt_objpack INTO ls_objpack INDEX 1.

ls_objpack-body_num = lv_txtlines.

MODIFY lt_objpack FROM ls_objpack INDEX 1.

READ TABLE lt_objpack INTO ls_objpack INDEX 2.

ls_objpack-body_start = lv_txtlines + 1.

MODIFY lt_objpack FROM ls_objpack INDEX 2.

  • append lines of PO-OTF to texttable

APPEND LINES OF lt_off_tab TO lt_objtxt.

  • fill mailreclist

CALL FUNCTION 'GET_RECIPIENT_DATA_PPF'

EXPORTING

is_recipient = is_mail_recipient

IMPORTING

ep_addressstring = lv_rec_email.

ls_reclist-receiver = lv_rec_email.

ls_reclist-rec_type = 'U'.

APPEND ls_reclist TO lt_reclist.

  • send mail

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = ls_doc_chng

sender_address = ls_send_mail

sender_address_type = 'U'

TABLES

packing_list = lt_objpack

object_header = lt_objhead

contents_bin = lt_objbin

contents_txt = lt_objtxt

contents_hex = lt_objhex

receivers = lt_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.

IF is_output_options-tdarmod <> 1.

  • we have to archive by ourselves

CALL FUNCTION 'CONVERT_OTF_AND_ARCHIVE'

EXPORTING

arc_p = is_archive_parameters

arc_tab = ct_archive_index_tab

archive_copies = is_output_options-tdarccop

TABLES

otf = es_job_output_info-otfdata

EXCEPTIONS

error_archiv = 1

error_communicationtable = 2

error_connectiontable = 3

error_kernel = 4

error_parameter = 5

error_format = 6

OTHERS = 7.

IF sy-subrc = 0.

es_job_output_info-archdone = 'X'.

MESSAGE i006(bcs_medium) INTO dummy.

CALL METHOD cl_log_ppf=>add_message

EXPORTING

ip_problemclass = '4'

ip_handle = ip_application_log.

ELSE.

MESSAGE i002(bcs_medium) WITH sy-subrc INTO dummy.

CALL METHOD cl_log_ppf=>add_message

EXPORTING

ip_problemclass = '4'

ip_handle = ip_application_log.

ENDIF.

endif.

es_job_output_info-outputdone = sppf_true.

MESSAGE i029(bbp_out) WITH ls_reclist-receiver INTO dummy.

CALL METHOD cl_log_ppf=>add_message

EXPORTING

ip_problemclass = '4'

ip_handle = ip_application_log.

ELSE.

  • add error messages to processing protocol

CASE sy-subrc.

WHEN 1.

MESSAGE i038(bbp_out) INTO dummy.

WHEN 2.

MESSAGE i032(bbp_out) INTO dummy.

WHEN 3.

MESSAGE i033(bbp_out) INTO dummy.

WHEN 4.

MESSAGE i035(bbp_out) INTO dummy.

WHEN 5.

MESSAGE i035(bbp_out) INTO dummy.

WHEN 6.

MESSAGE i037(bbp_out) INTO dummy.

WHEN 7.

MESSAGE i031(bbp_out) INTO dummy.

WHEN 8.

MESSAGE i036(bbp_out) INTO dummy.

ENDCASE.

CALL METHOD cl_log_ppf=>add_message

EXPORTING

ip_problemclass = '1'

ip_handle = ip_application_log.

ENDIF.

ELSE.

CASE sy-subrc.

WHEN 1.

MESSAGE e016(sppf_media) INTO dummy.

WHEN 2.

MESSAGE e017(sppf_media) WITH function_name INTO dummy.

WHEN 3.

MESSAGE e018(sppf_media) WITH function_name INTO dummy.

ENDCASE.

CALL METHOD cl_log_ppf=>add_message

EXPORTING

ip_problemclass = '1'

ip_handle = ip_application_log.

ENDIF.

CALL FUNCTION 'SSF_READ_ERRORS'

IMPORTING

errortab = et_error_tab.

Former Member
0 Kudos

Just want to reformat code from Catherine , credit goes to her (part 1)

 
** determin here the language of the smart form ** 
control_parameters = is_control_parameters. 
control_parameters-langu = lv_language. 
control_parameters-no_open = ' '. "SAP SF: General flag 
control_parameters-no_close = ' '. "SAP SF: General flag 
control_parameters-device = ' '. "Output device 
control_parameters-no_dialog = 'X'. "suppress printer dialog 
control_parameters-preview = ' '. "Print preview 
control_parameters-getotf = 'X'. "Return OTF tab, no print 
control_parameters-replangu1 = ' '. "Language key 
control_parameters-replangu2 = ' '. "Language key 
control_parameters-replangu3 = ' '. "Language key 
control_parameters-startpage = ' '. "SAP SF: Object name 
IF NOT gr_action_badi IS INITIAL. 
CALL METHOD gr_action_badi->change_language_for_printing 
 EXPORTING 
  iv_ref_guid = lv_object_guid 
  iv_ref_kind = lv_object_kind 
  io_partner = io_partner 
 CHANGING 
 cs_control_parameters = control_parameters 
  cs_language_texts = lv_language 
 EXCEPTIONS 
  error_occurred = 1 
 OTHERS = 2. 
ENDIF. 
*----------------------------------------------------------------------- 
* fill prepare sender 
  CALL FUNCTION 'GET_RECIPIENT_DATA_PPF' 
  EXPORTING 
   is_recipient = is_mail_sender 
  IMPORTING 
   ep_addressstring = lv_send_email. 
  ls_send_mail = lv_send_email. 
* begin of note 690147 
  lv_sender_name = lv_send_email. 
  CALL METHOD cl_pd_po_processing_bbp=>process_bbp_check_sender 
   EXPORTING 
    iv_po_guid = lv_guid 
   CHANGING 
    cv_po_sender = lv_sender_name. 
  ls_send_mail = lv_sender_name. 
* end of note 690147 
* call function to process smart form 
  CALL FUNCTION function_name 
   "EXPORTING 
      "............ Export parms 
   "IMPORTING .............. Import parms 

    EXCEPTIONS 
      output_canceled = 1 
      parameter_error = 2 
     OTHERS = 3. 


   IF is_output_options-tdarmod <> 2. "1 
* OSS NOTE 895550 - fill in subject line 
    IF ls_orderadm_h-process_type = 'TA'. 
*} INSERT
      ls_output_options-tdtitle = 'Quote'. 
    endif. 
*} INSERT 
   IF ls_output_options-tdtitle IS INITIAL. 
     SELECT SINGLE caption INTO ls_output_options-tdtitle 
     FROM stxfadmt 
     WHERE formname = ip_smart_form. 
   ENDIF. 
   REPLACE '&' WITH ls_orderadm_h-object_id 
   INTO ls_output_options-tdtitle. 
   concatenate 'Quote' ls_orderadm_h-object_id into ls_doc_chng-obj_descr 
   SEPARATED BY space. 
    ls_objtxt-line = 'To approve this quote to become an order '. 
   APPEND ls_objtxt TO lt_objtxt. 
   CONCATENATE 'select this link:' ' ' into ls_objtxt-line. APPEND ls_objtxt TO lt_objtxt. 
   ls_objtxt-line = ' To Reject this quote '. APPEND ls_objtxt TO lt_objtxt. 
   CONCATENATE 'select this link: ' ' ' into ls_objtxt-line. APPEND ls_objtxt TO lt_objtxt. 
   DESCRIBE TABLE lt_objtxt LINES lv_txtlines. 
    READ TABLE lt_objtxt INTO ls_objtxt INDEX lv_txtlines. * 
* ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT 
   CLEAR ls_objpack-transf_bin. 
   ls_objpack-head_start = 1. 
   ls_objpack-head_num = 0. 
   ls_objpack-body_start = 1. 
   ls_objpack-body_num = lv_txtlines. 
   ls_objpack-doc_type = 'RAW'. 
   APPEND ls_objpack TO lt_objpack. 
   LOOP AT es_job_output_info-otfdata INTO ls_otfdata. 
     ls_off_tab-line = ls_otfdata. 
     APPEND ls_off_tab TO lt_off_tab. 
   ENDLOOP. 
   CONCATENATE 'Quotation' 'PDF' INTO ls_objhead SEPARATED BY '.'. 
   APPEND ls_objhead TO lt_objhead. 
   CLEAR ls_objpack-transf_bin. 
   ls_objpack-head_start = 1. 
   ls_objpack-head_num = 1. 
   ls_objpack-body_start = lv_txtlines + 1. 
   DESCRIBE TABLE lt_off_tab LINES lv_txtlines. 
   ls_objpack-body_num = lv_txtlines. 
   ls_objpack-doc_type = 'OTF'. 
   lv_head_c = '1'. 
   ls_objpack-obj_name = ls_objname. 
   ls_objpack-obj_descr = lv_object_id. 
   ls_objpack-doc_size = lv_filelength. 
   APPEND ls_objpack TO lt_objpack. 
   lv_head_i = 2. 
   lv_bodystart_i = 1. 
   DESCRIBE TABLE lt_objtxt LINES lv_txtlines. 
   READ TABLE lt_objtxt INTO ls_objtxt INDEX lv_txtlines. 
   ls_doc_chng-doc_size = ( lv_txtlines - 1 ) * 255 + STRLEN( ls_objtxt ). 
   READ TABLE lt_objpack INTO ls_objpack INDEX 1. 
   ls_objpack-body_num = lv_txtlines. 
   MODIFY lt_objpack FROM ls_objpack INDEX 1. 
   READ TABLE lt_objpack INTO ls_objpack INDEX 2. 
   ls_objpack-body_start = lv_txtlines + 1. 
   MODIFY lt_objpack FROM ls_objpack INDEX 2. 
* append lines of PO-OTF to texttable 
   APPEND LINES OF lt_off_tab TO lt_objtxt. 
* fill mailreclist 
  CALL FUNCTION 'GET_RECIPIENT_DATA_PPF' 
  EXPORTING 
   is_recipient = is_mail_recipient 
  IMPORTING ep_addressstring = lv_rec_email. 
  ls_reclist-receiver = lv_rec_email. 
  ls_reclist-rec_type = 'U'. 
  APPEND ls_reclist TO lt_reclist. 
    "to be continued part 2
   ENDIF. 
    "to be continued part 3
 ENDIF.  
*to be continued to part 4

Former Member
0 Kudos

Part 2


ELSE. 
   CASE sy-subrc. 
     WHEN 1. MESSAGE e016(sppf_media) INTO dummy. 
     WHEN 2. MESSAGE e017(sppf_media) WITH function_name INTO dummy. 
     WHEN 3. MESSAGE e018(sppf_media) WITH function_name INTO dummy. 
   ENDCASE. 
   CALL METHOD cl_log_ppf=>add_message 
    EXPORTING 
      ip_problemclass = '1' 
      ip_handle = ip_application_log. 

Part 3


* send mail 
   CALL FUNCTION 'SO_DOCUMENT_SEND_API1' 
   EXPORTING 
     document_data = ls_doc_chng 
     sender_address = ls_send_mail 
     sender_address_type = 'U' 
   TABLES 
     packing_list = lt_objpack 
     object_header = lt_objhead 
     contents_bin = lt_objbin 
     contents_txt = lt_objtxt 
     contents_hex = lt_objhex 
     receivers = lt_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.  
      IF is_output_options-tdarmod <> 1. 
* we have to archive by ourselves 
        CALL FUNCTION 'CONVERT_OTF_AND_ARCHIVE' 
         EXPORTING 
          arc_p = is_archive_parameters 
          arc_tab = ct_archive_index_tab 
          archive_copies = is_output_options-tdarccop 
         TABLES 
          otf = es_job_output_info-otfdata 
         EXCEPTIONS 
          error_archiv = 1 
          error_communicationtable = 2 
          error_connectiontable = 3 
          error_kernel = 4 
          error_parameter = 5 
          error_format = 6  
         OTHERS = 7. 
         IF sy-subrc = 0. 
           es_job_output_info-archdone = 'X'. 
           MESSAGE i006(bcs_medium) INTO dummy. 
           CALL METHOD cl_log_ppf=>add_message 
            EXPORTING 
              ip_problemclass = '4' 
              ip_handle = ip_application_log. 
         ELSE. 
           MESSAGE i002(bcs_medium) WITH sy-subrc INTO dummy. 
           CALL METHOD cl_log_ppf=>add_message 
            EXPORTING 
              ip_problemclass = '4' 
              ip_handle = ip_application_log. 
         ENDIF. 
       endif. 
       es_job_output_info-outputdone = sppf_true. 
       MESSAGE i029(bbp_out) WITH ls_reclist-receiver INTO dummy. 
       CALL METHOD cl_log_ppf=>add_message 
        EXPORTING 
         ip_problemclass = '4' 
         ip_handle = ip_application_log. 
    ELSE. 
* add error messages to processing protocol 
      CASE sy-subrc. 
         WHEN 1. MESSAGE i038(bbp_out) INTO dummy. 
         WHEN 2. MESSAGE i032(bbp_out) INTO dummy. 
         WHEN 3. MESSAGE i033(bbp_out) INTO dummy. 
         WHEN 4. MESSAGE i035(bbp_out) INTO dummy. 
         WHEN 5. MESSAGE i035(bbp_out) INTO dummy. 
         WHEN 6. MESSAGE i037(bbp_out) INTO dummy.  
         WHEN 7. MESSAGE i031(bbp_out) INTO dummy. 
         WHEN 8. MESSAGE i036(bbp_out) INTO dummy. 
      ENDCASE. 
      CALL METHOD cl_log_ppf=>add_message 
       EXPORTING 
        ip_problemclass = '1' 
        ip_handle = ip_application_log. 

Part 4


CALL FUNCTION 'SSF_READ_ERRORS' 
    IMPORTING errortab = et_error_tab.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Glenn,

You can achieve your requirement by using mailforms instead of smart forms.

Mailforms have a provision for sending text as well as as you can give links (urls) in it.

Also you can send PDFs as attchement by using a mialform

To create a mailform use tcode CRMD_EMAIL

For more information refer the documentation

http://help.sap.com/saphelp_crm60/helpdata/en/2b/a85bd37c854cdebfaca00bcae6c4cb/frameset.htm

Regards

Itty

Former Member
0 Kudos

Let me re-phrase, can a CRM action email both a smartform (pdf) as well as some text in the body of the email? I am thinking a mail form from CRM_ERMS_MAILFORMS

any idea how?

Former Member
0 Kudos

hi,

you cannot send both body and text through action.

instuded of that you can use your own coding in through badi

and send the PDF and text at the same time with use of functionmodule(SO_NEW_DOCUMENT_ATT_SEND_API1).

Regards,

Tanveer.Ahmed