Application Development 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: 

How to save the pdf file or word doc into sap table

Former Member
0 Kudos

Hi Expertu2019s

I have a pfd file in my presentation server .Now I want to save the pdf file into sap table using module pool program. Whenever i need, I want to open that file from the table and show it in the Screen. Please any one tell me how I can save the file. What is the table name, guide me.

Regards,

S.Nehru.

5 REPLIES 5

Former Member
0 Kudos

Hi,

Try the following code


FORM gui_upload.
  DATA: lv_filetype(10) TYPE c,
        lv_gui_sep TYPE c,
        lv_file_name TYPE string.
  lv_filetype = 'PDF'.
  lv_file_name = <name of ur file>.
DATA: tb_file_data TYPE TABLE OF text4096.

* FM call to upload file
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = lv_file_name
      filetype                = lv_filetype
      has_field_separator     = lv_gui_sep
    TABLES
      data_tab                = tb_file_data
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    "gui_upload

I dont think you can save the data into sap tables in PDF format.

With the above code you can save data into an internal table.

Regards,

Manish

Former Member

Hello,

I think we cannot save the file in the sap tables in PDF formate.

I will give one solution try this if need it.

1)First create the table which will store the name of the file.

2)Store the file in the Application server.

3)Then if u want to display the file in Module pool. Take the file name from the Ztable which u have already stored.Take that file name get the data into the internal table.

4)Create the spool request number for that data which u have taken from the database.

5)Run this program RSTXPDF2 using keyword SUBMIT by giving the spool request number then it will generate the PDF file.

Try this i think it is help but little bit complex.

Former Member
0 Kudos

Here is an Idea.

1. Upload the file from Presentation Server Using GUI_UPLOAD and it will return the BINARY format of Uploaded PDF file.

2. Use FM "BINARY_TO_XSTRING" ( i dont exactly remember the FM ) to get the XSTRING of PDF Form.

3. Create a field in your custom table of XSTRING type and save the XSTRING in that field.

4. Now use this XSTRING value from the Table when ever you wish to display it from your module pool program.

Thanks,

Abhishek

Former Member
0 Kudos

Hi

first read the file into internal table from presentation server

and store it onto the application server instead of storing it in SAP table coz that would take lot of memory on the database & retreivaing records from that table would be slow.

using appl. server might help saving time.

thn when u require thm to display u can read it from the application server into internal table .

Regards.

Former Member
0 Kudos

Hi, you can read here process to save Word document as PDF file. Here, in this link you will complete procedure alogwith screenshots. Visit here: http://tech-freak-stuff.blogspot.in/2014/05/save-word-document-in-pdf-in-office.html