2006 Feb 23 3:53 PM
Good morning,
How can I send smartforms by email.
How can I view the generate function model once It has been activated.
Thanks
Best regards,
Hernán Rpo
2006 Feb 23 4:10 PM
HI Hernan
try this sample
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_REPORT'
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'.
w_compop-tddest = 'Locl'.
w_ctrlop-no_dialog = 'X'.
w_ctrlop-device = 'PRINTER'.
CALL FUNCTION v_form_name
EXPORTING
control_parameters = w_ctrlop
output_options = w_compop
user_settings = ' '
l_load = p_load
IMPORTING
job_output_info = w_return
TABLES
i_output = i_output
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Convert PDF from 132 to 255.
LOOP AT i_tline.
Replacing space by ~
TRANSLATE i_tline USING ' ~'.
CONCATENATE w_buffer i_tline INTO w_buffer.
ENDLOOP.
Replacing ~ by space
TRANSLATE w_buffer USING '~ '.
DO.
i_record = w_buffer.
Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR w_objhead.
Object with PDF.
i_objbin[] = i_record[].
DESCRIBE TABLE i_objbin LINES v_lines_bin.
Object with main text of the mail.
i_objtxt = text-002.
APPEND i_objtxt.
CLEAR i_objtxt.
APPEND i_objtxt.
i_objtxt = 'Kind regards,'.
APPEND i_objtxt.
i_objtxt = 'Client facing team'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
Document information.
w_doc_chng-obj_name = 'Smartform'.
w_doc_chng-expiry_dat = sy-datum + 10.
w_doc_chng-obj_descr = 'Shipment Summary Report'.
w_doc_chng-sensitivty = 'O'. "Standard
w_doc_chng-doc_size = v_lines_txt * 255.
Pack to main body as RAW.
Obj. to be transported not in binary form
CLEAR i_objpack-transf_bin.
Start line of object header in transport packet
i_objpack-head_start = 1.
Number of lines of an object header in object packet
i_objpack-head_num = 0.
Start line of object contents in an object packet
i_objpack-body_start = 1.
Number of lines of the object contents in an object packet
i_objpack-body_num = v_lines_txt.
Code for document class
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
Packing as PDF.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'Smartform'.
CONCATENATE 'Hazard report-' p_load '.pdf' INTO i_objpack-obj_descr.
i_objpack-doc_size = v_lines_bin * 255.
APPEND i_objpack.
IF sy-subrc = 0.
LOOP AT i_misc INTO w_misc.
i_reclist-receiver = w_misc-z_value_1.
i_reclist-express = 'X'.
i_reclist-rec_type = 'U'. "Internet address
APPEND i_reclist.
ENDLOOP.
Sending mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
object_header = w_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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Mail sent'(003)
txt1 = 'The report is sent via e-mail.'(004)
txt2 = ' '.
LEAVE PROGRAM.
ENDIF.
ELSE.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'No e-mail specified'(005)
txt1 = 'You need to maintain the e-mail adress in table'(006)
txt2 = text-007.
LEAVE PROGRAM.
ENDIF.
regards
kishore
2006 Feb 23 4:06 PM
Hi Hernan,
Please go to "Search Forum" to search sending smartforms by email example codes. There are a lot of good program coding and additional helpful information.
Hope this will help.
Regards,
Ferry Lianto
2006 Feb 23 4:10 PM
HI Hernan
try this sample
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_REPORT'
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'.
w_compop-tddest = 'Locl'.
w_ctrlop-no_dialog = 'X'.
w_ctrlop-device = 'PRINTER'.
CALL FUNCTION v_form_name
EXPORTING
control_parameters = w_ctrlop
output_options = w_compop
user_settings = ' '
l_load = p_load
IMPORTING
job_output_info = w_return
TABLES
i_output = i_output
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Convert PDF from 132 to 255.
LOOP AT i_tline.
Replacing space by ~
TRANSLATE i_tline USING ' ~'.
CONCATENATE w_buffer i_tline INTO w_buffer.
ENDLOOP.
Replacing ~ by space
TRANSLATE w_buffer USING '~ '.
DO.
i_record = w_buffer.
Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR w_objhead.
Object with PDF.
i_objbin[] = i_record[].
DESCRIBE TABLE i_objbin LINES v_lines_bin.
Object with main text of the mail.
i_objtxt = text-002.
APPEND i_objtxt.
CLEAR i_objtxt.
APPEND i_objtxt.
i_objtxt = 'Kind regards,'.
APPEND i_objtxt.
i_objtxt = 'Client facing team'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
Document information.
w_doc_chng-obj_name = 'Smartform'.
w_doc_chng-expiry_dat = sy-datum + 10.
w_doc_chng-obj_descr = 'Shipment Summary Report'.
w_doc_chng-sensitivty = 'O'. "Standard
w_doc_chng-doc_size = v_lines_txt * 255.
Pack to main body as RAW.
Obj. to be transported not in binary form
CLEAR i_objpack-transf_bin.
Start line of object header in transport packet
i_objpack-head_start = 1.
Number of lines of an object header in object packet
i_objpack-head_num = 0.
Start line of object contents in an object packet
i_objpack-body_start = 1.
Number of lines of the object contents in an object packet
i_objpack-body_num = v_lines_txt.
Code for document class
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
Packing as PDF.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'Smartform'.
CONCATENATE 'Hazard report-' p_load '.pdf' INTO i_objpack-obj_descr.
i_objpack-doc_size = v_lines_bin * 255.
APPEND i_objpack.
IF sy-subrc = 0.
LOOP AT i_misc INTO w_misc.
i_reclist-receiver = w_misc-z_value_1.
i_reclist-express = 'X'.
i_reclist-rec_type = 'U'. "Internet address
APPEND i_reclist.
ENDLOOP.
Sending mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
object_header = w_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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Mail sent'(003)
txt1 = 'The report is sent via e-mail.'(004)
txt2 = ' '.
LEAVE PROGRAM.
ENDIF.
ELSE.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'No e-mail specified'(005)
txt1 = 'You need to maintain the e-mail adress in table'(006)
txt2 = text-007.
LEAVE PROGRAM.
ENDIF.
regards
kishore
2006 Feb 23 5:45 PM
Hi Harikishore
I have done your instructions but the smartform that Iám trying to send by email is the standar IDWTCERT_CO_01. and I'm getting errors when I modify the parameters for v_form_name...
CALL FUNCTION v_form_name
EXPORTING
control_parameters = w_ctrlop
output_options = w_compop
user_settings = 'X'
WTINTERFACEALL = w_wtintercace
WTINTERFACEFORM = w_IDWTINTFORM
IMPORTING
job_output_info = w_return
TABLES
WTCOMPCD = ti_TY_IDWTCOMPCD
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
cause the generated function module of that smartforms ( /1BCDWB/SF00000001 ) the definitions es:
FUNCTION /1BCDWB/SF00000001.
*"--------------------------------------------------------------------
*"*"Global Interface:
*" IMPORTING
*" VALUE(ARCHIVE_INDEX) TYPE TOA_DARA OPTIONAL
*" VALUE(ARCHIVE_INDEX_TAB) TYPE TSFDARA OPTIONAL
*" VALUE(ARCHIVE_PARAMETERS) TYPE ARC_PARAMS OPTIONAL
*" VALUE(CONTROL_PARAMETERS) TYPE SSFCTRLOP OPTIONAL
*" VALUE(MAIL_APPL_OBJ) TYPE SWOTOBJID OPTIONAL
*" VALUE(MAIL_RECIPIENT) TYPE SWOTOBJID OPTIONAL
*" VALUE(MAIL_SENDER) TYPE SWOTOBJID OPTIONAL
*" VALUE(OUTPUT_OPTIONS) TYPE SSFCOMPOP OPTIONAL
*" VALUE(USER_SETTINGS) TYPE TDBOOL DEFAULT 'X'
*" REFERENCE(WTINTERFACEALL) TYPE IDWTINTALL
*" REFERENCE(WTINTERFACEFORM) TYPE IDWTINTFORM
*" EXPORTING
*" VALUE(DOCUMENT_OUTPUT_INFO) TYPE SSFCRESPD
*" VALUE(JOB_OUTPUT_INFO) TYPE SSFCRESCL
*" VALUE(JOB_OUTPUT_OPTIONS) TYPE SSFCRESOP
*" TABLES
*" WTCOMPCD TYPE TY_IDWTCOMPCD
*" WTPARTNER TYPE TY_IDWTPARTNER
*" WTFIDOC TYPE TY_IDWTFIDOC
...
...
So, how can I could create the internal table to send as parameter in the function 'v_form_name'...
thanks a lot,
Best regards,
Hernan Restrepo
2006 Feb 23 5:56 PM
Hi Heman
if you know your function module then you can directly call the functional module without using SSF_* functional
and dont forget to uncomment
*" VALUE(JOB_OUTPUT_INFO) TYPE SSFCRESCL
in the importing of the call fucntion
regards
kishore
2006 Feb 23 7:46 PM
Hi kishore,
I don´t know what is your idea with uncomment this sentence:
*" VALUE(JOB_OUTPUT_INFO) TYPE SSFCRESCL
I can´t modify it, cause is part of the definition of the function. Remember that the error is in the table´s parameters...
thanks ...
Best & redards
2006 Feb 23 8:29 PM
Hi,
Please check this weblog :
<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp Smartform via E-mail</a>
Regards,
2006 Feb 24 4:58 PM
Hi Lanka,
I have followed the instructions as is shown in that link, but I am having problems with the form_name parameters and if you can try calling the standar smartform <b>IDWTCERT_CO_01</b>.
I need the right parameters, just the declaration, cause I am getting problems with the parameter table WTCOMPCD TYPE TY_IDWTCOMPCD.
Best Regards,
Hernan Rpo
2006 Feb 24 5:02 PM
hi ,
Is there any standard O/P associated with your smartform.
Lanka
2006 Feb 24 5:18 PM
Really I don´t know what is an standar O/P, how I coud check it.
Thanks
2006 Feb 24 5:20 PM
hi,
Please let me know.
If you are using standard O/P type then create another O/P with medium as E-mail and assign print program and smartform.
If you don't have standard O/P type and provide me your e-mail ID . I will send you the sample code.
Regards,
Lanka
2006 Feb 24 5:24 PM
Hi Lanka ,
Off course... my email is: hrestrepo@isa.com.co
Regards,
Hernán Restrepo
2006 Feb 27 3:07 PM
Hello Lanka ,
My email is : hrestrepo@isa.com.co ... do you have the example code you say me last week?
thanks,
Best regards,
Hernán Restrepo
2006 Feb 27 3:15 PM
2006 Feb 27 4:14 PM
Dear Murthy ,
I can´t prove it.. Do you have the structure of that is in your code?:
ZEHS_DGTEXT,
thanks,
2006 Feb 27 4:17 PM
2006 Mar 06 4:00 PM