cancel
Showing results for 
Search instead for 
Did you mean: 

smartform Email

Former Member
0 Kudos

Hi,

I have a report whose output is a smartform layout which gives the changes in vendor master.

And know the requirement is it should send the mail to the vendor email address which is in vendor master.

How can I do this.

Please help me.

thanks n regards

vamshi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

the below, am just pasting the code for sending the output to email. maybe declarations are wrong just try to paste the code in ABAP EDITOR and check for syntax and correct it...

DATA ls_control_parameters TYPE ssfctrlop.

DATA lv_devtype TYPE rspoptype.

DATA ls_output_options TYPE ssfcompop.

loop at itab.

APPEND ls_data TO lt_data_lief.

AT END OF lifnr.

  • get the address no. of the vendor

SELECT SINGLE adrnr

INTO lf_adrnr

FROM lfa1

WHERE lifnr = ls_data-lifnr.

  • to get the communication values

CALL FUNCTION 'ADDR_GET_NEXT_COMM_TYPE'

EXPORTING

  • strategy = 'MAIL' "sdy2kor-24102007.o

strategy = 'ZIN1' "sdy2kor-24102007.n

address_number = lf_adrnr

IMPORTING

comm_type = lf_comm_type

comm_values = ls_comm_values

EXCEPTIONS

address_not_exist = 1

person_not_exist = 2

no_comm_type_found = 3

internal_error = 4

parameter_error = 5

OTHERS = 6.

  • to get the recipient & sender data

CALL FUNCTION 'CONVERT_COMM_TYPE_DATA'

EXPORTING

pi_comm_type = lf_comm_type

pi_comm_values = ls_comm_values

pi_screen = lf_screen

pi_repid = sy-repid

IMPORTING

pe_mail_recipient = ls_recipient

pe_mail_sender = ls_sender

EXCEPTIONS

comm_type_not_supported = 1

recipient_creation_failed = 2

sender_creation_failed = 3

OTHERS = 4.

  • if email address is not maintained for this address..

IF ls_comm_values-adsmtp-smtp_addr IS INITIAL.

MESSAGE e096(am).

ENDIF.

  • set output options & control params

ls_output_options-tdarmod = '1'.

ls_output_options-tdcopies = '001'.

ls_control_parameters-getotf = 'X'.

ls_control_parameters-no_dialog = 'X'.

ls_control_parameters-langu = lv_language.

ls_control_parameters-device = 'MAIL'.

  • call smartform

CALL FUNCTION gf_form_fm

EXPORTING

control_parameters = ls_control_parameters

mail_recipient = ls_recipient

mail_sender = ls_sender

output_options = ls_output_options

user_settings = space

lieferant_addr = lf_werk_ok "sdy2kor-12102007.n

IMPORTING

job_output_info = ls_output_data

TABLES

data = lt_data_lief

text = gt_text

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

  • set the paramters for mail sending

ls_mailoptions-tddevice = 'MAIL'.

ls_mailoptions-tdcopies = '1'.

ls_mailoptions-tdlifetime = 8.

ls_mailoptions-tddataset = 'MAIL'.

ls_mailoptions-tdimmed = 'X'.

ls_mailoptions-tdnewid = 'X'.

ls_mailoptions-bcs_commit = 'X'.

  • to send e-mail

CLEAR lv_ok.

CALL FUNCTION 'SSFCONVERT_OTF_AND_MAIL'

EXPORTING

mail_sender = ls_sender

mail_recipient = ls_recipient

mailoptions = ls_mailoptions

IMPORTING

mail_ok = lv_ok

TABLES

mail_application_object_ids = lt_appl_ids

otf = ls_output_data-otfdata.

endloop.

Hope it helps!!

Rgds,

Pavan

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Refer to this link..https://www.sdn.sap.com/irj/scn/directforumsearch?threadid=&q=sendsmartfromoutputasemail+&objID=c42&dateRange=all&numResults=30&rankBy=10001

Former Member
0 Kudos

Hello Vamshee

Try This code.



CALL FUNCTION u2018SSF_FUNCTION_MODULE_NAMEu2019

W_CTRLOP-GETOTF = u2018Xu2019.
W_CTRLOP-NO_DIALOG = u2018Xu2019.
W_COMPOP-TDNOPREV = u2018Xu2019.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = u2018Xu2019
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION u2018CONVERT_OTFu2019
EXPORTING
FORMAT = u2018PDFu2019
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
LINES = I_TLINE

LOOP AT I_TLINE.
TRANSLATE I_TLINE USING u2018~u2019.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING u2018~u2019.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH:
I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].

I_OBJTXT = u2018test with pdf-Attachment!u2019.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = u2019smartformu2019.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = u2019smartformu2019.
WA_DOC_CHNG-SENSITIVTY = u2018Fu2019.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.

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 = u2018RAWu2019.
APPEND I_OBJPACK.

I_OBJPACK-TRANSF_BIN = u2018Xu2019.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.

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 = u2018PDFu2019.
I_OBJPACK-OBJ_NAME = u2019smartu2019.
I_OBJPACK-OBJ_DESCR = u2018testu2019.
APPEND I_OBJPACK.

CLEAR I_RECLIST.
I_RECLIST-RECEIVER = u2018email idu2019.
I_RECLIST-REC_TYPE = u2018Uu2019.
APPEND I_RECLIST.

CALL FUNCTION u2018SO_NEW_DOCUMENT_ATT_SEND_API1u2032
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = u2018Xu2019
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.

Peak the Vendor ADRNR number from LFA1, goto ADRC table get the vendor details. and search tables ADR3 - 1 for further details.

Hope this helps.

Cheers,

Suvendu

Edited by: Suvendu Swain on Jun 23, 2009 1:20 PM

premal_mistry2
Active Participant
0 Kudos

Hi Vamshee,

You need to use the FM CONVERT_OTFSPOOLJOB_2_PDF. Let me know if you need more help.