0% found this document useful (0 votes)
335 views

Smartfrom Via Email

The document explains how to call a smartform for mailing by providing the necessary object IDs for the recipient, sender, and application. It describes forms for creating the recipient, sender, and application objects that are passed to the smartform function call along with control parameters to send the mail. Instructions are provided to check the mail traffic in transaction SOST if the mailing is successful.

Uploaded by

EmilS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
335 views

Smartfrom Via Email

The document explains how to call a smartform for mailing by providing the necessary object IDs for the recipient, sender, and application. It describes forms for creating the recipient, sender, and application objects that are passed to the smartform function call along with control parameters to send the mail. Instructions are provided to check the mail traffic in transaction SOST if the mailing is successful.

Uploaded by

EmilS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Well I try to explain what you need to mail a smartform.

Here is a part of the function call:

data: g_mail_rec_obj type SWOTOBJID,


g_mail_sen_obj type SWOTOBJID,
g_mail_app_obj type SWOTOBJID,
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.

g_cont_par-device = 'MAIL'.

* Get BOR-Objects for Recipient, Sender und Applikation


PERFORM mail_recipient_object CHANGING g_mail_rec_obj.
PERFORM mail_sender_object CHANGING g_mail_sen_obj.
PERFORM mail_appl_object CHANGING g_mail_app_obj.

* Calling Smartform
CALL FUNCTION fm_name
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = g_cont_par
mail_appl_obj = g_mail_app_obj
mail_recipient = g_mail_rec_obj
mail_sender = g_mail_sen_obj
output_options = g_output
user_settings = ' '
IMPORTING
... rest of function ...

COMMIT WORK.

Here are the Forms:


*&---------------------------------------------------------------------*
*& Form mail_recipient_object
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_G_MAIL_REC_OBJ text
*----------------------------------------------------------------------*
FORM mail_recipient_object CHANGING p_mail_rec_obj.
CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
EXPORTING
* IP_COUNTRY =
* IP_FAXNO =
ip_mailaddr = g_mail "g_mail type
" SO_NAME.
ip_type_id = g_rectype " 'U'
IMPORTING
ep_recipient_id = p_mail_rec_obj
* EP_ADDRESS =
* ET_RECIPIENT =
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

ENDFORM. " mail_recipient_object

*&---------------------------------------------------------------------*
*& Form mail_sender_object
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_G_MAIL_SEN_OBJ text
*----------------------------------------------------------------------*
FORM mail_sender_object CHANGING p_mail_sen_obj.

CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'


EXPORTING
ip_sender = sy-uname
IMPORTING
ep_sender_id = p_mail_sen_obj
EXCEPTIONS
invalid_sender = 1
OTHERS = 2.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

ENDFORM. " mail_sender_object

*&---------------------------------------------------------------------*
*& Form mail_appl_object
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_G_MAIL_APP_OBJ text
*----------------------------------------------------------------------*
FORM mail_appl_object CHANGING p_mail_app_obj.

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

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
OTHERS = 4.
IF sy-subrc NE 0.
CLEAR soud.
ELSE.
SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
ENDSELECT.
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 p_mail_app_obj.
ENDIF.
ENDIF.
ELSE.
CLEAR p_mail_app_obj.
ENDIF.

ENDFORM. " mail_appl_object

Please also search for "email" in this forum concerning the connection from SAP to a mailsystem.
If everything works you can check the mailtraffic in TA SOST.
Hope this helps you a bit further

You might also like