cancel
Showing results for 
Search instead for 
Did you mean: 

HR: Send Salary Receipt, as PDF form, by EMAIL

valter_oliveira
Active Contributor
0 Kudos

Hello friends,

Soon I'm having the requirement of sending the employee salary receipt (and probably anual income declaration), as a PDF document, by email. I think it can be done with SAP XI, changing the print program of the current smartform, to send an assyncronous message with an attachment, to employee email.

But I want to know if there is a better way (with some customizing). After searching, I found that I will need to create infotype 105 (comunication), subtype 0010 (email) to mantain employee email. However, I could not find any automatic way to create the pdf and send by email (like output type '5' - external send - in sales order, for example, where the system automatically send the script/smartform by email, converting automatically to pdf).

Any ideas?

Thanks in advance.

Regards,

Valter Oliveira.

Edited by: Valter Oliveira on Oct 8, 2008 9:42 AM

Accepted Solutions (0)

Answers (3)

Answers (3)

valter_oliveira
Active Contributor
0 Kudos

I developed a report. There is no other way.

Thanks.

jazib_tariq
Active Participant
0 Kudos

Hello Valter Oliveira kindly share that program with me also.

Former Member
0 Kudos

Hi,

This is the code to send email directly from Print Program

  • Get smartforms z_goods_receipt FM name.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'Z_QUALITY_NOTIFICATION'

IMPORTING

fm_name = fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

  • Check for the error in the previous call.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ssfcompop-tdnewid = 'X'.

ssfctrlop-no_dialog = 'X'.

ssfctrlop-preview = 'X'. " TO-DO COMMENT this line

ssfctrlop-getotf = 'X'.

  • ssfctrlop-device = 'TELEFAX'.

  • ssfctrlop-langu = sy-langu.

CLEAR ssfcompop.

SELECT SINGLE land1 FROM lfa1

INTO aux_land1 WHERE lifnr = stru_qn-vendor.

  • Set the printer parameters.

ssfcompop-tdnoprev = 'X'. " No print preview

ssfcompop-tdnoprint = ''. " No printing from print preview

ssfcompop-tdimmed = 'X'.

ssfcompop-tddelete = 'X'.

ssfcompop-tddest = p_tddest.

ssfcompop-tdnewid = 'X'.

IF stru_qn-ven_contact_fax IS NOT INITIAL.

ssfcompop-tdteleland = aux_land1.

ssfcompop-tdtelenum = stru_qn-ven_contact_fax.

ssfcompop-faxformat = 'PS'.

ENDIF.

CALL FUNCTION fm_name

EXPORTING

control_parameters = ssfctrlop

output_options = ssfcompop

user_settings = ''

p_qn = stru_qn

IMPORTING

job_output_info = output_data

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.

ENDIF.

  • CONVERT THE OTF INTO PDF.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = l_pdf_len

TABLES

otf = output_data-otfdata

lines = lt_lines

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

  • To pass PDF data to the email function module

LOOP AT lt_lines INTO wa_lines.

TRANSLATE wa_lines USING '~'.

CONCATENATE wa_buffer wa_lines INTO wa_buffer.

ENDLOOP.

TRANSLATE wa_buffer USING '~'.

DO.

i_record = wa_buffer.

APPEND i_record.

SHIFT wa_buffer LEFT BY 255 PLACES.

IF wa_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

i_objtxt-line = 'Please find the attached Quality Notification'.

APPEND i_objtxt.

DESCRIBE TABLE i_objtxt LINES v_lines_txt.

READ TABLE i_objtxt INDEX v_lines_txt.

DESCRIBE TABLE i_record LINES aux_num.

READ TABLE i_record INDEX aux_num.

  • Create body of the message

wa_doc_chng-obj_name = 'smartform'.

wa_doc_chng-obj_langu = sy-langu.

wa_doc_chng-expiry_dat = sy-datum + 10.

wa_doc_chng-obj_descr = 'EMD Quality Notification'.

wa_doc_chng-sensitivty = 'F'.

wa_doc_chng-doc_size = ( aux_num - 1 ) * 255 + STRLEN( i_objtxt-line ).

  • Body Text

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

i_objpack-body_num = v_lines_txt.

i_objpack-doc_type = 'RAW'.

APPEND i_objpack.

  • PDF Attachment

i_objpack-transf_bin = 'X'.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

i_objpack-doc_size = ( aux_num - 1 ) * 255 + STRLEN( i_record-line ).

i_objpack-body_num = aux_num.

i_objpack-doc_type = 'PDF'.

i_objpack-obj_name = 'smart'.

i_objpack-obj_descr = 'Quality Notification'.

i_objpack-obj_langu = sy-langu.

APPEND i_objpack.

aux_rec-address = 'XXXX'.

  • To pass the email address of the vendor to send email

  • i_reclist-receiver = stru_qn-ven_contact_email.

i_reclist-receiver = aux_rec.

i_reclist-express = 'X'.

i_reclist-rec_type = 'U'.

APPEND i_reclist.

CLEAR i_reclist.

  • To send email from smartform

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = wa_doc_chng

put_in_outbox = 'X'

TABLES

packing_list = i_objpack

contents_bin = i_record

contents_txt = i_objtxt

receivers = i_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8

.

valter_oliveira
Active Contributor
0 Kudos

Thanks Srinivasu,

If I cannot customize system to automatically send the standard HR form (not script, not smartform, it uses tcode PE51) I will have to do something very similar to what you have proposed in your post. That's a good way ... create the smartform, spool it, convert spool to PDF file, and send PDF file by email using the API.

But I will still trying to find a solution to avoid creating the smartform, because this one is a very very complex one (hundreds of HR wage types). If not, use your approach no doubt.

Regards,

Valter Oliveira.

Former Member
0 Kudos

Hi Boss,

For this program configurations is needed boss, so what is the T.code you are using ?. In that t.code you suppose to maintain the e-mail address . 2 or 3 configurations is needed.

Let me know incase of any issues.

With Regards,

Narasimha Rao.

valter_oliveira
Active Contributor
0 Kudos

Hi Narashima,

Thanks for the reply. I'm using standard report RPCEDTP0 to print the Remuneration Statement. Form name is PF01.

Tcode of the form: PC00_M19_CEDT. Tcode of the email maintnance: PA30.

In first post I made a mystake. Currently it's not a smartform, nor script. Standard program is giving a report .. and that report is the one that is printed! Perhaps I can manage a smartform and set type external send in receivers ...

Regards,

Valter Oliveira.

Edited by: Valter Oliveira on Oct 8, 2008 10:57 AM