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 Upload .TXT, BITMAP, .PDF files into a Data base Table.

Former Member
0 Kudos

Hi,

I have one requirement like Below.

I have to create a table which should hold a Text file or a Bitmap file or a PDF file and i should be able to down load it to the desktop with same format.

How i can upload or download such type of files.

Please let me know..

Srikanth.

5 REPLIES 5

FredericGirod
Active Contributor
0 Kudos

Hello,

it's the same way when you transfert PDF from internal table to file ..

or when you put a file in attachment to an email ..

Frederic

Former Member
0 Kudos

Hi srikanth,

As of my understanding, no table in sap will store the text file,bitmap file or PDF file. They will be directly stored as files & link for the same will be stored in tables.

I am telling the above analysis by referring to SE78(content server), where we can upload bitmap or text images(files) & they will be stored as application server files.

please lemme know if it is usefull anyways.

regards.

santosh

Former Member
0 Kudos

Hi Santosh,

The actual requirement is to uplaod text file or Bitmap file or PDF file into sap and have to store there.

If user wants to see it he should be allowed to download the same file to his desktop and view it.

How we can achieve this...

Thanks

Srikanth.

0 Kudos

Hi Srikanth,

*&----


*& Form f1104_download_to_lofile

*&----


  • Download to data from internal table to Logical File

*

FORM f1104_download_to_lofile.

  • Open the file in application server

OPEN DATASET v_filepht FOR OUTPUT IN TEXT MODE.

IF sy-subrc <> 0.

MESSAGE s185 WITH v_filepht. " File opening error

LEAVE LIST-PROCESSING.

ENDIF.

LOOP AT i_logfile INTO w_logfile.

TRANSFER w_logfile TO v_filepht.

CLEAR w_logfile.

ENDLOOP.

IF sy-subrc = 0.

WRITE:/ text-055, v_filepht, text-056. " File successfully created

ELSE.

WRITE:/ text-057, v_filepht. " Error creating file

ENDIF.

  • Closing the file

CLOSE DATASET v_filepht.

To Retrieve Data file from Application server

(Upload from Unix)

DATA: i_file like rlgrap-filename value '/usr/sap/tmp/filename.txt'.

OPEN DATASET i_file FOR INPUT IN TEXT MODE.

IF sy-subrc NE 0.

MESSAGE e999(za) WITH 'Error opening file' i_file.

ENDIF.

DO.

  • Reads each line of file individually

READ DATASET i_file INTO wa_datatab.

ENDDO.

Also check:

http://www.sapdevelopment.co.uk/file/file_updown.htm

http://www.sapdevelopment.co.uk/file/file_uptabsap.htm

OR

Regards,

Anjali

Former Member
0 Kudos

First, create a database table that look something like:


MANDT	MANDT	CLNT	3
KEYA	CHAR5	CHAR	5
KEY2	INT4	INT4	10
LENGTH	INT2	INT2	5
DATA		LCHR	1000

Create an Excel file and save it as c:\temp\tst.xls

Then create and run a program like:


REPORT ztest.

TABLES ztst_xl.

DATA: BEGIN OF itab OCCURS 0,
        data(1000),
      END   OF itab.

DATA: BEGIN OF dbtab OCCURS 0.
        INCLUDE STRUCTURE ztst_xl.
DATA: END   OF dbtab.

DATA count  LIKE sy-tabix.
DATA length LIKE sy-tabix.
DATA end    LIKE sy-tabix.

CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
          filename   = 'c:temptst.xls'
          filetype   = 'BIN'
     IMPORTING
          filelength = length
     TABLES
          data_tab   = itab.

DESCRIBE TABLE itab LINES count.
count = count - 1.
end    = length - 1000 * count.
count = count + 1.

dbtab-keya   = 'TEST'.
dbtab-key2   = 0.
dbtab-length = 1000.
LOOP AT itab.
  IF sy-tabix = count.
    dbtab-length = end.
  ENDIF.
  dbtab-key2   = dbtab-key2 + 1.
  dbtab-data = itab-data.
  APPEND dbtab.
ENDLOOP.

MODIFY ztst_xl FROM TABLE dbtab.

CLEAR:   dbtab, itab.
REFRESH: dbtab, itab.

SELECT * FROM ztst_xl
  INTO TABLE dbtab
  WHERE keya = 'TEST'.

LOOP AT dbtab.
  itab-data = dbtab-data.
  APPEND itab.
ENDLOOP.

CALL FUNCTION 'GUI_DOWNLOAD'
     EXPORTING
          bin_filesize = length
          filename     = 'c:temptsta.xls'
          filetype     = 'BIN'
     TABLES
          data_tab     = itab.

c:\temp\tsta.xls will be aduplicate of the original.

I think that's what you're trying to do.

Rob