Application Development and Automation 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: 
Read only

Smartform as attachment

Former Member
0 Likes
2,076

Hi!

The PO from ME23N is being sent via email through special function (transmission medium = 8). It is working fine except that the output opens directly when you display the message in SOST rather than being a PDF attachment. The other issue with this is the email size. It is noticeably larger with the output not as an attachment.

Can anyone share how to ensure that the output will be attached rather than being an 'in-line' email?

Thanks!

Cholen

1 ACCEPTED SOLUTION
Read only

rosenberg_eitan
Active Contributor
0 Likes
1,785

Hi,

- Please check how it comes at the final destination (Outlook)

(IMHO you will be surprised).

- See here http://scn.sap.com/community/abap/blog/2014/08/07/the-case-of-sending-mail-with-graphs

Program Y_R_EITAN_TEST_10_06 FORM mail_1_prep_5 (send a smart form as attachment)

Regards.

5 REPLIES 5
Read only

Former Member
0 Likes
1,785

Hi Cholen,

You need to apply the logic to send attachment as PDF.

First get the spool number which gets generated when the print is performed.

Convert the spool to PDF using FM FPCOMP_CREATE_PDF_FROM_SPOOL.

Attach the generated PDF using OO concept to the mail

Thanks

Kishan


Read only

0 Likes
1,785

Hi Kishan,

Sorry for the ignorance but how do I get the spool number? As I've mentioned, the email is already being sent except that the output itself is not attached. I checked on some messages in SOST, the document class is OTF while others that have attachment have theirs as RAW. If you can guide me further, that would really be awesome!

Cholen

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,786

Hi,

- Please check how it comes at the final destination (Outlook)

(IMHO you will be surprised).

- See here http://scn.sap.com/community/abap/blog/2014/08/07/the-case-of-sending-mail-with-graphs

Program Y_R_EITAN_TEST_10_06 FORM mail_1_prep_5 (send a smart form as attachment)

Regards.

Read only

0 Likes
1,785

Hi Cholen,

To send smart form as attachment in PDF format you need to convert into 'PDF' using FM 'CONVERT_OTF_2_PDF'.  To send as email you can use CL_BCS classes. Please refer standard program 'BCS_EXAMPLE_8'  to send PDF as email. You can modify the logic as per your requirement.

Regards,

Santosh

Read only

Former Member
0 Likes
1,785

I am trying to follow you recommendations but there is no email being sent with my changes. I copied the existing codeI restricted this for a particular company code for testing. The modification I've done are as follows:


....

  IF l_doc_xekko = '1000'.

  DATA: st_control_parameters TYPE ssfctrlop .

  DATA: st_output_options     TYPE ssfcompop .

  DATA: st_job_output_info    TYPE ssfcrescl .

  st_control_parameters-getotf = 'X'.

  st_control_parameters-no_dialog = 'X'.

    CALL FUNCTION lf_fm_name

      EXPORTING

        control_parameters = st_control_parameters

        output_options     = st_output_options

        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    = st_job_output_info

      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.

    DATA: bin_filesize TYPE i,

               bin_file  TYPE xstring,

               tlines  TYPE TABLE OF tline.

   CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

      format                = 'PDF'

    IMPORTING

      bin_filesize        = bin_filesize

      bin_file              = bin_file

    TABLES

      otf                   = st_job_output_info-otfdata

      lines                = tlines

    EXCEPTIONS

      err_max_linewidth     = 1

      err_format                 = 2

      err_conv_not_possible = 3

      err_bad_otf                 = 4

      OTHERS                    = 5.


ELSE.

  >> original code that is working with email but not as PDF attachment.



I suppose I have to add the BCS code? But how to do it, I'm not familiar especially with the parameters.I hope you can help me.



Thanks,

Cholen