Smartforms zu PDF - Geht unter Unicode nicht mehr

Alles rund um die Sprache ABAP®: Funktionsbausteine, Listen, ALV

Smartforms zu PDF - Geht unter Unicode nicht mehr

Postby Collin4850 » Mon Jul 28, 2014 2:47 pm

Hallo liebes Forum,

ich habe ein Problem, bei dem ich gerade einfach nicht mehr weiterkomme. Und zwar habe ich ein Programm, bei dem ein Smartforms in ein PDF umgewandelt und per Mail verschickt werden soll.
Dabei wird durch den Smartforms-Funktionsbaustein eine OTF-Datei ermittelt, die dann mithilfe des FuBas CONVERT_OTF in eine PDF-Binärdatei des Typs xString konvertiert wird.

Der FuBa SCMS_XSTRING_TO_BINARY macht dann daraus eine Tabelle mit Binärdaten, die dann als Attachment an eine Mail gehängt wird.

Dies funktionierte auch wunderbar, bis das System auf Unicode umgestellt wurde.

Doch nun bekomme ich beim Öffnen des PDFs in der SOST die Fehlermeldung, dass die Datei defekt sei und nicht repariert werden könne. Ich sehe auch, dass sie nur halb so groß ist wie im nicht-Unicode System und dass die PDF-datei mittendrin abbricht.
Im Debugger sehe ich asiatische Schriftzeiche in der OTF-Variablen, allerings scheinbar auch alle relevanten Informationen in lesbarer Form, die mit dem des nicht-Unicode-Systems vergleichbar sind. Die xString-Variable enthält nur noch asiatische Zeichen. Vielleicht ist dies aber auch nur ein Darstellungsproblem im Debugger aufgrund einer Default Codepage???

Hat jemand eine Idee, wo das Problem liegen könnte? Der angegebene Drucker hat einen unicodefähigen Gerätetyp und bei den Parametern für den Smartforms-Baustein wird auch die Sprache übergeben.

Muss ich andere Funktionsbausteine oder Methoden verwenden oder zusätzliche Parameter verwenden? Oder muss irgendetwas gecustomized oder eingestellt werden?

Ich bin momentan ziemlich ratlos und freue mich sehr über jeden Hinweis.

Ganz herzlichen Dank im Voraus,
Tina
Collin4850
.
.
 
Posts: 1
Joined: Mon Jul 28, 2014 2:47 pm

Re: Smartforms zu PDF - Geht unter Unicode nicht mehr

Postby Pelin2735 » Fri Sep 19, 2014 2:05 pm

Hallo,
ohne Auschnitte vom Quelltext zu sehen, ist das recht schwer.
Ich habe ein Programm selbst ein Programm geschrieben, das aus einem SmartForms-Dokument ein PDF erzeugt und es als email sendet.

Hier mal meine wichtigsten Schritte:

erzeugen des OTF-Streams
Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1.  "Call Smartform
  2.   CALL FUNCTION gv_fm_name
  3.     EXPORTING
  4.       control_parameters         = wa_control_par
  5.       output_options             = wa_output_options
  6.    IMPORTING
  7.      JOB_OUTPUT_INFO             = wa_job_output_info
  8.     TABLES
  9.       data_tab                   = alv_data_table
  10.     EXCEPTIONS
  11.       FORMATTING_ERROR           = 1
  12.       INTERNAL_ERROR             = 2
  13.       SEND_ERROR                 = 3
  14.       USER_CANCELED              = 4
  15.       OTHERS                     = 5.
  16.   IF sy-subrc <> 0 OR supress_dialog EQ ' '.
  17.   ELSE .
  18.     it_otf_data = wa_job_output_info-otfdata.
  19.     "Convert OTF data to PDF
  20.     CALL FUNCTION 'CONVERT_OTF'
  21.       EXPORTING
  22.         format                = 'PDF'
  23.       IMPORTING
  24.         bin_filesize          = gv_bin_filesize
  25.       TABLES
  26.         otf                   = it_otf_data
  27.         lines                 = it_pdf
  28.       EXCEPTIONS
  29.         err_max_linewidth     = 1
  30.         err_format            = 2
  31.         err_conv_not_possible = 3
  32.         err_bad_otf           = 4
  33.         OTHERS                = 5.
  34.   ENDIF.
GeSHi ©


dann senden vorbereiten:

Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1.  "convert pdf to xstring string
  2.     LOOP AT it_pdf INTO wa_pdf.
  3.       ASSIGN wa_pdf TO <hex> CASTING.
  4.       CONCATENATE gv_content <hex> INTO gv_content IN BYTE MODE.
  5.     ENDLOOP.
  6.  
  7.     "Convert xstring to binary table to pass to the LOAD_DATA method
  8.     CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  9.       EXPORTING
  10.         buffer     = gv_content
  11.       TABLES
  12.         binary_tab = lt_objbin.
  13.  
  14. *   Erstellen der Anlage für das Dokument
  15.     DESCRIBE TABLE lt_objbin LINES lv_tab_lines.
  16.     CONCATENATE lb_sys(3) ' ' sy-datum ' datei.pdf' INTO tmp_txt RESPECTING BLANKS.
  17.     ls_objhead = tmp_txt.
  18.     APPEND ls_objhead TO lt_objhead.
  19.  
  20. *   Erstellen des Eintrags zur komprimierten Anlage
  21.     CLEAR: ls_objpack.
  22.     ls_objpack-transf_bin = 'X'.
  23.     ls_objpack-head_start = 1.
  24.     ls_objpack-head_num   = 1.
  25.     ls_objpack-body_start = 1.
  26.     ls_objpack-body_num   = lv_tab_lines.
  27.     ls_objpack-doc_type   = 'PDF'.
  28.     ls_objpack-obj_name   = 'ANLAGE'.
  29.     ls_objpack-obj_descr  = 'Beschreibung'.
  30.     ls_objpack-doc_size   = lv_tab_lines * 255.
  31.     APPEND ls_objpack TO lt_objpack.
GeSHi ©

<hex> als <hex> TYPE x.
und dann senden:

Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. * Versenden des Dokuments
  2.   CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  3.     EXPORTING
  4.       document_data              = ls_document_data
  5.       put_in_outbox              = 'X'
  6.       commit_work                = 'X'
  7.     TABLES
  8.       packing_list               = lt_objpack
  9.       object_header              = lt_objhead
  10.       contents_bin               = lt_objbin
  11.       contents_txt               = lt_objtxt
  12.       receivers                  = lt_reclist
  13.     EXCEPTIONS
  14.       too_many_receivers         = 1
  15.       document_not_sent          = 2
  16.       operation_no_authorization = 4
  17.       OTHERS                     = 99.
GeSHi ©


Hoffe du kannst was mit den Schnipseln anfangen.

Viele Grüße Stefan
Pelin2735
..
..
 
Posts: 28
Joined: Wed Jan 16, 2013 2:13 pm


Return to ABAP® Core

Who is online

Users browsing this forum: No registered users and 20 guests