Skip to Content
0
Jul 19, 2020 at 09:37 AM

Translate using variable via pattern

131 Views

Hello experts

I use CONVERT_ABAPSPOOLJOB_2_PDF in order to convert ABAP spool to PDF. After that I Transfer the 132-long strings to 255-long strings with the translate command.

When writing:

TRANSLATE ls_pdf_output USING ' ~'.

Then when opening the pdf Sometimes it is OK but sometimes I receive an error message 'CANNOT EXTRACT THE EMBEDDED FONT…'

When writing:

DATA: lv_translate_str TYPE string VALUE ' ~'

TRANSLATE ls_pdf_output USING lv_translate_str.

Then when opening the pdf, until now It was always ok.

Thanks in advance

Hagit

FORM convert_spool_to_pdf
USING pv_job_id TYPE tsp01-rqident
CHANGING pt_mess_att TYPE esy_tt_solisti1
.

CONSTANTS: lc_no(1) TYPE c VALUE ' '
,lc_device(4) TYPE c VALUE 'LOCL'
.

DATA: lt_pdf_output TYPE TABLE OF tline
,lv_buffer TYPE string
,ls_mess_att TYPE solisti1 "like line of pt_mess_att
.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = pv_job_id
no_dialog = lc_no
dst_device = lc_device
* IMPORTING
* pdf_bytecount =
TABLES
pdf = lt_pdf_output
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.
RAISE no_conv2pdf.
ELSE.
DATA: lv_translate_str TYPE string VALUE ' ~'
,lv_translate_back_str TYPE string VALUE '~ '
.

* Transfer the 132-long strings to 255-long strings
LOOP AT lt_pdf_output INTO DATA(ls_pdf_output).
* TRANSLATE ls_pdf_output USING ' ~'.
TRANSLATE ls_pdf_output USING lv_translate_str.
CONCATENATE lv_buffer ls_pdf_output INTO lv_buffer.
ENDLOOP.

* TRANSLATE lv_buffer USING '~ '.
TRANSLATE lv_buffer USING lv_translate_back_str.

DO.
ls_mess_att = lv_buffer.
APPEND ls_mess_att TO pt_mess_att.
SHIFT lv_buffer LEFT BY 255 PLACES.
IF lv_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDIF.


ENDFORM. "convert_spool_to_pdf