cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate a PDF with data coming from BAPI ?

Former Member
0 Kudos

Hi all,

i wonder how to create a PDF:I want to create a iView that display personal datas(these datas come from a BAPI), and add a button which open a new window which displays a PDF.

This PDF resumes datas displayed by iView.

I don't know how to do(use of a PDF package service ? others?...)

The version of portal:5.05.08

Best regards,

Nicolas

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks.

But the solution doesn't seem to be the best for me. If i have understand, I have to update all computers(some thousands) to ACROBAT Reader 6.0, buy ACROBAT Designer and add ACROBAT Library on the server.

Then, i have to generate a binary for each user who click on a button to generate a PDF.

Can you tell me if it's true or wrong ?

Former Member
0 Kudos

Hi,

We had a similiar problem and used the following solution :

Have a function module that returns a smartform in PDF format (as XSTRING)

Have an iView that writes this data out to the response.

Java Code for iView :

private void writeText(IPortalComponentRequest request, IPortalComponentResponse response, String pdfResult)

{

PrintWriter out = null;

javax.servlet.http.HttpServletResponse myResponse = request.getServletResponse(true);

try

{

out = myResponse.getWriter();

}

catch(IOException ex) { }

if(out == null)

return;

myResponse.setHeader ("Content-Disposition", "inline;filename=\"ShortCV.pdf\"");

myResponse.setContentType("application/pdf");

myResponse.setContentLength(pdfResult.getBytes().length);

out.write(pdfResult);

out.flush();

return;

}

Part of FM code :

...

call function 'CONVERT_OTF'

exporting

format = 'PDF'

importing

bin_filesize = pdf_bytecount

tables

otf = output_data-otfdata

lines = pdfout

exceptions

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

others = 4.

if sy-subrc <> 0.

raise error. " oops

endif.

l1 = 0.

len = 134.

loop at pdfout into wa_pdfout.

clear str.

str+l1(134) = wa_pdfout.

len = 134 + l1.

l1 = 134 - strlen( wa_pdfout ).

if sy-tabix = 85.

len = 56.

endif.

assign str to <p> type 'X'.

concatenate pdf_xstring <p>(len)

into pdf_xstring.

endloop.

...

Hope this helps... btw. was on a 46c system...

Former Member
0 Kudos

Jacques,

I am trying to implement what you have written here and I am nearly there, however I am not following the code shown below.

I have generated the OTFDATA from the smartform, and converted it to PDF. When this is downloaded to the PDF displays. However I have "file corrupted" errors when called by iView. I must be either generating the XSTRING incorrectly or not receiving it into the iView correctly.

When I run the code you provided I get field offset(length) error and a short dump. Can you help me with what you are trying to achieve with the loop and move to pdfdata.

Thanks,

joe

Oliver5
Advisor
Advisor
0 Kudos