exemplo envio email com reportanexo2

Download Exemplo Envio Email Com Reportanexo2

If you can't read please download the document

Upload: fjaimesilva

Post on 17-Dec-2015

216 views

Category:

Documents


1 download

DESCRIPTION

Exemplo Envio Email Com Reportanexo2 ABAP

TRANSCRIPT

*&---------------------------------------------------------------------**& Report ZGERALDO002*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*report zgeraldo003.*---------------------------------------------------------------------** Internal Tables **---------------------------------------------------------------------** For Sending the express maildata: itab_objhead like soli occurs 0 with header line, itab_objcont like soli occurs 0 with header line, itab_objpara like selc occurs 0 with header line, itab_objparb like soop1 occurs 0 with header line, itab_receivers like soos1 occurs 0 with header line, itab_attcont type standard table of soli, itab_auxcont type standard table of solix, itab_packing like soxpl occurs 0 with header line, itab_pdf type standard table of tline, wa_attcont like soli, wa_pdf like tline.*---------------------------------------------------------------------** Work Areas **---------------------------------------------------------------------** For Sending the express maildata: w_object_hd_change like sood1, w_folder_id like soodk, vg_bytecount type i, vg_pdfspool like tsp01-rqident.* countersdata: w_ok_count(10) type n.data: w_err_count(10) type n.data: w_tot_count(10) type n, vg_type like soodk-objtp, vg_rqident like tsp01-rqident.* pri paramsdata: print_parameters type pri_params.*---------------------------------------------------------------------** start-of-selection **---------------------------------------------------------------------*start-of-selection. break-point. w_ok_count = 200. w_err_count = 300. w_tot_count = 500. new-page print on parameters print_parameters no dialog. write / 'Relatrio de teste para e-mail com report em anexo'. skip 5. write / 'O report ser criado e poder ser acessado via SP01'. write / 'Os comandos new page print on e off, abriro a sesso'. write / 'do spoll direto no SAP spool system'. new-page print off.*---------------------------------------------------------------------** End-of-selection **---------------------------------------------------------------------*end-of-selection.* Initialize the fields clear: w_object_hd_change. clear: itab_objcont, itab_objhead, itab_objpara, itab_objparb, itab_receivers, itab_packing, itab_attcont. refresh: itab_objcont, itab_objhead, itab_objpara, itab_objparb, itab_receivers, itab_packing, itab_attcont.* Fill the message text concatenate 'Number of records processed:' w_tot_count into itab_objcont-line separated by space. append itab_objcont. concatenate 'Number of records processed Correctly:' w_ok_count into itab_objcont-line separated by space. append itab_objcont. concatenate 'Number of records Errored Out:' w_err_count into itab_objcont-line separated by space. append itab_objcont.* Fill w_object_hd_change structure w_object_hd_change-objla = sy-langu. w_object_hd_change-objnam = sy-repid. w_object_hd_change-objdes = 'Job ABC results'. w_object_hd_change-objcp = 'X'.* Specify the receivers itab_receivers-rcdat = sy-datum. itab_receivers-rctim = sy-uzeit. itab_receivers-recnam = sy-uname. "Send to UserId" itab_receivers-rtunam = sy-uname. itab_receivers-sndex = 'X'. "Express mail message. append itab_receivers.*> Carrega report vg_rqident = sy-spono.*> Usado para adicionar ordem SPOOL como anexo* call function 'RSPO_RETURN_SPOOLJOB'* exporting* rqident = vg_rqident* importing* real_type = vg_type* tables* buffer = itab_attcont* 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.** call function 'CONVERT_ABAPSPOOLJOB_2_PDF' exporting src_spoolid = vg_rqident importing pdf_bytecount = vg_bytecount pdf_spoolid = vg_pdfspool tables pdf = itab_pdf exceptions err_no_abap_spooljob = 1 err_no_spooljob = 2 err_no_permission = 3 err_conv_not_possible = 4 err_bad_destdevice = 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.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. itab_packing-transf_bin = 'X'.* itab_packing-head_start = 1.* itab_packing-head_num = 5.* itab_packing-body_start = 7.* itab_packing-body_num = 20. itab_packing-objtp = 'EXT'. "g_type. itab_packing-objdes = 'Arquivo Report em PDF'. itab_packing-file_ext = 'PDF'.* itab_packing-objlen = vg_bytecount.* describe table itab_attcont.* itab_packing-OBJLEN = sy-tleng * 3.* append itab_packing. call function 'SO_OBJECT_SEND' exporting* folder_id = w_folder_id object_hd_change = w_object_hd_change object_type = 'RAW' owner = sy-uname tables objcont = itab_objcont objhead = itab_objhead objpara = itab_objpara objparb = itab_objparb receivers = itab_receivers packing_list = itab_packing att_cont = itab_attcont exceptions others = 01.