on 10-13-2004 10:45 PM
In the form interface of my form, I am passing the recipients email in MAIL_RECIPIENT and the current user's email in the MAIL_SENDER parameters. I need my form to be emailed once its processed. During runtime it gives errors. Does anyone have any experience in sending a smartform via email?
Also has anyone tried dynamically to show JPG files in the smartforms. I entered a fieldname using &, in the Graphics window but it gives compile errors. This field is filled in the program.
<MOVED BY MODERATOR TO THE CORRECT FORUM>
Edited by: Alvaro Tejada Galindo on Dec 26, 2008 11:15 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mohit,
I tried the code what you had attached but I am getting error as
"OTF end command // missing in OTF data".
Could you please help me in this regard.
When I checked in transaction sost it is giving blank pdf.
Suppose if I want to add the image from my pc with a path like 'c:/documents and setting' etc how can I specify for the graphics part.
My code is
REPORT zprogram66_10.
INCLUDE <cntn01>.
* DECLARATION SECTION
START-OF-SELECTION.
* My Smartforms.
MOVE 'ZMY_SMARTFORMS' TO w_formname.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSMARTFORM99'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = w_funcname
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.
MOVE : 'X' TO is_control_param-no_dialog ,
' ' TO is_control_param-preview ,
'X' TO is_control_param-getotf ,
sy-langu TO is_control_param-langu ,
'PRINTER' TO is_control_param-device ,
'X' TO is_composer_param-tdnoprint ,
'X' TO is_composer_param-tdnoprev ,
'X' TO is_composer_param-tdfinal ,
'X' TO is_composer_param-xdfcmode ,
' ' TO is_composer_param-xdf ,
'X' TO is_composer_param-xsfcmode ,
'X' TO is_composer_param-xsf ,
' ' TO is_composer_param-xsfoutdev ,
'A' TO is_composer_param-xsfoutmode ,
'X' TO is_composer_param-xsfformat ,
'My Mail' TO is_composer_param-tdtitle.
* For the Graphics
MOVE : 'GRAPHICS' TO is_xfsparam-name ,
'EXTRACT' TO is_xfsparam-value.
APPEND is_xfsparam TO is_composer_param-xsfpars.
MOVE : 'GRAPHICS-DIRECTORY' TO is_xfsparam-name ,
'MyDirY' TO is_xfsparam-value.
APPEND is_xfsparam TO is_composer_param-xsfpars.
MOVE : 'CONTENT-ID' TO is_xfsparam-name ,
'ENABLE' TO is_xfsparam-value.
APPEND is_xfsparam TO is_composer_param-xsfpars.
* Conversion du HTML Hex en Text.
LOOP AT is_job_info-xmloutput-trfresult-content
INTO is_html_raw.
CONCATENATE w_html_xtxt
is_html_raw
INTO w_html_xtxt
IN BYTE MODE.
ENDLOOP.
w_html_xtxt = w_html_xtxt(is_job_info-xmloutput-trfresult-length).
CALL FUNCTION 'SCP_TRANSLATE_CHARS'
EXPORTING
inbuff = w_html_xtxt
incode = '4110'
outcode = '0000'
csubst = 'X'
substc_space = 'X'
IMPORTING
outbuff = w_html_txt
outused = w_html_len
EXCEPTIONS
OTHERS = 5.
REPLACE ALL OCCURRENCES OF 'utf-8' IN w_html_txt WITH 'latin1'.
w_html_len = strlen( w_html_txt ).
* Creation objet pour mail.
CREATE OBJECT obj_mime_helper.
* Récupère les graphiques.
it_graphics = is_job_info-xmloutput-xsfgr[].
LOOP AT it_graphics
INTO is_graphic.
CLEAR w_gr_xtxt.
LOOP AT is_graphic-content
INTO is_gr_raw.
CONCATENATE w_gr_xtxt
is_gr_raw-line
INTO w_gr_xtxt
IN BYTE MODE.
ENDLOOP.
w_gr_xtxt = w_gr_xtxt(is_graphic-length).
w_offset = 0.
w_len = 255.
CLEAR it_solix[].
WHILE w_offset < is_graphic-length.
w_diff = is_graphic-length - w_offset.
IF w_diff > w_len.
is_solix-line = w_gr_xtxt+w_offset(w_len).
ELSE.
is_solix-line = w_gr_xtxt+w_offset(w_diff).
ENDIF.
APPEND is_solix TO it_solix.
ADD w_len TO w_offset.
ENDWHILE.
CONCATENATE 'MyDir'
is_graphic-graphics
'.bmp'
INTO w_file.
CONCATENATE 'MyDir'
is_graphic-graphics
'.bmp'
INTO w_content_id.
w_content_type = is_graphic-httptype.
w_obj_len = is_graphic-length.
CALL METHOD obj_mime_helper->add_binary_part
EXPORTING
content = it_solix
filename = w_file
extension = 'BMP'
description = 'Graphic in BMP format'
content_type = w_content_type
length = w_obj_len
content_id = w_content_id2.
ENDLOOP.
w_offset = 0.
w_len = 255.
WHILE w_offset < w_html_len.
w_diff = w_html_len - w_offset.
IF w_diff > w_len.
is_soli-line = w_html_txt+w_offset(w_len).
ELSE.
is_soli-line = w_html_txt+w_offset(w_diff).
ENDIF.
APPEND is_soli TO it_soli.
ADD w_len TO w_offset.
ENDWHILE.
* Ajoute le corps.
CALL METHOD obj_mime_helper->set_main_html
EXPORTING
content = it_soli
filename = ''
description = 'My mail'.
* Ajoute le titre
MOVE is_composer_param-tdtitle TO w_title.
obj_doc_bcs = cl_document_bcs=>create_from_multirelated(
i_subject = w_title
i_importance = '9' " 1 / 5 / 9
i_multirel_service = obj_mime_helper ).
CALL METHOD obj_doc_bcs->get_docno
RECEIVING
result = w_docno.
obj_bcs = cl_bcs=>create_persistent( ).
obj_bcs->set_document( i_document = obj_doc_bcs ).
*---------------------------------------------------------------------*
* Create the attachment. *
*---------------------------------------------------------------------*
* Call the Smartforms
CALL FUNCTION w_funcname
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = is_control_param
mail_appl_obj = is_mailobj
mail_recipient = is_recipient
mail_sender = is_sender
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
invoice = p
output_options = is_composer_param
user_settings = ' '
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = is_job_info
*JOB_OUTPUT_OPTIONS =
TABLES
itab = itab
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
break fgi.
** Convert the OTF to PDF.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = w_doc_size
TABLES
otf = is_job_info-otfdata
doctab_archive = it_docs
lines = it_tline
EXCEPTIONS
OTHERS = 3.
CLEAR w_gr_xtxt.
CREATE OBJECT obj_conv.
* Change the output format.
LOOP AT it_tline
INTO is_tline.
CALL METHOD obj_conv->convert
EXPORTING
inbuff = is_tline
outbufflg = 2500
IMPORTING
outbuff = w_xtxt.
CONCATENATE w_gr_xtxt
w_xtxt
INTO w_gr_xtxt
IN BYTE MODE.
ENDLOOP.
w_gr_xtxt = w_gr_xtxt(w_doc_size).
w_offset = 0.
w_len = 255.
CLEAR it_solix[].
WHILE w_offset < w_doc_size.
w_diff = w_doc_size - w_offset.
IF w_diff > w_len.
is_solix-line = w_gr_xtxt+w_offset(w_len).
ELSE.
is_solix-line = w_gr_xtxt+w_offset(w_diff).
ENDIF.
APPEND is_solix TO it_solix.
ADD w_len TO w_offset.
ENDWHILE.
MOVE : 'Attachment' TO w_title ,
'Attachment.pdf' TO w_content_id.
w_content_type = ' '.
w_obj_len = w_doc_size.
* Add as attachment the PDF
CALL METHOD obj_doc_bcs->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = w_content_id
i_attachment_size = w_obj_len
i_att_content_hex = it_solix.
* add the email address.
obj_recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = 'zzzz@gmail.com' ).
obj_bcs->add_recipient( i_recipient = obj_recipient ).
* Statut change
MOVE 'N' TO w_status.
CALL METHOD obj_bcs->set_status_attributes
EXPORTING
i_requested_status = w_status.
* Send the mail.
obj_bcs->send( ).
* Commit Work.
IF sy-subrc EQ space.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
END-OF-SELECTION.
Thank You.
Hi Moulika,
of course you need a smartform delivered before trying it
START-OF-SELECTION.
* My Smartforms.
MOVE 'ZMY_SMARTFORMS' TO w_formname.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSMARTFORM99' <--- This one needs to replaced!!
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = w_funcname
.
But this is a very basic, so please work through the official help provided by SAP, there are also a lot examples included. Also Send Smartforms per Mail.
Here is the link:
Introduction - SAP Smart Forms (BC-SRV-SSF) - SAP Library
~Florian
Hi Moulika,
check at this line, if you really got the table filled with data to convert. If not, you have to check the smartforms error.
** Convert the OTF to PDF.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
These you can easiliy check by using transaction Smartform_trace (perhaps its smartforms_trace, I don't know yet exactly)
Did you set a breakpoint at the message raising yet? That would be very helpful to find the issue.
And please, share your error-message (class + Message) with us. It is really hard to suggest things by just having a few infos.
~Florian
Firstly, Olaf many thanks for your example. I have this working with minimum extra effort.
However, I have one unresolved issue - in the smartform there is a graphic (logo) and this is not being emailed - the received email has white space where the logo should appear. Does anybody have any ideas about this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First, I will thank Oaf's suggest and help for mail function~
Then, The original post have a question for dynamically to show JPG files in the smartforms.
To this, you can set condition in your node, for example: Graphics Node.
In every node in smartforms, it contain a slice "Condition", in there, you can set the condition which you want to show this node.
for example: if the graphic is jack's sign-name, and jack's sap id is SAP_JACK,
you can set the graphics's condition as : sy-uname = 'SAP_JACK'.
So, only when SAP_JACK login and execute the smartform, the graphic will show out, otherwise will not show~
May it can help you~
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi all,
i am sending shipment details smartform via email through standard transaction.the moment when i configure output type in VT02N,with dispatch time 4(immediatly print)it is throwing error 'update was terminated'.
i have checked in OSS note for the above error.
Note 86147 -
but my requirement is not to set the printer, it should go mail directly,can anyone tell me about how to delete default printer setting from smartform
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Everybody,
I have used the code in my driver program suggested by Olaf. But I am facing a little problem. When I am starting the send process in scot I am receiving a mail in my workplace mail box with the following message-
The following status was received for the document <New Purchase Order Printout> sent by you to the recipient <REMOVED BY MODERATOR - DON'T WRITE DOWN E-MAILS>:
<Cannot process message in SAP System>.
Can any body help me???
Edited by: Alvaro Tejada Galindo on Dec 26, 2008 11:15 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello people,
thank i advance for this posts, i have implemented in my system and works very well, but i have a question, can i use a distribution list for the recepient?
Thanks
AOL
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
I also would like to send a smartform via email, I changed my code based on Olaf's example, got no error, just a
"MAIL request 00000000000xx created successfully"
message. (xx -> an increasing number)
And nothing happens.
I checked the TA SCOT to see any mail movement/error occurs or not. But there is neither error, nor successfully mail send.
What could be the problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
I am able to get mail in SAP Inbox (IP type ID B)with Smartform body but when I use external mail (IP type ID U), User gets e-mail to company mail Id but not smartform attachment - form is missing.
I would appreciate any help.
Thanks in advance.
-Bharat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bharat,
Check out your SAPConnect configuration (transaction SCOT). You need to specify which document extensions you want to send to your partners. You currently have .OTF (SAP internal SAPScript format) enabled so SAP wont do the conversion.
The config is slightly different between 4.6 and 4.7 (at first glance, it seems they have stripped some of the functionality in 4.7 to make it simpler) but essentially you need to choose the document type you wish to send to your partners according to the SAP document (Smartform, ABAP list, etc.).
This thread is starting to get a bit long, can I suggest that if you have further questions that you start a new one.
Cheers,
Brad
Message was edited by: Brad Williams
That was a typo on my part, I did try a 'C' and it doesn't work. Any other suggestions on how I can use this for a distribution list would be appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I forgot to mention that under call function 'CREATE_RECIPIENT_OBJ_PPF', I tried entering the distribution list under IP_MAILADDR and 'S' under IP_TYPE_ID, but this did not seem to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've got it working now - thanks for your help! One last question. I have already defined distribution lists in SAP. Is there somewhere that I can enter the distirbution list name to send the e-mail to rather than the individual e-mail addresses?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is this in 4.6C? If not does anybody have any hints for me on how to email a smartform in 4.6C?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you want to mail to a sap-user or to an external internet mail address?
- For sap-user as recipient you will have to change the
parameter for <b>ip_type_id</b> of the
function 'CREATE_RECIPIENT_OBJ_PPF' to either <b>B
</b> or <b>O</b>.
- the internet mail address has to be in complete form like name@company.com, in variable g_mail (as in my coding snippet)
I would also like to see some example code of how to email a smartform using the function generated by smartforms.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
well I try to explain what you need to mail a smartform.
Here is a part of the function call:
...
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 ...
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
Olaf
Code Formatted by: Alvaro Tejada Galindo on Dec 26, 2008 11:14 AM
Hi,
sorry i forgot the declarations
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.
Please try again
Thanks, Olaf.
But I'm sorry, it is not working for me. I go to SCOT and nothing is there. We do already have SAPConnect working because we send emails from SAP.
I'll keep messing around and see if I can get it to work. Does seem like this process would be more simple - but then it wouldn't be SAP.
within the output_options of the Smartforms function
you can give the mail title like this
g_output-tdtitle = titel.
(I refer to my code example upwards.)
You can create your specific titel before you call your function.
I don't think there is a possibility to add a mail content when mailing a smartform directly. If you have to give your own content to your mail, you will have to create a PDF-File out of your smartform before and mail it with fm SO_NEW_DOCUMENT_ATT_SEND_API1 afterwards.
There have been quite good hints for using this FM.
Regards Olaf
Well what I've used several times is the function CONVERT_OTFSPOOLJOB_2_PDF to convert the smartform spool output to a pdf and attach this one to the email. Unfortunately you have to transfer the output table of the function to a mail attachable format (the function returns a table of type tline, the email function SO_NEW_DOCUMENT_ATT_SEND_API1 needs a table of type solisti1).
Hope it helps...
Regards
Roger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Roger, thanks for your reply. Unfortunately I do not want to use the API1 fm. I would like to use the internal email parameters supplied with SMARTFORMS. Also I'm trying to show a graphic dynamically with no success so far. If that's not possible then show the URL of the graphic in a hypertext format.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.