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 get the size of uploaded file in sap ABAP MODULE POOL PROGRAMMING

Former Member
0 Kudos

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 REPLIES 11

Former Member
0 Kudos

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.

0 Kudos

thanx.

But without using classes and objects.

Is there any other way.

using some function modules only.

Reply.

0 Kudos

Hi,

Guess GUI_GET_FILE_INFO could do the trick...

Kr,

Manu.

0 Kudos

its an obsolete fm so we cannot use it in real time operations.

0 Kudos

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

0 Kudos

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.

0 Kudos

Only thing i am left with is ' SIZE ' of the File.

Why not with the export parameter FILELENGTH ??

Manu.

0 Kudos

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".

-


0 Kudos

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.

0 Kudos

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

0 Kudos

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.