Você está na página 1de 33

*&---------------------------------------------------------------------* *& Include ZH99_HRFORMS_CALL_FORM *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form enable_disable_fields *&---------------------------------------------------------------------* form enable_disable_fields.

statics sx_all_enabled type xfeld. *if report is called via menu/transaction no molga and fclass *if report is called from somewhere else molga and fclass = active if p_molga is initial and p_fclass is initial. loop at screen. if screen-name eq 'P_MOLGA' or screen-name eq 'P_FCLASS'. screen-input = 1. modify screen. endif. endloop. sx_all_enabled = 'X'. "molga/fclass is initial! else. loop at screen. if screen-name cs 'P_MOLGA' or screen-name cs 'P_FCLASS'. if sx_all_enabled is initial and not sy-tcode eq 'SE38'. screen-input = 0. else. screen-input = 1. endif. modify screen. endif. endloop. endif. endform. "enable_disable_fields *&---------------------------------------------------------------------* *& Form check_all *&---------------------------------------------------------------------* form check_all using iv_molga type thrforms_01-molga iv_variant type vari-variant changing ov_fclass type thrforms_01-formclass ov_fname type thrforms_01-infonet ov_report type rsvar-report ox_error type sysubrc. data ls_thrforms like thrforms_01. ox_error = 0. *****get/check the name of the print program (message if error) perform get_report_name changing ov_fname ov_report ox_error. check ox_error eq 0. *transform all parameters to upper case translate ov_fclass to upper case. "#EC SYNTCHAR translate ov_fname to upper case. "#EC SYNTCHAR *****check if report, molga and fclass belong together select single * from thrforms_01 into corresponding fields of ls_thrforms where infonet eq ov_fname and molga eq iv_molga and printprog eq ov_report and formclass eq ov_fclass. if sy-subrc <> 0. *there is no form with this name ox_error = 1. perform error_msg using 'S' 'HRFORMS' '038' '' '' '' '' c_save_error_msg.

elseif ls_thrforms-printprog is initial. *there is no active print report for this form ox_error = 2. perform error_msg using 'S' 'HRFORMS' '036' '' '' '' '' c_save_error_msg. endif. check ox_error eq 0. *****check if variant exists (no check if no variant assigned) perform check_variant using ov_report iv_variant changing ox_error. check ox_error eq 0. endform. "check_all *&---------------------------------------------------------------------* *& Form get_report_name *&---------------------------------------------------------------------* form get_report_name changing ov_fname type thrforms_01-infonet ov_report type rsvar-report ox_error type sysubrc. ox_error = 0. translate ov_fname to upper case. "#EC SYNTCHAR

call method cl_hrform_hrf02=>get_program exporting im_infonet = ov_fname receiving re_program = ov_report exceptions infonet_error = 1 no_authority = 2 others = 3. if sy-subrc <> 0. ox_error = 1. perform error_msg using sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 c_save_error_msg. elseif ov_report is initial. *there is no active print report for this form ox_error = 2. perform error_msg using 'S' 'HRFORMS' '036' '' '' '' '' c_save_error_msg. endif. endform. " get_report_name *&---------------------------------------------------------------------* *& Form get_variant *&---------------------------------------------------------------------* form get_variant using iv_report type rsvar-report changing ov_variant type vari-variant ox_error type sysubrc. data: lv_variant like rsvar-variant. ox_error = 0. call function 'RS_VARIANT_CATALOG' exporting report = iv_report importing sel_variant = lv_variant exceptions

no_report report_not_existent report_not_supplied no_variants no_variant_selected variant_not_existent others

= = = = = = =

1 2 3 4 5 6 7.

if sy-subrc eq 1 or sy-subrc eq 2 or sy-subrc eq 3. ox_error = 1. perform error_msg using 'S' 'HRFORMS' '036' '' '' '' '' c_save_error_msg. elseif sy-subrc eq 4 or sy-subrc eq 5 or sy-subrc eq 6 or sy-subrc eq 7. ox_error = 2. perform error_msg using 'S' 'HRFORMS' '037' '' '' '' '' c_save_error_msg. endif. ov_variant = lv_variant. endform. " get_variant *&---------------------------------------------------------------------* *& Form check_variant *&---------------------------------------------------------------------* form check_variant using iv_report type rsvar-report iv_variant type vari-variant changing ox_error type sysubrc. ox_error = 0. check not iv_variant is initial. call function 'RS_VARIANT_EXISTS' exporting report = iv_report variant = iv_variant importing r_c = ox_error exceptions not_authorized = 1 no_report = 2 report_not_existent = 3 report_not_supplied = 4 others = 5. if sy-subrc <> 0. ox_error = 1. perform error_msg using sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 c_save_error_msg. elseif ox_error ne 0. perform error_msg using 'S' 'HRFORMS' '037' '' '' '' '' c_save_error_msg. endif. endform. "check_variant *&---------------------------------------------------------------------* *& Form read_dynpro *&---------------------------------------------------------------------* *the dynpro reading is only to avoid pressing 'enter' every time, *when choosing the form via F4 or entering the name manually form read_dynpro changing ov_molga type thrforms_01-molga ov_fclass type thrforms_01-formclass

ov_fname

type thrforms_01-infonet.

data lt_dynpfields like dynpread occurs 1 with header line. data lv_dynpro_prog like d020s-prog. lt_dynpfields-fieldname = 'P_MOLGA'. append lt_dynpfields. lt_dynpfields-fieldname = 'P_FCLASS'. append lt_dynpfields. lt_dynpfields-fieldname = 'P_FNAME'. append lt_dynpfields. lv_dynpro_prog = sy-repid. call function 'DYNP_VALUES_READ' exporting dyname = lv_dynpro_prog dynumb = '1000' tables dynpfields = lt_dynpfields. read table lt_dynpfields with key fieldname = 'P_MOLGA'. ov_molga = lt_dynpfields-fieldvalue. read table lt_dynpfields with key fieldname = 'P_FCLASS'. ov_fclass = lt_dynpfields-fieldvalue. read table lt_dynpfields with key fieldname = 'P_FNAME'. ov_fname = lt_dynpfields-fieldvalue. endform. " read_dynpro *&---------------------------------------------------------------------* *& Form select_data_f4 *&---------------------------------------------------------------------* form select_data_f4 using iv_molga type thrforms_01-molga changing ov_fclass type thrforms_01-formclass ox_error type sysubrc. data: begin of lt_value_tab occurs 0. data: infonet like thrforms_01-infonet, text like tinfonet_t_01-text, end of lt_value_tab, lt_field_tab type standard table of dfies, ls_field_tab like line of lt_field_tab, lt_help_tab type standard table of dfies, ls_help_tab like line of lt_help_tab. data: lv_dynpro_prog like d020s-prog. ox_error = 0. translate ov_fclass to upper case. "#EC SYNTCHAR

select thrforms_01~infonet tinfonet_t_01~text into corresponding fields of table lt_value_tab from thrforms_01 inner join tinfonet_t_01 "#EC CI_BUFFJOIN on thrforms_01~infonet = tinfonet_t_01~infonet where thrforms_01~molga eq iv_molga and thrforms_01~formclass eq ov_fclass and tinfonet_t_01~sprsl eq sy-langu. lv_dynpro_prog = sy-repid. *change the text for the 1st column of the F4 screen to "Formularname"

*and not "Objectname" call function 'DDIF_FIELDINFO_GET' exporting tabname = 'THRFORMS_01' langu = sy-langu all_types = 'X' tables dfies_tab = lt_field_tab exceptions others = 0. delete lt_field_tab where not fieldname eq 'INFONET'. loop at lt_field_tab into ls_field_tab. ls_field_tab-reptext = text-002. modify lt_field_tab from ls_field_tab. endloop. *add text for the second column "Beschreibung" call function 'DDIF_FIELDINFO_GET' exporting tabname = 'TINFONET_T_01' langu = sy-langu all_types = 'X' tables dfies_tab = lt_help_tab exceptions others = 0. delete lt_help_tab where not fieldname eq 'TEXT'. loop at lt_help_tab into ls_help_tab. ls_help_tab-offset = '16'. append ls_help_tab to lt_field_tab. endloop. *call F4 screen call function 'F4IF_INT_TABLE_VALUE_REQUEST' exporting retfield = 'INFONET' dynpprog = lv_dynpro_prog dynpnr = '1000' dynprofield = 'P_FNAME' window_title = text-002 value_org = 'S' tables value_tab = lt_value_tab field_tab = lt_field_tab exceptions parameter_error = 1 no_values_found = 2 others = 3. if sy-subrc <> 0. ox_error = 1. perform error_msg using sy-msgty sy-msgid sy-msgno sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 c_save_error_msg. endif. endform. " select_data_f4 *&---------------------------------------------------------------------*

*& Form error_msg *&---------------------------------------------------------------------* form error_msg using iv_msgty type symsgty iv_msgid type symsgid iv_msgno type symsgno iv_msgv1 type symsgv iv_msgv2 type symsgv iv_msgv3 type symsgv iv_msgv4 type symsgv ix_save_or_output type c. statics ss_symsg type symsg. if ix_save_or_output eq c_save_error_msg. clear ss_symsg. ss_symsg-msgty = iv_msgty. ss_symsg-msgid = iv_msgid. ss_symsg-msgno = iv_msgno. ss_symsg-msgv1 = iv_msgv1. ss_symsg-msgv2 = iv_msgv2. ss_symsg-msgv3 = iv_msgv3. ss_symsg-msgv4 = iv_msgv4. elseif ix_save_or_output eq c_output_error_msg. if not ss_symsg is initial. if iv_msgty is initial. "message type not forced message id ss_symsg-msgid type ss_symsg-msgty number ss_symsg-msgno with ss_symsg-msgv1 ss_symsg-msgv2 ss_symsg-msgv3 ss_symsg-msgv4. else. "message type forced (prevents dumps at F4s) message id ss_symsg-msgid type iv_msgty number ss_symsg-msgno with ss_symsg-msgv1 ss_symsg-msgv2 ss_symsg-msgv3 ss_symsg-msgv4. endif. clear ss_symsg. endif. endif. "save or output message ? endform. "error_msg *&---------------------------------------------------------------------* *& Form SUB_DISPLAY *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_display . data: lv_cont type i value 1, lv_frac type p. data: lv_abkrs type t569v-abkrs, lv_pabrp type t569v-pabrp, lv_pabrj type t569v-pabrj, lv_indctr type c. move pnpxabkr to lv_abkrs. move pnppabrp to lv_pabrp. move pnppabrj to lv_pabrj. * to get the calender period from payroll area and fi period call function 'PA03_PERIODDATES_GET' exporting f_abkrs = lv_abkrs

importing f_current_begda = gv_start_date f_current_endda = gv_end_date changing f_current_period = lv_pabrp f_current_year = lv_pabrj exceptions pcr_does_not_exist = 1 abkrs_does_not_exist = 2 period_does_not_exist = 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. loop at gt_mail into gs_mail. lv_frac = frac( lv_cont / 2 ). if lv_frac > 0. format color col_normal intensified on inverse off. else. format color col_normal intensified off inverse off. endif. clear gv_check. if p_check is initial. write:/3 gv_check as checkbox input on, 8 '|'. else. write:/3 gv_check as checkbox input off, 8 '|'. endif. clear gv_stat. gv_stat = '@5B@'. if gs_mail-mflag is initial. gv_stat = '@5D@'. gt_log-pernr = gs_mail-pernr. gt_log-class = '00'. gt_log-msgno = '398'. gt_log-msgv1 = 'There is no'. gt_log-msgv2 = 'Email ID'. gt_log-sever = 'W'. append gt_log. endif. clear lv_indctr. * subroutine to check whether the finnce posting is done for the employee in the given period or not perform sub_check_post_pernr using gs_mail-pernr changing lv_indctr. if lv_indctr = 'X'. gv_stat = '@5C@'. endif. write: 9(6) gv_stat. write: 16 '|', 17(10) gs_mail-pernr hotspot on, 28 '|',

29(30) gs_mail-ename, 60 '|', 61(40) gs_mail-usrid, 102 '|'. hide gs_mail. lv_cont = lv_cont + 1. endloop. if p_check is not initial. if gt_log[] is not initial. message s003(zemami_message) with 'Please see Error Log!'. endif. endif. endform. " SUB_DISPLAY *&---------------------------------------------------------------------* *& Form SUB_HEADING *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_heading . new-line. uline at 1(102). new-line. format color col_heading intensified on inverse off. write:/3 'Check', 8 '|', 9(6) 'Status', 16 '|', 17(10) 'EmployeeID', 28 '|', 32 'Employee Name', 60 '|', 67 'Email ID', 102 '|'. new-line. uline at 1(102). new-line. endform. " SUB_HEADING *&---------------------------------------------------------------------* *& Form SUB_SELECT_ALL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_select_all . data: lv_cnt type i, lv_chk type c, lv_stat type char4. sy-lsind = sy-lsind - 1. lv_cnt = 1. do.

read line lv_cnt index sy-lsind field value gv_check into lv_chk gv_stat into lv_stat. if sy-subrc <> 0. exit. endif. if lv_chk = ' ' and lv_stat = '@5B@'. modify line lv_cnt index sy-lsind field value gv_check from 'X'. endif. lv_cnt = lv_cnt + 1. enddo. endform. " SUB_SELECT_ALL *&---------------------------------------------------------------------* *& Form SUB_DESELECT_ALL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_deselect_all . data: lv_cnt type i, lv_chk type c. sy-lsind = sy-lsind - 1. lv_cnt = 1. do. read line lv_cnt index sy-lsind field value gv_check into lv_chk. if sy-subrc <> 0. exit. endif. if lv_chk = 'X'. modify line lv_cnt index sy-lsind field value gv_check from ' '. endif. lv_cnt = lv_cnt + 1. enddo. endform. " SUB_DESELECT_ALL *&---------------------------------------------------------------------* *& Form SUB_SEND_MAIL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_send_mail . data: lv_abkrs type t569v-abkrs, lv_pabrp type t569v-pabrp, lv_pabrj type t569v-pabrj, lv_indctr type c, ls_selected type ts_mail. move pnpxabkr to lv_abkrs. move pnppabrp to lv_pabrp. move pnppabrj to lv_pabrj. refresh: gt_mail_log, gt_error. clear gt_error.

clear: gv_selec, gv_sent, bin_size. * to get the calender period from payroll area and fi period call function 'PA03_PERIODDATES_GET' exporting f_abkrs = lv_abkrs importing f_current_begda = gv_start_date f_current_endda = gv_end_date changing f_current_period = lv_pabrp f_current_year = lv_pabrj exceptions pcr_does_not_exist = 1 abkrs_does_not_exist = 2 period_does_not_exist = 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. *-- setup the print parmaters call function 'GET_PRINT_PARAMETERS' exporting authority = space copies = '1' cover_page = space data_set = space department = space destination = space expiration = '1' immediately = space new_list_id = 'X' no_dialog = 'X' user = sy-uname importing out_parameters = mstr_print_parms valid = mc_valid exceptions archive_info_not_found = 1 invalid_print_params = 2 invalid_archive_params = 3 others = 4. describe table gt_selected lines gv_selec. loop at gt_selected into ls_selected. if ls_selected-usrid is initial. gt_log-pernr = ls_selected-pernr. gt_log-class = '00'. gt_log-msgno = '398'. gt_log-msgv1 = 'There is no'. gt_log-msgv2 = 'Email ID'. gt_log-sever = 'W'. append gt_log.

continue. endif. clear: job_name, job_cnt, lv_indctr, gv_seqnr, gs_seqnr, gt_mess_att, gt_mess_bod, gt_log. refresh: gt_seqnr, gt_mess_att, gt_mess_bod. * subroutine to check whether the finnce posting is done for the employee in the given period or not perform sub_check_post_pernr using ls_selected-pernr changing lv_indctr. if lv_indctr = 'X'. continue. endif. concatenate 'PAY' ls_selected-pernr sy-datum sy-uzeit into job_name. call function 'JOB_OPEN' exporting jobname = job_name importing jobcount = job_cnt exceptions cant_create_job = 1 invalid_job_data = 2 jobname_missing = 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. * submitting the spool request submit (gv_report) "#EC CI_SUBMIT to sap-spool spool parameters mstr_print_parms without spool dynpro via job job_name number job_cnt with pnptimed eq pnptimed "curr period, other period, etc with pnpbegda eq pnpbegda "selection begin date with pnpendda eq pnpendda "selection end date with pnpxabkr eq pnpxabkr "payroll period with pnppabrp eq pnppabrp with pnppabrj eq pnppabrj with pnppayty eq pnppayty with pnppayid eq pnppayid with pnpbondt eq pnpbondt with pnppernr eq ls_selected-pernr"IN pnppernr "pernrs "WITH pnpabkrs IN pnpabkrs "payroll periods *UNNI - 1122174 - passing PNP Personnel Area table - Begin with pnpwerks in pnpwerks *UNNI - 1122174 - End of changes *UNNI - 1102750 - passing sort tables - Begin with pnpsort eq pnpsort

with pnpsortt eq pnpsortt *UNNI - 1102750 - End of changes *KVHN1459714 - Starts with pnpansvh in pnpansvh with pnpbtrtl in pnpbtrtl with pnpbukrs in pnpbukrs with pnpename in pnpename with pnpfistl in pnpfistl with pnpfkber in pnpfkber with pnpgeber in pnpgeber with pnpgsber in pnpgsber with pnpjuper in pnpjuper with pnpkokrs in pnpkokrs with pnpkostl in pnpkostl with pnporgeh in pnporgeh with pnppersg in pnppersg with pnppersk in pnppersk with pnpplans in pnpplans with pnpsacha in pnpsacha with pnpsachp in pnpsachp with pnpsachz in pnpsachz with pnpsname in pnpsname with pnpstat1 in pnpstat1 with pnpstat2 in pnpstat2 with pnpstat3 in pnpstat3 with pnpstell in pnpstell with pnpvdsk1 in pnpvdsk1 *KVHN1459714 - Ends with p_popup eq p_popup and return.

"show print popup switch

call function 'JOB_CLOSE' exporting jobcount = job_cnt jobname = job_name strtimmed = 'X' exceptions cant_start_immediate = 1 invalid_startdate = 2 jobname_missing = 3 job_close_failed = 4 job_nosteps = 5 job_notex = 6 lock_failed = 7 invalid_target = 8 others = 9. if sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. commit work. if sy-subrc = 0. do. * selecting from tbtcp table the spool id select single * from tbtcp where jobname = job_name and jobcount = job_cnt and stepcount = 1 and

listident <> '0000000000'. if sy-subrc = 0. exit. endif. enddo. endif. *converting the spool request into pdf data lv_listident type tsp01-rqident. move tbtcp-listident to lv_listident. data lv_flag type i value 0. data lv_status type tbtcjob-status. lv_listident = lv_listident - 1. call function 'RSPO_GET_PAGES_SPOOLJOB' exporting rqident = lv_listident importing rq = gs_tsp01 exceptions no_such_job = 1 others = 2. if sy-subrc <> 0. gt_error-pernr = ls_selected-pernr. gt_error-arbgb = '00'. gt_error-msgno = '398'. gt_error-msgv1 = 'No Payslip Data for the Employee'. gt_error-msgv2 = 'In the given Period'. gt_error-arbgb = 'E'. append gt_error. continue. elseif gs_tsp01-rq0name <> 'HRFORM'. gt_error-pernr = ls_selected-pernr. gt_error-arbgb = '00'. gt_error-msgno = '398'. gt_error-msgv1 = 'No Payslip for the Employee'. gt_error-msgv2 = 'In the given Period'. gt_error-arbgb = 'E'. append gt_error. continue. else. call function 'CONVERT_OTFSPOOLJOB_2_PDF' exporting src_spoolid = lv_listident no_dialog = 'X' pdf_destination = 'X' no_background = 'X' importing pdf_bytecount = bin_size bin_file = pdf_xstring tables pdf = it_pdf exceptions err_no_otf_spooljob = 1 err_no_spooljob = 2 err_no_permission = 3

err_conv_not_possible = 4 err_bad_dstdevice = 5 user_cancelled = 6 err_spoolerror = 7 err_temseerror = 8 err_btcjob_open_failed = 9 err_btcjob_submit_failed = 10 err_btcjob_close_failed = 11 others = 12. if sy-subrc <> 0. gt_log-pernr = ls_selected-pernr. gt_log-class = sy-msgid. gt_log-msgno = sy-msgno. gt_log-msgv1 = sy-msgv1. gt_log-msgv2 = sy-msgv2. gt_log-msgv3 = sy-msgv3. gt_log-msgv4 = sy-msgv4. gt_log-sever = sy-msgty. append gt_log. else. lv_flag = 1. endif. endif. check sy-subrc = 0. do. call function 'BP_JOB_CHECKSTATE' exporting dialog = 'N' jobcount = job_cnt jobname = job_name importing actual_status = lv_status exceptions checking_of_job_has_failed = 1 correcting_job_status_failed = 2 invalid_dialog_type = 3 job_does_not_exist = 4 no_check_privilege_given = 5 ready_switch_too_dangerous = 6 others = 7. if sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. if lv_status = 'F'. exit. endif. enddo. data lv_spoolid type tsp01_sp0r-rqid_char. move tbtcp-listident to lv_spoolid. call function 'RSPO_R_RDELETE_SPOOLREQ' exporting spoolid = lv_spoolid. clear lv_spoolid.

move lv_listident to lv_spoolid. call function 'RSPO_R_RDELETE_SPOOLREQ' exporting spoolid = lv_spoolid. call function 'BP_JOB_DELETE' exporting jobcount = job_cnt jobname = job_name exceptions cant_delete_event_entry = 1 cant_delete_job = 2 cant_delete_joblog = 3 cant_delete_steps = 4 cant_delete_time_entry = 5 cant_derelease_successor = 6 cant_enq_predecessor = 7 cant_enq_successor = 8 cant_enq_tbtco_entry = 9 cant_update_predecessor = 10 cant_update_successor = 11 commit_failed = 12 jobcount_missing = 13 jobname_missing = 14 job_does_not_exist = 15 job_is_already_running = 16 no_delete_authority = 17 others = 18. if sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. if lv_flag = 1. * * * * * * * * * * * CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE' EXPORTING line_width_dst = 255 TABLES content_in = it_pdf content_out = gt_mess_att EXCEPTIONS err_line_width_src_too_long = 1 err_line_width_dst_too_long = 2 err_conv_failed = 3 OTHERS = 4.

pdf_size = bin_size. * to prepare the mail and send it to the mail id of the employee move ls_selected-usrid to gv_mail_id. if p_check is initial. perform sub_send using gv_mail_id ls_selected-pernr. * PERFORM sub_send_email USING gv_mail_id * ls_selected-pernr. endif. endif. endloop. * to display mail error log perform sub_show_mail_error_log.

endform. " SUB_SEND_MAIL *&---------------------------------------------------------------------* *& Form SUB_GET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_get_data . * selecting the employee ids select pernr from pa0001 into table gt_pernr where abkrs = pnpxabkr and pernr in pnppernr and werks in pnpwerks and btrtl in pnpbtrtl and persg in pnppersg and persk in pnppersk. if gt_pernr is not initial. * selecting the name details of the employee select pernr nachn vorna midnm into table gt_name from pa0002 for all entries in gt_pernr where pernr = gt_pernr-pernr. * selecting the mail details of the employee select * from pa0105 into table gt_0105 for all entries in gt_pernr where pernr = gt_pernr-pernr and subty = '0010'. endif. * forming the report display of employees and email ids loop at gt_pernr into gs_pernr. read table gt_name into gs_name with key pernr = gs_pernr-pernr. gs_mail-pernr = gs_pernr-pernr. concatenate gs_name-vorna gs_name-midnm gs_name-nachn into gs_mail-ename sep arated by ' '. read table gt_0105 into gs_0105 with key pernr = gs_pernr-pernr. if gs_0105-usrid_long is initial. gs_mail-mflag = ' '. elseif gs_0105-usrid_long is not initial. gs_mail-mflag = 'X'. endif. gs_mail-usrid = gs_0105-usrid_long. append gs_mail to gt_mail. clear: gs_mail, gs_pernr, gs_0105,

gs_name. endloop. sort gt_mail by pernr. delete adjacent duplicates from gt_mail comparing pernr. endform. " SUB_GET_DATA *&---------------------------------------------------------------------* *& Module STATUS_2000 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* module status_2000 output. * SET PF-STATUS 'ZMAIL'. * SET TITLEBAR 'ZMAIL'. endmodule. " STATUS_2000 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_2000 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* module user_command_2000 input. * CASE ok_code. * WHEN 'ACCEPT'. * CLEAR ok_code. * IF email IS NOT INITIAL. * PERFORM sub_update_mail. * ELSE. * MESSAGE 'No Email ID is Entered!!' TYPE 'W'. * ENDIF. * WHEN 'CANCEL'. * CLEAR ok_code. * LEAVE SCREEN. * ENDCASE. endmodule. " USER_COMMAND_2000 INPUT *&---------------------------------------------------------------------* *& Module SUB_DISPLAY OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* module sub_display output. * empid = gv_pernr_sel. * empname = gv_name_sel. endmodule. " SUB_DISPLAY OUTPUT *&---------------------------------------------------------------------* *& Form SUB_UPDATE_MAIL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_update_mail . data lv_email type pa0105-usrid_long.

move email to call function exporting pernr = email = tables message = leave screen.

lv_email. 'ZEMAMI_UPDATE_MAIL' gv_pernr lv_email message.

endform. " SUB_UPDATE_MAIL *&---------------------------------------------------------------------* *& Form SUB_LINE_SELECTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_line_selection . data: lv_fld(40) type c, lv_val(40) type c, lv_pernr type p_pernr. get cursor field lv_fld value lv_val. check lv_fld = 'GS_MAIL-PERNR'. lv_pernr = lv_val. read table gt_mail into gs_mail with key pernr = lv_pernr. refresh gt_sval. read table gt_0105 into gs_0105 with key pernr = gs_mail-pernr. if sy-subrc = 0. gv_flag = 'X'. else. gv_flag = ' '. endif. gv_pernr = gs_mail-pernr. move gs_mail-pernr to gv_pernr_sel. move gs_mail-ename to gv_name_sel. gs_sval-tabname = 'PA0002'. gs_sval-fieldname = 'PERNR'. gs_sval-value = gs_mail-pernr. gs_sval-field_attr = '05'. append gs_sval to gt_sval. clear gs_sval. gs_sval-tabname = 'PA0002'. gs_sval-fieldname = 'CNAME'. gs_sval-value = gs_mail-ename. gs_sval-field_attr = '05'. append gs_sval to gt_sval. clear gs_sval. gs_sval-tabname = 'PA0105'. gs_sval-fieldname = 'USRID_LONG'. gs_sval-value = gs_mail-usrid. gs_sval-field_attr = '01'. gs_sval-fieldtext = 'Email ID'. append gs_sval to gt_sval.

clear gs_sval. sy-lsind = sy-lsind - 1. clear gv_return. call function 'POPUP_GET_VALUES' exporting popup_title = 'Email ID' importing returncode = gv_return tables fields = gt_sval exceptions error_in_fields = 1 others = 2. if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else. if gv_return <> 'A'. read table gt_sval into gs_sval index 3. if gs_sval-value is not initial. move gs_sval-value to gv_mail. call function 'ZEMAMI_UPDATE_MAIL' exporting pernr = gs_mail-pernr email = gv_mail flag = gv_flag tables message = gt_message. data lv_indctr type c. * subroutine to check whether the finnce posting is done for the employee in the given period or not perform sub_check_post_pernr using lv_pernr changing lv_indctr. if lv_indctr = 'X'. modify line sy-lilli index sy-lsind field value gs_mail-usrid from gs_ sval-value gv_stat from '@5C@'. elseif lv_indctr = ' '. modify line sy-lilli index sy-lsind field value gs_mail-usrid from gs_ sval-value gv_stat from '@5B@'. endif. gs_0105-usrid_long = gv_mail. modify table gt_0105 from gs_0105. clear: gv_mail, gs_0105, gv_flag. endif. endif. endif. endform. " SUB_LINE_SELECTION *&---------------------------------------------------------------------* *& Form SUB_SHOW_PAYSLIP *&---------------------------------------------------------------------*

* text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_show_payslip . data: lv_fld(40) type c, lv_val(40) type c, lv_pernr type p_pernr. clear: job_name, job_cnt, gs_tsp01. data HRDATA type /1PYXXFO/ZEMAMI_PAYSLIPV2. data DIM_EMPLOYEE like line of hrdata-dim_employee. "/1PYXXFO/ZEMAMI_PAYSLIPV2 T0007. get cursor field lv_fld value lv_val. * check lv_fld = 'GS_MAIL-PERNR'. * lv_pernr = lv_val. *data p_fname1(25) TYPE c. *CONCATENATE 'ZPYXXFO_' P_FNAME INTO p_fname1. BREAK-POINT. lv_pernr = GS_MAIL-PERNR. data : formname type rs38l_fnam. *select *-- setup the print parmaters call function 'SSF_FUNCTION_MODULE_NAME' exporting formname = 'ZPYXXFO_ZEMAMI_PAYSLIPVW' importing fm_name = formname exceptions no_form = 1 no_function_module = 2 others = 3. if sy-subrc <> 0. message id sy-msgid type sy-msgty number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. call function formname exporting LV_PERNR = GS_MAIL-PERNR. hrdata = hrdata.

******************************************************************************** ****************** * call function 'GET_PRINT_PARAMETERS' * exporting * authority = space * copies = '1' * cover_page = space * data_set = space * department = space * destination = space

* expiration = '1' * immediately = space * new_list_id = 'X' * no_dialog = 'X' * user = sy-uname * importing * out_parameters = mstr_print_parms * valid = mc_valid * exceptions * archive_info_not_found = 1 * invalid_print_params = 2 * invalid_archive_params = 3 * others = 4. * * concatenate 'PAY' lv_pernr sy-datum sy-uzeit into job_name. * call function 'JOB_OPEN' * exporting * jobname = job_name * importing * jobcount = job_cnt * exceptions * cant_create_job = 1 * invalid_job_data = 2 * jobname_missing = 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. * * ** submitting the spool request * submit (gv_report) "#EC CI_SUBMIT * to sap-spool * spool parameters mstr_print_parms * without spool dynpro * via job job_name number job_cnt * with pnptimed eq pnptimed "curr period, other period, etc * with pnpbegda eq pnpbegda "selection begin date * with pnpendda eq pnpendda "selection end date * with pnpxabkr eq pnpxabkr "payroll period * with pnppabrp eq pnppabrp * with pnppabrj eq pnppabrj * with pnppayty eq pnppayty * with pnppayid eq pnppayid * with pnpbondt eq pnpbondt * with pnppernr eq lv_pernr"IN pnppernr "pernrs * with pnpabkrs in pnpabkrs "payroll periods **UNNI - 1122174 - passing PNP Personnel Area table - Begin * with pnpwerks in pnpwerks **UNNI - 1122174 - End of changes **UNNI - 1102750 - passing sort tables - Begin * with pnpsort eq pnpsort * with pnpsortt eq pnpsortt **UNNI - 1102750 - End of changes **KVHN1459714 - Starts * with pnpansvh in pnpansvh * with pnpbtrtl in pnpbtrtl * with pnpbukrs in pnpbukrs * with pnpename in pnpename

* with pnpfistl in pnpfistl * with pnpfkber in pnpfkber * with pnpgeber in pnpgeber * with pnpgsber in pnpgsber * with pnpjuper in pnpjuper * with pnpkokrs in pnpkokrs * with pnpkostl in pnpkostl * with pnporgeh in pnporgeh * with pnppersg in pnppersg * with pnppersk in pnppersk * with pnpplans in pnpplans * with pnpsacha in pnpsacha * with pnpsachp in pnpsachp * with pnpsachz in pnpsachz * with pnpsname in pnpsname * with pnpstat1 in pnpstat1 * with pnpstat2 in pnpstat2 * with pnpstat3 in pnpstat3 * with pnpstell in pnpstell * with pnpvdsk1 in pnpvdsk1 **KVHN1459714 - Ends * with p_popup eq p_popup "show print popup switch * and return. * * call function 'JOB_CLOSE' * exporting * jobcount = job_cnt * jobname = job_name * strtimmed = 'X' * exceptions * cant_start_immediate = 1 * invalid_startdate = 2 * jobname_missing = 3 * job_close_failed = 4 * job_nosteps = 5 * job_notex = 6 * lock_failed = 7 * invalid_target = 8 * others = 9. * if sy-subrc <> 0. ** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO ** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. * endif. * * commit work. * if sy-subrc = 0. * do. ** selecting from tbtcp table the spool id * select single * * from tbtcp * where jobname = job_name and * jobcount = job_cnt and * stepcount = 1 and * listident <> '0000000000'. * if sy-subrc = 0. * exit. * endif. * enddo. * endif. *

* **converting the spool request into pdf * data lv_listident type tsp01-rqident. * data lt_otf type tsfotf. * data lv_flag type i value 0. * data lv_status type tbtcjob-status. * move tbtcp-listident to lv_listident. * lv_listident = lv_listident - 1. * * call function 'RSPO_GET_PAGES_SPOOLJOB' * exporting * rqident = lv_listident * importing * rq = gs_tsp01 * exceptions * no_such_job = 1 * others = 2. * if sy-subrc <> 0. * message ' No Payslip for the Employee in this period!' type 'S'. * elseif gs_tsp01-rq0name <> 'HRFORM'. * message ' No Payslip for the Employee in this period!' type 'S'. * else. * call function 'RSPO_RETURN_SPOOLJOB' * exporting * rqident = lv_listident * tables * buffer = lt_otf * exceptions * no_such_job = 1 * job_contains_no_data = 2 * selection_empty = 3 * no_permission = 4 * can_not_access = 5 * read_error = 6 * type_no_match = 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. * lv_flag = 1. * endif. * endif. * * * * check sy-subrc = 0. * * do. * * call function 'BP_JOB_CHECKSTATE' * exporting * dialog = 'N' * jobcount = job_cnt * jobname = job_name * importing * actual_status = lv_status * exceptions * checking_of_job_has_failed = 1 * correcting_job_status_failed = 2

* * * * * * ** ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** ** * * * ** * * * * *

invalid_dialog_type = 3 job_does_not_exist = 4 no_check_privilege_given = 5 ready_switch_too_dangerous = 6 others = 7. if sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. if lv_status = 'F'. exit. endif. enddo. data lv_spoolid type tsp01_sp0r-rqid_char. move tbtcp-listident to lv_spoolid. call function 'RSPO_R_RDELETE_SPOOLREQ' exporting spoolid = lv_spoolid. clear lv_spoolid. move lv_listident to lv_spoolid. call function 'RSPO_R_RDELETE_SPOOLREQ' exporting spoolid = lv_spoolid. call function 'BP_JOB_DELETE' exporting jobcount = job_cnt jobname = job_name exceptions cant_delete_event_entry = 1 cant_delete_job = 2 cant_delete_joblog = 3 cant_delete_steps = 4 cant_delete_time_entry = 5 cant_derelease_successor = 6 cant_enq_predecessor = 7 cant_enq_successor = 8 cant_enq_tbtco_entry = 9 cant_update_predecessor = 10 cant_update_successor = 11 commit_failed = 12 jobcount_missing = 13 jobname_missing = 14 job_does_not_exist = 15 job_is_already_running = 16 no_delete_authority = 17 others = 18. if sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. if lv_flag = 1. displaying payslip call function 'HR_EFI_SHOW_PDF_FORM' tables otf_table = lt_otf. endif.

endform. " SUB_SHOW_PAYSLIP *&---------------------------------------------------------------------* *& Form SUB_DISABLE_FIELDS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_disable_fields . loop at screen. if screen-group1 = 'PSL'. screen-input = 0. modify screen. endif. endloop. endform. " SUB_DISABLE_FIELDS *&---------------------------------------------------------------------* *& Form SUB_CHECK_POST_PERNR *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_GS_PERNR text * <--P_LV_INDCTR text *----------------------------------------------------------------------* form sub_check_post_pernr using p_pernr type p_pernr changing p_indctr type c. data: lv_lines type i, lv_post type c, lv_date1 type char10, lv_date2 type char10, lv_msg type char20. write gv_start_date to lv_date1. write gv_end_date to lv_date2. concatenate lv_date1 '-' lv_date2 into lv_msg. * fetching the sequence numbers from HRPY_RGDIR for the employee in the given pe riod select seqnr into table gt_seqnr from hrpy_rgdir where pernr = p_pernr and fpbeg >= gv_start_date and fpend <= gv_end_date. * to select the latest record describe table gt_seqnr lines lv_lines. if lv_lines = 0. gt_log-pernr = p_pernr. gt_log-class = '00'. gt_log-msgno = '398'. gt_log-msgv1 = 'There is no Payroll Run for the Period'. gt_log-msgv2 = lv_msg. gt_log-sever = 'E'. append gt_log. p_indctr = 'X'.

exit. endif. read table gt_seqnr into gs_seqnr index lv_lines. gv_seqnr = gs_seqnr-seqnr. * to check whether the finance posting is done or not call function 'HR_EVAL_PROD_A_RUN_GET' exporting perno = p_pernr seqno = gv_seqnr importing run_not_posted = lv_post exceptions no_run_found = 1 others = 2. if sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. if lv_post = 'X'. gt_log-pernr = p_pernr. gt_log-class = '00'. gt_log-msgno = '398'. gt_log-msgv1 = 'Account Posting'. gt_log-msgv2 = 'Not Found'. gt_log-sever = 'E'. append gt_log. p_indctr = 'X'. exit. endif. endform. " SUB_CHECK_POST_PERNR *&---------------------------------------------------------------------* *& Form SUB_SHOW_ERROR_LOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_show_error_log . data lv_count type i. sort gt_log[]. delete adjacent duplicates from gt_log[]. describe table gt_log lines lv_count. if lv_count < 1. message 'No Error Log generated.' type 'S'. elseif lv_count >= 1. call function 'HR_BEN_SHOW_ERROR_LOG' exporting title = 'ERROR LOG' tree_text = 'ERROR' tables error_table = gt_log. endif. endform. " SUB_SHOW_ERROR_LOG *&---------------------------------------------------------------------*

*& Form SUB_GET_SELECTED_EMP *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_get_selected_emp . data: lv_cnt type i, lv_chk type c, ls_mail type ts_mail. refresh: gt_selected. sy-lsind = sy-lsind - 1. lv_cnt = 1. do. read line lv_cnt index sy-lsind field value gv_check into lv_chk gs_mail-pernr into ls_mail-pernr gs_mail-usrid into ls_mail-usrid . if sy-subrc <> 0. exit. endif. if lv_chk = 'X'. append ls_mail to gt_selected. clear ls_mail. endif. lv_cnt = lv_cnt + 1. enddo. endform. " SUB_GET_SELECTED_EMP *&---------------------------------------------------------------------* *& Form SUB_SEND_EMAIL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_GV_MAIL_ID text *----------------------------------------------------------------------* form sub_send_email using p_mail_id type so_recname p_pernr type p_pernr. data: lv_body type string, lv_date1 type char10, lv_date2 type char10. refresh gt_mess_bod. * default subject matter gd_subject = 'Payslip'. gd_attachment_desc = 'Payslip'. gd_attachment_name = 'Payslip'. write gv_start_date to lv_date1. write gv_end_date to lv_date2. concatenate 'Payslip for period' lv_date1 '-' lv_date2 into lv_body separated by ' '. gt_mess_bod = lv_body. append gt_mess_bod. gt_mess_bod = 'EMAMI PVT. INDIA LTD.'. append gt_mess_bod. gd_sender_type = 'INT'.

* with all the parameters and attachment sending the mail perform send_file_as_email_attachment tables gt_mess_bod gt_mess_att using p_mail_id 'Payslip Attachment' 'PDF' gd_attachment_name gd_attachment_desc gv_sender gd_sender_type gd_subject p_pernr changing gd_error gd_reciever. endform. " SUB_SEND_EMAIL *&---------------------------------------------------------------------* *& Form SEND_FILE_AS_EMAIL_ATTACHMENT *&---------------------------------------------------------------------* * Send email *----------------------------------------------------------------------* form send_file_as_email_attachment tables it_message it_attach using p_email p_mtitle p_format p_filename p_attdescription p_sender_address p_sender_addres_type p_subject p_pernr changing p_error p_reciever. data: ld_error type sy-subrc, ld_reciever type sy-subrc, ld_mtitle like sodocchgi1-obj_descr, ld_email like somlreci1-receiver, ld_format type so_obj_tp , ld_attdescription type so_obj_nam , ld_attfilename type so_obj_des , ld_sender_address like soextreci1-receiver, ld_sender_address_type like soextreci1-adr_typ, ld_receiver like sy-subrc, t_header type standard table of solisti1 with header line. data: t_packing_list like sopcklsti1 occurs 0 with header line, t_contents like solisti1 occurs 0 with header line, t_receivers like somlreci1 occurs 0 with header line, t_attachment like solisti1 occurs 0 with header line, t_object_header like solisti1 occurs 0 with header line, w_cnt type i, w_sent_all(1) type c, w_doc_data like sodocchgi1 . ld_email = p_email. ld_mtitle = p_mtitle. ld_format = p_format.

ld_attdescription = p_attdescription. ld_attfilename = p_filename. ld_sender_address = p_sender_address. ld_sender_address_type = p_sender_addres_type. t_header-line = p_subject. append t_header. * fill the document data. w_doc_data-doc_size = 1. * populate the subject/generic message attributes w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = 'SAPRPT'. w_doc_data-obj_descr = ld_mtitle . w_doc_data-sensitivty = 'F'. * fill the document data and get size of attachment clear w_doc_data. describe table it_attach lines w_cnt. read table it_attach index w_cnt. w_doc_data-doc_size = ( w_cnt - 1 ) * 255 + strlen( it_attach ). w_doc_data-obj_langu = sy-langu. w_doc_data-obj_name = 'SAPRPT'. w_doc_data-obj_descr = ld_mtitle. w_doc_data-sensitivty = 'F'. clear t_attachment. refresh t_attachment. t_attachment = it_attach. t_attachment[] = it_attach[]. * describe the body of the message clear t_packing_list. refresh t_packing_list. t_packing_list-transf_bin = space. t_packing_list-head_start = 1. t_packing_list-head_num = 0. t_packing_list-body_start = 1. describe table it_message lines t_packing_list-body_num. t_packing_list-doc_type = 'RAW'. append t_packing_list. * create attachment notification t_packing_list-transf_bin = 'X'. t_packing_list-head_start = 1. t_packing_list-head_num = 1. t_packing_list-body_start = 1. describe table t_attachment lines t_packing_list-body_num. t_packing_list-doc_type = ld_format. t_packing_list-obj_descr = ld_attdescription. t_packing_list-obj_name = ld_attfilename. t_packing_list-doc_size = t_packing_list-body_num * 255. append t_packing_list. * add the recipients email address clear t_receivers. refresh t_receivers. t_receivers-receiver = ld_email. t_receivers-rec_type = 'U'. t_receivers-com_type = 'INT'. t_receivers-notif_del = 'X'. t_receivers-notif_ndel = 'X'.

append t_receivers. * to send the mail with attachment call function 'SO_DOCUMENT_SEND_API1' exporting document_data = w_doc_data sender_address = ld_sender_address sender_address_type = ld_sender_address_type commit_work = 'X' importing sent_to_all = w_sent_all tables object_header = t_header packing_list = t_packing_list contents_bin = t_attachment contents_txt = it_message receivers = t_receivers 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. gt_error-pernr = p_pernr. gt_error-arbgb = sy-msgid. gt_error-msgno = sy-msgno. gt_error-msgv1 = sy-msgv1. gt_error-msgv2 = sy-msgv2. gt_error-msgv3 = sy-msgv3. gt_error-msgv4 = sy-msgv4. gt_error-msgty = 'E'. append gt_error. else. gv_sent = gv_sent + 1. endif. * populate zerror return code ld_error = sy-subrc. endform. "SEND_eMAIL *&---------------------------------------------------------------------* *& Form SUB_SHOW_MAIL_ERROR_LOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form sub_show_mail_error_log . data: lv_char1 type n, lv_char2 type n, lv_msg type trantree-stext. move gv_selec to lv_char1. move gv_sent to lv_char2. concatenate 'Log:' lv_char2 'out of' lv_char1 'mails sent.' into lv_msg separa

ted by ' '. data lv_count type i. sort gt_error[]. delete adjacent duplicates from gt_error[]. describe table gt_error lines lv_count. if lv_count < 1. gt_error-arbgb = gt_error-msgty = gt_error-msgno = gt_error-msgv1 = append gt_error. endif. '00'. 'S'. '398'. 'All mails sent successfully'.

call function 'HR_DISPLAY_ERROR_LIST' exporting no_print = 'X' no_img = ' ' no_msgno = 'X' linesize = sy-linsz listheader = lv_msg colheader = 'Message' tables error = gt_error exceptions invalid_linesize = 1 others = 2. if sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. endform. " SUB_SHOW_MAIL_ERROR_LOG *&---------------------------------------------------------------------* *& Form SUB_SEND *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_GV_MAIL_ID text * -->P_LS_SELECTED_PERNR text *----------------------------------------------------------------------* form sub_send using mail_id selected_pernr. data: lv_body type soli_tab, lt_message_body type bcsy_text value is initial, lv_body1 type soli, lv_header type soli_tab, lv_string type string, lv_date1 type char10, lv_date2 type char10, lv_vorna type pa0002-vorna, lv_nachn type pa0002-nachn, lv_midnm type pa0002-midnm, lv_anred type pa0002-anred, lv_name type string, lv_atext type char5, lv_ename type string.

clear: send_request, pdf_content, document, recipient, sent_to_all. * fetching the name of the employee select single vorna midnm nachn anred from pa0002 into (lv_vorna , lv_midnm , lv_nachn , lv_anred) where pernr = selected_pernr and begda <= gv_end_date and endda >= gv_end_date. select single atext from t522t into lv_atext where sprsl = 'E' and anred = lv_anred. if lv_midnm is initial. concatenate lv_atext '.' lv_vorna into lv_name. else. concatenate lv_atext '.' lv_vorna ' ' lv_midnm into lv_name. endif. concatenate 'Dear' lv_name lv_nachn ',' into lv_ename separated by ' '. write gv_start_date to lv_date1. write gv_end_date to lv_date2. concatenate 'Please find the attached Payslip for period' lv_date1 '-' lv_date 2 into lv_string separated by ' '. append lv_ename to lt_message_body. append '' to lt_message_body. append lv_string to lt_message_body. append '' to lt_message_body. ** CONCATENATE '***Wishing you and your family a very Happy Durga Puja***' '.' into lv_string SEPARATED BY ' '. ** APPEND lv_string TO lt_message_body. ** APPEND '' TO lt_message_body. ** APPEND '' TO lt_message_body. append 'Thank you,' to lt_message_body. append 'EMAMI Ltd.' to lt_message_body. move mail_id to mailto. try. * create persistent send request send_request = cl_bcs=>create_persistent( ). * create and set document pdf_content = cl_document_bcs=>xstring_to_solix( pdf_xstring ). document = cl_document_bcs=>create_document( i_type = 'RAW' i_text = lt_message_body i_subject = 'Payslip' ).

* attaching payslip document->add_attachment( exporting i_attachment_type = 'PDF' i_attachment_subject = 'Payslip' i_attachment_size = pdf_size i_att_content_hex = pdf_content ). * * * * * * * document = cl_document_bcs=>create_document( i_type = 'PDF' "i_text = lv_body i_hex = pdf_content i_length = pdf_size "i_header = lv_header i_subject = 'Payslip' ).

* add document object to send request send_request->set_document( document ). * add recipient (e-mail address) * create recipient object recipient = cl_cam_address_bcs=>create_internet_address( mailto ). * add recipient object to send request send_request->add_recipient( recipient ). * send document sent_to_all = send_request->send( i_with_error_screen = 'X' ). commit work. if sent_to_all is initial. gt_error-pernr = selected_pernr. message i500(sbcoms) with mailto into gt_error-msgv1. gt_error-msgty = 'E'. append gt_error. else. gv_sent = gv_sent + 1. endif. * exception handling catch cx_bcs into bcs_exception. gt_error-pernr = selected_pernr. message i865(so) with bcs_exception->error_type into gt_error-msgv1. gt_error-msgty = 'E'. append gt_error. endtry. endform. " SUB_SEND

Você também pode gostar