11-05-2011 9:12 AM
Hello,
I am using a fucntion module GUI UPLOAD to upload a file from pc to SAP .
I want to upload the details of the file.
i.e TYPE NAME AND SIZE of the file.
I am unable to do so.
Help me.
Gaur Mayank
11-05-2011 9:25 AM
Hi,
You can use the exporting parameter FILELENGTH.
You could also call the method FILE_GET_SIZE and FILE_GET_ATTRIBUTES of class CL_GUI_FRONTEND_SERVICES.
Kr,
Manu.
11-05-2011 9:35 AM
thanx.
But without using classes and objects.
Is there any other way.
using some function modules only.
Reply.
11-05-2011 9:40 AM
11-05-2011 9:44 AM
11-05-2011 9:48 AM
Yep obsolete and to convert to CL_GUI_FRONTEND_SERVICES methods...;)
Hence my first proposal.
Don't think there's another "standard" FM for that...
But you have the filesize with gui_upload, the name (since you've uploaded it) and you can derive the type from the file extension, no?
Kr,
m.
Edited by: Manu D'Haeyer on Nov 5, 2011 10:56 AM
11-05-2011 10:02 AM
Yeah Exactly.
But i have been given this task to do without using OO Concepts.
Moreover, Type and Name i am getting by Using SPLITING FUNCTION MODULE.
And then Splitting the output into two strings using split string query.
Only thing i am left with is ' SIZE ' of the File.
11-05-2011 10:05 AM
Only thing i am left with is ' SIZE ' of the File.
Why not with the export parameter FILELENGTH ??
Manu.
11-05-2011 10:13 AM
Runtime error.
-
Error in the ABAP Application Program
The current ABAP program "ZMG_TENDER" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Function module "GUI_UPLOAD" was called
with the parameter "FILELENGTH".
-
11-05-2011 10:23 AM
Are you calling it this way ?...
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_filename
IMPORTING
filelength = l_len
TABLES
data_tab = lt_data
Kr,
m.
11-05-2011 10:40 AM
I tried.
But it is not showing the proper value..
the File size is 4kb.
and the value it is showing = 18kb.
May be some garbage value.
reply
11-05-2011 1:03 PM
Perhaps you could count this by yourself...
You could approach the correct size by calculating the number of bytes contained in each rows of your table.
For this you will first need to upload the file to a table of string, so that each field separator is counted.
something like:
DATA: lt_data TYPE STANDARD TABLE OF string,
l_len TYPE i.
FIELD-SYMBOLS <data> TYPE string.
"... gui_upload to lt_data
DESCRIBE TABLE lt_data LINES l_len.
l_len = ( l_len - 1 ) * 2. "Count 2 bytes at end of each line for CRLF
LOOP AT lt_data ASSIGNING <data>. "Add length of each line
l_len = l_len + strlen( <data> ).
ENDLOOP.
WRITE: l_len.
This for a single-byte codepage of course... you can use charlen in order to have the length of one char on your system, here I'm asuming it is 1.
Kr,
Manu.