Hello All,
I'm having an issue with a PDF generation from a BSP. My file does not open and is corrupt. However, I can download the pdf_table and the file is fine. I must be missing something (perhaps something obvious). Any help would be greatly appreciated.
Here is my code.
I submit a report and retrieve it from the spoolfile, this is all easy and works great.
Then I convert the spoolfile to PDF using CONVERT_ABAPSPOOLJOB_2_PDF. That seems fine too, but just in case I'll post the code starting from there. After that a simple string to xstring conversion and then the 'server->response(s)'. It shouldn't be that difficult, I may be missing something fundamental. Again, any help...greatly appreciated. I'm making no headway on this.
FYI...I'm using jquery in my bsp, I can't imagine that would be causing me an issue though.
Thanks much,
Greg
DATA: pdf_table TYPE rcl_bag_tline,
output TYPE string,
outputx TYPE xstring,
wa_pdf_table TYPE tline.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spool_id
no_dialog = 'X'
TABLES
pdf = pdf_table.
LOOP AT pdf_table INTO wa_pdf_table.
TRANSLATE wa_pdf_table USING ' ~'. "possible format recommendation by Raja
CONCATENATE output wa_pdf_table-tdline INTO output IN CHARACTER MODE.
ENDLOOP.
TRANSLATE output USING '~ '. " possible format recommendation by Raja
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = output
mimetype = 'APPLICATION/PDF'
IMPORTING
buffer = outputx.
server->response->set_header_field( name = 'content-type' value = 'application/pdf' ).
server->response->delete_header_field( name = 'cache-control' ).
server->response->set_header_field( name = 'cache-control' value = 'max-age=0' ).
outputx_len = XSTRLEN( outputx ).
server->response->set_data( data = outputx length = outputx_len ).