Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Which program is run when mail sending is triggered for Purchase Order

almedin_hodzic53
Participant
0 Kudos
872

I set my purchase order to send mail when it is saved. Mail is sent with pdf and it works fine. But, I want to attach some custom documents in the mail, and my question is which program or BTE or anything is run for mail sending.

Kind regards.

1 ACCEPTED SOLUTION

jack_graus2
Active Contributor
726

You can check this by transaction NACE for application EF and output type Z101.

9 REPLIES 9

jack_graus2
Active Contributor
727

You can check this by transaction NACE for application EF and output type Z101.

726

or table TNAPR

0 Kudos
726

Both suggestions worked. The program is SAPFM06P.

But, I fail to debug it. I put breakpoints inside include programs inside this program, but it never stops.

I am using me22n, I go to messages, then I write entries for external mail sending. It sends mail after saving, and I would like to debug when the document is attached to an email. But I fail to find and do it.

Any suggestion?

0 Kudos
726

When the PO output is processed in an update task then you either need to change the output timing in 'Output further data' from 'Send immediately' to 'Send with application own transaction' or you not set a 'Session' breakpoint but an 'External' breakpoint in the output processing program.

0 Kudos
726

alhodzic Use transaction ME9F if you want to debut it

Ryan-Crosby
Active Contributor
0 Kudos
726

There is a BADI definition 'BADI_MM_PO_OC_EMAIL', but it does not provide the capability to add additional attachments. It has methods for changing the sender, the recipients, the subject and the body of the message.

Regards,

Ryan Crosby

raymond_giuseppi
Active Contributor
0 Kudos
726

almedin_hodzic53
Participant
0 Kudos
726

I did but this can not help me completely.

Do you know maybe when the attachment is attached to mail before sending? When I debug, program FM06PE02 is opened, and form 'entry_neu' is run. But I can not see the place where an attachment is being attached. I see also some FMs inside this form, but I could not find exact place

Ryan-Crosby
Active Contributor
726

alhodzic as I had already answered... the program does not provide a mechanism for adding additional attachments - your only option is to copy and modify which should be used as a last resort. However, the code that executes to place the attachment to the email body would be something like (variances based on your system version😞

* ------------ Call BCS interface ----------------------------------
      TRY.
*   ---------- create persistent send request ----------------------
          send_request = cl_bcs=>create_persistent( ).

*   ---------- add document ----------------------------------------
*   get PDF xstring and convert it to BCS format
          lp_pdf_size = xstrlen( os_formout-pdf ).

          PERFORM xstring_to_solix
                      USING
                         os_formout-pdf.
* if BAdI is implementet create eMail with body and attach document
          IF lo_badi_mm_po_oc_email IS BOUND.
            CALL METHOD cl_document_bcs=>create_document
              EXPORTING
                i_type     = 'TXT'
                i_subject  = lv_subject
*                i_language = lv_language
                i_text     = lt_body
              RECEIVING
                result     = document .
*--- Add the document as an attachment
            CALL METHOD document->add_attachment
              EXPORTING
                i_attachment_type     = 'PDF'
                i_attachment_size     = lp_pdf_size
                i_attachment_subject  = lv_attachment_subject
*                i_attachment_language = lv_language
                i_att_content_hex     = pdf_content.

          ELSE.
            lv_subject = fp_outputparams-covtitle.
            document = cl_document_bcs=>create_document(
                  i_type    = 'PDF' " cf. RAW, DOC
                  i_hex     = pdf_content
                  i_length  = lp_pdf_size
                  i_subject = lv_subject ).                   "#EC NOTEXT
          ENDIF.

          CALL METHOD document->get_docno                   "^2805618
            RECEIVING
              result = doc_no.

          IF doc_no IS NOT INITIAL.
            sy-msgv1 = doc_no.
          ENDIF.

          IF nast-nacha EQ 5 OR nast-nacha EQ 2.
            MESSAGE i095(vn) WITH sy-msgv1 INTO mesg.
            CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
              EXPORTING
                msg_arbgb = 'VN'
                msg_nr    = '095'
                msg_ty    = 'I'
                msg_v1    = sy-msgv1
              EXCEPTIONS
                OTHERS    = 1.
          ENDIF.                                            "v2805618

*   add document to send request
          send_request->set_document( document ).