cancel
Showing results for 
Search instead for 
Did you mean: 

How to send smartform as an email or fax

Former Member
0 Kudos

Hi Friends,

Problem is i am getting smartform output, but how to send the output as an email or fax( say for ex it should be sent to vendor). Also kindly explain how to convert smartform to PDF output. Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Satyesh,

Use the following function module(CONVERT_OTF) to convert Samrtform output to PDF:


DATA: v_size TYPE i,
          
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname = 'Z_SMTF'
    IMPORTING
      fm_name  = v_fname.

  CALL FUNCTION v_fname
    EXPORTING
      control_parameters = x_ctrl_p
    IMPORTING
      job_output_info    = x_output_data.

  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
      max_linewidth         = 134
    IMPORTING
      bin_filesize          = v_size
    TABLES
      otf                   = x_output_data-otfdata
      lines                 = it_lines
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      OTHERS                = 4.

Ashvender

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Look at thi sblog, this is well explained about the Smartforms to send as a Fax and email ..

/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp

and also look at this thread

Regards

Sudheer

Former Member
0 Kudos

Local data:

DATA:

ls_control_param TYPE ssfctrlop, "Control paramters

ls_output_options TYPE ssfcompop. "Output options

  • Data for email smart form:

DATA:

lv_ip_mailaddr TYPE so_name, "Address of a Mail Recipient

lv_ip_type_id TYPE so_escape, "Recipient type

ls_recipient_id TYPE swotobjid, "Structure for recvr obj ID

ls_sender_id TYPE swotobjid. "Structure for sender obj id

  • Constants:

CONSTANTS:

lc_ip_type_id TYPE so_escape VALUE 'U', "For internet address.

lc_smartform TYPE tdsfname VALUE 'ZVSF_ASN_DELNOTE', "Smart form name

lc_mail TYPE tddevice VALUE 'MAIL'. "Mail device

  • Assign recipient

lv_ip_mailaddr = gv_smtp_addr. "CSAM email id

lv_ip_type_id = lc_ip_type_id. "External address

  • Create Mail title

CONCATENATE text-001

nast-objky

INTO ls_output_options-tdtitle.

  • Create recipient object

CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'

EXPORTING

ip_mailaddr = lv_ip_mailaddr

ip_type_id = lv_ip_type_id

IMPORTING

ep_recipient_id = ls_recipient_id

EXCEPTIONS

invalid_recipient = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

  • Get sender object id.

CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'

EXPORTING

ip_sender = sy-uname

IMPORTING

ep_sender_id = ls_sender_id

EXCEPTIONS

invalid_sender = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

  • Assign the smart form name

w_ssfname = lc_smartform.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = w_ssfname

IMPORTING

fm_name = lf_fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

  • Control parameters.

  • For Print output:

IF nast-nacha = '1'. "Print output

ls_control_param-preview = 'X'.

ls_control_param-no_dialog = 'X'.

ENDIF.

  • For fax/email output.

IF nast-nacha = '2'. "Fax/Email

  • Output options

ls_output_options-tdteleland = gs_kna1-land1.

ls_output_options-tdtelenum = gs_kna1-telfx.

ls_output_options-tdfaxuser = sy-uname.

ls_output_options-BCS_COMMIT = 'X'.

ls_control_param-device = lc_mail.

ENDIF.

  • dynamically call Fm behind the Smart form

CALL FUNCTION lf_fm_name

EXPORTING

control_parameters = ls_control_param

mail_recipient = ls_recipient_id

mail_sender = ls_sender_id

output_options = ls_output_options

user_settings = ' '

TABLES

delivery = gt_delivery

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • Error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

IF NAST-NACHA = '2'.

ls_control_param-device = 'TELEFAX'.

CALL FUNCTION lf_fm_name

EXPORTING

control_parameters = ls_control_param

  • mail_recipient = ls_recipient_id

  • mail_sender = ls_sender_id

output_options = ls_output_options

user_settings = ' '

TABLES

delivery = gt_delivery

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • Error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

ENDIF.

Local data:

DATA:

ls_control_param TYPE ssfctrlop, "Control paramters

ls_output_options TYPE ssfcompop. "Output options

  • Data for email smart form:

DATA:

lv_ip_mailaddr TYPE so_name, "Address of a Mail Recipient

lv_ip_type_id TYPE so_escape, "Recipient type

ls_recipient_id TYPE swotobjid, "Structure for recvr obj ID

ls_sender_id TYPE swotobjid. "Structure for sender obj id

  • Constants:

CONSTANTS:

lc_ip_type_id TYPE so_escape VALUE 'U', "For internet address.

lc_smartform TYPE tdsfname VALUE 'ZVSF_ASN_DELNOTE', "Smart form name

lc_mail TYPE tddevice VALUE 'MAIL'. "Mail device

  • Assign recipient

lv_ip_mailaddr = gv_smtp_addr. "CSAM email id

lv_ip_type_id = lc_ip_type_id. "External address

  • Create Mail title

CONCATENATE text-001

nast-objky

INTO ls_output_options-tdtitle.

  • Create recipient object

CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'

EXPORTING

ip_mailaddr = lv_ip_mailaddr

ip_type_id = lv_ip_type_id

IMPORTING

ep_recipient_id = ls_recipient_id

EXCEPTIONS

invalid_recipient = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

  • Get sender object id.

CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'

EXPORTING

ip_sender = sy-uname

IMPORTING

ep_sender_id = ls_sender_id

EXCEPTIONS

invalid_sender = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

  • Assign the smart form name

w_ssfname = lc_smartform.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = w_ssfname

IMPORTING

fm_name = lf_fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

  • Control parameters.

  • For Print output:

IF nast-nacha = '1'. "Print output

ls_control_param-preview = 'X'.

ls_control_param-no_dialog = 'X'.

ENDIF.

  • For fax/email output.

IF nast-nacha = '2'. "Fax/Email

  • Output options

ls_output_options-tdteleland = gs_kna1-land1.

ls_output_options-tdtelenum = gs_kna1-telfx.

ls_output_options-tdfaxuser = sy-uname.

ls_output_options-BCS_COMMIT = 'X'.

ls_control_param-device = lc_mail.

ENDIF.

  • dynamically call Fm behind the Smart form

CALL FUNCTION lf_fm_name

EXPORTING

control_parameters = ls_control_param

mail_recipient = ls_recipient_id

mail_sender = ls_sender_id

output_options = ls_output_options

user_settings = ' '

TABLES

delivery = gt_delivery

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • Error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

IF NAST-NACHA = '2'.

ls_control_param-device = 'TELEFAX'.

CALL FUNCTION lf_fm_name

EXPORTING

control_parameters = ls_control_param

  • mail_recipient = ls_recipient_id

  • mail_sender = ls_sender_id

output_options = ls_output_options

user_settings = ' '

TABLES

delivery = gt_delivery

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • Error handling

cf_retcode = sy-subrc.

PERFORM protocol_update.

ENDIF.

ENDIF.

Former Member
0 Kudos

Hi,

Follow below steps in the main program:

1. Set print parameters.

2. Use the below code in step 2,

IF ENT_RETCO = 3 AND

NAST-NACHA = '5'.

ENT_RETCO = 0.

LS_CONTROL_PARAM-GETOTF = 'X'.

LS_CONTROL_PARAM-NO_DIALOG = 'X'.

LS_CONTROL_PARAM-PREVIEW = 'X'. "SCREEN.

LS_CONTROL_PARAM-LANGU = NAST-SPRAS.

ENDIF.

3. Use FM SSF_FUNCTION_MODULE_NAME

4. lastly use FM LF_FM_NAME

Regards,

Azaz Ali.