cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello,

I have a problem with generating a PDF file with ABAP WebDynpro. I have an ALV and there I read a line. From this line I want to build a smartform which should be converted into PDF. I think my coding works. I have no syntax errors and when I debug the coding, everything looks good. I also get my popup that I want to have. But then I got an error: "File does not begin with '%PDF-'."

I look for this error here in SDN but I could not find a solution. I have also tried to do what is mentioned in note 1042424.

Can anybody helps me?

Regards, Markus

0 Likes
View Entire Topic
Former Member
0 Likes

Sebastian, thanks for your help, but I have used the funtions you have written.

I summarize my coding:


call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
      formname                  = 'ZRPM_STECKBRIEF'
    importing
      fm_name                   = fm_name
    exceptions
      no_form                     = 1
      no_function_module    = 2
      others                        = 3.


CALL FUNCTION fm_name
        EXPORTING
          control_parameters =  ls_control_parameters
          is_attributes      =  ls_attributes
          lt_cap             = lt_cap_data
          iv_dateinr         = lv_dateinr
          iv_gate1           = lv_datgate1
          iv_chancen         = lv_chancen
*          IV_RISIKEN         =
*          IV_BEWERTUNG       =
          iv_ziel            = lv_short_texts
          it_fin             = lt_fin_data
          report_reason      = doc_type
        IMPORTING
          job_output_info    = ls_formdata
        TABLES
          it_nutzen          = lt_test3
        EXCEPTIONS
          formatting_error   =  1
          internal_error     =  2
          send_error         =  3
          user_canceled      =  4
          OTHERS             =  5.


lt_otf[] = ls_formdata-otfdata[].
  call function 'SSFCOMP_PDF_PREVIEW'
    exporting
      i_otf                    = lt_otf
    exceptions
      convert_otf_to_pdf_error = 1
      cntl_error               = 2
      others                   = 3.

CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
*        max_linewidth         = 132
      IMPORTING
        bin_filesize          = pdf_size
        bin_file              = pdf_data
      TABLES
        otf                   = lt_otf   
        lines                 = lt_pdf   
      EXCEPTIONS
        err_max_linewidth     = 1
        err_format            = 2
        err_conv_not_possible = 3
        err_bad_otf           = 4
        OTHERS                = 5.


data:
        node_pdf     type ref to if_wd_context_node,
        elem_pdf     type ref to if_wd_context_element,
        stru_pdf     type        if_componentcontroller=>element_pdf ,
        item_source  like        stru_pdf-source.

* navigate from <CONTEXT> to <PDF> via lead selection
  node_pdf = wd_context->get_child_node( name = if_componentcontroller=>wdctx_changing ).
* get element via lead selection
  elem_pdf = node_pdf->get_element( ).
* set single attribute
  elem_pdf->set_attribute(
    exporting
*      name = `SOURCE`
      name = `PDF`
      value = pdf_data ).

Former Member
0 Likes

In order to analyize that issue, please tell, if the pdf binary is created.

Does pdf_data have any value?

If not, does lt_otf any data.

That gives a hint, if webdynpro or smartform is the problem.