Send Report output to spool
Hi,
i developed one report.My Requirement is i have to send that report output to spool and aswell as i have to display the output in the output screen.At present i am using GET_PRINT_PARAMETERS function module.
Regards,
Kiran Kumar.G.A
Hi
FORM GET_PRINTER_PARAMETERS .
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = GV_SPLD
COPIES = 1
LIST_NAME = 'TEST'
LIST_TEXT = 'Test NEW-PAGE PRINT ON'
IMMEDIATELY = ' '
RELEASE = ' '
NEW_LIST_ID = 'X'
EXPIRATION = DAYS
LINE_SIZE = 255
LINE_COUNT = 65
LAYOUT = 'Y_PAPER'
SAP_COVER_PAGE = 'X'
RECEIVER = 'SAP*'
DEPARTMENT = 'System'
SAP_OBJECT = 'RS'
AR_OBJECT = 'TEST'
ARCHIVE_ID = 'XX'
ARCHIVE_INFO = 'III'
ARCHIVE_TEXT = 'Description'
NO_DIALOG = 'X'
IMPORTING
OUT_PARAMETERS = PARAMS
OUT_ARCHIVE_PARAMETERS = ARPARAMS
VALID = VALID.
NEW-PAGE PRINT ON
NEW-SECTION
PARAMETERS PARAMS
ARCHIVE PARAMETERS ARPARAMS
NO DIALOG.
LOOP AT GT_FINAL_ABAP_TABLE INTO GS_FINAL_ABAP_TABLE.
*To print each ABAP spool in new page
IF GS_FINAL_ABAP_TABLE = 'NEW-PAGE'.
NEW-PAGE.
ENDIF.
IF GS_FINAL_ABAP_TABLE <> 'NEW-PAGE'.
WRITE / GS_FINAL_ABAP_TABLE.
ENDIF.
ENDLOOP .
NEW-PAGE PRINT OFF .
SELECT RQIDENT
RQCLIENT
RQO1NAME
INTO TABLE GT_TSP01
FROM TSP01
WHERE RQOWNER = SY-UNAME
AND RQ2NAME = 'TEST' .
IF SY-SUBRC = 0 .
SORT GT_TSP01 BY RQIDENT DESCENDING.
READ TABLE GT_TSP01 INTO GS_TSP01 INDEX 1.
FREE GT_TSP01.
ENDIF
Reward if useful
narendra
Similar Messages
-
Need to send report output to spool
HI,
I dont need to run the report in background.....But i need to get the output in spool ... is there any function module.....give me some sample coding....
rgds
SaravanaThe easiest way of printing a list while creating it, is for the user to choose Execute + print on the report's selection screen. The user can choose between displaying the list on the screen (choosing Execute) or printing it directly without displaying it (choosing Execute + print).
use this function module SET_PRINT_PARAMETERS' to send a report directly to spool.
sample program.
REPORT SAPMZTST NO STANDARD PAGE HEADING LINE-COUNT 0(2).
PARAMETERS P TYPE I.
INITIALIZATION.
CALL FUNCTION 'SET_PRINT_PARAMETERS'
EXPORTING
ARCHIVE_MODE = '3'
COPIES = '5'
DEPARTMENT = 'BASIS'
DESTINATION = 'LT50'
EXPIRATION = ' '
IMMEDIATELY = 'X'
LAYOUT = 'X_65_132'
LINE_COUNT = 54
LINE_SIZE = 20
LIST_NAME = 'Test'
LIST_TEXT = 'Test for User''s Guide'
NEW_LIST_ID = 'X'
RECEIVER = 'KELLERH'
RELEASE = ' '
SAP_COVER_PAGE = 'X'.
START-OF-SELECTION.
DO P TIMES.
WRITE / SY-INDEX.
ENDDO.
TOP-OF-PAGE.
WRITE: 'Page', SY-PAGNO.
ULINE.
END-OF-PAGE.
ULINE.
WRITE: 'End of', SY-PAGNO.[/code]
or
Printing Lists
You can send a list from a called program directly to the spool system instead of displaying it on the screen. To do this, use the TO SAP-SPOOL addition in the SUBMIT statement:
SUBMIT... TO SAP-SPOOL print-parameters.
follow this link for more information.
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba54635c111d1829f0000e829fbfe/content.htm -
Send report output to SPOOL only, but do not print
It looks like I'm almost there, just one more issue to solve We had a report with ALV output to the screen. The customer requested that we make this report available to run in batch, with its output sent to the spool.
What I've done now is create a wrapper program that calls GET_PRINT_PARAMETERS with parameters to suppress the dialog and retain the spool job (release parameter is empty) after completion.
When the 'valid' flag is x'ed, submits the original report like this:
SUBMIT zcheck_nsn_hers TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
ARCHIVE PARAMETERS archi_parameters
WITHOUT SPOOL DYNPRO.
However when I execute the wrapper report, I still get a popup to print the job. Afterwards, the spool request remains and can be viewed (perfect!). Now all I want to do is make sure that SAP does not try to print it immediately.
Is that something that I can control from the program, or could this be in the settings for the spool (i.e. automatically print when a job arrives)?
Thanks in advance!Hi,
In FM GET_PRINT_PARAMETERS pass space to IMMEDIATELY
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'Dest'
list_name = 'name'
immediately = ' '
no_dialog = 'X'
IMPORTING
out_parameters = print_parameters
valid = valid_flag.
Regards,
Srini. -
How to maintain the report output in Spool
Hi All,
I have a requirement to display a normal report and also send the same report output to spool simultaneously while executing in foreground. How can this be done? Any kind of help is welcome.
Regards,
BansiHi,
try creating your own spool request.
Sample
FORM maak_aparte_spool .
DATA: l_layout LIKE tsp01-rqpaper,
l_doctype LIKE tsp01-rqdoctype,
l_name TYPE tsp01-rq0name,
l_length TYPE i,
l_pri_params TYPE pri_params,
l_spool_handle TYPE sy-tabix,
lv_lines TYPE i,
l_line_length TYPE i.
l_doctype = 'LIST'.
l_layout = 'X_PAPER'.
l_name = l_pri_params-plist.
** Open Spool
CALL FUNCTION 'RSPO_SR_OPEN'
EXPORTING
dest = 'PDUM'
layout = l_layout
name = l_name
immediate_print = l_pri_params-primm
titleline = 'this'
receiver = l_pri_params-prrec
division = l_pri_params-prabt
authority = l_pri_params-prber
doctype = l_doctype
IMPORTING
handle = l_spool_handle
spoolid = gv_spool_nr
EXCEPTIONS
device_missing = 1
name_twice = 2
no_such_device = 3
operation_failed = 4
OTHERS = 5.
** Schrijven naar spool
LOOP AT gt_spool INTO gs_spool.
lv_lines = lv_lines + 1.
l_line_length = 255.
CALL FUNCTION 'RSPO_SR_WRITE'
EXPORTING
handle = l_spool_handle
text = gs_spool
length = l_line_length.
IF lv_lines EQ '65'.
CALL FUNCTION 'RSPO_SR_PAGE_BREAK'
EXPORTING
handle = l_spool_handle
EXCEPTIONS
handle_not_valid = 1
operation_failed = 2
OTHERS = 3.
CLEAR: lv_lines.
ENDIF.
ENDLOOP.
* Zorg ervoor dat er op het einde zoiezo een page break zit
* dit ivm met het openen van de PDF
CALL FUNCTION 'RSPO_SR_PAGE_BREAK'
EXPORTING
handle = l_spool_handle
EXCEPTIONS
handle_not_valid = 1
operation_failed = 2
OTHERS = 3.
** Spool sl
CALL FUNCTION 'RSPO_SR_CLOSE'
EXPORTING
handle = l_spool_handle.
ENDFORM. " MAAK_APARTE_SPOOL
Best regards,
John -
Very urjent how to send report output in mail
hi experts,
how to send report output in mail which function module should i use wht parameters should i pass.
thanks in addavnce,
points to be awarded.CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = '026c'
copies = count
list_name = 'VATS_ASBUILT'
list_text = v_list
immediately = 'X'
release = 'X'
new_list_id = 'X'
expiration = days
line_size = 132
line_count = 65
layout = 'X_65_132'
* sap_cover_page = 'X'
* cover_page = 'X'
receiver = 'SAP*'
department = 'VATS'
no_dialog = 'X'
IMPORTING
out_parameters = params
valid = valid.
SUBMIT zppr_vats_asbuilt WITH p_aufnr EQ v_aufnr
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS params
AND RETURN.
SELECT SINGLE rqident FROM tsp01 INTO l_spoolno
WHERE rqtitle = v_list .
* convert report to PDF format
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = l_spoolno
no_dialog = 'X'
TABLES
pdf = l_ipdf
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.
EXIT .
ENDIF.
Now comes the part to send the mail
try.
* -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
clear document.
* -------- create and set document with attachment ---------------
* create document from internal table with text
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = text
i_length = '12'
i_subject = '' ).
*changing the content of the attachment
binary_content[] = l_iobjbin[].
*change the name of the PDF attachment
concatenate 'Build ID' s_buildid_i 'Rev' v_buildid_rev
into i_att_sub separated by space.
* add attachment to document
call method document->add_attachment
exporting
i_attachment_type = 'PDF'
i_attachment_subject = i_att_sub
i_att_content_hex = binary_content.
*setting the option to send an e-mail more than 50 characters
call method send_request->set_message_subject
exporting
ip_subject = t_sub.
* add document to send request
call method send_request->set_document
exporting
i_document = document.
* --------- set sender -------------------------------------------
* note: this is necessary only if you want to set the sender
* different from actual user (SY-UNAME). Otherwise sender is
* set automatically with actual user.
sender = cl_sapuser_bcs=>create( 'VATSUPPORT' ).
call method send_request->set_sender
exporting
i_sender = sender.
*Send the list based on receivers list obtained
loop at l_ireclist.
AD_SMTPADR = l_ireclist-receiver.
* --------- add recipient (e-mail address) -----------------------
* create recipient - please replace e-mail address !!!
recipient = cl_cam_address_bcs=>create_internet_address(
AD_SMTPADR ).
* add recipient with its respective attributes to send request
call method send_request->add_recipient
exporting
i_recipient = recipient
i_express = 'X'.
ENDLOOP.
call method send_request->set_status_attributes
exporting
i_requested_status = 'E'
i_status_mail = 'E'.
* To send the mail immediately
call method send_request->set_send_immediately( 'X' ).
* ---------- send document ---------------------------------------
call method send_request->send( ).
commit work. -
Submitting Report output to spool
Hi All,
We have problem while submitting reort output to spool.Have tried using FM'Get_print_parameters and submitting the report using stmt
SUBMIT REP TO SAP-SPOOL AND RETURN.We have to submit report output to spool
But its going to infinite loop.Any help is utmost regarded as this is very urgent.
Thanks and Regards,
Raj.Hi,
See this sample code it might help u.
http://sap.ionelburlacu.ro/abap/sap2/Save_Report_Output_to_a_PDF_File.html
Save Report Output to a PDF File
This report takes another report as input, and captures the output of that report. The output is then converted to PDF and saved to a local file. This shows how to use some of the PDF function modules, as well as an easy way to create PDF files.
One thing I am not thrilled about is how the spool number is retrieved. If anyone has any better method, please let me know! Until I actually have a production use for a program like this, I will not try to find a better way.
Source Code Listing
report zabap_2_pdf.
*-- Enhancements: only allow to be run with variant. Then called
*-- program will be transparent to users
*-- TABLES
tables:
tsp01.
*-- STRUCTURES
data:
mstr_print_parms like pri_params,
mc_valid(1) type c,
mi_bytecount type i,
mi_length type i,
mi_rqident like tsp01-rqident.
*-- INTERNAL TABLES
data:
mtab_pdf like tline occurs 0 with header line,
mc_filename like rlgrap-filename.
*-- SELECTION SCREEN
parameters:
p_repid like sy-repid, " Report to execute
p_linsz like sy-linsz default 132, " Line size
p_paart like sy-paart default 'X_65_132'. " Paper Format
start-of-selection.
concatenate 'c:'
p_repid
'.pdf'
into mc_filename.
*-- Setup the Print Parmaters
call function <b>'GET_PRINT_PARAMETERS'</b>
exporting
authority= space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
in_archive_parameters = space
in_parameters = space
layout = space
mode = 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.
*-- Make sure that a printer destination has been set up
*-- If this is not done the PDF function module ABENDS
if mstr_print_parms-pdest = space.
mstr_print_parms-pdest = 'LOCL'.
endif.
*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
mstr_print_parms-linsz = p_linsz.
mstr_print_parms-paart = p_paart.
<b> submit (p_repid) to sap-spool without spool dynpro
spool parameters mstr_print_parms
via selection-screen
and return.</b>*-- Find out what the spool number is that was just created
perform get_spool_number using sy-repid
sy-uname
changing mi_rqident.
*-- Convert Spool to PDF
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid= mi_rqident
no_dialog = space
dst_device = mstr_print_parms-pdest
importing
pdf_bytecount = mi_bytecount
tables
pdf = mtab_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.
call function 'DOWNLOAD'
exporting
bin_filesize = mi_bytecount
filename = mc_filename
filetype = 'BIN'
importing
act_filename = mc_filename
tables
data_tab = mtab_pdf.
* FORM get_spool_number *
* Get the most recent spool created by user/report *
* --> F_REPID *
* --> F_UNAME *
* --> F_RQIDENT *
form get_spool_number using f_repid
f_uname
changing f_rqident.
data:
lc_rq2name like tsp01-rq2name.
concatenate f_repid+0(8)
f_uname+0(3)
into lc_rq2name separated by '_'.
select * from tsp01 where rq2name = lc_rq2name
order by rqcretime descending.
f_rqident = tsp01-rqident.
exit.
endselect.
if sy-subrc ne 0.
clear f_rqident.
endif.
endform." get_spool_number
Hope this helps u.
Also refer
Re: PDF Output
PDF Output
Message was edited by: Judith Jessie Selvi -
Need help reg. Conversion of report output into spool
Hi Experts,
I need to convert the report output into spool while report is executed in foreground not in background. Please let me know your inputs.
Thanks
GopalSUBMIT... TO SAP-SPOOL AND RETURN : Prints output of a report that you call with the SUBMIT keyword. As with NEW-PAGE PRINT ON, the list is printed during its generation, so that both PRINT-CONTROL and FORMAT keywords take effect. Also, SUBMIT... TO SAP-SPOOL AND RETURN allows the programmer to set the format and other printing parameters. As with NEW-PAGE PRINT ON, you can set printing and archiving parameters with the GET_PRINT_PARAMETERS function module.
CONVERT_ABAPSPOOLJOB_2_PDF convert abap spool output to PDF -
Send report output as pdf attachment (without collecting spool )
I used to do this requirement by collecting the spool and then convert it to pdf. But in this case we should use the report output ( NOT FROM SPOOL ) and convert it to PDF and send it as email attachment.
Please help.
Thanks!Hi,
I can think of these options. Please explore on the possibilities.
1) Create one MAIN Report , which will submit your report. Get the List output from memory. Convert the Data to PDF and send the PDF as attachment in mail.
2) Create a smartform which will be called in your report. Convert the returned data to PDF and then send the PDF as attachment in mail.
3) Create one MAIN Report , which will submit your report thorugh a JOB. Wait for the JOB to be completed. Convert the ABAP Spool data to PDF and send the PDF as attachment in mail.
Regards,
Abhishek -
Sending report output via E-mail (excel pivoted format)
Hi all,
i have a written a report where i need to send the report output to somebody via
E-mail.i am sending this report output via E-mail successfully.The receiver receives, my output in excel format.but this excel is not <b>pivoted</b>.
i want , the receiver should get my output in pivoted excel format.i.e my output data should be exactly fit in the excel sheet.
now the columns in excel sheet are overlapping.once i double clicked, the columns are getting separated.i do not want to double click.i want all the columns should come properly i.e excel field length should be adjusted as per the output field length.
i am giving my coding below.plz suggest how i can do the above thing .it's urgent.
any idea will be highly appreaciated.
Regards
if not p_email1 is initial.
perform fill_report_csv.
perform f_send_internet_mail.
endif.
FORM fill_report_csv.
data : l_text(232) type c,
v_matnr1(21) type c,
v_matnr(21) type c,
v_matkl(14) type c,
v_maktx(45) type c,
v_ttlstk(14) type c,
v_verpr(14) type c,
v_werks(14) type c,
v_lgort(14) type c,
v_char(10) type c,
v_stks type p ,
v_po(40) type c,
v_qty(13) type c,
v_qty1 type sy-datum,
v_date(15) type c,
v_date1(15) TYPE C,
v_name(35) type c,
v_eknam(18) type c,
v_lifnr(15) type c,
l_po(40) type c,
v_matnr(20) type c,
l_rate(11) type p decimals 5,
l_flag type c.
concatenate c_equal c_colon 'PO no.' c_colon
into v_po.
concatenate c_equal c_colon 'Material no.' c_colon
into v_matnr.
concatenate c_equal c_colon 'Description.' c_colon
into v_maktx.
concatenate c_equal c_colon 'Due Qty.' c_colon
into v_qty.
concatenate c_equal c_colon 'Del Date.' c_colon
into v_date.
concatenate c_equal c_colon 'Vendor.' c_colon
into v_name.
concatenate c_equal c_colon 'Buyer.' c_colon
into v_eknam.
concatenate c_equal c_colon 'Vendor Code.' c_colon
into v_lifnr.
concatenate
v_po v_matnr v_maktx v_qty
v_date v_name v_eknam v_lifnr
into i_download
SEPARATED BY con_tab.
append i_download .
clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
clear wa_output.
loop at i_output into wa_output.
on change of wa_output-ebeln.
clear v_lines.
loop at i_eket into wa_eket
where ebeln = wa_output-ebeln.
v_lines = v_lines + 1.
clear wa_eket.
endloop.
**-- Checking of page break
v_lines = sy-linno + v_lines .
if 55 < v_lines .
write:/0(161) sy-uline.
new-page.
endif.
clear v_lines.
loop at i_eket into wa_eket
where ebeln = wa_output-ebeln.
v_lines = v_lines + 1.
clear wa_eket.
endloop.
*-- Calculating the due qty.
wa_output-dumng = wa_output-menge - wa_output-wemng.
*-- Writing the Line items of the PO.
read table i_ekpo into wa_ekpo
with key ebeln = wa_output-ebeln
ebelp = wa_output-ebelp.
l_rate = wa_ekpo-netpr / wa_ekpo-peinh.
*-- Writing of PO detail
if wa_output-dumng gt 0 .
v_qty = wa_output-dumng.
v_date1 = wa_output-eindt.
v_maktx = wa_output-maktx.
if wa_output-maktx+0(1) = '"' .
concatenate c_equal wa_output-maktx
into v_maktx .
else .
concatenate c_equal c_colon wa_output-maktx c_colon
into v_maktx .
endif .
if wa_output-name1+0(1) = '"' .
concatenate c_equal wa_output-name1
into v_name .
else .
concatenate c_equal c_colon wa_output-name1 c_colon
into v_name .
endif .
v_name = wa_output-name1.
v_lifnr = wa_output-lifnr.
write wa_output-eindt to v_date1 DD/MM/YYYY.
concatenate '="' wa_output-ebeln '/'
wa_output-ebelp '"' into v_po .
concatenate '="' wa_output-matnr '"' into v_matnr .
concatenate c_equal c_colon wa_output-maktx c_colon
into v_maktx .
concatenate c_equal c_colon wa_output-dumng c_colon
into v_qty1 .
concatenate c_equal c_colon wa_output-eindt c_colon
into v_date1 .
concatenate c_equal c_colon wa_output-name1 c_colon
into v_name .
concatenate c_equal c_colon wa_output-eknam c_colon
into v_eknam .
concatenate c_equal c_colon wa_output-lifnr c_colon
into v_lifnr .
concatenate c_equal c_colon wa_mard-werks '/'
wa_mard-lgort c_colon
into v_lgort .
concatenate '="' wa_output-lifnr '"' into v_lifnr .
condense:v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
concatenate
v_po v_matnr v_maktx v_qty
v_date1 v_name v_eknam v_lifnr
into i_download
SEPARATED BY con_tab.
concatenate con_cret i_download INTO i_download .
append i_download .
endif.
clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
endloop.
ENDFORM. " fill_report_csv
*& Form f_send_internet_mail
text
--> p1 text
<-- p2 text
FORM f_send_internet_mail.
Variables
data: it_packing_list like sopcklsti1 occurs 0 with header line,
it_contents like solisti1 occurs 0 with header line,
it_receivers like somlreci1 occurs 0 with header line,
it_attachment like solisti1 occurs 0 with header line,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of SOLISTI1 initial size 0
with header line.
data : found_receiver type c,
v_title(80) type c,
l_text(180) type c.
Fill the document data.
gd_doc_data-doc_size = 1.
Adds text to email text table
append 'Pls see attached open purchase order report.' to it_message.
append '' to it_message.
concatenate 'Note: This is system generated report'
', figures may subject to actual physical count.'
into l_text separated by space.
append l_text to it_message.
Populate the subject/generic message attributes
CLEAR gd_doc_data.
READ TABLE i_download INDEX w_cnt.
gd_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( i_download ).
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
if p_asdate is initial .
concatenate p_title ' '
sy-datum sy-uzeit into v_title separated by space.
else .
concatenate p_title ' '
p_bldat p_cputm into v_title separated by space.
endif .
gd_doc_data-obj_descr = v_title .
gd_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = i_download[].
Describe the body of the message
clear it_packing_list.
refresh it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
describe table it_message lines it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
append it_packing_list.
Create attachment notification
it_packing_list-transf_bin = 'X'.
it_packing_list-head_start = 1.
it_packing_list-head_num = 1.
it_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES it_packing_list-body_num.
it_packing_list-doc_type = 'XLS'.
it_packing_list-obj_descr = 'OPEN PURCHASE ORDER' .
it_packing_list-obj_name = 'PO.XLS' .
it_packing_list-doc_size = it_packing_list-body_num * 255.
APPEND it_packing_list.
assign SAP user smtp address from successful retrieval.
loop at p_email.
Add the recipients email address
found_receiver = 'X' .
it_receivers-receiver = p_email-low.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = ''.
it_receivers-notif_ndel = 'X'.
append it_receivers .
endloop .
Add default recipient email when unable to locate purc group email
if found_receiver is initial .
it_receivers-receiver = p_email.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = ''.
it_receivers-notif_ndel = 'X'.
append it_receivers.
endif .
Call the FM to post the message to SAPMAIL
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = gd_doc_data
put_in_outbox = 'X'
commit_work = 'X'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = it_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.
Store function module return code
gd_error = sy-subrc.
Get it_receivers return code
loop at it_receivers.
endloop.
Instructs mail send program for SAPCONNECT to send email.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = ' '
and return.
endif.
ENDFORM. " f_send_internet_mailHi,
go through this link,
http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm
you have some sample programs.
Regards,
Raghavendra -
Email sending: "sending report output directly to the body of the email"
Hi
I got one requirement.this is the enhancement to already exisitng report.when user clicks on send email check box,report has to be display and this report output has to be send to email of the particular vendor. it has be seen directly in the body of the mail.not as attachement.Report output is in ALV format.Data is stored in internal table t_data.can anyone suggest what is the procedure for this.Hi i have tried the same thing and it works very fine,
i will share my code, you just follow exactly, hopefully you can solve the issue..
you refer clearly the body of the mail,
it should solve your issue/
FORM send_email .
DATA lt_message TYPE bcsy_text.
DATA lv_mail_title TYPE so_obj_des.
DATA document TYPE REF TO cl_document_bcs.
DATA recipient TYPE REF TO if_recipient_bcs.
DATA send_request TYPE REF TO cl_bcs.
DATA sent_to_all TYPE os_boolean.
DATA bcs_execption TYPE REF TO cx_bcs.
DATA wf_string(200) TYPE c.
* DATA wf_string TYPE string.
DATA doc_execption TYPE REF TO cx_document_bcs.
DATA lv_status(20) TYPE c.
DATA lv_count_email TYPE i.
DATA lv_temp_stepcount TYPE c.
LOOP AT wt_email INTO wa_email.
TRY.
CLEAR send_request.
send_request = cl_bcs=>create_persistent( ).
*Create Title
lv_mail_title = 'Report Title'.
*Create Message(EMAIL Body)
REFRESH lt_message.
APPEND '<p><b>Dear Sir/Madam,</b></p>' TO lt_message.
APPEND '<p>The following report shows the status of </p>' TO lt_message.
APPEND '<br>' TO lt_message.
APPEND '<table border= "1" color = 2>' TO lt_message.
CLEAR wf_string.
CONCATENATE '<th><tr>'
'<td>Vendor </td>'
'<td>Vendor Name</td>'
'<td>Coloun 1</td>'
'<td>Coloum 2</td>'
'</tr></th>' INTO wf_string.
APPEND wf_string TO lt_message.
LOOP AT wt_itbl INTO wa_itbl WHERE vendor = wa_email-vendor. "-> Define your Condition here wt_email( should contains vendor and its respective email id)
CLEAR wf_string.
CONCATENATE '<tr><td>' wa_itbl-vendor '</td>' INTO wf_string.
APPEND wf_string TO lt_message.
CONCATENATE '<td>' wa_itbl-Vendor_name '</td>' INTO wf_string.
APPEND wf_string TO lt_message.
CONCATENATE '<td>' wa_itbl-COL2 '</td></tr>' INTO wf_string.
APPEND wf_string TO lt_message.
CONCATENATE '<td>' wa_itbl-COL3 '</td></tr>' INTO wf_string.
APPEND wf_string TO lt_message.
ENDLOOP.
APPEND '</table>' TO lt_message.
APPEND '<br>' TO lt_message.
APPEND '<p><b>Thank You</b></p>' TO lt_message.
*Create Document
CLEAR document.
TRY.
CALL METHOD cl_document_bcs=>create_from_text
EXPORTING
i_text = lt_message
i_documenttype = 'HTM'
i_subject = lv_mail_title
RECEIVING
result = document.
CATCH cx_document_bcs INTO doc_execption.
ENDTRY.
*Add document to email
send_request->set_document( document ).
*Add recipients to send request
IF wa_email-smtp_addr IS NOT INITIAL.
recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = wa_email-smtp_addr ).
send_request->add_recipient( i_recipient = recipient ).
ENDIF.
*Send Email
CALL METHOD send_request->send
RECEIVING
result = sent_to_all.
COMMIT WORK.
IF sent_to_all EQ 'X'.
lv_count_email = lv_count_email + 1.
ENDIF.
CATCH cx_bcs INTO bcs_execption.
ENDTRY.
ENDLOOP.
IF sent_to_all = 'X'.
SKIP 2.
FORMAT COLOR COL_GROUP INTENSIFIED ON.
ULINE /(10).
WRITE: / 'Remark : '.
ULINE /(10).
FORMAT RESET.
WRITE: / 'Email Message Sent Succesfully'.
RETURN.
ENDIF.
ENDFORM. -
Sending report output to Excel
Dear buddies
I'm using OLE Object in my report to send its output to excel. I find this way from an example at the same forum. But I feel that this example is for very small sized reports which have to send a few cells to excel because in this method we've to map each boiler plate and data field to excel like this.
function B_DEPTNOFormatTrigger return boolean is
begin
RPT2XLS.put_cell(1, 'DEPTNO', FontColor => 10, FontSize => 8, FontStyle => RPT2XLS.BOLD);
RPT2XLS.new_line;
return (TRUE);
end;
In this way its very hard to map large reports to excel which have more than 50 or 60 data fields and labels. So is there any short way to send its output to excel. Be careful that I also dont wanna use Delimited option coz Delimited file has also to be formatted while importing to Excel. Is there anyway that OLE Object should automatically detect all my Report Labels and fields or some other solution in yours minds???If you are using 10g reports you can use the latest parameter desformat=spreadsheet
Rajesh Alex -
Unable to send report output to printer when using RUN_REPORT_OBJECT in 10g
Hello All,
When I try to send my report output to a file from my form(10g), I get 'FRM-41213: Unable to connect to report server'. I can sucessfully send my report to printer when I set the REPORT_DESTYPE to 'PRINTER'.Here is the code from my when-button-pressed trigger.
Am I missing something?
declare
repid REPORT_OBJECT;
v_rep VARCHAR2(100);
rep_status VARCHAR2(20);
BEGIN
repid := find_report_object('PWRR_CTRL_TYP_MAINT');
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'rep_ipkcaf7vm');
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,BATCH);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,FILE);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'DFLT');
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_FILENAME,'C:\TEST1.doc');
v_rep := RUN_REPORT_OBJECT(repid);
rep_status := REPORT_OBJECT_STATUS(v_rep);
WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
LOOP
rep_status := report_object_status(v_rep);
END LOOP;
IF rep_status = 'FINISHED' THEN
msg_alert('Report print successfully', 'I', FALSE);
ELSE
msg_alert('Error when running report', 'I', FALSE);
END IF;
END;
Thanks,
AnnaHi,
its because
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_FILENAME,'C:\TEST1.doc');
references the report rdf pr rep file to run, not the output file. The Reports output file is always specified with DESNAME
Frank -
Error when sending report output to printer from Forms 10g
Hi,
I have a simple report that I am running from a form using run_report_object built-in. I can successfully send the report output to a file but when I send the report output to a printer my report is
terminated with report status of 'TERMINATED_WITH_ERROR'. I am using the default forms service and reports server that comes with the forms builder. How do I specify the reports server to user my default network printer ?Following is the code that runs my report.
Thanks,
Anna
PROCEDURE SEND_TO_PRINTER IS
repid REPORT_OBJECT;
v_rep VARCHAR2(100);
rep_status VARCHAR2(50);
rep_server system_variables.reports_server%type;
alldone exception;
BEGIN
select reports_server
into rep_server
from system_variables;
if rep_server is null then
msg_alert('Error getting the reports server name', 'I', FALSE);
raise alldone;
end if;
:ctrl.run_report_errors := 'N';
repid := find_report_object('REP_OBJ1');
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,rep_server);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,BATCH);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
IF :ctrl.rg_print = 'P' THEN
--Send the output to printer.
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,PRINTER);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'dflt');
ELSIF :ctrl.rg_print = 'R' THEN
--Rich Text Format
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,FILE);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'rtf');
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESNAME,:ctrl.filename);
END IF;
v_rep := RUN_REPORT_OBJECT(repid);
rep_status := REPORT_OBJECT_STATUS(v_rep);
WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
LOOP
rep_status := report_object_status(v_rep);
END LOOP;
IF rep_status = 'FINISHED' THEN
null;
ELSE
:ctrl.run_report_errors := 'Y';
msg_alert('Error when running report.' || rep_status, 'I', FALSE);
END IF;
EXCEPTION
when no_data_found then
msg_alert('Error getting the reports server name', 'I', FALSE);
when alldone then
null;
END;If you use Windows the user that runs the reports server is usually LocalSystem. Check this in the Windows Services panel.
LocalSystem has no printer access. To be able to print, you have to use a real domain user that has access to the printer. So, change the Log on properties in the Services panel. -
How to send report output from SUBMIT statement
Hi,
I need to develop one report whcih can be use to send any report output in mail as attachment in txt of execl format. So i will be using SUBMIT statement to execute the report in my new report and i need to convert the reportout in txt or excel format and need to send as attachment in mail. This new report can be use to execute any report which may have ALV GRid, Normal outout screen. So what could be the best way to develop this kind of report.
Br,
Piyush>
piyush mathur wrote:
> Hi Suhas,
>
> LIST_TO_ASCI will give me data in lines. and its difficult to separate the columns in another internal table for attachment file. As this report is going to use to send any report output so i can not fixed the delimiter. So i am looking some function which can split the data in columns when I am reading from List.
> Br,
> Piyush
No need to seperate nothing additionally, this will come automatically in the attached file. Draft below
DATA list_tab TYPE TABLE OF abaplist.
SUBMIT your_report EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
DATA string_tab TYPE list_string_table.
"use table type appropriate for attchement
DATA ascii_tab TYPE soli_tab.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = ascii_tab
listobject = list_tab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\test.txt'
filetype = 'ASC'
TABLES
data_tab = ascii_tab.
DATA go_email_doc TYPE REF TO cl_document_bcs.
go_email_doc = cl_document_bcs=>create_document(
i_type = 'TXT'
go_email_doc->add_attachment( i_attachment_type = 'TXT'
i_attachment_subject = 'My Attachment'
i_att_content_text = ascii_tab ).
Regards
Marcin -
Send Report output as attachment in excel
Hi All,
I am scheduling background Job for Auto mail of standard SAP report. I am able to send the details in html format, please guide me how to send report details in excel format.
I have already check SCN but unable to find exact solution for same.
Regards
RashidRashid,
When u Go SM37 Follow This Step Then U Get The Data In Excel Format.
Follow step
Select Spool Option
Then U got the screen
Select the type option then u got screen.
In This Screen U Find the option save in Local File then get the option.
When U Select the Spreadsheet Option You can Able to save your data in excel format.
Hope its help full for you
Maybe you are looking for
-
Photoshop CS6 memory leak when idle and nothing open
Photoshop CS6 runs away with memory after being used and then going idle. If I open up PS and leave it, it will be ok but as soon as I open any file it will go up in memory usage (which is normal) but when I close all files and hide PS the memory wil
-
Update to Acrobat 9.5.1 breaks Flash functionality for reading archived emails
On installing update 9.5.1 to Acrobat Pro on WinXP, I can no longer read the index of previously archived email collections created using the Email to PDF macro in Outlook 2007. The PDF data file indices were readable before, and are still readable i
-
Can't DL previous purchased songs on authorized computer
-
VIDEO CONVERTER & ALBUM ART...someone help me ple
i have troubles with my video converter...it always show me the error thing...but not saying why cannot be converter only that it cant...and also i wanna know how to put album art thank u[img"]http://forums.creative.com/i/smilies/6x6_smiley-very-happ
-
I am trying to receive my security question but iTunes keeps sending it to the wrong email, I have the right email on the settings and Apple ID