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: 

FILE_GET_SIZE

Former Member
0 Kudos

Hi, profs!

I found a problem using CL_GUI_FRONTEND_SERVICES meth FILE_GET_SIZE. It does not return an value.

I tried FILE_EXIST, FILE_GET_ATTRIBUTES - all works properly, but not FILE_GET_SIZE. At all! I tried with existing file and not existing - always 0.

Is anybody familiar with this problem?

With best regards,

Constantine

PS

Frontend MS WIN XP SP2, SAP GUI 640, Path level 11

System SAP R/3 4.7 620

Patches:

SAP_BASIS 620 0050 SAPKB62050

SAP_ABA 620 0050 SAPKA62050

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Konstantin,

No not familiar, but that is because i use the following code to determine both the existance AND the file size of any file:

    DATA: FILETAB TYPE TABLE OF FILE_INFO,
          FILEREC TYPE FILE_INFO,
          COUNT TYPE i,
          FZISE TYPE i.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
      EXPORTING
        DIRECTORY                   = '<Yourfilename>'
        FILTER                      = ''
        FILES_ONLY                  = 'X'
      CHANGING
        FILE_TABLE                  = FILETAB
        COUNT                       = COUNT
      EXCEPTIONS
        CNTL_ERROR                  = 1
        DIRECTORY_LIST_FILES_FAILED = 2
        WRONG_PARAMETER             = 3
        ERROR_NO_GUI                = 4
        others                      = 5.

    IF SY-SUBRC <> 0.
      RAISE CNTL_ERROR.
    ENDIF.

    IF COUNT = 0.
*     Does not exist
      RESULT = ABAP_FALSE.
      FSIZE  = 0.
    ELSE.
*     Does exist
      RESULT = ABAP_TRUE.
      READ FILETAB INDEX 1 INTO FILEREC.
      FSIZE = FILEREC-FILELENGTH.
    ENDIF.

Hope this helps you,

Regards,

Rob.

3 REPLIES 3

Former Member
0 Kudos

Hi Konstantin,

No not familiar, but that is because i use the following code to determine both the existance AND the file size of any file:

    DATA: FILETAB TYPE TABLE OF FILE_INFO,
          FILEREC TYPE FILE_INFO,
          COUNT TYPE i,
          FZISE TYPE i.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
      EXPORTING
        DIRECTORY                   = '<Yourfilename>'
        FILTER                      = ''
        FILES_ONLY                  = 'X'
      CHANGING
        FILE_TABLE                  = FILETAB
        COUNT                       = COUNT
      EXCEPTIONS
        CNTL_ERROR                  = 1
        DIRECTORY_LIST_FILES_FAILED = 2
        WRONG_PARAMETER             = 3
        ERROR_NO_GUI                = 4
        others                      = 5.

    IF SY-SUBRC <> 0.
      RAISE CNTL_ERROR.
    ENDIF.

    IF COUNT = 0.
*     Does not exist
      RESULT = ABAP_FALSE.
      FSIZE  = 0.
    ELSE.
*     Does exist
      RESULT = ABAP_TRUE.
      READ FILETAB INDEX 1 INTO FILEREC.
      FSIZE = FILEREC-FILELENGTH.
    ENDIF.

Hope this helps you,

Regards,

Rob.

Former Member
0 Kudos

Thanks, Rob!

I spent some time and find func working properly - GUI_GET_FILE_INFO. Not very clever, but fast.

I tryed foollow you suggestion - all ok.

I think i try to measure processing time for both methods and apply fastest.

Greatly thanks,

Constantin

andreas_mann3
Active Contributor

Hi Konstantin ,

method file_get_size works - you've forgotten the <b>flush</b>!

try that:

CALL METHOD cl_gui_frontend_services=>file_get_size
  EXPORTING
    file_name            = str
   IMPORTING
     file_size            = size.

<b>CALL METHOD  cl_gui_cfw=>flush( ).</b>
WRITE: / file(50), size.

regards Andreas

Message was edited by: Andreas Mann