Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

transfer PDF to application server

Former Member
0 Likes
2,578

hi all,

i'm trying to save a pdf of a smartform to the application server(unix). i'm using the function C13Z_RAWDATA_WRITE, but when opening the pdf from the application server it is blank or can't be opened. the pdf schould be transfered from the application server to an external DMS.

when i use GUI_DOWNLOAD and save it locally the PDF is ok.

has anybody an idea?

coding:



* generated result: PDF format
    DATA: l_pdf_xstring  TYPE xstring,
          lt_lines       TYPE TABLE OF tline,
          ls_line        TYPE tline,
          l_pdf_len      TYPE i,
          h_file LIKE rcgiedial-iefile,
          h_file_size TYPE i,
          i_rcgrepfile_tab TYPE rcgrepfile OCCURS 0 WITH HEADER LINE,
          i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
          h_gui_file TYPE string,
          h_gui_len TYPE i.


    ls_control_param-getotf      = 'X'.
* call smartform
    CALL FUNCTION lf_fm_name
      EXPORTING
        archive_index      = toa_dara
        archive_parameters = arc_params
        control_parameters = ls_control_param
        mail_recipient     = ls_recipient
        mail_sender        = ls_sender
        output_options     = ls_composer_param
        zxekko             = l_doc-xekko  " user_settings = ' '
        zxpekko            = l_doc-xpekko
        nast               = nast
      IMPORTING
        job_output_info    = w_return
      TABLES
        l_xekpo            = l_doc-xekpo[]
        l_xekpa            = l_doc-xekpa[]
        l_xpekpo           = l_doc-xpekpo[]
        l_xeket            = l_doc-xeket[]
        l_xtkomv           = l_doc-xtkomv[]
        l_xekkn            = l_doc-xekkn[]
        l_xekek            = l_doc-xekek[]
        l_xkomk            = l_xkomk
      EXCEPTIONS
        formatting_error   = 1
        internal_error     = 2
        send_error         = 3
        user_canceled      = 4
        OTHERS             = 5.

* get pdf data
    i_otf[] =  w_return-otfdata[].

*now convert the final document (OTF format) into PDF format
    CALL FUNCTION 'CONVERT_OTF'
         EXPORTING
           format                      = 'PDF'
          max_linewidth               = 132
*        ARCHIVE_INDEX               = ' '
*        COPYNUMBER                  = 0
         IMPORTING
           bin_filesize                = l_pdf_len
         TABLES
           otf                         = i_otf
           lines                       = lt_lines
         EXCEPTIONS
           err_max_linewidth           = 1
           err_format                  = 2
           err_conv_not_possible       = 3
           err_bad_otf                 = 4
           OTHERS                      = 5.


    h_file_size = l_pdf_len.
    i_rcgrepfile_tab[] = lt_lines[].
* transfer to application server
    CALL FUNCTION 'C13Z_RAWDATA_WRITE'
      EXPORTING
        i_file                 = h_file
        i_file_size            = h_file_size
*   I_LINES                = 0
*   I_FILE_OVERWRITE       = ESP1_TRUE
      TABLES
        i_rcgrepfile_tab       = i_rcgrepfile_tab
     EXCEPTIONS
       no_permission          = 1
       open_failed            = 2
       ap_file_exists         = 3
       OTHERS                 = 4
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

1 ACCEPTED SOLUTION
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
866

Use OPEN DATASET... CLOSE DATASET instead of GUI_DOWNLOAD. Look up ABAP Help.

2 REPLIES 2
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
867

Use OPEN DATASET... CLOSE DATASET instead of GUI_DOWNLOAD. Look up ABAP Help.

Read only

Former Member
0 Likes
866

i had to use the binary pdf data (bin_file). then the upload with "open dataset" to the application server works.

greetz

CALL FUNCTION 'CONVERT_OTF'
         EXPORTING
           format                      = 'PDF'
          max_linewidth               = 132
*        ARCHIVE_INDEX               = ' '
*        COPYNUMBER                  = 0
         IMPORTING
           bin_filesize                = l_pdf_len
           bin_file                    = l_pdf_xstring       " binary file
         TABLES
           otf                         = i_otf
           lines                       = lt_lines
         EXCEPTIONS
           err_max_linewidth           = 1
           err_format                  = 2
           err_conv_not_possible       = 3
           err_bad_otf                 = 4
           OTHERS                      = 5.


    CONCATENATE '/PO/BIN_' l_doc-xekko-ebeln '.PDF' INTO h_file.


    OPEN DATASET h_file FOR OUTPUT IN BINARY MODE.
    CHECK sy-subrc EQ 0.
    TRANSFER l_pdf_xstring  TO h_file.
    CLOSE DATASET h_file.