05-31-2012 10:39 AM
Hi all,
I would like to send PO by email with text message on the body of the send mail.But my program doesnt use the
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' but instead it uses 'WFMC_PREPARE_SMART_FORM .Do you know a way to achieve this?
see code snippet below to understand clearly:->
PERFORM set_print_param USING ls_addr_key
CHANGING ls_control_param
ls_composer_param
ls_recipient
ls_sender
ent_retco.
*Get the Smart Form name.
IF NOT tnapr-sform IS INITIAL.
lf_formname = tnapr-sform.
ELSE.
MESSAGE e001(ssfcomposer).
ENDIF.
* Determine smartform function module for purchase document
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* error handling
ent_retco = sy-subrc.
IF sy-subrc = 1.
MESSAGE e001(ssfcomposer).
ENDIF.
IF sy-subrc = 2.
MESSAGE e002(ssfcomposer) WITH tnapr-sform.
ENDIF.
PERFORM protocol_update_i.
ENDIF.
* if it is faxed, changed its title to PO number
IF ls_control_param-device = 'TELEFAX'.
ls_composer_param-tdtitle = l_doc-xekko-ebeln.
ENDIF.
* if it is mail, changed its title to PO number
IF l_nast-nacha = '5'.
DATA: g_mail_rec_obj TYPE swotobjid,
g_mail_sen_obj TYPE swotobjid,
g_mail_app_obj TYPE swotobjid,
folder TYPE swc_object.
PERFORM mail_recipient_object using l_doc-xekko-lifnr CHANGING g_mail_rec_obj.
PERFORM mail_sender_object CHANGING g_mail_sen_obj.
ls_control_param-device = 'MAIL'.
ls_control_param-getotf = 'X'.
ls_control_param-no_dialog = 'X'.
ENDIF.
DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
w_return TYPE ssfcrescl.
* Change of Parameters <<<<<<<<<<<<<<<<<<<<<<<
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_appl_obj = g_mail_app_obj
mail_recipient = g_mail_rec_obj
mail_sender = g_mail_sen_obj
output_options = ls_composer_param
is_ekko = l_doc-xekko
user_settings = '' "Disable User Printer
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
Job_output_info = w_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
if w_return-otfdata[] is not initial.
i_otf[] = w_return-otfdata[].
ls_control_param-device = 'MAIL'.
ls_control_param-no_dialog = 'X'.
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
* mail_appl_obj = g_mail_app_obj
mail_recipient = g_mail_rec_obj
mail_sender = g_mail_sen_obj
output_options = ls_composer_param
is_ekko = l_doc-xekko
user_settings = '' "Disable User Printer
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
Job_output_info = w_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
endif.
IF sy-subrc <> 0.
ent_retco = sy-subrc.
PERFORM protocol_update_i.
* get SmartForm protocoll and store it in the NAST protocoll
PERFORM add_smfrm_prot.
else.
clear: g_mail_rec_obj,g_mail_sen_obj.
* required for Discrete Manufacturing scenario 230
**<<<< Start of insertion >>>>*
IF l_nast-kappl eq 'EL' AND ent_screen IS INITIAL
AND l_from_memory IS INITIAL AND l_nast-sndex IS INITIAL.
IF sy-ucomm NE '9ANZ' AND sy-ucomm NE '9DPR'.
PERFORM update_release(saplmedruck)
TABLES l_doc-xekpo l_doc-xekek l_doc-xekeh
USING iv_druvo l_nast-kschl.
ENDIF.
ENDIF.
*<<<< End of insertion >>>>*
read table ls_job_info-spoolids into l_spoolid index 1.
if sy-subrc is initial.
export spoolid = l_spoolid to memory id 'KYK_SPOOLID'.
endif.
ENDIF.
*&---------------------------------------------------------------------*
*& Form set_print_param
*&---------------------------------------------------------------------*
FORM set_print_param USING is_addr_key LIKE addr_key
CHANGING cs_control_param TYPE ssfctrlop
cs_composer_param TYPE ssfcompop
cs_recipient TYPE swotobjid
cs_sender TYPE swotobjid
cf_retcode TYPE sy-subrc.
DATA: ls_itcpo TYPE itcpo.
DATA: lf_repid TYPE sy-repid.
DATA: lf_device TYPE tddevice.
DATA: ls_recipient TYPE swotobjid.
DATA: ls_sender TYPE swotobjid.
lf_repid = sy-repid.
CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
EXPORTING
pi_nast = nast
pi_addr_key = is_addr_key
pi_repid = lf_repid
IMPORTING
pe_returncode = cf_retcode
pe_itcpo = ls_itcpo
pe_device = lf_device
pe_recipient = cs_recipient
pe_sender = cs_sender.
IF cf_retcode = 0.
MOVE-CORRESPONDING ls_itcpo TO cs_composer_param.
* cs_composer_param-tdnoprint = 'X'. "Note 591576
cs_control_param-device = lf_device.
cs_control_param-no_dialog = 'X'.
cs_control_param-preview = xscreen.
cs_control_param-getotf = ls_itcpo-tdgetotf.
cs_control_param-langu = nast-spras.
ENDIF.
ENDFORM. "set_print_param
05-31-2012 11:05 AM
Hi Studantof ABAP,
You need to use FM SO_NEW_DOCUMENT_ATT_SEND_API1 for body of mail.
Please search SCN for usage of FM and related issues.
Regrds,
Sachin
Message was edited by: Sachin Adak
05-31-2012 11:05 AM
Hi Studantof ABAP,
You need to use FM SO_NEW_DOCUMENT_ATT_SEND_API1 for body of mail.
Please search SCN for usage of FM and related issues.
Regrds,
Sachin
Message was edited by: Sachin Adak
05-31-2012 12:28 PM
Hi Sachin,
I am aware that FM SO_NEW_DOCUMENT_ATT_SEND_API1 can achieve this,but currently my program can be able to send email PO as pdf attached perfectly ,my concern is that it didnt use FM SO_NEW_DOCUMENT_ATT_SEND_API1 but instead it uses ls_itcpo and fm WFMC_PREPARE_SMART_FORM see the code above .Is their a way i can retain this functions and include the body text part ?
If not then i'll will be forced to change the whole program logic to the new function SO_NEW_DOCUMENT_ATT_SEND_API1 instead of
m WFMC_PREPARE_SMART_FORM
05-31-2012 12:44 PM
Hi studentof ABAP,
Please check:
http://wiki.sdn.sap.com/wiki/display/Snippets/Program+for+SMARTFORMS+output+into+PDF
three is nothing mentioned about Text message in the body.
I think you need to change the code and use FM SO_NEW_DOCUMENT_ATT_SEND_API1 .
Best Regards
Sachin
06-12-2012 7:17 AM
THnx Sachin your
SO_NEW_DOCUMENT_ATT_SEND_API1 does work but instead
i have used BCS to implement this ,its easier to use and it uses the OOP principle.Apart from that all SAP new examples for email uses this new concept.
Thx