‎2016 Mar 09 3:31 AM
Hi All,
I am using the standard FM 'SCI_INSPECT_LIST' to get the Code Inspector results. After getting the results I have to convert them as a PDF and send as an email to a user.
The output of the standard FM comes in an export parameter P_RESULTS of table type 'SCIT_REST' . In this structure there is one component called DETAIL of type RAWSTRING , now I need the data from this component to be converted into a PDF.
I tried every conversion XSTRING TO BINARY, XSTRING to STRING, XSTRING to SOLIX, and then used GUI_DOWNLOAD to create a PDF, but with no success.
I could able to generate a PDF, but while opening the PDF I am getting an error like this - 'Adobe Acrobat Reader could not open 'file.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)'
If any one has faced similar issue, please share your inputs on how to resolve it.
Regards
Mohammed Zia
‎2016 Mar 09 4:44 AM
Hello,
Please try this.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_content
append_to_table = abap_true
TABLES
binary_tab = lt_data.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = lv_filepath
filetype = 'BIN'
CHANGING
data_tab = lt_data.
Regards,
Sri.
‎2016 Mar 09 10:39 AM
Hi Sridhar,
Thanks for your reply.
I tried the way mentioned by you. I am able to generate a PDF by this approach, but the PDF is not correct. I mean I am unable to open it. I am getting the below message when I try to open it
'Adobe Acrobat Reader could not open 'file.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)'
Regards
Mohammed Zia
‎2016 Mar 09 9:19 AM
Hello Mohammed,
what I would try in this case:
Sorry for the pseudocode...
Best regards,
Laszlo
‎2016 Mar 09 1:37 PM
Hi Mohammed,
Yes, I would try the approach mentioned by Laszlo as the table type SCIT_REST is not going to be directly compatible with the file specification necessary for PDF output. The other option is to take the internal table and create and Adobe form output if you have ADS running and then download that for emailing to someone.
Regards,
Ryan Crosby
‎2016 Mar 09 3:25 PM
Hi Laszlo,
Thanks for your reply.
I followed the steps you have mentioned and could create a spool request, but the spool request is generated with type as "RAW DOCUMENT'' and with ZERO pages.
And when I use the FMs CONVERT_ABAPSPOOLJOB_2_PDF with CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD to convert and download PDF, I am getting a PDF with ZERO pages. When I try to open the PDF its says - There was an error opening this document. This file cannot be opened because it has no pages.
I am using the FM 'RSPO_SX_OUTPUT_TEXTDATA' to create a Spool Request. Below is the code snippet of what I am doing to create a spool request. Please see, if I am doing anything wrong.
**** RAW TO TEXT
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
input_length = filesize
* FIRST_LINE = 0
* LAST_LINE = 0
append_to_table = 'X'
* MIMETYPE = ' '
* WRAP_LINES = ' '
* ENCODING =
IMPORTING
output_length = filesize1
TABLES
binary_tab = gt_tab "In this gt_tab, I have my data from Std FM 'SCI_INSPECT_LIST'
text_tab = data_txt " this table I am passing to 'RSPO_SX_OUTPUT_TEXTDATA'
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
DESCRIBE TABLE data_txt
LINES lv_lines.
CALL FUNCTION 'RSPO_SX_OUTPUT_TEXTDATA'
EXPORTING
* NAME =
dest = 'LPDF'
rows = lv_lines
startrow = 1
pages = lv_lines
* RQTITLE =
* RQCOPIES =
* RQOWNER =
immediately = 'X'
IMPORTING
rqid = spoolid
TABLES
text_data = data_txt
EXCEPTIONS
name_missing = 1
name_twice = 2
not_found = 3
illegal_layout = 4
internal_error = 5
size_mismatch = 6
OTHERS = 7
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
‎2016 Mar 10 8:33 AM
Hello Mohammed,
Stefan's answer seems to be a reliable solution - anyway, what you have mentioned seems to be happening because of the binary spool type.
I don't have the entire PDF conversion algorithm in my head, but either the whole binary spool will be skipped by the conversion program or some kind of structure information could not be found in the spool.
The "regular" way to create spool requests is:
Report RSPOPRNT is a SAP-standard program featuring these programs, you can analyse / debug it to see how this kind of spool creating works.
If you can not find RSPOPRNT in your system, see SAP Note #1318419 - Programm RSPOPRNT missing after upgrade.
Otherwise, Stefan's solution seems to be quicker and easier.
Best regards,
Laszlo
‎2016 Mar 09 4:04 PM
Hi,
regarding to post
you can export the results via List to file. maybe you will find an answer debugging the SAP-Standard-Export of this list.
Regards
Stefan Seeburger