I am trying to convert a binary screen to pdf output. The methodology we are using produces the pdf document correctly in a non unicode system. In our unicode system, the same abap code produces errors when the pdf is displayed. Following is a program for producing the error. The problem seems to occur in the function 'SCMS_BINARY_TO_STRING'. When comparing the output of this function between unicode and non unicode, the resulting text data is altered even though the input binary data is identical. We have tried passing various codepage options in the encoding parameter without success. Has anyone seen this problem and what did you do to correct it?
When testing this function use any valid path for an existing PDF file.
FUNCTION-POOL zpdf2. "MESSAGE-ID ..
TYPE-POOLS: abap, icon.
DATA: gt_pdfitab TYPE STANDARD TABLE OF bapiqcmime...
FUNCTION zpdf_test2.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IF_FILE) TYPE STRING DEFAULT 'G:\test.pdf'
*"----------------------------------------------------------------------
DATA: lf_size TYPE i,
lf_xstring TYPE xstring.
DATA: lf_string TYPE string,
lt_x TYPE TABLE OF x255,
lt_content TYPE ccrctt_text_tab.
* get a pdf document and convert it to a xstring.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = if_file
filetype = 'BIN'
IMPORTING
filelength = lf_size
CHANGING
data_tab = lt_x
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
CHECK sy-subrc = 0.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lf_size
IMPORTING
buffer = lf_xstring
TABLES
binary_tab = lt_x
EXCEPTIONS
failed = 1
OTHERS = 2.
CHECK sy-subrc = 0.
refresh lt_x.
* now convert the xstring and display the pdf
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lf_xstring
append_to_table = 'X'
IMPORTING
output_length = lf_size
TABLES
binary_tab = lt_X.
CHECK sy-subrc = 0.
CALL FUNCTION 'SCMS_BINARY_TO_STRING'
EXPORTING
input_length = lf_size
IMPORTING
text_buffer = lf_string
TABLES
binary_tab = lt_X
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc = 0.
* Simple conversion of binary PDF string to itab
CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = lf_string
i_tabline_length = 255
TABLES
et_table = gt_pdfitab.
ENDIF.
CALL SCREEN '0100'.
ENDFUNCTION.
*----------------------------------------------------------------------*
***INCLUDE LZPDF2O01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STANDARD_FULLSCREEN'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module DO_PBO OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE do_pbo OUTPUT.
data: lf_url type char255,
lr_html_container TYPE REF TO cl_gui_custom_container,
lr_html_control TYPE REF TO cl_gui_html_viewer.
IF lr_html_container IS INITIAL.
CREATE OBJECT lr_html_container
EXPORTING
container_name = 'O100_CONT'.
CREATE OBJECT lr_html_control
EXPORTING
parent = lr_html_container.
ENDIF.
CALL METHOD lr_html_control->load_data
EXPORTING
type = 'Application'(500)
subtype = 'PDF'
IMPORTING
assigned_url = lf_url
CHANGING
data_table = gt_pdfitab.
CALL METHOD lr_html_control->show_data
EXPORTING
url = lf_url
in_place = 'X'.
ENDMODULE. " DO_PBO OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
leave to screen 0.
ENDMODULE. " USER_COMMAND_0100 INPUT