Skip to Content
0
Feb 03, 2021 at 07:57 AM

Payslip Turkish Language Charset problem

159 Views

Hello Experts,

I'm currently working on a project that is sending the payslip as a PDF attachment in email.

I'm having trouble with encoding character on Turkish language specific characters, when the pdf open on desktop with adobe acrobat reader.

When i try to open that pdf on chrome or edge browser, everything is looks fine.

What's the problem with that?

Thank you.

*&---------------------------------------------------------------------*
*& Report /GRUBE/PDF_TEST_PSLIP_ENCRYP
*&
*&---------------------------------------------------------------------*
*&
*& Example for encrypted Payslip (HRFORMS)
*& Code was basically copied from class
*& CL_HRXSS_REM
*& Method: L_PRODUCE_FORM
*&
*& Please create user IYOMAIL in SU01 with some email address (e.g.
*& payroll@mycompany.com to set the sender address
*& tested on IDES / Client 800 mit Adobe Document Service (ADS) 8.x
*&---------------------------------------------------------------------*

* Selection Texts
* P_FPPER Payperiod (YYYYMM)
* P_PERNR Employee Number

REPORT /grube/pdf_test_pslip_encryp.

DATA: xpayslip TYPE xstring.
"data: data_lines type /grube/raw256_table.
DATA: len1 TYPE i.
DATA: fl TYPE string.
DATA: file TYPE file_table.
DATA: files TYPE filetable.
DATA: rc TYPE i.
DATA: l_molga TYPE molga.
DATA: l_rgdir TYPE h99_clst_t_rgdir.
DATA: wa_rgdir TYPE LINE OF h99_clst_t_rgdir.
DATA: lt_evp TYPE h99_clst_t_rgdir.
DATA: i0001 TYPE TABLE OF p0001.
DATA: wa_i0001 TYPE p0001.
DATA: pmehf TYPE pmehf.
DATA: hrform_name TYPE hrf_name.
DATA: message1 TYPE bapiret1.
DATA: form_object TYPE REF TO object.
DATA: pass(12).
DATA: upass TYPE string.
DATA: opass TYPE string.
DATA: line TYPE soli.
DATA: result TYPE xstring.
DATA: len TYPE so_obj_len.
DATA: lt_xpdf TYPE solix_tab.
DATA: l_xpdf TYPE solix.
DATA: send_request TYPE REF TO cl_bcs.
DATA: bcs_exception TYPE REF TO cx_bcs.
DATA: text_line TYPE soli.
DATA: text TYPE bcsy_text.
DATA: document TYPE REF TO cl_document_bcs.
DATA: sender TYPE REF TO cl_sapuser_bcs.
DATA: recipient TYPE REF TO if_recipient_bcs.
DATA: sent_to_all TYPE os_boolean.



PARAMETERS: p_pernr TYPE p_pernr.
PARAMETERS: p_fpper TYPE faper DEFAULT '202004'.


START-OF-SELECTION.


* Get the payroll runs
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr = p_pernr
IMPORTING
molga = l_molga
TABLES
in_rgdir = l_rgdir
EXCEPTIONS
no_record_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'Error reading Molga and RGDIR:', p_pernr.
EXIT.
ENDIF.

* Find the requested payrun
READ TABLE l_rgdir INTO wa_rgdir
WITH KEY fpper = p_fpper.

APPEND wa_rgdir TO lt_evp.
* Get some employee details
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = p_pernr
infty = '0001'
TABLES
infty_tab = i0001
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: 'Error Reading Infotype 1',p_pernr.
EXIT.
ENDIF.
LOOP AT i0001 INTO wa_i0001
WHERE begda LE wa_rgdir-ipend
AND endda GE wa_rgdir-ipend.
ENDLOOP.
* determine id of hrforms form
MOVE-CORRESPONDING wa_i0001 TO pmehf.
MOVE-CORRESPONDING wa_rgdir TO pmehf.
pmehf-rclas = 'CESS'.
pmehf-molga = l_molga.
pmehf-uname = sy-uname.

* find the name of the HRForm Feature HRFOR (PE03)
CALL FUNCTION 'HR_FEATURE_BACKFIELD'
EXPORTING
feature = 'HRFOR'
struc_content = pmehf
kind_of_error = space
IMPORTING
back = hrform_name
EXCEPTIONS
dummy = 1
error_operation = 2
no_backvalue = 3
feature_not_generated = 4
invalid_sign_in_funid = 5
field_in_report_tab_in_pe03 = 6
OTHERS = 7.
IF sy-subrc <> 0.
WRITE: 'Config Error Feature: HRFOR', p_pernr.
EXIT.
ENDIF.
IF hrform_name EQ '$CEDT$'. "VKI
* use classic version of payslip program (RPCEDTx0)
CALL FUNCTION 'BAPI_GET_PAYSLIP_PDF'
EXPORTING
employeenumber = p_pernr
sequencenumber = wa_rgdir-seqnr
payslipvariant = space
IMPORTING
return = message1
payslip = xpayslip
pdf_fsize = len1.
IF NOT message1-type IS INITIAL.
WRITE: / 'Problem calling BAPI_GET_PAYSLIP_PDF', p_pernr.
ENDIF.
ELSE. "VKI
* use new version of payslip program (HRForms)
* init HRFORMS
CALL FUNCTION 'HRFORMS_CALL_INIT'
EXPORTING
hrform_name = hrform_name
begin_date = wa_rgdir-fpbeg "VKIN994383
end_date = wa_rgdir-fpend "VKIN994383
IMPORTING
form_object = form_object
EXCEPTIONS
form_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'Error calling HRFORMS_CALL_INIT', p_pernr, hrform_name.
EXIT.
ENDIF.
* process payroll data of pernr at hrforms to create form
CALL FUNCTION 'HRFORMS_CALL_PERNR'
EXPORTING
form_object = form_object
pernr = p_pernr
result_list = lt_evp
call_evp = 'X'
molga = l_molga
rgdir = l_rgdir
* BUFFER_INFTY =
EXCEPTIONS
form_error = 1
payroll_read_error = 2
reject = 3
no_form = 4
OTHERS = 5.
IF sy-subrc <> 0.
WRITE: / 'Error calling HRFORMS_CALL_PERNR', p_pernr, hrform_name.
EXIT.
ENDIF.
* get form as pdf stream
CALL FUNCTION 'HRFORMS_CALL_PDF'
EXPORTING
form_object = form_object
IMPORTING
pdf_size = len1
pdf_xstring = xpayslip
EXCEPTIONS
form_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'Error calling HRFORMS_CALL_PDF', p_pernr, hrform_name.
EXIT.
ENDIF. "IF sy-subrc <> 0
ENDIF. "IF 'CEDT' or 'HRForms'

len1 = xstrlen( xpayslip ).
len = xstrlen( xpayslip ).

* convert to a solix_tab
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = xpayslip
TABLES
binary_tab = lt_xpdf.


DATA: attch TYPE so_obj_des.
DATA: d_start(10) TYPE c.
DATA: d_end(10) TYPE c.

WRITE wa_rgdir-fpbeg TO d_start.
WRITE wa_rgdir-fpend TO d_end.
CONCATENATE 'Payslip_from_' d_start '_to_' d_end INTO attch.

* create the mail and attachment as described in the BCS_EXAMPLE programs
TRY.
send_request = cl_bcs=>create_persistent( ).
CONCATENATE 'Dear' wa_i0001-ename ',' INTO line-line SEPARATED BY ' '.
APPEND line TO text.
line-line = ''.
APPEND line TO text.
APPEND 'please find your payslip in the attachment' TO text.
line-line = ''.
APPEND line TO text.
line-line = ''.
APPEND line TO text.
line-line = 'Kind Reagrads'.
APPEND line TO text.
line-line = 'Payroll'.
APPEND line TO text.

DATA: lo_head TYPE REF TO cl_bcs_objhead.
lo_head = cl_bcs_objhead=>create( ).
lo_head->set_format( lo_head->gc_asc ). "ASC for text document
" lo_head->set_codepage( '4110' ). "1100 = ISO-8859-1 ? is it LATIN1 ?

document = cl_document_bcs=>create_document(
i_type = 'RAW'
" i_header = lo_head->mt_objhead
"i_language = ''

i_text = text
* i_length = '72'
i_subject = attch ).

CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = attch
i_attachment_size = len
" i_attachment_language = '1'
i_att_content_hex = lt_xpdf.

CALL METHOD send_request->set_document( document ).
sender = cl_sapuser_bcs=>create( 'SHUR' ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
recipient = cl_cam_address_bcs=>create_internet_address(
'selimhur@polifarma.com.tr' ).
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.

CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
IF sent_to_all = 'X'.
WRITE: / 'Document Sent Successfully'.
ENDIF.
COMMIT WORK.

CATCH cx_bcs INTO bcs_exception.
WRITE: 'Fehler aufgetreten.'(001).
WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
EXIT.

ENDTRY.

Attachments

adobe-preview.jpg (52.6 kB)
chrome-preview.jpg (28.7 kB)