Problem in converting reports to PDF format - bug
dear all,
There is a problem in converting the reports in PDF format.
The situation is that if we use the tool bar icon in SAP B1 to get the reports in PDF format, there are printing errors. The output PDF file does not contain the exact data that is in the report, the values are getting interchanged and mismatched.
But if we do the same using the print in the PDF option in choose from printers window as we do regular pringting, the document is printed properly.
what may be the cause for this bug like thing. How can we solve it??
please help me..
thanks and regards,
Yeshwanth Prakash
Check this SAP Note: 1089388 Incorrect value in exported PDF when Concat function is used
[https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/smb_searchnotes/display.htm?note_langu=E¬e_numm=1089388]
Similar Messages
-
How to convert report to PDF format
Hi,
Please let me know the procedure to convert reports into PDF format.
Thanks in Advance
Irfan HussainRefer these links
http://www.sap-img.com/bc037.htm
http://www.members.tripod.com/abap4/Save_Report_Output_to_a_PDF_File.html
<b>CONVERT_ABAPSPOOLJOB_2_PDF</b> FM convert abap spool output to PDF -
A big problem of Generate report with PDF format....Urgent
I want to generate a report with pdf format through one java file, it have two page 1)gen_report.jsp 2) report_gen.java , the compliation was failed. However, i don't what the problem is .... i hope anyone can help me as it is very argent for me ....Thanks a lot
1)gen_report.jsp
<table id="AutoNumber1">
<tr>
<td background="images/top5movie.png">
<p align="center"> </p>
</td>
</tr>
<tr>
<td >
<div align="center">
<table id="AutoNumber2" >
<form method="GET" action="../report_gen" name="report_gen" target="_blank" onSubmit="javascript:return checkr1(this)">
<tr>
<td ><b>Report Description:</b></td>
<td >This report is to show the top five popular movies in cinemix for a period </td>
</tr>
<tr>
<td><b>Data scope:</b></td>
<td >Start from
<input type="text" name="start" value="2003-1-1" >to
<input type="text" name="end" value="2006-1-1" ></td>
</tr>
<tr>
<td><b>Data processing:</b></td>
<td >Show
<select name="order_by">
<option value="desc" selected>top</option>
<option value="asc">bottom</option>
</select>
5 films</td>
</tr>
<tr>
<td> <p align="center">
<input type="submit" value="View_Report" name="subm">
</p></td>
</tr>
<input type="hidden" name="report" value="r1">
</form>
<form method="GET" action="../report_gen" name="report_gen" target="_blank" onSubmit="javascript:return checkr2(this)">
<input type="hidden" name="report" value="r2">
</form>
</table>
</div>
</td>
</tr>
</table>Then my java code is here
report_gen.java
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
// chart and pdf out
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.xy.*;
import org.jfree.data.xy.XYBarDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.statistics.SimpleHistogramDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.DefaultFontMapper;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.pdf.PdfPCell;
public class report_gen extends HttpServlet
private final String titles[] = {"Top Five popular movies ",
"Financial cirumstance of cinemas",
"Distribution of time segment",
"Distribution of favourite movie type"
private final String descs[] = {"This report is to show the top five popular movies in cinemix for a period ",
"This report is to show the financial circumstance of each cinema site ",
"This report is to analysis the customer when is the most visit time ",
"This report is to analysis the customer which type of movie do they watch the most"
private final String bigTitle = "Cinemix";
private final String driver = "org.gjt.mm.mysql.Driver";
private final String url= "jdbc:mysql://localhost:3306/cinemix";
private final String userID = "abc";
private final String passwd = "abc";
public void init(ServletConfig config) throws ServletException
super.init(config);
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
final int width = 550;
final int height = 200;
/ title font (centre and report title)
final Font fTitle0 = FontFactory.getFont("Helvetica", 42, Font.BOLD);
final Font fTitle1 = FontFactory.getFont("Helvetica", 30, Font.BOLD);
// centre name:
final String title0 = bigTitle;
// Default category for DefaultCategoryDataset
final String cat = "data";
Connection conn;
JFreeChart chart;
String title1 = "xyz Report";
String chartDesc = "description";
String notes[] = new String[4];
String chartTitle = "so bad this is title";
String chartXTitle = "this is x";
String chartYTitle = "this is y.";
String report = request.getParameter("report");
int max=-10000;
int min=10000;
int j=0;
// do some basic checking
if (report == null || report.equals(""))
report = "-1"; // this course unknow report error message
String start = request.getParameter("start");
String end = request.getParameter("end");
String order_by = request.getParameter("order_by"); // ToDo: check invalid string
int topN = 5;
String order = (order_by.equals("desc")) ? "Top" : "Last";
String inv[] = {"08:30", "09:30", "10:30", "11:30", "12:30", "11:30", "12:30", "13:30", "14:30", "15:30", "16:30", "17:30","18:30","19:30","20:30","21:30","22:30","23:30"};
int inv_val[] = new int[inv.length - 1];
try
Class.forName(driver).newInstance();
catch(Exception e)
printE("Cannot load mysql database driver!", response);
e.printStackTrace();
return;
try
conn = DriverManager.getConnection(url, userID, passwd);
if (report.equals("r1")) { // report 1
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
Statement stmt = conn.createStatement();
String sql = "select *,count(f.Name),f.Name from film f, filmDetail fd, ticket t where f.startDate > '" + start + "' and f.endDate < '" + end + "'and fd.filmID = f.filmID and fd.filmDetailID = t.filmDetailID group by f.name order by fd.filmDetailID asc limit '" +topN+"'";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next())
if (rs.getInt("fd.filmDetailID") > max) max = rs.getInt("fd.filmDetailID");
if (rs.getInt("fd.filmDetailID") < min) min = rs.getInt("fd.filmDetailID");
j++;
ataset.setValue(rs.getInt("fd.filmDetailID"), cat,rs.getString("f.Name"));
title1 = titles[0];
chartDesc = descs[0];
chartTitle = order + " " + topN + " popular movie";
chartYTitle = "Box Office record";
chartXTitle = "Film Name";
gender = " ";
chart = ChartFactory.createBarChart(chartTitle, chartXTitle, chartYTitle, dataset,PlotOrientation.VERTICAL, false, true, false);
else
print("Error: I don't inderstand your request!", response);
return;
catch (SQLException e)
printE("Cannot open database connection? <br>", response);
// printE(e.toString);
e.printStackTrace();
return;
response.setContentType("application/pdf");
Document document = new Document(PageSize.A4, 5, 5, 5, 5);
try
PdfWriter writer;
writer = PdfWriter.getInstance(document, response.getOutputStream());
HeaderFooter footer = new HeaderFooter(new Phrase("Page: "), true);
footer.setBorder(Rectangle.NO_BORDER);
document.setFooter(footer);
footer.setAlignment(Element.ALIGN_CENTER);
// step 3
document.open();
document.add(getHeader(title0, title1, start, end, gender, order, topN, chartDesc));
document.add(printChart(chart, writer));
document.add(getFooter(notes));
catch(DocumentException de)
de.printStackTrace();
// step 5
document.close();
return;
}// end doGet()
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
// processRequest(request, response);
/** Returns a short description of the servlet.
public String getServletInfo()
return "Generate reports for " + bigTitle;
/* To print en error and exit(?) */
private void printE(Object obj, HttpServletResponse response) throws IOException
response.setContentType("text/html");
PrintWriter out;
out = response.getWriter();
out.print(obj.toString());
out.close();
// To-Do: how to force exiting?
// create data chart
private PdfPTable getHeader(String title0, String title1, String start, String end, String sex, String order, int topN, String desc)
Font fTitle0 = FontFactory.getFont("Helvetica", 42, Font.BOLD);
Font fTitle1 = FontFactory.getFont("Helvetica", 24, Font.BOLD);
Font fTitle3 = FontFactory.getFont("Helvetica", 12, Font.BOLD);
Font fValue = FontFactory.getFont("Helvetica", 12, Font.UNDERLINE);
Paragraph parStartEnd = new Paragraph();
parStartEnd.add(new Phrase("Data start from: ", fTitle3));
parStartEnd.add(new Phrase(start, fValue));
parStartEnd.add(new Phrase(" to ", fTitle3));
parStartEnd.add(new Phrase(end, fValue));
Paragraph parGenerateDate = new Paragraph();
parGenerateDate.add(new Phrase("Report generated at: ", fTitle3));
parGenerateDate.add(new Phrase(new java.util.Date().toString(), fValue));
Paragraph parGender = new Paragraph();
parGender.add(new Phrase("Current show gender: ", fTitle3));
parGender.add(new Phrase(sex, fValue));
Paragraph parTopN = new Paragraph();
parTopN.add(new Phrase("Now is showing ", fTitle3));
parTopN.add(new Phrase(order, fValue));
parTopN.add(new Phrase(" ", fValue));
parTopN.add(new Phrase(new Integer(topN).toString(), fValue));
parTopN.add(new Phrase(" record(s)", fTitle3));
// Start main table
PdfPTable tblMain = new PdfPTable(1);
tblMain.getDefaultCell().setBorder(0);
// Print title
tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
tblMain.addCell(new Paragraph(title0, fTitle0));
tblMain.addCell(new Paragraph(title1, fTitle1));
tblMain.addCell("");
tblMain.addCell("");
tblMain.addCell("");
// Print headers data
//tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
//tblMain.addCell(parInvoiceNum);
//tblMain.addCell("");
tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
tblMain.addCell(parStartEnd);
tblMain.addCell("");
tblMain.addCell(parGenerateDate);
tblMain.addCell("");
if (sex != " ")
tblMain.addCell(parGender);
else if(order != null && topN > 0)
tblMain.addCell(parTopN);
else
tblMain.addCell(" \n");
tblMain.addCell("");
tblMain.setWidthPercentage(96);
tblMain.addCell(new Paragraph("Description of this report:", fTitle3));
tblMain.addCell(desc);
tblMain.addCell("\n");
// Finish main table
return tblMain;
// print a chart _directly_ to pdf and return a empty Pdftable...
public PdfPTable printChart(JFreeChart chart, PdfWriter writer)
PdfContentByte cb = writer.getDirectContent();
int width = 550;
int height = 450;
PdfTemplate tp = cb.createTemplate(width, height);
Graphics2D g2d = tp.createGraphics(width, height, new DefaultFontMapper());
Rectangle2D r2d = new Rectangle2D.Double(0, 0, width, height); //->,
chart.draw(g2d, r2d);
g2d.dispose();
cb.addTemplate(tp, 20, 170);
// quick method to push down the footer text
// the only things this method return
PdfPTable tblDownDown = new PdfPTable(1);
tblDownDown.getDefaultCell().setBorder(0);
tblDownDown.addCell(" \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n");
tblDownDown.addCell(" \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n");
tblDownDown.addCell(" \n \n \n \n \n \n");
return tblDownDown;
public PdfPTable getFooter(String notes[])
Font fNote = FontFactory.getFont("Helvetica", 14, Font.UNDERLINE);
Font fComment = FontFactory.getFont("Helvetica", 12, Font.ITALIC);
Font fTitle1 = FontFactory.getFont("Helvetica", 30, Font.ITALIC);
// Start footer table
PdfPTable tblFooter = new PdfPTable(1);
tblFooter.getDefaultCell().setBorder(0);
if (notes != null)
tblFooter.addCell(new Paragraph("Notes:", fNote));
tblFooter.addCell("");
tblFooter.addCell("");
tblFooter.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
for (int i=0;i<notes.length;i++)
if (notes[i] != null)
tblFooter.addCell(new Paragraph("" + (i+1) + ". " + notes[i] + "", fComment));
tblFooter.addCell("");
tblFooter.addCell("");
tblFooter.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
tblFooter.addCell(new Paragraph("- End of report -", fComment));
return tblFooter;
}Go to the cache directory and see if you can open the report directly from here (not in IE).
I have seen posts on problems with Acrobat Reader Plugin for IE (I believe it was version 6 of Reader). -
How to convert report to pdf format after that I want to send on mail
Hi
Guru
What is my requirement . I want put push button on output list of a normal report. When user click on mail push button, mail should go to customer mail id according to customer no i gave input for customer no in selection screen.
For this I need what is function module (Code) for convert a report to pdf format and whats function module for send mail to customer.
Plz help me out
thanks
DurgeshHi ,
I think this is helpful
FM are used to convert pdf file and attachem.
CONVERT_ABAPSPOOLJOB_2_PDF
SO_DOCUMENT_SEND_API1
*& Report ZSPOOLTOPDF2 *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program can be run in background or online and a spool request *
*& will still be created *
REPORT zspooltopdf2.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX,
p_online no-display.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i,
w_spool_nr like sy-spono.
%_print LIKE pri_params.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
If p_online = 'X'.
Processing performed when program calls itself when run online
gd_spool_nr = sy-spono.
EXPORT gd_spool_nr TO MEMORY ID 'SPOOLTOPDF'.
EXIT.
endif.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
ELSE.
gd_spool_nr = sy-spono.
If executed online, it submits a program to perform the write statements
instructing it to create a spool request, this could be another program
which just performs the write statements and then exports sy-spono
to memory. But in this example it calls itself passing X to parameter
p_online, which takes it down an alternative procesing path.
submit ZSPOOLTOPDF2
with p_online = 'X'
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
ENDIF.
Get spool id from program called above
IMPORT gd_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& 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
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.
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.
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.
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[].
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.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. -
Problem in converting Spool to PDF file, having non-English characters
Hi All,
I have problem in converting Spool to PDF format.
Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
Regards,
Navin.Hi All,
I have problem in converting Spool to PDF format.
Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
Regards,
Navin. -
Problem in converting report output to pdf
Hi,
I'm managing to get the spool id and other requirements but could'nt get the output of the program converted to pdf format.When i'm trying to do this i'm getting the pdf format of the functional module which retrievs the header and item records and displays the numbers records in the header and item like for eg. header records 8 and item records 10 this its displaying in the format in which we get our funtional module output when we give some data into it.....
Can any one please tell me how to solve this for ur information i'm using hierarchail squential report with multiple reports in the same report.............
for instance i'm using the following coding please find the bug......
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& 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
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.
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.
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.
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[].
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.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.Please go throught the code ... this is my salary sending program to all the employees as pdf attach file of his salary breakup ...... it was so clear how the data is converted in th pdf format .... and more understanding way the internal tables are declared ....
DATA W_OPTIONS LIKE ITCPO OCCURS 0 WITH HEADER LINE.
DATA : z_itcpp LIKE itcpp OCCURS 0 WITH HEADER LINE.
DATA : otfdt like ITCOO OCCURS 0 WITH HEADER LINE.
DATA : pdfdt like TLINE OCCURS 0 with header line.
DATA: NUMBYTES TYPE I.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA: Begin of i_errors occurs 0,
type(1) type c,
descr(100) type c,
End of i_errors.
w_options-tdprinter = 'POSTSCPT'.
W_options-TDRDIDEV = 'XP45'.
W_options-TDGETOTF = 'X'.
APPEND W_options.
call function 'OPEN_FORM'
exporting
device = 'PRINTER'
dialog = ' '
form = 'ZHRPAYSLIP'
language = sy-langu
options = w_options
* IMPORTING
* LANGUAGE =
* NEW_ARCHIVE_PARAMS =
* RESULT =
exceptions
canceled = 1
device = 2
form = 3
options = 4
unclosed = 5
mail_options = 6
archive_error = 7
invalid_fax_number = 8
more_params_needed_in_batch = 9
others = 10 .
CALL FUNCTION 'CLOSE_FORM'
* IMPORTING
* RDI_RESULT =
TABLES
OTFDATA = otfdt
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
OTHERS = 4.
EXPORT otfdt TO MEMORY ID 'PDFT'.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = NUMBYTES
* BIN_FILE =
TABLES
otf = otfdt
lines = pdfdt
* EXCEPTIONS
* ERR_MAX_LINEWIDTH = 1
* ERR_FORMAT = 2
* ERR_CONV_NOT_POSSIBLE = 3
* ERR_BAD_OTF = 4
* OTHERS = 5
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
Refresh OBJTXT. clear OBJTXT.
Refresh OBJPACK. clear OBJPACK.
Refresh objbin. clear objbin.
Refresh OBJHEAD. clear OBJHEAD.
Refresh RECLIST. Clear RECLIST.
* Creation of the document to be sent
* File Name
DOC_CHNG-OBJ_NAME = 'PAYSLIP'.
* Mail Subject
DOC_CHNG-OBJ_DESCR = 'Payslip'.
* Mail Contents
OBJTXT = 'This e-mail was sent from an automated system...'.
APPEND OBJTXT.
OBJTXT = 'Do not reply to this message.'.
APPEND OBJTXT.
OBJTXT = 'Please open the attachment to view the Payslip'.
APPEND OBJTXT.
OBJTXT = ''.
APPEND OBJTXT.
if not msgtxt1 is initial.
OBJTXT = msgtxt1.
APPEND OBJTXT.
endif.
if not msgtxt2 is initial.
OBJTXT = msgtxt2.
APPEND OBJTXT.
endif.
if not msgtxt3 is initial.
OBJTXT = msgtxt3.
APPEND OBJTXT.
endif.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
* Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
* Creation of the document attachment
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = pdfdt
t_target_tab = objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
describe table objbin lines tab_lines.
OBJHEAD = 'Payslip.PDF'.
APPEND OBJHEAD.
** Creation of the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-OBJ_NAME = 'Payslip'.
OBJPACK-OBJ_DESCR = 'Payslip'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
* Completing the recipient list
* Read table i_pa0105 with key pernr = pernr-pernr binary search.
loop at i_pa0105 where pernr = pernr-pernr and USRTY = '0010'.
endloop.
if sy-subrc = 0.
RECLIST-RECEIVER = i_pa0105-USRID_LONG.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
endif.
if RECLIST[] is initial.
loop at i_pa0105 where pernr = pernr-pernr and USRTY = 'MAIL'.
endloop.
if sy-subrc = 0.
RECLIST-RECEIVER = i_pa0105-USRID.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
endif.
endif.
if not RECLIST[] is initial.
* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = ''
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
LOOP AT RECLIST.
* Concatenate pernr-pernr '-' RECLIST-RECEIVER(48)
into error1.
IF RECLIST-RETRN_CODE = 0.
* Concatenate error1 ': The document was sent' into
error1.
i_errors-descr = pernr-pernr.
i_errors-type = 'S'.
append i_errors.
ELSE.
Concatenate error1 ': The document could not be
sent' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
ENDIF.
ENDLOOP.
WHEN 1.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into
error1.
Concatenate error1 ': No authorization for sending to the
recipients' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN 2.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into
error1.
Concatenate error1 ': Document could not be sent to the
recipient' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN 4.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into
error1.
Concatenate error1 ': No send authorization' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN OTHERS.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into
error1.
Concatenate error1 ': Error occurred while sending' into
error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
ENDCASE.
else.
error1 = pernr-pernr.
* Concatenate error1 ': Maintain Infotype 0105.' into error1.
i_errors-descr = error1.
i_errors-type = 'M'.
append i_errors.
endif.
girish -
Report with PDF format in IExplorer problem
report with PDF format in IExplorer problem
Hi,
when i make the desformat=PDF it gave me error
"file does not start with '%PDF' " in the IExplorer despite i have updated version of Acrobat reader and IE.
I'm using this URL:
http://bss9i.stc.com.sa:7779/reports/rwservlet?destype=SCREEN&desformat=PDF&report=CR1.rdf&userid=webcr/webcr1@cr&p_cr='AP/63'.
Any suggestion is greatly appreciated.
Thanks.
Kamal KhafagyShouldn't destype be CACHE?
-
Converting report to PDF and mailing
Hi every one,
I've gone through various threads and i'm aware of the Functional module's used to
convert the report to pdf and mail it back.Like CONVERT_OTFSPOOLJOB_2_PDF, CONVERT_OTF_2_PDF and for mailing we have SEND_NEW_DOCUMENT_ATT_SEND_API1.
I've worked with this but my problem is i'm not able to convet the report output to pdf.When i'm doing this i'm getting the output of my functional module converted to pdf like the number of header and item records available for the given data in the selection screen.
Since all the threads i've gone through is converting the single internal table which has the output to pdf.
But i've got the REUSE_ALV_HIERSQL_LIST_DISPLAY, hierarchial report which as known has got two internal tables.How to the same to this kind of report....More over is it possible to convert report to pdf in online without transfering it to spool and getting the spool id to convert it to pdf.........
Any help or suggestions will surely be rewarded......
Thanks in Advance.....Here is the complete code for you;
It Converts spool request into PDF document and emails it.
<b>http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm</b>
Regards,
Vishal -
IllegalArgumentException error while exporting report in PDF format
Hi all,
we are using Crystal Report 2008, Java 1.5.22 and JRC 11.8.4.1094 to export reports in pdf format within java.
It is working fine for all reports except for a specific report where it gives IllegalArgumentException while exporting the PDF.
Below the error occurred:
12:39:16,875 ERROR [c] Disk Exporter: no output file was created by an exporter
12:39:16,875 ERROR <b> PdfExporter: caught Exception in PDFFormatter.finalizeFormatJob (from destination?); aborting export
java.lang.IllegalArgumentException
at com.crystaldecisions.reports.exporters.destination.disk.c.a(Unknown Source)
at com.crystaldecisions.reports.exporters.format.page.pdf.b.a(Unknown Source)
at com.crystaldecisions.reports.a.e.if(Unknown Source)
at com.crystaldecisions.reports.formatter.a.c.if(Unknown Source)
at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.AdvancedReportSource.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.NonDCPAdvancedReportSource.export(Unknown Source)
at com.crystaldecisions.reports.reportengineinterface.JPEReportSource.export(Unknown Source)
at com.crystaldecisions.report.web.event.br.a(Unknown Source)
at com.crystaldecisions.report.web.event.w.a(Unknown Source)
at com.crystaldecisions.report.web.event.b7.broadcast(Unknown Source)
at com.crystaldecisions.report.web.event.av.a(Unknown Source)
at com.crystaldecisions.report.web.WorkflowController.do(Unknown Source)
at com.crystaldecisions.report.web.WorkflowController.doLifecycle(Unknown Source)
at com.crystaldecisions.report.web.ServerControl.a(Unknown Source)
at com.crystaldecisions.report.web.viewer.ReportExportControl.a(Unknown Source)
at com.crystaldecisions.report.web.ServerControl.getHtmlContent(Unknown Source)
12:39:16,875 INFO [c] Disk Exporter: finalizing export to destination
12:39:16,875 ERROR [JRCCommunicationAdapter] Failed to export report
com.crystaldecisions.reports.exporters.format.page.pdf.a.a: Unknown exception is thrown
at com.crystaldecisions.reports.exporters.format.page.pdf.b.a(Unknown Source)
at com.crystaldecisions.reports.a.e.if(Unknown Source)
at com.crystaldecisions.reports.formatter.a.c.if(Unknown Source)
at com.crystaldecisions.reports.formatter.a.c.a(Unknown Source)
at com.businessobjects.reports.sdk.b.b.int(Unknown Source)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.x.a(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.q.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.dd.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.AdvancedReportSource.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.NonDCPAdvancedReportSource.export(Unknown Source)
at com.crystaldecisions.reports.reportengineinterface.JPEReportSource.export(Unknown Source)
at com.crystaldecisions.report.web.event.br.a(Unknown Source)
at com.crystaldecisions.report.web.event.w.a(Unknown Source)
at com.crystaldecisions.report.web.event.b7.broadcast(Unknown Source)
at com.crystaldecisions.report.web.event.av.a(Unknown Source)
at com.crystaldecisions.report.web.WorkflowController.do(Unknown Source)
at com.crystaldecisions.report.web.WorkflowController.doLifecycle(Unknown Source)
at com.crystaldecisions.report.web.ServerControl.a(Unknown Source)
at com.crystaldecisions.report.web.viewer.ReportExportControl.a(Unknown Source)
at com.crystaldecisions.report.web.ServerControl.getHtmlContent(Unknown Source)
Caused by: java.lang.IllegalArgumentException
at com.crystaldecisions.reports.exporters.destination.disk.c.a(Unknown Source)
... 56 more
Have an idea?
ThanksHello Andrea.
I searched through the SAP Notes for the error that you are encountering. There is an SAP Note that exists titled the following:
1332907 - Report being exported to PDF format using the Crystal Reports for Eclipse 1.x runtime, errors with the exception: PdfExporter: caught Exception in PDFFormatter.finalizeFormatJob
Since you may not have access to the SAP Notes, I will extract the details that are mentioned in the note here:
=============================================
Symptom
Attempting to export a report to Adobe PDF format using the Crystal Reports for Eclipse 1.x runtime results in an exception.
The exception indicates "PdfExporter: caught Exception in PDFFormatter.finalizeFormatJob"
Environment
Windows 2003
Apache Tomcat 5.0
Crystal Reports for Eclipse version 1.x
Reproducing the Issue
Using the Crystal Reports for Eclipse runtime version 1.x attempt to export a report to PDF format that has the "Repeat Group Header on Each Page" option enabled.
Note: This does not occur if this option is enabled in a subreport.
Cause
When the "Repeat Group Header on Each Page" is enabled for a group in a main report the Crystal Reports for Eclipse 1.x runtime is unable to correclty format the PDF document which results in an exception.
Resolution
Updating the application to use Crystal Reports for Eclipse version 2.x runtime will resolve the issue.
The most recent updates to the Crystal Reports for Eclipse runtime can be freely downloaded from the SAP SDN Website.
http://www.sdn.sap.com/irj/boc/crystalreports-java
=============================================
Since you are on JRC 11.8.4.1094 which is Crystal Reports for Eclipse 1.x, this may be the cause of your problem.
I hope that this helps.
Regards.
- Robert -
How to get a report in pdf format.
Hi Experts,
Could any one let me know that, how to get the report in PDF format.
Once a report is generated it should be displayed in pdf format or downloaded in pdf format.
Thanks in Advance,
Regards,
Irfan HussainHi,
Check out this code:
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
* Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
* Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
* Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
* Write statement to represent report output. Spool request is created
* if write statement is executed in background. This could also be an
* ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
*** Alternative way could be to submit another program and store spool
*** id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
* to sap-spool
* spool parameters %_print
* archive parameters %_print
* without spool dynpro
* and return.
* Get spool id from program called above
* IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
* FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
* FORM get_job_details *
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
* FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
* FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
Regards,
Gayathri -
Reports in PDF format does not show up on solaris box
Hi,
I am trying to generate a report in pdf format.
This shows up a blank page.
But i could see that the cache file is generated for the report.
This works fine in Win 2000.
I have fixed the IE adobe issue.
IS there anything special i need to do while
generating this output.
Your help will be highly appreciated.
Thanks in advance,
shailesh
nullI did all the config as mentioned on adobe site. It seems to me the dataset problem.
I am running 2 reports one for which i have more data and for the other less data.
The one with more data comes up properly on browser. But the one with less data is showing me blank page.
shailesh
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by david Mille ([email protected]):
hi,
Did you install the nppdf32.dll of acrobat reader in your plugins directory in your browser ?<HR></BLOCKQUOTE>
null -
Issues in exporting SSRS report to PDF format in Report Server - Blank spaces are deleted
Hi Gurus,
I have a problem in exporting SSRS report to PDF format. It deletes all the blank spaces when I use bullet in a Text box and try to export to PDF formt in Report Server . For example
• Project submitted to the TRC
Result in PDF format:
• ProjectsubmittedtotheTRC
I also noted that when I try to export to PDF in Visual Stuio 2005 (Business Intelligence development studio), it does not delete any blank spaces and shows the correct aligned Data in PDF format.
Please help me as it is frustrating a lot
I would highly appreciate for your quick responseWas there ever a solution found for this as i have the same issue.
When bullet point is entered in a field all the spaces are removed when exported to PDF
i tried exporting to excel and it does not remove spaces, however this is no use to me as it needs to be in PDF
Using IE 7 (Don't think the browser has anything to do with it as this happened via a subscription)
Didn't know SSRS had specific Service Packs, i though they came as patches to SQL Server (SQL Server is on Service Pack 3)
This should be easy to replicate all you need to do is copy text containing a bullet point into a sql server database field and then add this field to a report export to pdf and the spaces are gone
Thanks in advance,
Mark Brunton
brunzire -
Problem in converting spool to pdf
Hi Experts,
I want an internal table to be converted to the PDF. For this RSPO_OPEN_SPOOLREQUEST, RSPO_WRITE_SPOOLREQUEST and RSPO_CLOSE_SPOOLREQUEST to create the spool. However, somehow the table tsp01 does not gets updated as a result i could not convert the data to PDF. Can any one help me how this problem could be solved.
Thank.
Warm Regards,
Harshad.Hi,
you can refer this sample code.
DATA: t_otfdata_tab LIKE ITCOO OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CLOSE_FORM'
TABLES
OTFDATA = t_otfdata_tab
fill the exceptions..
IF SY-SUBRC = 0.
ENDIF.
then pass the t_otfdata_tab to this function module..
CONSTANTS: c_pdf(03) VALUE 'PDF'.
PDF File size
DATA: w_file_size TYPE I.
Internal Table to hold Form contents in PDF format
DATA: t_pdfdata_tab LIKE tline OCCURS 0 WITH HEADER LINE.
for converting. the output format from OTF to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT eq c_pdf
IMPORTING
BIN_FILESIZE = w_file_size
TABLES
OTF eq t_otfdata_tab
LINES eq t_pdfdata_tab
EXCEPTIONS...
use these links, hope it will be useful to you....
Problem in converting spool to PDF file
Problem in converting the spool to PDF.
Thanks and Regards,
Ahamed. -
How to get the output of the report in pdf format
how to get the output of the report in pdf format?
Thanks in advance,
madan.Refer these links
http://www.sap-img.com/bc037.htm
http://www.members.tripod.com/abap4/Save_Report_Output_to_a_PDF_File.html
CONVERT_ABAPSPOOLJOB_2_PDF FM convert abap spool output to PDF -
Report in PDF format can not support double byte character ?
Hi :
I am developing the simplified chinese application , when i generate the report in PDF format , i found all double byte character did not display correctly . i am using dev6i+patch5 , why ?
it is a bug of form or not ???????
HELP !!!try this ,Install acrobat4.0 or above and make sure you got acrobat distiller which will add a acrobat distiller printer in you windows. print report direct to that printer (don't change desformat) and you should got your PDF file with correct font setting.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by xie min ([email protected]):
Hi :
I am developing the simplified chinese application , when i generate the report in PDF format , i found all double byte character did not display correctly . i am using dev6i+patch5 , why ?
it is a bug of form or not ???????
HELP !!!<HR></BLOCKQUOTE>
null
Maybe you are looking for
-
How do you add a multiple entries at once to a drop-down list box?
I'm making a form for students to fill out and I want them to be able to pick from about 200 different courses. In the Field/List Items place, it would appear that you can only enter one item one at a time. I did this for 56 faculty,which took too mu
-
Pre-Yosemite I was running Obsidian Bar and Bartender but since I've update my menu is missing several icons including the time, batter image/percentage, and user. When I go to System Preferences and select Date & Time and go to clock, whenever I che
-
Hi, I am trying to create a process order from a planned order. I have generated the planned order through MRP run. The process order that is generating taking process order type which is not desired. I want to know from where it takes the process or
-
Possible instant access security hole
When using instant access camera from the lock screen, then pressing home on iPhone 4 IOS 5, it goes straight into the home page without needing to enter a passcode. Anyone else seeing this?
-
Hi, I'm generating xml according to jar biuld on xsd (im using xmlbeans) and in generated xml I got <MESSAGES xmlns="phonesat"> some content </MESSAGES> Is there possibility to get rid of xmlns="phonesat" and get in result <MESSAGES> some content </M