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

Where does GUI_UPLOAD function store the files?

Former Member
0 Likes
1,366

Where does GUI_UPLOAD function store the files?

1 ACCEPTED SOLUTION
Read only

thomas_jung
Developer Advocate
Developer Advocate
0 Likes
1,168

The content of the file being uploaded is transfered from memory of the frontend device (via the SAPGui), accross the network to your application server. There it resides in ABAP memory as an internal table (which you supply as a parameter to the GUI_UPLOAD Function).

Therefore the content never persists anywhere unless the calling application stores it somehow. Otherwise it has the same lifespan as any other internal table in your ABAP application.

8 REPLIES 8
Read only

thomas_jung
Developer Advocate
Developer Advocate
0 Likes
1,169

The content of the file being uploaded is transfered from memory of the frontend device (via the SAPGui), accross the network to your application server. There it resides in ABAP memory as an internal table (which you supply as a parameter to the GUI_UPLOAD Function).

Therefore the content never persists anywhere unless the calling application stores it somehow. Otherwise it has the same lifespan as any other internal table in your ABAP application.

Read only

0 Likes
1,168

Thomas,

Thanks for clarifying that that GUI_UPLOAD uploads files from the frontend device.

My files are already on the server, so I can't use GUI_UPLOAD. But I need those files in an internal table like how GUI_UPLOAD does (output of data_tab). I need the files in an interal table because I eventually call the function module RSOD_DOC_MAST_CHANGE which uses the internal table.

How can I do this?

Is there another function similar to GUI_UPLOAD but instead uploads files from the server?

OR, how can I manually put the files in an internal table? To do this I would need to know the structure of data_tab (the file produced by GUI_UPLOAD). Does anyone know the structure?

Thanks!!!! I'm in desperate need of help!!!

Read only

0 Likes
1,168

What you want are the abap key words open dataset and read dataset. These commands will read a file from the application server. The following is a simple example from a 46C system:


function z_e_read_from_file.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(FILENAME1)
*"  TABLES
*"      ITAB1
*"----------------------------------------------------------------------

**** Open the Input file
  open dataset filename1 for input in text mode message message_text.

**** Test that the open was successful
  if sy-subrc = 8.
    message x013 with filename1 message_text.
  endif.

****Read the input file into internal memory
  while sy-subrc = 0.
    read dataset filename1 into itab1.
    if sy-subrc ne 0.
      if sy-subrc ne 4.   "End of file
        message x015 with filename1.
      endif.
    endif.
    append itab1.
  endwhile.

Read only

0 Likes
1,168

THANK YOU!

I am trying out the code now.

I'm a new ABAP programmer so my next question is going to sound dumb.

How do I declare itab1 as an internal table?

Thanks so much!

Read only

0 Likes
1,168

Well it depends upon what kind of structure you need itab1 to have. In its simplest form you might do this:

data: itab1 type table of string.

Then you would have an internal table of strings. But you knew you were going to pass this internal table to a SAP function module. You probably want your internal table to match the type it is expecting. I would have a look at the definition of that function module. Also the on-line help does have a nice syntax layout for internal tables. There are many different options on the type of internal table created (with/without header lines, sorted, hash, standard, etc).

Read only

0 Likes
1,168

yet another question from me!

I have added the declaration statement for itab1

Now I get a syntax error on this statement...

read dataset filename into itab1

The syntax error i get is... "ITAB1 cannot be a table, a reference, a string, or contain any of these objects"

This doesn't make any sense to me.

PLEASE HELP!

Read only

0 Likes
1,168

That's probably my fault. I gave you a read example that had a table with a header line, but a table declaration without one. Try the following:


data: itab1 type table of string.
data: wa_itab1 like line of itab.

 while sy-subrc = 0.
    read dataset filename1 into wa_itab1.
    if sy-subrc ne 0.
      if sy-subrc ne 4.   "End of file
        message x015 with filename1.
      endif.
    endif.
    append wa_itab1 to itab1.
  endwhile.

I'm afraid I am coding from memory and not at a system right now. Hopefully this will work a little better (I'm questioning my append statement - it doesn't look quite right. You might check this in the online help if it isn't right.)

Read only

Former Member
0 Likes
1,168

Hi Audrey

Here is an example of accessing files from application server:

open dataset w_file for input in text mode.

if sy-subrc <> 0.

message e895 with 'Unable to locate file'.

else.

do.

read dataset w_file into it_data.

if sy-subrc eq 4. " End of file reached

clear it_data.

exit.

else.

append it_data.

clear it_data.

endif.

enddo.

close dataset w_file.

In the above example, w_file is declared as string containing c:\usr\sap\test.txt

And this file should be there on this path on application server.

And, yes, you need to declare it_data as an internal table containing fields corresponding to file from which you are reading data.

Regards

Ashish Jain

ashishjain@ko-india.com