cancel
Showing results for 
Search instead for 
Did you mean: 

Display a pdf after action

Former Member
0 Kudos

Hi all,

I'm working on a report which contains actions allowing the user to reach a a new page. In this new one, a pdf stored on the application server has to be displayed.

On the PDF view, I created an interactive form linked with my context (PDF_DATA-PDF : xstring)


       gv_filepath = '/tmp/test.pdf'.


       " Open the file in binary mode
       OPEN DATASET gv_filepath FOR INPUT IN BINARY MODE.


       IF sy-subrc = 0.
         READ DATASET gv_filepath INTO gv_filedata.
       

           IF sy-subrc = 0.
                CLOSE DATASET gv_filepath. "Close the file

                " Convert the file from hex-string to Binary format
                CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
                  EXPORTING
                    buffer        = gv_filedata
                  IMPORTING
                    output_length = gv_filesize
                  TABLES
                    binary_tab    = gt_bin_data.



************************

Here, I don't know what to do with this gt_bin_data....


************************


            lo_node = wd_context->get_child_node( 'PDF_DATA' ).
            lo_node->set_attribute( name = 'PDF' value = ?).

            wd_comp_controller->gestion_affichage( ).


         ENDIF.

       ENDIF.

Please suggest how do I handle this?
      

Accepted Solutions (1)

Accepted Solutions (1)

veerababu_alladi
Explorer
0 Kudos

Hi stephane,

After getting binary file use this code.

data tab_otf_data  type ssfcrescl,

           gt_bin_data type table of itcoo,

           bin_filesize  type i,

           bin_file      type xstring,

           pdf_tab       type table of tline.

   call function 'CONVERT_OTF'

     exporting

       format                = 'PDF'

       max_linewidth         = 132

     importing

       bin_filesize          = bin_filesize

       bin_file              = bin_file

     tables

       otf                   = gt_bin_data

       lines                 = pdf_tab

     exceptions

       err_max_linewidth     = 1

       err_format            = 2

       err_conv_not_possible = 3

       err_bad_otf           = 4

       others                = 5.

Then bind it.



Is this you are looking for ?


Thanks,


Veerababu

Former Member
0 Kudos

Well i solved my problem with my colleague, thank you

OPEN DATASET gv_filepath FOR INPUT in BINARY MODE.

      IF sy-subrc = 0.
        CLEAR l_len.
        CLEAR l_data_tab.
        DO.
          READ DATASET gv_filepath INTO l_data actual LENGTH l_len.
          IF sy-subrc <> 0.
            IF l_len > 0.
              file_size = file_size + l_len.
              APPEND l_data to l_data_tab.
            ENDIF.
            EXIT.
          ENDIF.
          file_size = file_size + l_len.
          APPEND l_data to l_data_tab.
        ENDDO.

        CLOSE DATASET gv_filepath. "Close the file
        " Convert the file from hex-string to Binary format
        input_lenght = file_size.

        CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
          EXPORTING
            input_length       = input_lenght
          IMPORTING
            buffer             = gv_filedata
          TABLES
            binary_tab         = l_data_tab
            .

Answers (0)