cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform Email

Former Member
0 Kudos

I am sending a smartform through email. It is a report.

I am using the email options in smartform function itself and not doing any conversions to pdf.

I am able to receive the smartform as pdf in email but its a blank pdf. The templates are there but no data.

I am searching through all the forums and it is obvious that everyone is converting the OTF file to PDF and then sending it through another email FM.

But why there is an email function in smartform?

And why I am receiving the blank pdf ?

Can anybody help me on this ?

Thanks,

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

first convert smart form output as pdf format by executing program "RSTX PDF4"

then call the f.m SO_NEW_DOCUMENT_SEND_API1

Former Member
0 Kudos

Hi

Check my post in this following thread.

Regards,

Sravanthi

Former Member
0 Kudos

Hi Arbaab,

I was quite surprised for the same reason a few days ago. I've sorted out a way to get this done, dough I would like the community to comment my approach.

This method involves the use of the mail_recipient and mail_sender parameters of the calling smartform function.

First you can see here the regular code in the main program:


  data: p_email type ad_smtpadr.

  constants: c_form type tdsfname value 'ZSOME_SMARTFORM'.
  data: l_func type rs38l_fnam.
  data: l_appl type swotobjid.
  data: l_receiver type swotobjid.
  data: l_sender type swotobjid.
  data: l_control type ssfctrlop.
  data: l_output type ssfcompop.

*get smartform function
  call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
      formname           = c_form
    importing
      fm_name            = l_func
    exceptions
      no_form            = 1
      no_function_module = 2
      others             = 3.
  if sy-subrc <> 0.
    message e897(sd) with 'Error finding smartform' c_form.
  endif.

*sent message to email
  l_control-device = 'MAIL'.

*prepare send&receive recipient's
  call function 'Z_EMAIL_CREATE_BOR'
    exporting
      uname             = p_uname
      email_recipient   = p_email
    importing
      sender_id         = l_sender
      recipient_id      = l_receiver.

*Call smartform
  call function l_func
    exporting
      control_parameters = l_control
      mail_recipient     = l_receiver
      mail_sender        = l_sender
    exceptions
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      others             = 5.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  else.
    write: / 'Success!'.
  endif.
*It needs a commit
  commit work and wait.

So, it's a quite simple main program. Now for the hard part, the recipient construction function:



function z_email_create_bor.
*"----------------------------------------------------------------------
*"*"Interface local:
*"  IMPORTING
*"     REFERENCE(UNAME) TYPE  SY-UNAME OPTIONAL
*"     VALUE(EMAIL_RECIPIENT) TYPE  SOXNA-FULLNAME
*"  EXPORTING
*"     REFERENCE(SENDER_ID) TYPE  SWOTOBJID
*"     REFERENCE(RECIPIENT_ID) TYPE  SWOTOBJID
*"----------------------------------------------------------------------

  data: l_uname like sy-uname.
  if uname is initial.
    l_uname = sy-uname.
  else.
    l_uname = uname.
  endif.

  data:  sender         type swc_object,
         recipient      type swc_object.       
  
  swc_container container.

*SENDER - it's a user
  swc_create_object sender 'RECIPIENT' space.
  swc_clear_container container.
  swc_set_element container 'AddressString' l_uname.
  swc_set_element container 'TypeId' 'B'.
  swc_call_method sender 'FindAddress' container.
  if sy-subrc ne 0.
    message id sy-msgid type 'E' number sy-msgno.
  endif.
  swc_object_to_persistent sender sender_id.

*RECEIVER - it's an email address
  swc_create_object recipient 'RECIPIENT' space.
  swc_clear_container container.
  swc_set_element container 'TypeId' 'U'.
  swc_set_element container 'AddressString' email_recipient.
  swc_call_method recipient 'CreateAddress' container.
  if sy-subrc ne 0.
    message id sy-msgid type 'E' number sy-msgno.
  endif.
  swc_object_to_persistent recipient recipient_id.
endfunction.

You'll have to add the include <CNTN01> to the function group.


include: <cntn01>.

I find this a neat and clean approach, but I don't feel too comfortable with the call to SWO_CREATE function in the swc_create_object macro.

Please comment, whomever have a say on this.

0 Kudos

Hey , I was searching for this since hours! thanks a lot for your example . It works well!

Florian
Active Contributor
0 Kudos

Hi unnati,

no need to do it in that way. Have a look in TA SODIS

~Florian

0 Kudos

hi florian,

   i just went through this link -

http://scn.sap.com/people/hagen.dittmer/blog/2011/09/26/the-full-disclosure--sodis-email-disclosure-...

seems pretty cool

-unnati