Skip to Content
0
Former Member
Mar 14, 2006 at 06:56 PM

How to email Smartforms

791 Views

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.