on 01-23-2007 10:20 AM
Hi
I need mail a sapscript form on clivk of save button in transaction vt02n.I have created an o/p type in Nace but the mail dosen't get triggered on click of save button.I created another output type that prints the form on clicking the save button.This works properly so I assume that all the configurations in SPRO are done properly..Also I am able to send mails to internet addresses if I execute a seperate program .That means that there are no problem in the scot settings.
Can someone please suggest what could be wrong and what should I do to trigger the mail
Thanks in advance
HI,
the mail config data i mean the NAcha value of NASt table is not populated properly in this case . there will be no other issue coz as u said it is working with other output type .so plz recheck the output type defined correctly or not
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi I am using the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' for mailing.
The code that I am using for converting the sapscript into pdf and mailing is given below.
&----
*& Report Z_SCRIPT *
*& *
&----
*& *
*& *
*&----
Report Z_SCRIPT.
DATA: itcpo LIKE itcpo,
tab_lines LIKE sy-tabix.
Variables for EMAIL functionality
DATA: maildata LIKE sodocchgi1.
DATA: mailpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: mailhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: mailbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: mailtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: mailrec LIKE somlrec90 OCCURS 0 WITH HEADER LINE.
DATA: solisti1 LIKE solisti1 OCCURS 0 WITH HEADER LINE.
PERFORM send_form_via_email.
************************************************************************
FORM SEND_FORM_VIA_EMAIL *
************************************************************************
FORM send_form_via_email.
CLEAR: maildata, mailtxt, mailbin, mailpack, mailhead, mailrec.
REFRESH: mailtxt, mailbin, mailpack, mailhead, mailrec.
Creation of the document to be sent File Name
maildata-obj_name = 'TEST'.
Mail Subject
maildata-obj_descr = 'Subject'.
Mail Contents
mailtxt-line = 'Here is your file'.
APPEND mailtxt.
Prepare Packing List
PERFORM prepare_packing_list.
Set recipient - email address here!!!
mailrec-receiver = 'XYZ@ABC.COM'.
mailrec-rec_type = 'U'.
APPEND mailrec.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = maildata
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = mailpack
object_header = mailhead
contents_bin = mailbin
contents_txt = mailtxt
receivers = mailrec
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
ENDFORM.
************************************************************************
Form PREPARE_PACKING_LIST
************************************************************************
FORM prepare_packing_list.
CLEAR: mailpack, mailbin, mailhead.
REFRESH: mailpack, mailbin, mailhead.
DESCRIBE TABLE mailtxt LINES tab_lines.
READ TABLE mailtxt INDEX tab_lines.
maildata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( mailtxt ).
Creation of the entry for the compressed document
CLEAR mailpack-transf_bin.
mailpack-head_start = 1.
mailpack-head_num = 0.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'RAW'.
APPEND mailpack.
Creation of the document attachment
This form gets the OTF code from the SAPscript form.
If you already have your OTF code, I believe that you may
be able to skip this form. just do the following code, looping thru
your SOLISTI1 and updating MAILBIN.
PERFORM get_otf_code.
LOOP AT solisti1.
MOVE-CORRESPONDING solisti1 TO mailbin.
APPEND mailbin.
ENDLOOP.
DESCRIBE TABLE mailbin LINES tab_lines.
mailhead = 'TEST.OTF'.
APPEND mailhead.
Creation of the entry for the compressed attachment
mailpack-transf_bin = 'X'.
mailpack-head_start = 1.
mailpack-head_num = 1.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'OTF'.
mailpack-obj_name = 'TEST'.
mailpack-obj_descr = 'Subject'.
mailpack-doc_size = tab_lines * 255.
APPEND mailpack.
ENDFORM.
************************************************************************
Form GET_OTF_CODE
************************************************************************
FORM get_otf_code.
DATA: BEGIN OF otf OCCURS 0.
INCLUDE STRUCTURE itcoo .
DATA: END OF otf.
DATA: itcpo LIKE itcpo.
DATA: itcpp LIKE itcpp.
CLEAR itcpo.
itcpo-tdgetotf = 'X'.
.
Start writing OTF code
CALL FUNCTION 'OPEN_FORM'
EXPORTING
device = 'PRINTER'
form = 'Z_ASH_FRM1'
options = itcpo
dialog = ' '
EXCEPTIONS
exceptions
canceled = 1
device = 2
form = 3
options = 4
unclosed = 5
others = 6.
CALL FUNCTION 'START_FORM'
EXCEPTIONS
error_message = 01
OTHERS = 02.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
window = 'MAIN'
EXCEPTIONS
error_message = 01
OTHERS = 02.
Close up Form and get OTF code
CALL FUNCTION 'END_FORM'
EXCEPTIONS
error_message = 01
OTHERS = 02.
MOVE-CORRESPONDING itcpo TO itcpp.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
result = itcpp
TABLES
otfdata = otf
EXCEPTIONS
OTHERS = 1.
Move OTF code to structure SOLI form email
CLEAR solisti1. REFRESH solisti1.
LOOP AT otf.
solisti1-line = otf.
APPEND solisti1.
ENDLOOP.
ENDFORM.
Hi ,
the code u have mentioned is the right but im talking about the code that is responsible for triggering the mail
&----
*& Form nacha_5
&----
Send the Form as an Email
----
-->P_FOUND Flag 'X' if sub routine is found
----
FORM nacha_5 USING write_out TYPE xfeld
CHANGING p_found TYPE xfeld.
DATA : lv_mail_id TYPE so_name,
lv_mail_tp TYPE so_escape VALUE 'U',
l_subrc TYPE sy-subrc.
p_found = 'X'.
Get the Mail ID from the Control Table
lv_mail_id = t_ctrl_app-recipient.
Create The Recipient Object
CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
EXPORTING
ip_mailaddr = lv_mail_id
ip_type_id = lv_mail_tp
IMPORTING
ep_recipient_id = w_recipient
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF write_out = 'X'.
FORMAT COLOR 6.
WRITE AT /5 text-001.
ENDIF.
RAISE other.
ENDIF.
Create The Sender Object
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
EXPORTING
ip_sender = sy-uname
IMPORTING
ep_sender_id = w_sender
EXCEPTIONS
invalid_sender = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF write_out = 'X'.
FORMAT COLOR 6.
WRITE AT /5 text-002.
ENDIF.
RAISE other.
ENDIF.
Populate the Control Data & Title
w_sf_control-device = 'MAIL'.
w_sf_control-no_dialog = 'X'.
w_sf_control-langu = t_ctrl_app-spras.
***************************************************
Nacha = 2
Populate the Fax Number and the country.
Data : lv_fax_tp TYPE so_escape VALUE 'F',
lv_fax = t_ctrl_app-recipient.
lv_land1 = t_ctrl_app-country.
Create the Recipient Object
CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
EXPORTING
ip_country = lv_land1
ip_faxno = lv_fax
ip_type_id = lv_fax_tp
IMPORTING
ep_recipient_id = w_recipient
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF write_out = 'X'.
FORMAT COLOR 6.
WRITE AT /5 text-004.
ENDIF.
RAISE other.
ENDIF.
Create The Sender Object
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
EXPORTING
ip_sender = sy-uname
IMPORTING
ep_sender_id = w_sender
EXCEPTIONS
invalid_sender = 1
OTHERS = 2.
IF sy-subrc NE 0.
IF write_out = 'X'.
FORMAT COLOR 6.
WRITE AT /5 text-003.
ENDIF.
RAISE other.
ENDIF.
Populate the Control Data
w_sf_control-device = 'TELEFAX'.
w_sf_control-no_dialog = 'X'.
w_sf_control-langu = t_ctrl_app-spras.
Populate the Output Options.
w_output_options-tdteleland = lv_land1.
w_output_options-tdtelenum = lv_fax.
w_output_options-faxformat = 'PS'.
The above code should be included in the print program so that when the value in the output of the transaction is defined as mail and saved the mail is sent automatically.
as u rightly said , when u run Driver Program it works fine , but when u run from tcode its not going ?
That means problem with ur output types , Access Sequence , Condition on what basis it will pick this Driver program along with ur Output Type.
So tell me, what print media u are using ? .
2.What are the septs ur taking in case of MAIL output ?
3.Have u Debugged the Driver Program when u give output type of MAIL ?
4.Control is going to Driver program or not ?
5.If yer , what is the SY-SUBRC of that FM ?
Regards
Prabhu
Hi,
the logic is u need to include this code and check the SCOT settings (this is functional work developer has nothing to do in it).once the scot settings are available.
u can generate a automated mail when the mail option output is defined in the transaction.
the system will pick the sy-user(sap user) as sender and distribution list or a single email id as the reciever and the mail is delivered accordingly.
i used the same code and it is working .hop it works with u also
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.