Skip to Content
0
Former Member
Jun 26, 2006 at 05:50 AM

Problem in sending smartform via email

391 Views

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.