Smartforms nach PDF konvertieren

BusinessServerPages; Erstellung von Webapplikationen.

Smartforms nach PDF konvertieren

Postby Leah824 » Sat Jun 14, 2008 10:57 am

Hello ,

ICh hoffe mir kann jemand helfen oder mich auf jemanden verweisen

Ich möchte mein Smartform in meiner BSP Applikation nach PDF konvertieren und das PDF in einem neuen Fenster anzuzeigen.
Ich habe eine Seite mit einem Button(Druckansicht) implemtiert. Diesen habe ich im InputProcessing event implementiert. Auf einer neuen Seite soll nun der Smart form aufruf stattfinden und die anschließende Konvertierung nach pdf.

Wenn das PDF geöffnet werden soll, geht der Adobe Reade auf , ohne Inhalt und es kommt die Nachricht: Daei beginnt nicht mit "%-pdf".

Habe hierbei schon alles probiert.
Mein Code ist:
Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. * event handler for data retrieval
  2.  
  3. * parameters for generated function module
  4. data: l_function_module_name type rs38l_fnam,
  5.       ls_output_options      type ssfcompop,
  6.       ls_control_parameters  type ssfctrlop,
  7.       ls_output_data         type ssfcrescl,
  8.       l_devtype              type rspoptype.
  9.  
  10. * generated result: HTML with embedded CSS
  11. data: ls_xmloutput   type ssfxmlout,
  12.       lt_html_raw    type tsfixml,
  13.       l_xstring      type xstring,    "needed for HTTP response
  14.       l_html_xstring type xstring,
  15.       l_xlength      type i.
  16.  
  17.  
  18. * generated result: PDF format
  19. data: l_pdf_xstring  type xstring,
  20.       lt_lines       type table of tline,
  21.       ls_line        type tline,
  22.       l_pdf_len      type i.
  23.  
  24. * Cookie mit Eingabewerten holen
  25. cl_bsp_server_side_cookie=>get_server_cookie(
  26.   EXPORTING
  27.      name                      = 'lt_fields'
  28.      application_namespace     = 'NONE'
  29.      application_name          = 'NONE'
  30.      username                  = 'NONE'
  31.      session_id                = 'NONE'
  32.      data_name                 = 'NONE'
  33.   "IMPORTING
  34.     "expiry_date                = date
  35.     "expiry_time                = time
  36.   CHANGING
  37.     data_value                 = lt_fields ).
  38.  
  39.  
  40. * Cookie mit Equipmentdaten holen
  41. cl_bsp_server_side_cookie=>get_server_cookie(
  42.   EXPORTING
  43.      name                      = 'ums_equip_ges'
  44.      application_namespace     = 'NONE'
  45.      application_name          = 'NONE'
  46.      username                  = 'NONE'
  47.      session_id                = 'NONE'
  48.      data_name                 = 'NONE'
  49.   "IMPORTING
  50.     "expiry_date                = date
  51.     "expiry_time                = time
  52.   CHANGING
  53.     data_value                 = ums_equip ).
  54.  
  55. *-----------------------------------------------------------------------
  56. * Get name of generated function module
  57. *-----------------------------------------------------------------------
  58. call function 'SSF_FUNCTION_MODULE_NAME'
  59.      exporting  formname           = 'Z_REPKOST_GES'
  60. *                 variant            = ' '
  61. *                 direct_call        = ' '
  62.      importing  fm_name            = l_function_module_name
  63.      exceptions no_form            = 1
  64.                 no_function_module = 2
  65.                 others             = 3.
  66.  
  67. if sy-subrc  0.
  68. *   error handling
  69.   message id sy-msgid type sy-msgty number sy-msgno
  70.           with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  71.   exit.
  72.  
  73. *---------------------------------------------------------------------------
  74. * get device type from language
  75. *---------------------------------------------------------------------------
  76. call function 'SSF_GET_DEVICE_TYPE'
  77.   exporting
  78.     i_language                   = sy-langu
  79. *     i_application                = 'SAPDEFAULT'
  80.   importing
  81.     e_devtype                    = l_devtype
  82.   exceptions
  83.     no_language                  = 1
  84.     language_not_installed       = 2
  85.     no_devtype_found             = 3
  86.     system_error                 = 4
  87.     others                       = 5.
  88.  
  89. if sy-subrc  0.
  90. *   error handling
  91.   message id sy-msgid type sy-msgty number sy-msgno
  92.           with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  93.  
  94. * set device type in output options
  95. ls_output_options-tdprinter = l_devtype.
  96.  
  97. *-----------------------------------------------------------------------
  98. * Call the generated function module
  99. *-----------------------------------------------------------------------
  100. call function l_function_module_name
  101.      exporting
  102. *                 archive_index        =
  103. *                 archive_parameters   =
  104.                 control_parameters   = ls_control_parameters
  105. *                 mail_appl_obj        =
  106. *                 mail_recipient       =
  107. *                 mail_sender          =
  108.                 output_options       = ls_output_options
  109.                 user_settings        = space
  110.                 UMS_EQUIP             = UMS_EQUIP
  111.                 LT_FIELDS             = LT_FIELDS
  112.  
  113.      importing
  114. *                 document_output_info =
  115.                 job_output_info      = ls_output_data
  116. *                 job_output_options   =
  117. *      tables
  118. *                zsystems             = lt_sys
  119.      exceptions formatting_error     = 1
  120.                 internal_error       = 2
  121.                 send_error           = 3
  122.                 user_canceled        = 4
  123.                 others               = 5.
  124.  
  125. if sy-subrc  0.
  126. *   error handling
  127.   message id sy-msgid type sy-msgty number sy-msgno
  128.           with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  129.  
  130. *-----------------------------------------------------------------------
  131. * Conversion of output format OTF into PDF format
  132. *-----------------------------------------------------------------------
  133. * now convert the final document (OTF format) into PDF format
  134. call function 'CONVERT_OTF'
  135.      exporting
  136.        format                      = 'PDF'
  137. *        MAX_LINEWIDTH               = 132
  138. *        ARCHIVE_INDEX               = ' '
  139. *        COPYNUMBER                  = 0
  140.      importing
  141.        bin_filesize                = l_pdf_len
  142.        bin_file                    = l_pdf_xstring       " binary file
  143.      tables
  144.        otf                         = ls_output_data-otfdata
  145.        lines                       = lt_lines
  146.      exceptions
  147.        err_max_linewidth           = 1
  148.        err_format                  = 2
  149.        err_conv_not_possible       = 3
  150.        err_bad_otf                 = 4
  151.        others                      = 5
  152.               .
  153. if sy-subrc  0.
  154. *   error handling
  155.   message id sy-msgid type sy-msgty number sy-msgno
  156.           with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  157.  
  158. DATA: cached_response TYPE REF TO if_http_response.
  159. DATA: guid TYPE guid_32.
  160. DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD.
  161.  
  162.  if sy-subrc EQ 0.
  163.  
  164.     CREATE OBJECT cached_response TYPE  CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.
  165.  
  166.     l_pdf_len = xstrlen( l_pdf_xstring ).
  167.     cached_response->set_data( data   = l_pdf_xstring
  168.                         length = l_pdf_len ).
  169.  
  170.     cached_response->set_header_field( name  = if_http_header_fields=>content_type
  171.                                        value = 'application/pdf' ).
  172.     cached_response->set_status( code = 200 reason = 'OK' ).
  173.     cached_response->server_cache_expire_rel( expires_rel = 180 ).
  174.  
  175.     CALL FUNCTION 'GUID_CREATE'
  176.       IMPORTING
  177.         ev_guid_32 = guid.
  178.     CONCATENATE runtime->application_url '/' guid '.pdf' INTO display_url.
  179.  
  180.     cl_http_server=>server_cache_upload( url      = display_url
  181.                                          response = cached_response ).
  182.  
  183.   ENDIF.
  184.   RETURN.
  185.  
GeSHi ©


Hoffe mir kann einer sagen, wo der Fehler ist.
Danke.

Grüße
Leah824
..
..
 
Posts: 35
Joined: Mon Oct 22, 2007 8:29 am

Postby Yunus3041 » Mon Aug 11, 2008 1:13 pm

Ohne mir Deinen Code angesehen zu haben,kann ich Dir mal meinen Fehler nennen, den ich mit gleichem Aussehen in der Kommunikation WebDynpro <=> SAP hatte: bei der Generierung des PDFs aus einem Smartforms im ABAP wurden in der PDF-Tabelle Zeilenumbrüche nicht korrekt umgesetzt. Ich empfehle Dir, so ein PDF mal nur im ABAP herzustellen, zu speichern und ein diff auf das im Browser angezeigte PDF zu machen. Damit findest Du eine Stelle, wo es schief geht, was Dir vielleicht zeigt, _was_ schiefgeht.
Yunus3041
..
..
 
Posts: 65
Joined: Mon May 21, 2007 1:18 pm

Postby Carl3263 » Fri Sep 12, 2008 12:58 pm

Hi,

ich würde an Deiner Stelle folgendes tun:
Wenn Du Deine PDF-Daten erzeugt hast, rufe eine BSP-Seite auf. Die Seite muß zwingend die Endung .pdf (nicht .htm) haben. Dieser Seite übergibst Du die PDF-Tabelle.
Im Layout steht dann nur eine einzige Zeile:
<%page language="abap"%><%loop at pdf_lines into ls_lines.%><%=lslines(134)%><%if ls_lines+133(1) eq space %> <%endif.%><%endloop.%>
Die Seite darf keinerlei blanks oder sonstiges enthalten.

Damit geht es.

Gruß

Mathias
Carl3263
.
.
 
Posts: 2
Joined: Fri Sep 12, 2008 12:58 pm

Postby Leah824 » Fri Sep 12, 2008 1:40 pm

ist schon seit knapp e monaten gelöst ;-). Trotzdem danke
Leah824
..
..
 
Posts: 35
Joined: Mon Oct 22, 2007 8:29 am


Return to BSP + BHTML

Who is online

Users browsing this forum: No registered users and 2 guests

cron