Skip to Content
0
Former Member
Jul 07, 2012 at 12:32 PM

Junk data getting added to the Body content for the payslip as email

18 Views

Dear Freinds,

I have developed a custom program to send the custom payslip as email. The payslip is successfuly geting in the inbox of the employee's external email as PDF attachment .

Iam facing only one problem is pertaining to body of the email , it is getting append with unwanted characters in additon to the actual contents of the body in the mail. as follows

As per the Requiremnt the Actual contents of the Body of the mail should be as follows

Dear Employee, Please find your Payslip for the month of JAN , 2012 in the attachment . Regards , Payroll Department .

Instead of the above iam getting as of now is as follows : Dear Employee, Please find your Payslip for the month of JAN , 2012 in the attachment . Regards , Payroll Department . 倥䙄ㄭ㌮਍쿣ී㈊〠漠橢਍㰼਍启灹⁥䘯湯䑴獥牣灩潴൲⼊獁散瑮㜠〲਍䌯灡效杩瑨㘠〶਍䐯獥散瑮ⴠ㜲ര⼊汆条 ⁳㈳਍䘯湯䉴潂⁸ⵛ㜱‷㈭㤶ㄠ㈱″㘸崶਍䘯湯乴浡⁥䠯汥敶楴慣䈭汯൤⼊瑉污捩湁汧⁥ര⼊瑓浥 ⁖〱വ㸊ാ攊摮扯൪㌊〠漠橢਍圯湩湁楳湅潣楤杮਍湥潤橢਍‴‰扯൪㰊഼┊敄瑶灹⁥䅓坐义†䘠湯⁴䕈噌⁅†戠汯⁤慌杮䔠ൎ⼊祔数⼠潆瑮਍匯扵祴数⼠祔数റ⼊慂敳潆瑮⼠

So could any one let me know how i can avoid this extra (unreadble characters ) characters getting append to my actual mail content in the body .

Pls help me

The code i have used is follows :

Assigning the OTFDATA to OTF Structure table

CLEAR gt_otf. gt_otf[] = wa_job_output_info-otfdata[].

* Convert the OTF DATA to SAP Script Text lines CLEAR gt_pdf_tab.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = gv_bin_filesize

TABLES

otf = gt_otf

lines = gt_pdf_tab

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.

* Assigning the Description of the object sent in the mail

CLEAR gs_docdata.

gs_docdata-obj_name = gc_tst.

* gs_docdata-obj_descr = gc_testing.

CONCATENATE 'Payslip for' gv_text INTO gs_docdata-obj_descr SEPARATED BY space.

* Assigning the email id to Structure of the API Recipient List table

CLEAR : gt_reclist, gs_reclist.

SELECT SINGLE usrid_long FROM pa0105 INTO gs_reclist-receiver WHERE pernr = wa_final-pernr AND subty = '0010'

AND endda = '99991231'.

IF gs_reclist-receiver IS INITIAL.

WRITE: / 'Please maintain email id for ', gv_name.

ELSE.

gs_reclist-rec_type = 'U'.

"&-- Send to SAP Inbox

gs_reclist-com_type = 'INT'.

gs_reclist-notif_del = 'X'.

gs_reclist-notif_ndel = 'X'.

APPEND gs_reclist TO gt_reclist.

ENDIF.

CHECK NOT gs_reclist-receiver IS INITIAL.

* Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table

CLEAR : gs_objbin, gs_pdf_tab.

LOOP AT gt_pdf_tab INTO gs_pdf_tab.

gv_pos = 255 - gv_len.

IF gv_pos > 134.

"length of pdf_table

gv_pos = 134.

ENDIF.

gs_objbin+gv_len = gs_pdf_tab(gv_pos).

gv_len = gv_len + gv_pos.

IF gv_len = 255. "length of out (contents_bin)

APPEND gs_objbin TO gt_objbin.

CLEAR: gs_objbin, gv_len.

IF gv_pos < 134.

gs_objbin = gs_pdf_tab+gv_pos.

gv_len = 134 - gv_pos.

ENDIF.

ENDIF.

ENDLOOP.

IF gv_len > 0.

APPEND gs_objbin TO gt_objbin.

ENDIF.

* Filling the details in SAPoffice: Description of Imported Object Components table

DESCRIBE TABLE gt_objbin LINES gv_tab_lines.

CLEAR gs_objbin. CLEAR gs_objbin. gs_objpack-head_start = 1.

gs_objpack-head_num = 0.

gs_objpack-body_start = 1.

gs_objpack-body_num = gv_tab_lines.

gs_objpack-doc_type = 'RAW'.

APPEND gs_objpack TO gt_objpack.

CLEAR gs_objbin.

READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.

IF sy-subrc = 0.

gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + strlen( gs_objbin ).

gs_objpack-transf_bin = 'X'.

gs_objpack-head_start = 1.

gs_objpack-head_num = 0.

gs_objpack-body_start = 1.

gs_objpack-body_num = gv_tab_lines.

gs_objpack-doc_type = 'PDF'.

gs_objpack-obj_name = 'ATTACHMENT'.

gs_objpack-obj_descr = gv_text .

APPEND gs_objpack TO gt_objpack.

ENDIF.

* CLEAR: i_objtxt,gs_objpack.

* Append all message body here

CONCATENATE 'Dear 'gv_name ',' INTO i_objtxt SEPARATED BY space.

APPEND i_objtxt. CLEAR i_objtxt. APPEND i_objtxt.

CONCATENATE 'Please find your Payslip for the month of'gv_text 'in the attachment' '.' INTO i_objtxt SEPARATED BY space.

CONDENSE i_objtxt.

APPEND i_objtxt. CONDENSE i_objtxt. CLEAR i_objtxt. APPEND i_objtxt.

CONCATENATE 'Regards' ',' INTO i_objtxt SEPARATED BY space.

CONDENSE i_objtxt. APPEND i_objtxt. CLEAR i_objtxt.

CONCATENATE 'Payroll Department' '.' INTO i_objtxt SEPARATED BY space.

CONDENSE i_objtxt. APPEND i_objtxt. CLEAR i_objtxt.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gs_docdata

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = gt_objpack

contents_bin = gt_objbin

receivers = gt_reclist

contents_txt = i_objtxt

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.

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: / 'Email sent successfully to ', gv_name.

ENDIF.

Thanks and Regards

Divya