Code: Alles auswählen.
DATA: lv_bin_filesize TYPE i
, lt_lines TYPE TABLE OF tline WITH HEADER LINE
, lt_attachement TYPE TABLE OF solisti1 WITH HEADER LINE
, lv_buffer TYPE string
*Attachement aufbereiten
*OTF Daten des Formulars in PDF konvertieren
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = lv_bin_filesize
TABLES
otf = it_otf
lines = lt_lines
EXCEPTIONS
OTHERS = 0.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*Convert PDF from 132 to 255.
LOOP AT lt_lines.
* Replacing space by ~
TRANSLATE lt_lines USING ' ~'.
CONCATENATE lv_buffer lt_lines INTO lv_buffer.
ENDLOOP.
* Replacing ~ by space
TRANSLATE lv_buffer USING '~ '.
DO.
lt_attachement = lv_buffer.
* Appending 255 characters as a record
APPEND lt_attachement.
SHIFT lv_buffer LEFT BY 255 PLACES.
IF lv_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Code: Alles auswählen.
DATA: BEGIN OF pdf OCCURS 0,
t(134),
END OF pdf.
DATA:
i TYPE i,
k TYPE i,
j TYPE i.
:
:
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spoolid
no_dialog = ' '
* DST_DEVICE =
* PDF_DESTINATION =
IMPORTING
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
* OTF_PAGECOUNT =
btc_jobname = jobname
btc_jobcount = jobcount
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 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.
IF sy-subrc = 0.
k = i = 0.
LOOP AT pdf.
DO 134 TIMES.
j = sy-index - 1.
object_bin+i(1) = pdf+j(1).
i = i + 1.
IF i > 254.
APPEND object_bin.
CLEAR i.
ENDIF.
k = k + 1.
IF k GE numbytes.
IF i NE 0. APPEND object_bin.ENDIF.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
ELSE.
EXIT.
ENDIF.