2018 Aug 16 9:54 AM
Hello Experts,
I am trying to save a spool output into the server as PDF file. For that I am using the next code:
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gv_spoolid
use_cascading = 'X'
* no_dialog = 'X'
TABLES
pdf = gt_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.
IF sy-subrc = 0.
CALL FUNCTION 'HR_JP_CONV_TAB_TO_CP_XSTR'
IMPORTING
ev_xstring_stream = gv_contentbin
TABLES
it_datatab = gt_pdf
EXCEPTIONS
OTHERS = 3.
ENDIF.
After that I save the content of GV_CONTENTBIN into the Server in BINARY MODE.
The problem is that the file is not being saved correctly (in the Spool is perfectly shown) when I see it in the OS or downloading using G3CY. The text and the layout is not being shown correctly when I open it with Adobe reader.
Another point is that I have copied this code from another system where works perfectly... I have noticed that in the system which works is is a Unicode system and the one which is not working is a Non-Unicode System (though maybe it has nothing to do with the problem).
I have tried different FMs but everything keeps going wrongly... could you please help me with this?
Thanks in advance,
Pablo del Pino
2018 Aug 16 2:38 PM
Dear Pablo,
I think the problem is the call of function module HR_JP_CONV_TAB_TO_CP_XSTR.
Function module CONVERT_ABAPSPOOLJOB_2_PDF creates the PDF data in the final format. This means the PDF data must not be changed. If you change any byte of the PDF data, you can destroy them.
In general, it is recommended to use the export parameter BIN_FILE when calling the function module CONVERT_ABAPSPOOLJOB_2_PDF.
The advantage of the parameter BIN_FILE is that it automatically returns the PDF data in XSTRING format in parameter BIN_FILE. So you don't need the function HR_JP_CONV_TAB_TO_CP_XSTR.
(see note 2339019)
Best regards,
Hedvig
Dear Pablo,
I think the problem is the call of function module HR_JP_CONV_TAB_TO_CP_XSTR.
Function module CONVERT_ABAPSPOOLJOB_2_PDF creates the PDF data in the final format. This means the PDF data must not be changed. If you change any byte of the PDF data, you can destroy them.
In general, it is recommended to use the export parameter BIN_FILE when calling the function module CONVERT_ABAPSPOOLJOB_2_PDF.
The advantage of the parameter BIN_FILE is that it automatically returns the PDF data in XSTRING format in parameter BIN_FILE. So you don't need the function HR_JP_CONV_TAB_TO_CP_XSTR.
(see note 2339019)
Best regards,
Hedvig
2018 Aug 16 2:38 PM
Dear Pablo,
I think the problem is the call of function module HR_JP_CONV_TAB_TO_CP_XSTR.
Function module CONVERT_ABAPSPOOLJOB_2_PDF creates the PDF data in the final format. This means the PDF data must not be changed. If you change any byte of the PDF data, you can destroy them.
In general, it is recommended to use the export parameter BIN_FILE when calling the function module CONVERT_ABAPSPOOLJOB_2_PDF.
The advantage of the parameter BIN_FILE is that it automatically returns the PDF data in XSTRING format in parameter BIN_FILE. So you don't need the function HR_JP_CONV_TAB_TO_CP_XSTR.
(see note 2339019)
Best regards,
Hedvig
2018 Aug 17 7:53 AM
Thank you so much Hedvig, now is working fine... I suppose that the FM HR_JP_CONV_TAB_TO_CP_XSTR includes some conversion in unicode and as this system is an old one it introduced some changes... taking the BIN_FILE directly from the FM CONVERT_ABAPSPOOLJOB_2_PDF without any transformation it is perfect.
Have a nice day!
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |