TABLES: pernr.
INFOTYPES: 0000,
0001,
0002,
0008.
TYPES: BEGIN OF ty_pa0000,
pernr LIKE pa0000-pernr,
begda LIKE pa0000-begda,
endda LIKE pa0000-endda,
END OF ty_pa0000.
TYPES: BEGIN OF ty_final,
pernr LIKE pa0001-pernr,
END OF ty_final.
DATA: it_pa0000 TYPE TABLE OF p0000 WITH HEADER LINE,
it_pa0001 TYPE TABLE OF p0001 WITH HEADER LINE,
it_pa0002 TYPE TABLE OF p0002 WITH HEADER LINE,
it_pa0008 TYPE TABLE OF p0008 WITH HEADER LINE.
* SSF Decleration
DATA: l_form TYPE tdsfname VALUE 'ZHR_PAYSILP_EMPLOYEE',
lf_fm_name TYPE rs38l_fnam.
GET pernr.
rp-provide-from-last p0000 space pn-begda pn-endda.
IF pnp-sw-found = '1'.
IF p0000-stat2 = '3'.
MOVE p0000-pernr TO it_pa0000-pernr.
MOVE pn-begda TO it_pa0000-begda.
MOVE pn-endda TO it_pa0000-endda.
APPEND it_pa0000.
CLEAR it_pa0000.
ENDIF.
ENDIF.
END-OF-SELECTION.
PERFORM get_time_quota.
PERFORM call_smartform.
*&---------------------------------------------------------------------*
*& Form CALL_SMARTFORM
*----------------------------------------------------------------------*
FORM call_smartform .
*data:
* Data declaration for mail
DATA: i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_tline TYPE TABLE OF tline WITH HEADER LINE,
i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
wa_doc_chng LIKE sodocchgi1,
l_lines TYPE sy-tabix.
DATA: it_otfdata TYPE TABLE OF itcoo WITH HEADER LINE.
DATA : output_options TYPE ssfcompop.
DATA: control_parameters TYPE ssfctrlop,
job_output_info TYPE ssfcrescl.
DATA: v_pabrp TYPE pabrp,
v_pabrj TYPE pabrj.
IF pnptimr9 = 'X'.
v_pabrp = pnpdispp.
v_pabrj = pnpdispj.
ELSE.
v_pabrp = pnppabrp.
v_pabrj = pnppabrj.
ENDIF.
output_options-tddest = 'LOCL'.
output_options-tdarmod = '1'.
output_options-tdnoprev = 'X'.
output_options-tdnoprint = 'X'.
*OUTPUT_OPTIONS-TDPRINTER = 'PRINTER'.
control_parameters-getotf = 'X'.
control_parameters-no_dialog = 'X'.
control_parameters-device = 'PRINTER'.
control_parameters-preview = ''.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = l_form
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
LOOP AT it_pa0000.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000062'
EXPORTING
control_parameters = control_parameters
output_options = output_options
pernr = it_pa0000-pernr
abkrs = pnpabkrs-low
pabrp = v_pabrp
pabrj = v_pabrj
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = job_output_info
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
.
REFRESH : it_otfdata[],
i_objtxt,
i_objpack,
it_otfdata,
i_tline,
i_record,
i_reclist.
it_otfdata[] = job_output_info-otfdata[].
CLEAR : i_objbin, i_reclist, i_objtxt.
REFRESH : i_objbin, i_reclist, i_objtxt.
*Populate values for mail text.
i_objtxt = 'Employee Payslip'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES l_lines.
READ TABLE i_objtxt INDEX l_lines.
wa_doc_chng-doc_size = l_lines * 255.
wa_doc_chng-obj_name = 'EMAIL'.
wa_doc_chng-obj_descr = 'Employee Payslip'.
* Main Text
CLEAR : i_objpack.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-doc_type = 'RAW'.
i_objpack-body_num = l_lines.
APPEND i_objpack.
CLEAR i_objpack.
*Convert output of script to OTF data
CLEAR: i_tline, l_lines.
REFRESH i_tline.
* Convert OTF to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = l_lines
TABLES
otf = it_otfdata
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0 OR
l_lines IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
REFRESH : i_record.
*Format OTF data
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = i_tline
t_target_tab = i_record
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE : / 'Error in conversion of pdf lines'(015).
ENDIF.
APPEND LINES OF i_record TO i_objbin.
*Creation of the entry for the compressed attachment
DESCRIBE TABLE i_objbin LINES l_lines.
CLEAR i_objpack.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = l_lines.
i_objpack-obj_name = 'Employee Payslip'.
i_objpack-obj_descr = 'Employee Payslip'.
i_objpack-doc_size = l_lines * 255 .
i_objpack-doc_type = 'PDF'.
APPEND i_objpack.
CLEAR i_objpack.
DATA: l_usrid_long TYPE pa0105-usrid_long.
CLEAR : l_usrid_long.
SELECT SINGLE usrid_long
FROM pa0105
INTO l_usrid_long
WHERE pernr = it_pa0000-pernr
AND subty = '0010'.
IF sy-subrc EQ 0.
i_reclist-receiver = l_usrid_long. "'ravi.me1231@gmail.com'.
i_reclist-rec_type = 'U'.
i_reclist-com_type = 'INT'.
APPEND i_reclist.
ELSE.
WRITE:/ 'No email id is maintained for this personnel number' , it_pa0000-pernr.
ENDIF.
IF NOT i_reclist[] IS INITIAL.
*sending report output and script output as mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
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.
ENDIF.
ENDLOOP.
ENDFORM. " CALL_SMARTFORM
ALSO READ:
- Time Quota For An Employee In HR ABAP.
- Employee Deduction Report In HR ABAP.
- Comparison Report For The Employee Salaries In HR ABAP.
- Cash Payment Report In HR ABAP.
- Bank Report For Employees In HR ABAP.
.....Back To Sub-Index On HR ABAP.
.....Back To MAIN INDEX.
Thank you for this code
ReplyDelete