Skip to Content
author's profile photo Former Member
Former Member

Sending PO by email with text message body

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on May 31, 2012 at 10: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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Sachin Adak

      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


Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.