Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to email Smartforms

Former Member
0 Kudos

I am trying to e-mail a smartform and I think I might have most of it figured out. The part I am confused about is the mail_appl_object and what exactly is required. I have copied my code below and I am getting the error "The type swc_object is unknown". I basically copied most of this code from other users on the SDN. Can someone please help .... what exactly would I need to do? thx!

control_parameters TYPE ssfctrlop.

control_parameters-device = 'MAIL'.

DATA: email_recipient TYPE SWOTOBJID,

email_sender TYPE SWOTOBJID,

g_mail_app_obj type SWOTOBJID,

FOLDER TYPE swcobject,

BEGIN OF SOFMFOL_KEY,

FOLDERTYPE LIKE SOFM-FOLTP,

FOLDERYEAR LIKE SOFM-FOLYR,

FOLDERNUMBER LIKE SOFM-FOLNO,

TYPE LIKE SOFM-DOCTP,

YEAR LIKE SOFM-DOCYR,

NUMBER LIKE SOFM-DOCNO,

FORWARDER LIKE SOUB-USRNAM,

END OF SOFMFOL_KEY,

BOR_KEY LIKE SWOTOBJID-OBJKEY.

PERFORM mail_recipient_object.

PERFORM mail_sender_object.

PERFORM mail_appl_object.

*Determine Function Module Name of SmartForm

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZMY_SMARTFORM' "SmartForm Name

IMPORTING

FM_NAME = func_mod_name EXCEPTIONS

OTHERS = 1.

CALL FUNCTION func_mod_name

EXPORTING

CONTROL_PARAMETERS = control_parameters

MAIL_APPL_OBJ = g_mail_app_obj

MAIL_RECIPIENT = email_recipient

MAIL_SENDER = email_sender

USER_SETTINGS = 'X'

MTRL_NO = icoa_dlvrys-matnr

MTRL_DESCR = icoa_dlvrys-maktx

CUSTOMER_NO = icoa_dlvrys-kunnr

CUSTOMER_NAME = icoa_dlvrys-name1

V_MANDT = sy-mandt

V_SYSID = sy-sysid

CERTIFIED_BY = r_certby

TABLES

izqm_coa_prpylene = izqm_coa_prpylene

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

**----


**FORM: mail_recipient_object

**----


FORM mail_recipient_object.

data: email_address TYPE SO_NAME.

email_address = 'MyEmail@Address.Com'.

CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'

EXPORTING

IP_MAILADDR = email_address

IP_TYPE_ID = 'U'

IMPORTING

EP_RECIPIENT_ID = email_recipient

EXCEPTIONS

INVALID_RECIPIENT = 1

OTHERS = 2.

ENDFORM. "mail_recipient_object.

*----


*FORM: mail_sender_object

**----


FORM mail_sender_object.

CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'

EXPORTING

IP_SENDER = sy-uname

IMPORTING

EP_SENDER_ID = email_sender

EXCEPTIONS

INVALID_SENDER = 1

OTHERS = 2.

ENDFORM. "mail_sender_object.

*----


* FORM mail_appl_object.

**----


FORM mail_appl_object.

SELECT * from soud INTO soud

WHERE sapnam LIKE sy-uname and deleted = ''.

endselect.

IF sy-subrc <> 0.

CALL FUNCTION 'SO_USER_AUTOMATIC_INSERT'

EXPORTING

SAPNAME = SY-UNAME

EXCEPTIONS

NO_INSERT = 1

SAP_NAME_EXIST = 2

X_ERROR = 3

SAP_NAME_NOT_EXIST = 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.

CLEAR soud.

ELSE.

ENDIF.

ENDIF.

CLEAR sofmfol_key.

sofmfol_key-type = 'FOL'.

sofmfol_key-year = soud-inbyr.

sofmfol_key-number = soud-inbno.

bor_key = sofmfol_key.

IF NOT bor_key IS INITIAL.

swc_create_object folder 'SOFMFOL' bor_key.

IF sy-subrc = 0.

swc_object_to_persistent folder p_mail_app_obj.

IF sy-subrc NE 0.

CLEAR g_mail_app_obj.

ENDIF.

ENDIF.

ELSE.

CLEAR g_mail_app_obj.

ENDIF.

ENDFORM. "mail_appl_object.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Janice,

Chek these links:


* 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 = 'jayanthi.gayathri@wipro.com'.
  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,

Anjali

17 REPLIES 17

Former Member
0 Kudos

There is a sample code in attached thread. Have a look

Former Member
0 Kudos

Hi ,

Please provide me your E-mail ID. I will send u the code. It is too big and I can't paste it here.

Lanka

ferry_lianto
Active Contributor
0 Kudos

Hi Janice,

Please check this weblog.

/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp

Hope this will help.

Regards,

Ferry Lianto

0 Kudos

All of this code seems really really involved ... is there not an easier way to do this?

Former Member
0 Kudos

HI,

Instead of using your solution use "SO_OBJECT_SEND"

once you get the OTF code from smartform call and converted into PDF. This way you can send the attachments

very easily.Or else you can send your smartform output as it is as attachement along with some text in the body.

Try this .....

Praveen

0 Kudos

My preference would be to send the smartform email as an attachment. Do you have some example code of how to do this? thx

0 Kudos

These threads give information to send smartform by mail. Have a look -

Let me know if this helps.

ashish

0 Kudos

The Threads you sent are actually the same one I used to build my code ... could perhaps explain what the mail_appl_object is for any why I am getting the error "The type swc_object is unknown".

0 Kudos

I have tried this weblog earlier and it worked for me -

/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp

Not sure about your error though...

0 Kudos

Hi,

Try : OBJECT_TYPE as OTF for Smartforms .

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

FOLDER_ID = X_SOODK

  • FORWARDER = ' '

  • OBJECT_FL_CHANGE = ' '

OBJECT_HD_CHANGE = X_SOOD1

  • OBJECT_ID = ' '

<b> OBJECT_TYPE = 'OTF'</b>

Regards,

Lanka

0 Kudos

I'm still not getting it. Any chance you could post me a complete and simple example?

0 Kudos

Most of my Problem was that I was missing the

include <cntn01>. statement. I have copied all of my code just in case it might benefit someone else.

tables: soud.

data: control_parameters TYPE ssfctrlop,

output_options TYPE ssfcompop,

EMail_Subject(50) TYPE c.

DATA: email_recipient TYPE SWOTOBJID,

email_sender TYPE SWOTOBJID,

g_mail_app_obj type SWOTOBJID.

concatenate text-004 '400000124' into EMail_Subject.

control_parameters-device = 'MAIL'.

control_parameters-no_dialog = 'X'.

control_parameters-preview = space.

output_options-tdnewid = 'X'.

output_options-tdtitle = EMail_Subject.

PERFORM mail_recipient_object.

PERFORM mail_sender_object.

PERFORM mail_appl_object changing g_mail_app_obj.

*Determine Function Module Name of SmartForm

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZMY_SMARTFORM'

IMPORTING

FM_NAME = func_mod_name

EXCEPTIONS

OTHERS = 1.

CALL FUNCTION func_mod_name

EXPORTING

CONTROL_PARAMETERS = control_parameters

MAIL_APPL_OBJ = g_mail_app_obj

MAIL_RECIPIENT = email_recipient

MAIL_SENDER = email_sender

OUTPUT_OPTIONS = output_options

USER_SETTINGS = 'X'

MTRL_NO = icoa_dlvrys-matnr

MTRL_DESCR = icoa_dlvrys-maktx

CUSTOMER_NO = icoa_dlvrys-kunnr

CUSTOMER_NAME = icoa_dlvrys-name1

V_MANDT = sy-mandt

V_SYSID = sy-sysid

CERTIFIED_BY = r_certby

TABLES

izqm_coa_prpylene = izqm_coa_prpylene

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

**----


**FORM: mail_recipient_object

**----


FORM mail_recipient_object.

data: email_address TYPE SO_NAME.

email_address = 'MyEmail@Address.Com'.

CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'

EXPORTING

IP_MAILADDR = email_address

IP_TYPE_ID = 'U'

IMPORTING

EP_RECIPIENT_ID = email_recipient

EXCEPTIONS

INVALID_RECIPIENT = 1

OTHERS = 2

.

ENDFORM. "mail_recipient_object.

*----


*FORM: mail_sender_object

**----


FORM mail_sender_object.

CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'

EXPORTING

IP_SENDER = sy-uname

IMPORTING

EP_SENDER_ID = email_sender

EXCEPTIONS

INVALID_SENDER = 1

OTHERS = 2.

ENDFORM. "mail_sender_object.

*----


* FORM mail_appl_object.

**----


FORM mail_appl_object changing g_mail_app_obj.

include <cntn01>.

DATA: FOLDER TYPE swc_object,

BEGIN OF SOFMFOL_KEY,

FOLDERTYPE LIKE SOFM-FOLTP,

FOLDERYEAR LIKE SOFM-FOLYR,

FOLDERNUMBER LIKE SOFM-FOLNO,

TYPE LIKE SOFM-DOCTP,

YEAR LIKE SOFM-DOCYR,

NUMBER LIKE SOFM-DOCNO,

FORWARDER LIKE SOUB-USRNAM,

END OF SOFMFOL_KEY,

BOR_KEY LIKE SWOTOBJID-OBJKEY.

SELECT single * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.

IF sy-subrc NE 0.

CALL FUNCTION 'SO_USER_AUTOMATIC_INSERT'

EXPORTING

SAPNAME = SY-UNAME

EXCEPTIONS

NO_INSERT = 1

SAP_NAME_EXIST = 2

X_ERROR = 3

SAP_NAME_NOT_EXIST = 4

OTHERS = 5.

ENDIF.

clear sofmfol_key.

sofmfol_key-type = 'FOL'.

sofmfol_key-year = soud-inbyr.

sofmfol_key-number = soud-inbno.

bor_key = sofmfol_key.

IF not bor_key is initial.

swc_create_object folder 'SOFMFOL' bor_key.

IF sy-subrc = 0.

swc_object_to_persistent folder g_mail_app_obj.

IF sy-subrc ne 0.

clear g_mail_app_obj.

ENDIF.

ENDIF.

ELSE.

clear g_mail_app_obj.

ENDIF.

ENDFORM. "mail_appl_object.

0 Kudos

Janice,

You've been more than kind. Your code helped me out of my own problem.

Now I am able to send payment advices by email.

Thanks a lot.

Warm regards,

Ernesto

ZF Sachs Suspension Mexico - SAP Financials.

Former Member
0 Kudos

Hi Janice,

Chek these links:


* 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 = 'jayanthi.gayathri@wipro.com'.
  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,

Anjali

Former Member
0 Kudos

Hello SAP gurus,

I am trying to send a sample smartform by email by using the code below. When I execute the program system shows below succes message.

"MAIL request 000000000029 created successfully.

Message no. SSFCOMPOSER024"

But I can see nothing coming in SCOT/SOST and it doesnt sends any email.

Is there anything I need to configure in system settings.

Moreover when I try to send any email to extenal email addresses from SAP office system is sending email correctly.

Any help would be highly appreciated.

Thanks in advance,

Shabbeer.

&----


*& Report Z_SF_EX_03 *

*& *

&----


*& *

*& *

&----


REPORT Z_SF_EX_03 .

tables: soud.

data: carr_id type sbook-carrid,

fm_name type rs38l_fnam.

  • cust_id type scustom-id.

parameter: p_custid type scustom-id default 1.

select-options: "s_custid for cust_id default 1 to 1,

s_carrid for carr_id default 'LH' to 'LH'.

parameter: p_form type tdsfname default 'SF_EXAMPLE_01'.

  • p_email type

data: customer type scustom,

bookings type ty_bookings,

connections type ty_connections,

output_option type ssfcompop,

zssfcrescl type ssfcrescl,

zssfcresop type ssfcresop.

include <cntn01>.

  • get data

select single * from scustom

into customer

where id eq p_custid.

check sy-subrc = 0.

select * from sbook into table bookings

where customid eq p_custid

and carrid in s_carrid

order by primary key.

select * from spfli into table connections

for all entries in bookings

where carrid = bookings-carrid

and connid = bookings-connid

order by primary key.

data: control_parameters TYPE ssfctrlop,

output_options TYPE ssfcompop,

EMail_Subject(50) TYPE c.

DATA: email_recipient TYPE SWOTOBJID,

email_sender TYPE SWOTOBJID,

g_mail_app_obj type SWOTOBJID.

concatenate text-004 '400000124' into EMail_Subject.

control_parameters-device = 'MAIL'.

control_parameters-no_dialog = 'X'.

control_parameters-preview = 'X'."space.

output_options-tdnewid = 'X'.

output_options-tdtitle = EMail_Subject.

PERFORM mail_recipient_object.

PERFORM mail_sender_object.

PERFORM mail_appl_object changing g_mail_app_obj.

*Determine Function Module Name of SmartForm

call function 'SSF_FUNCTION_MODULE_NAME'

exporting formname = p_form

  • variant = ' '

  • direct_call = ' '

importing fm_name = fm_name

exceptions no_form = 1

no_function_module = 2

others = 3.

if sy-subrc <> 0.

  • error handling

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

exit.

endif.

  • now call the generated function module

call function fm_name

exporting

  • archive_index =

  • archive_parameters =

control_parameters = control_parameters

mail_appl_obj = g_mail_app_obj

mail_recipient = email_recipient

mail_sender = email_sender

output_options = output_options

user_settings = 'X'

customer = customer

bookings = bookings

connections = connections

importing

  • document_output_info =

job_output_info = zssfcrescl

job_output_options = zssfcresop

exceptions formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

others = 5.

*break-point.

**----


**FORM: mail_recipient_object

**----


FORM mail_recipient_object.

data: email_address TYPE SO_NAME.

email_address = 'shabbir_be@yahoo.com'.

CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'

EXPORTING

IP_MAILADDR = email_address

IP_TYPE_ID = 'U'

IMPORTING

EP_RECIPIENT_ID = email_recipient

EXCEPTIONS

INVALID_RECIPIENT = 1

OTHERS = 2

.

ENDFORM. "mail_recipient_object.

*----


*FORM:

*form mail_sender_object

**----


FORM

form mail_sender_object.

CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'

EXPORTING

IP_SENDER = sy-uname

IMPORTING

EP_SENDER_ID = email_sender

EXCEPTIONS

INVALID_SENDER = 1

OTHERS = 2.

ENDFORM. "mail_sender_object.

*----


* FORM

*form mail_appl_object.

**----


FORM

form mail_appl_object changing g_mail_app_obj.

DATA: FOLDER TYPE swc_object,

BEGIN OF SOFMFOL_KEY,

FOLDERTYPE LIKE SOFM-FOLTP,

FOLDERYEAR LIKE SOFM-FOLYR,

FOLDERNUMBER LIKE SOFM-FOLNO,

TYPE LIKE SOFM-DOCTP,

YEAR LIKE SOFM-DOCYR,

NUMBER LIKE SOFM-DOCNO,

FORWARDER LIKE SOUB-USRNAM,

END OF SOFMFOL_KEY,

BOR_KEY LIKE SWOTOBJID-OBJKEY.

SELECT single * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.

IF sy-subrc NE 0.

CALL FUNCTION 'SO_USER_AUTOMATIC_INSERT'

EXPORTING

SAPNAME = SY-UNAME

EXCEPTIONS

NO_INSERT = 1

SAP_NAME_EXIST = 2

X_ERROR = 3

SAP_NAME_NOT_EXIST = 4

OTHERS = 5.

ENDIF.

clear sofmfol_key.

sofmfol_key-type = 'FOL'.

sofmfol_key-year = soud-inbyr.

sofmfol_key-number = soud-inbno.

bor_key = sofmfol_key.

IF not bor_key is initial.

swc_create_object folder 'SOFMFOL' bor_key.

IF sy-subrc = 0.

swc_object_to_persistent folder g_mail_app_obj.

IF sy-subrc ne 0.

clear g_mail_app_obj.

ENDIF.

ENDIF.

ELSE.

clear g_mail_app_obj.

ENDIF.

ENDFORM. "mail_appl_object.

sushant_singh
Participant
0 Kudos

Hi all,

How can I add text in the body of the email generated through a smartform.

Thanks.

Hi ,

Shabeer: Use COMMIT WORK after your smartform call.

Sushant Singh:

I am also having the same issue as you are having ...

How to add text to the body of the email ? Anybody ....your help is appreciated.

Thank you,

Surya.